-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(check): check all rust files in project
REFERENCE #10
- Loading branch information
Showing
7 changed files
with
107 additions
and
7 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
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_all_files" | ||
version = "0.1.0" | ||
authors = ["Maximilian Goisser <[email protected]>"] | ||
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] | ||
|
||
mod some_module; | ||
|
||
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,4 @@ | ||
use std::ops::Add; | ||
use std::string::String; | ||
|
||
fn some_fn() {} |
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,44 @@ | ||
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_all_files") | ||
.assert() | ||
.code(1); | ||
} | ||
|
||
#[test] | ||
fn it_prints_cause() { | ||
let output = Command::main_binary() | ||
.unwrap() | ||
.arg("check") | ||
.current_dir("./tests/detect_explicit_use_std_all_files") | ||
.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)); | ||
} | ||
|
||
#[test] | ||
fn it_does_not_warn_about_no_std_statement() { | ||
let output = Command::main_binary() | ||
.unwrap() | ||
.arg("check") | ||
.current_dir("./tests/detect_explicit_use_std_all_files") | ||
.output() | ||
.unwrap() | ||
.stdout; | ||
let output = String::from_utf8(output).unwrap(); | ||
|
||
let expected_cause = "Did not find a #![no_std] attribute"; | ||
assert!(!output.contains(expected_cause)); | ||
} |