-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #12 from hobofan/feat/check_use_std
feat(check): add simple check for `use std::` statements
- Loading branch information
Showing
7 changed files
with
107 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
target |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
[package] | ||
name = "detect_explicit_use_std" | ||
version = "0.1.0" | ||
authors = ["Maximilian Goisser <goisser94@gmail.com>"] | ||
edition = "2018" | ||
|
||
[dependencies] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
#![no_std] | ||
|
||
use std::ops::Add; | ||
|
||
fn main() { | ||
println!("Hello, world!"); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
extern crate assert_cmd; | ||
|
||
use assert_cmd::prelude::*; | ||
use std::process::Command; | ||
|
||
#[test] | ||
fn it_fails_with_exit_code_1() { | ||
Command::main_binary() | ||
.unwrap() | ||
.arg("check") | ||
.current_dir("./tests/detect_explicit_use_std") | ||
.assert() | ||
.code(1); | ||
} | ||
|
||
#[test] | ||
fn it_prints_cause() { | ||
let output = Command::main_binary() | ||
.unwrap() | ||
.arg("check") | ||
.current_dir("./tests/detect_explicit_use_std") | ||
.output() | ||
.unwrap() | ||
.stdout; | ||
let output = String::from_utf8(output).unwrap(); | ||
|
||
let expected_cause = | ||
"Source code contains an explicit `use std::` statement"; | ||
assert!(output.contains(expected_cause)); | ||
} |