diff --git a/.github/workflows/msrv.yaml b/.github/workflows/msrv.yaml index c638b29..58b4247 100644 --- a/.github/workflows/msrv.yaml +++ b/.github/workflows/msrv.yaml @@ -5,10 +5,13 @@ env: CARGO_TERM_COLOR: always MSRV: "1.51" jobs: - # build but don't test the crate with the Minimum Supported Rust Version + # Build and test the tool with the Minimum Supported Rust Version msrv: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 + - name: Install valgrind + run: sudo apt install valgrind - run: rustup update $MSRV && rustup default $MSRV - - run: cargo check + - name: Run tests + run: cargo test diff --git a/src/driver.rs b/src/driver.rs index 377f0df..e42e74e 100644 --- a/src/driver.rs +++ b/src/driver.rs @@ -3,6 +3,7 @@ use std::env; use std::ffi::OsString; use std::io; +use std::path::Path; use std::process::Command; /// The prefix line for the target host output. @@ -18,16 +19,23 @@ const HOST_PREFIX: &[u8] = b"host: "; /// executed. pub fn driver() -> io::Result { let cargo = env::var_os("CARGO").expect("CARGO environment variable is not set"); + let rustc = Path::new(&cargo).with_file_name("rustc"); /* get the output of `cargo version -v` */ - let rustc_info = Command::new(&cargo).args(&["version", "-v"]).output()?.stdout; + let cargo_info = Command::new(&cargo) + .args(&["version", "-v"]) + .output()? + .stdout; + /* old cargo versions don't include the host-field, so fall back to rustc */ + let rustc_info = Command::new(rustc).arg("-vV").output()?.stdout; + let info = [cargo_info, rustc_info].concat(); /* get the host information (all after the "host: ..." line) */ - let host = rustc_info + let host = info .windows(HOST_PREFIX.len()) .position(|window| window == HOST_PREFIX) - .expect("Host information not present in `cargo version -v`"); - let host: String = rustc_info + .expect("Host information not present in `cargo version -v` or `rustc -vV"); + let host: String = info .into_iter() .skip(host) .skip(HOST_PREFIX.len()) @@ -36,7 +44,7 @@ pub fn driver() -> io::Result { .collect(); /* convert to runner env variable */ - let host = host.replace(&['-', '.'], "_").to_uppercase(); + let host = host.replace('-', "_").replace('.', "_").to_uppercase(); let runner = format!("CARGO_TARGET_{}_RUNNER", host); /* cargo run with a custom runner */ diff --git a/tests/corpus/issue-74.rs b/tests/corpus/issue-74.rs index 93d38e5..2b31425 100644 --- a/tests/corpus/issue-74.rs +++ b/tests/corpus/issue-74.rs @@ -29,9 +29,9 @@ fn ex4() { let (a, b) = split_at_mut(r, 4); - println!("a={a:?} (should be [1, 2, 3, 4]"); + println!("a={:?} (should be [1, 2, 3, 4]", a); drop(a); - println!("b={b:?} (should be [5, 6])"); + println!("b={:?} (should be [5, 6])", b); // assert_eq!(a, &mut[1, 2, 3, 4]); // assert_eq!(b, &mut[5, 6]); }