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 fc2fb66
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 10 deletions.
9 changes: 4 additions & 5 deletions cc-test/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ fn main() {
fn run_forked_capture_output(out: &Path, action: &str) {
let program = env::current_exe().unwrap();
let output = Command::new(&program).arg(action).output().unwrap();
assert!(output.status.success());
assert!(output.status.success(), "output: {:#?}", output);
// we've captured the output and now we write it to a dedicated directory in the
// build output so our tests can access the output.
let action_dir = out.join(action);
Expand Down Expand Up @@ -152,10 +152,9 @@ fn build_cargo_warnings(warnings: bool) {
cc::Build::new()
.cargo_metadata(false)
.cargo_warnings(warnings)
.file("src/compile_error.c")
.try_compile("compile_error")
// we expect the compilation to fail in this case
.unwrap_err();
.file("src/compile_warning.c")
.try_compile("compile_warning")
.unwrap();
}

fn build_cargo_metadata(metadata: bool) {
Expand Down
1 change: 0 additions & 1 deletion cc-test/src/compile_error.c

This file was deleted.

3 changes: 3 additions & 0 deletions cc-test/src/compile_warning.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#warning "if you see this, cargo_warnings(false) didn't do its job"

void compile_warning(void) {}
2 changes: 2 additions & 0 deletions cc-test/src/dummy.c
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
/* just an empty file */

void dummy(void) {}
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), "instruction present: {}", instr);
}
}

#[track_caller]
Expand Down

0 comments on commit fc2fb66

Please sign in to comment.