Skip to content

Commit fc2fb66

Browse files
committed
hopefully make the tests work on win32
1 parent fc72499 commit fc2fb66

File tree

5 files changed

+32
-10
lines changed

5 files changed

+32
-10
lines changed

cc-test/build.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ fn main() {
124124
fn run_forked_capture_output(out: &Path, action: &str) {
125125
let program = env::current_exe().unwrap();
126126
let output = Command::new(&program).arg(action).output().unwrap();
127-
assert!(output.status.success());
127+
assert!(output.status.success(), "output: {:#?}", output);
128128
// we've captured the output and now we write it to a dedicated directory in the
129129
// build output so our tests can access the output.
130130
let action_dir = out.join(action);
@@ -152,10 +152,9 @@ fn build_cargo_warnings(warnings: bool) {
152152
cc::Build::new()
153153
.cargo_metadata(false)
154154
.cargo_warnings(warnings)
155-
.file("src/compile_error.c")
156-
.try_compile("compile_error")
157-
// we expect the compilation to fail in this case
158-
.unwrap_err();
155+
.file("src/compile_warning.c")
156+
.try_compile("compile_warning")
157+
.unwrap();
159158
}
160159

161160
fn build_cargo_metadata(metadata: bool) {

cc-test/src/compile_error.c

Lines changed: 0 additions & 1 deletion
This file was deleted.

cc-test/src/compile_warning.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#warning "if you see this, cargo_warnings(false) didn't do its job"
2+
3+
void compile_warning(void) {}

cc-test/src/dummy.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
11
/* just an empty file */
2+
3+
void dummy(void) {}

cc-test/tests/output.rs

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,16 +19,35 @@ fn cargo_warnings_off() {
1919
fn cargo_metadata_on() {
2020
let (stdout, stderr) = load_output("metadata-on");
2121
assert!(stderr.is_empty());
22-
assert!(stdout.contains("rustc-link-lib="));
23-
assert!(stdout.contains("rustc-link-search="));
22+
assert!(stdout.contains("cargo:rustc-link-lib="));
23+
assert!(stdout.contains("cargo:rustc-link-search="));
2424
}
2525

2626
#[test]
2727
fn cargo_metadata_off() {
2828
let (stdout, stderr) = load_output("metadata-off");
2929
assert!(stderr.is_empty());
30-
assert!(!stdout.contains("rustc-link-lib="));
31-
assert!(!stdout.contains("rustc-link-search="));
30+
31+
// most of the instructions aren't currently used
32+
const INSTRUCTIONS: &[&str] = &[
33+
"cargo:rerun-if-changed=",
34+
"cargo:rerun-if-env-changed=",
35+
"cargo:rustc-cdylib-link-arg=",
36+
"cargo:rustc-cfg=",
37+
"cargo:rustc-env=",
38+
"cargo:rustc-flags=",
39+
"cargo:rustc-link-arg-benches=",
40+
"cargo:rustc-link-arg-bin=",
41+
"cargo:rustc-link-arg-bins=",
42+
"cargo:rustc-link-arg-examples=",
43+
"cargo:rustc-link-arg-tests=",
44+
"cargo:rustc-link-arg=",
45+
"cargo:rustc-link-lib=",
46+
"cargo:rustc-link-search=",
47+
];
48+
for instr in INSTRUCTIONS {
49+
assert!(!stdout.contains(instr), "instruction present: {}", instr);
50+
}
3251
}
3352

3453
#[track_caller]

0 commit comments

Comments
 (0)