Skip to content

Commit c495558

Browse files
committed
warn when there's a newer version of the x tool available
1 parent 726bbfc commit c495558

File tree

4 files changed

+47
-1
lines changed

4 files changed

+47
-1
lines changed

src/tools/tidy/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,3 +69,4 @@ pub mod ui_tests;
6969
pub mod unit_tests;
7070
pub mod unstable_book;
7171
pub mod walk;
72+
pub mod x;

src/tools/tidy/src/main.rs

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,21 @@ fn main() {
5353
VecDeque::with_capacity(concurrency.get());
5454

5555
macro_rules! check {
56+
($p:ident) => {
57+
while handles.len() >= concurrency.get() {
58+
handles.pop_front().unwrap().join().unwrap();
59+
}
60+
61+
let handle = s.spawn(|| {
62+
let mut flag = false;
63+
$p::check(&mut flag);
64+
if (flag) {
65+
bad.store(true, Ordering::Relaxed);
66+
}
67+
});
68+
handles.push_back(handle);
69+
};
70+
5671
($p:ident $(, $args:expr)* ) => {
5772
drain_handles(&mut handles);
5873

@@ -64,7 +79,8 @@ fn main() {
6479
}
6580
});
6681
handles.push_back(handle);
67-
}
82+
};
83+
6884
}
6985

7086
check!(target_specific_tests, &src_path);
@@ -107,6 +123,8 @@ fn main() {
107123
check!(alphabetical, &compiler_path);
108124
check!(alphabetical, &library_path);
109125

126+
check!(x);
127+
110128
let collected = {
111129
drain_handles(&mut handles);
112130

src/tools/tidy/src/x.rs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
use std::process::Command;
2+
3+
pub fn check(_bad: &mut bool) {
4+
let result = Command::new("x")
5+
.arg("--version")
6+
.output();
7+
let output = match result {
8+
Ok(output) => output,
9+
Err(_e) => todo!(),
10+
};
11+
12+
if output.status.success() {
13+
let version = String::from_utf8_lossy(&output.stdout);
14+
assert_eq!("0.1.0", version.trim_end());
15+
}
16+
// FIXME: throw some kind of tidy error when the version of x isn't
17+
// greater than or equal to the version we'd expect.
18+
//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`")
19+
}

src/tools/x/src/main.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,14 @@ fn exec_or_status(command: &mut Command) -> io::Result<ExitStatus> {
5252
}
5353

5454
fn main() {
55+
match env::args().skip(1).next().as_deref() {
56+
Some("--version") => {
57+
let version = env!("CARGO_PKG_VERSION");
58+
println!("{}", version);
59+
return;
60+
}
61+
_ => {}
62+
}
5563
let current = match env::current_dir() {
5664
Ok(dir) => dir,
5765
Err(err) => {

0 commit comments

Comments
 (0)