X-Git-Url: https://git.proxmox.com/?a=blobdiff_plain;f=tests%2Finternal.rs;h=c42cfa8f07b409e98c19acf46e6fd20354bcf05a;hb=050458aabf1b0fe9c8dfe73f58d2e83457765878;hp=2631d787381bd273e3d947e3ad81bb03296b70a3;hpb=62711bd385dd8a3803f8b7dcb16231ab2d012e3a;p=cargo.git diff --git a/tests/internal.rs b/tests/internal.rs index 2631d7873..c42cfa8f0 100644 --- a/tests/internal.rs +++ b/tests/internal.rs @@ -1,16 +1,26 @@ //! Tests for internal code checks. + +#![allow(clippy::all)] + use std::fs; #[test] fn check_forbidden_code() { // Do not use certain macros, functions, etc. - if !cargo::util::is_ci() { + if !cargo_util::is_ci() { // Only check these on CI, otherwise it could be annoying. + use std::io::Write; + writeln!( + std::io::stderr(), + "\nSkipping check_forbidden_code test, set CI=1 to enable" + ) + .unwrap(); return; } - let path = std::path::Path::new(env!("CARGO_MANIFEST_DIR")).join("src"); - for entry in walkdir::WalkDir::new(path) + let root_path = std::path::Path::new(env!("CARGO_MANIFEST_DIR")).join("src"); + for entry in walkdir::WalkDir::new(&root_path) .into_iter() + .filter_entry(|e| e.path() != root_path.join("doc")) .filter_map(|e| e.ok()) { let path = entry.path(); @@ -22,8 +32,12 @@ fn check_forbidden_code() { { continue; } + eprintln!("checking {}", path.display()); let c = fs::read_to_string(path).unwrap(); for (line_index, line) in c.lines().enumerate() { + if line.trim().starts_with("//") { + continue; + } if line_has_print(line) { if entry.file_name().to_str().unwrap() == "cargo_new.rs" && line.contains("Hello") { // An exception.