diff --git a/Cargo.toml b/Cargo.toml index 75b34ea..eba7271 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -9,7 +9,7 @@ description = "Automatic cfg for Rust compiler features" readme = "README.md" keywords = ["rustc", "build", "autoconf"] categories = ["development-tools::build-utils"] -exclude = ["/.github/**"] rust-version = "1.0" +include = ["Cargo.toml", "LICENSE-APACHE", "LICENSE-MIT", "README.md", "src/**/*.rs", "tests/**/*.rs"] [dependencies] diff --git a/tests/support/wrap_ignored.rs b/tests/support/wrap_ignored.rs new file mode 100644 index 0000000..80f2cf6 --- /dev/null +++ b/tests/support/wrap_ignored.rs @@ -0,0 +1,7 @@ +fn main() { + let mut args = std::env::args(); + // Add our own version so we can check that the wrapper is used for that. + if args.any(|f| f == "--version") { + println!("release: 12345.6789.0"); + } +} 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..0fa5c49 100644 --- a/tests/wrappers.rs +++ b/tests/wrappers.rs @@ -17,6 +17,8 @@ fn test_wrappers() { } } + let original_rustc = std::env::var("RUSTC").unwrap_or_else(|_| String::from("rustc")); + let out = support::out_dir(); // This is used as a heuristic to detect rust-lang/cargo#9601. @@ -44,9 +46,20 @@ fn test_wrappers() { } } + // compile the wrap_ignored wrapper + let wrapper_output_path = format!("{}/wrap_ignored", out.display()); + let res = std::process::Command::new(original_rustc) + .arg("./tests/support/wrap_ignored.rs") + .arg("-o") + .arg(&wrapper_output_path) + .status() + .unwrap(); + assert!(res.success(), "Failed to compile wrapper"); + println!("{wrapper_output_path}"); + // 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"); + env::set_var("RUSTC_WRAPPER", wrapper_output_path); 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!