]> git.lizzy.rs Git - rust.git/blobdiff - tests/fmt.rs
add tests for a false negative on `needless_return`
[rust.git] / tests / fmt.rs
index ba35abbfbbb7d4a8f5d720937086da3da6df2fc3..7616d8001e8853bb8e9de4e44659d01b3253bd6f 100644 (file)
@@ -1,12 +1,13 @@
+use std::path::PathBuf;
 use std::process::Command;
 
 #[test]
 fn fmt() {
-    if option_env!("RUSTC_TEST_SUITE").is_some() {
+    if option_env!("RUSTC_TEST_SUITE").is_some() || option_env!("NO_FMT_TEST").is_some() {
         return;
     }
 
-    // Skip this test if rustup nightly is unavailable
+    // Skip this test if nightly rustfmt is unavailable
     let rustup_output = Command::new("rustup")
         .args(&["component", "list", "--toolchain", "nightly"])
         .output()
@@ -17,13 +18,10 @@ fn fmt() {
         return;
     }
 
-    let root_dir = std::path::PathBuf::from(env!("CARGO_MANIFEST_DIR"));
-    let dev_dir = root_dir.join("clippy_dev");
-    let target_dir = root_dir.join("target");
-    let target_dir = target_dir.to_str().unwrap();
+    let root_dir = PathBuf::from(env!("CARGO_MANIFEST_DIR"));
     let output = Command::new("cargo")
-        .current_dir(dev_dir)
-        .args(&["+nightly", "run", "--target-dir", target_dir, "--", "fmt", "--check"])
+        .current_dir(root_dir)
+        .args(&["dev", "fmt", "--check"])
         .output()
         .unwrap();
 
@@ -33,6 +31,6 @@ fn fmt() {
 
     assert!(
         output.status.success(),
-        "Formatting check failed. Run `./util/dev fmt` to update formatting."
+        "Formatting check failed. Run `cargo dev fmt` to update formatting."
     );
 }