diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 67eb066..f377ebf 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -15,7 +15,7 @@ jobs: rust: [1.0.0, 1.5.0, 1.10.0, 1.15.0, 1.20.0, 1.25.0, 1.30.0, 1.35.0, 1.40.0, 1.45.0, 1.50.0, 1.55.0, 1.60.0, 1.65.0, 1.70.0, 1.75.0, 1.80.0, # first version with rustc-check-cfg - 1.85.0, stable, beta, nightly] + 1.85.0, 1.90.0, 1.95.0, stable, beta, nightly] steps: - uses: actions/checkout@v4 - uses: dtolnay/rust-toolchain@master diff --git a/Cargo.toml b/Cargo.toml index 75b34ea..8e9bf95 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "autocfg" -version = "1.5.0" +version = "1.5.1" authors = ["Josh Stone "] license = "Apache-2.0 OR MIT" repository = "https://github.com/cuviper/autocfg" @@ -12,4 +12,15 @@ categories = ["development-tools::build-utils"] exclude = ["/.github/**"] rust-version = "1.0" -[dependencies] +[[test]] +name = "no_std" + +[[test]] +name = "rustflags" + +[[test]] +name = "tests" + +[[test]] +name = "wrappers" +harness = false diff --git a/README.md b/README.md index a3d8ac4..05dbfc6 100644 --- a/README.md +++ b/README.md @@ -43,6 +43,10 @@ should only be used when the compiler supports it. ## Release Notes +- 1.5.1 (2026-05-22) + + - Refactor the `test_wrappers` test without any shell script. + - 1.5.0 (2025-06-17) - Add `edition` and `set_edition` to control the Rust edition used in probes. diff --git a/tests/wrap_ignored b/tests/wrap_ignored deleted file mode 100755 index 5e577d0..0000000 --- a/tests/wrap_ignored +++ /dev/null @@ -1,12 +0,0 @@ -#!/bin/bash - -for arg in "$@"; do - case "$arg" in - # Add our own version so we can check that the wrapper is used for that. - "--version") echo "release: 12345.6789.0" ;; - # Read all input so the writer doesn't get EPIPE when we exit. - "-") read -d "" PROBE ;; - esac -done - -exit 0 diff --git a/tests/wrappers.rs b/tests/wrappers.rs index cacca71..69a64dd 100644 --- a/tests/wrappers.rs +++ b/tests/wrappers.rs @@ -1,13 +1,39 @@ extern crate autocfg; use std::env; +use std::io; mod support; +fn main() { + let args: Vec<_> = env::args().skip(1).collect(); + if args.is_empty() { + // With no arguments, this must be a (harness-free) test run. + // (we're using system binaries as wrappers, so ignore other platforms) + if cfg!(unix) { + test_wrappers(); + } + } else { + // Otherwise we're acting like a no-op rustc wrapper, ignoring almost everything. + for arg in args { + match &*arg { + // Add our own version so we can check that the wrapper is used for that. + "--version" => println!("release: 12345.6789.0"), + + // Read all input so the writer doesn't get EPIPE when we exit. + "-" => { + let stdin = io::stdin(); + let _ = io::copy(&mut stdin.lock(), &mut io::sink()); + } + + _ => {} + } + } + } +} + /// Tests that autocfg uses the RUSTC_WRAPPER and/or RUSTC_WORKSPACE_WRAPPER /// environment variables when running rustc. -#[test] -#[cfg(unix)] // we're using system binaries as wrappers fn test_wrappers() { fn set(name: &str, value: Option) { match value { @@ -45,8 +71,9 @@ fn test_wrappers() { } // Finally, make sure that `RUSTC_WRAPPER` is applied outermost - // by using something that doesn't pass through at all. - env::set_var("RUSTC_WRAPPER", "./tests/wrap_ignored"); + // by using something (ourself) that doesn't pass through at all. + let wrap_ignored = env::current_exe().unwrap(); + env::set_var("RUSTC_WRAPPER", &wrap_ignored); env::set_var("RUSTC_WORKSPACE_WRAPPER", "/bin/false"); let ac = autocfg::AutoCfg::with_dir(out.as_ref()).unwrap(); assert!(ac.probe_type("mesize")); // anything goes!