Skip to content

Commit

Permalink
hopefully make the tests work on win32
Browse files Browse the repository at this point in the history
  • Loading branch information
scootermon committed Jan 23, 2024
1 parent fc72499 commit 670f63d
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 7 deletions.
4 changes: 2 additions & 2 deletions cc-test/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down
1 change: 0 additions & 1 deletion cc-test/src/compile_error.c

This file was deleted.

1 change: 1 addition & 0 deletions cc-test/src/compile_warning.c
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#warning "if you see this, cargo_warnings(false) didn't do its job"
27 changes: 23 additions & 4 deletions cc-test/tests/output.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down

0 comments on commit 670f63d

Please sign in to comment.