diff options
| author | Caleb Cartwright <caleb.cartwright@outlook.com> | 2022-03-28 20:27:42 -0500 |
|---|---|---|
| committer | Caleb Cartwright <calebcartwright@users.noreply.github.com> | 2022-03-28 21:33:45 -0500 |
| commit | 4fecede7fdaeeb859b066394bf27401fd13743a7 (patch) | |
| tree | b690a017e0962e2d5f6faaf1039f3b1e3e6ab3d8 | |
| parent | 63acf90044f9e27ca4683af9e8ec9afb6daa39f6 (diff) | |
| download | rust-4fecede7fdaeeb859b066394bf27401fd13743a7.tar.gz rust-4fecede7fdaeeb859b066394bf27401fd13743a7.zip | |
Revert "Use cargo-fmt in self_tests"
This reverts commit c63d42e80473a0c18714b55058f27506fd24955c.
| -rw-r--r-- | src/test/mod.rs | 46 |
1 files changed, 34 insertions, 12 deletions
diff --git a/src/test/mod.rs b/src/test/mod.rs index 4191e3e96b0..ab966d4a360 100644 --- a/src/test/mod.rs +++ b/src/test/mod.rs @@ -375,21 +375,43 @@ fn idempotence_tests() { }); } +// Run rustfmt on itself. This operation must be idempotent. We also check that +// no warnings are emitted. +// Issue-3443: these tests require nightly #[nightly_only_test] #[test] fn self_tests() { - let get_exe_path = |name| { - let mut path = env::current_exe().unwrap(); - path.pop(); - path.set_file_name(format!("{name}{}", env::consts::EXE_SUFFIX)); - path - }; - let status = Command::new(get_exe_path("cargo-fmt")) - .args(["--check", "--all"]) - .env("RUSTFMT", get_exe_path("rustfmt")) - .status() - .unwrap(); - assert!(status.success()); + init_log(); + let mut files = get_test_files(Path::new("tests"), false); + let bin_directories = vec!["cargo-fmt", "git-rustfmt", "bin", "format-diff"]; + for dir in bin_directories { + let mut path = PathBuf::from("src"); + path.push(dir); + path.push("main.rs"); + files.push(path); + } + files.push(PathBuf::from("src/lib.rs")); + + let (reports, count, fails) = check_files(files, &Some(PathBuf::from("rustfmt.toml"))); + let mut warnings = 0; + + // Display results. + println!("Ran {} self tests.", count); + assert_eq!(fails, 0, "{} self tests failed", fails); + + for format_report in reports { + println!( + "{}", + FormatReportFormatterBuilder::new(&format_report).build() + ); + warnings += format_report.warning_count(); + } + + assert_eq!( + warnings, 0, + "Rustfmt's code generated {} warnings", + warnings + ); } #[test] |
