about summary refs log tree commit diff
diff options
context:
space:
mode:
authorDebugSteven <debugsteven@gmail.com>2022-11-17 13:21:36 -0700
committerDebugSteven <debugsteven@gmail.com>2022-12-31 11:37:13 -0700
commitc49555821f9735239bf12281b9151eac3b4596d4 (patch)
tree498d65db4aca485c2b754c3f3160092aeb0ae4c1
parent726bbfc8f0d6eb431dfa620c1c8fc3848020cd3c (diff)
downloadrust-c49555821f9735239bf12281b9151eac3b4596d4.tar.gz
rust-c49555821f9735239bf12281b9151eac3b4596d4.zip
warn when there's a newer version of the x tool available
-rw-r--r--src/tools/tidy/src/lib.rs1
-rw-r--r--src/tools/tidy/src/main.rs20
-rw-r--r--src/tools/tidy/src/x.rs19
-rw-r--r--src/tools/x/src/main.rs8
4 files changed, 47 insertions, 1 deletions
diff --git a/src/tools/tidy/src/lib.rs b/src/tools/tidy/src/lib.rs
index ce7e7ac5cd4..bfcf0907365 100644
--- a/src/tools/tidy/src/lib.rs
+++ b/src/tools/tidy/src/lib.rs
@@ -69,3 +69,4 @@ pub mod ui_tests;
 pub mod unit_tests;
 pub mod unstable_book;
 pub mod walk;
+pub mod x;
diff --git a/src/tools/tidy/src/main.rs b/src/tools/tidy/src/main.rs
index 6714c63ee62..f01d4673368 100644
--- a/src/tools/tidy/src/main.rs
+++ b/src/tools/tidy/src/main.rs
@@ -53,6 +53,21 @@ fn main() {
             VecDeque::with_capacity(concurrency.get());
 
         macro_rules! check {
+            ($p:ident) => {
+                while handles.len() >= concurrency.get() {
+                    handles.pop_front().unwrap().join().unwrap();
+                }
+
+                let handle = s.spawn(|| {
+                    let mut flag = false;
+                    $p::check(&mut flag);
+                    if (flag) {
+                        bad.store(true, Ordering::Relaxed);
+                    }
+                });
+                handles.push_back(handle);
+            };
+
             ($p:ident $(, $args:expr)* ) => {
                 drain_handles(&mut handles);
 
@@ -64,7 +79,8 @@ fn main() {
                     }
                 });
                 handles.push_back(handle);
-            }
+            };
+
         }
 
         check!(target_specific_tests, &src_path);
@@ -107,6 +123,8 @@ fn main() {
         check!(alphabetical, &compiler_path);
         check!(alphabetical, &library_path);
 
+        check!(x);
+
         let collected = {
             drain_handles(&mut handles);
 
diff --git a/src/tools/tidy/src/x.rs b/src/tools/tidy/src/x.rs
new file mode 100644
index 00000000000..2cbbde8de82
--- /dev/null
+++ b/src/tools/tidy/src/x.rs
@@ -0,0 +1,19 @@
+use std::process::Command;
+
+pub fn check(_bad: &mut bool) {
+    let result = Command::new("x")
+        .arg("--version")
+        .output();
+    let output = match result {
+        Ok(output) => output,
+        Err(_e) => todo!(),
+    };
+
+    if output.status.success() {
+        let version = String::from_utf8_lossy(&output.stdout);
+        assert_eq!("0.1.0", version.trim_end());
+    }
+    // FIXME: throw some kind of tidy error when the version of x isn't
+    // greater than or equal to the version we'd expect.
+    //tidy_error!(bad, "Current version of x is {version} Consider updating to the newer version of x by running `cargo install --path src/tools/x`")
+}
diff --git a/src/tools/x/src/main.rs b/src/tools/x/src/main.rs
index f07ff43efe9..db5d03710d7 100644
--- a/src/tools/x/src/main.rs
+++ b/src/tools/x/src/main.rs
@@ -52,6 +52,14 @@ fn exec_or_status(command: &mut Command) -> io::Result<ExitStatus> {
 }
 
 fn main() {
+    match env::args().skip(1).next().as_deref() {
+        Some("--version") => {
+            let version = env!("CARGO_PKG_VERSION");
+            println!("{}", version);
+            return;
+        }
+        _ => {}
+    }
     let current = match env::current_dir() {
         Ok(dir) => dir,
         Err(err) => {