From 670f63d17ea714b9c3e0cbad5ee953fb71a822ab Mon Sep 17 00:00:00 2001 From: Simon Berger Date: Tue, 23 Jan 2024 12:50:38 +0100 Subject: [PATCH] hopefully make the tests work on win32 --- cc-test/build.rs | 4 ++-- cc-test/src/compile_error.c | 1 - cc-test/src/compile_warning.c | 1 + cc-test/tests/output.rs | 27 +++++++++++++++++++++++---- 4 files changed, 26 insertions(+), 7 deletions(-) delete mode 100644 cc-test/src/compile_error.c create mode 100644 cc-test/src/compile_warning.c diff --git a/cc-test/build.rs b/cc-test/build.rs index f1f9f1b8e..332e43cac 100644 --- a/cc-test/build.rs +++ b/cc-test/build.rs @@ -152,8 +152,8 @@ fn build_cargo_warnings(warnings: bool) { cc::Build::new() .cargo_metadata(false) .cargo_warnings(warnings) - .file("src/compile_error.c") - .try_compile("compile_error") + .file("src/compile_warning.c") + .try_compile("compile_warning") // we expect the compilation to fail in this case .unwrap_err(); } diff --git a/cc-test/src/compile_error.c b/cc-test/src/compile_error.c deleted file mode 100644 index 535ae3419..000000000 --- a/cc-test/src/compile_error.c +++ /dev/null @@ -1 +0,0 @@ -#error "if you see this, cargo_warnings(false) didn't do its job" diff --git a/cc-test/src/compile_warning.c b/cc-test/src/compile_warning.c new file mode 100644 index 000000000..17bf14be1 --- /dev/null +++ b/cc-test/src/compile_warning.c @@ -0,0 +1 @@ +#warning "if you see this, cargo_warnings(false) didn't do its job" diff --git a/cc-test/tests/output.rs b/cc-test/tests/output.rs index b891d21d4..663d20c07 100644 --- a/cc-test/tests/output.rs +++ b/cc-test/tests/output.rs @@ -19,16 +19,35 @@ fn cargo_warnings_off() { fn cargo_metadata_on() { let (stdout, stderr) = load_output("metadata-on"); assert!(stderr.is_empty()); - assert!(stdout.contains("rustc-link-lib=")); - assert!(stdout.contains("rustc-link-search=")); + assert!(stdout.contains("cargo:rustc-link-lib=")); + assert!(stdout.contains("cargo:rustc-link-search=")); } #[test] fn cargo_metadata_off() { let (stdout, stderr) = load_output("metadata-off"); assert!(stderr.is_empty()); - assert!(!stdout.contains("rustc-link-lib=")); - assert!(!stdout.contains("rustc-link-search=")); + + // most of the instructions aren't currently used + const INSTRUCTIONS: [&str] = &[ + "cargo:rerun-if-changed=", + "cargo:rerun-if-env-changed=", + "cargo:rustc-cdylib-link-arg=", + "cargo:rustc-cfg=", + "cargo:rustc-env=", + "cargo:rustc-flags=", + "cargo:rustc-link-arg-benches=", + "cargo:rustc-link-arg-bin=", + "cargo:rustc-link-arg-bins=", + "cargo:rustc-link-arg-examples=", + "cargo:rustc-link-arg-tests=", + "cargo:rustc-link-arg=", + "cargo:rustc-link-lib=", + "cargo:rustc-link-search=", + ]; + for instr in INSTRUCTIONS { + assert!(!stdout.contains(instr), instr); + } } #[track_caller]