Skip to content

Commit 8811d19

Browse files
committed
ctest: Add generation, compilation, and running of tests for constants.
1 parent 27d3507 commit 8811d19

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

ctest-next/build.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ fn main() {
1414
println!(
1515
"cargo:rustc-env={}={}",
1616
"LINKER",
17-
env::var("CC").unwrap_or("cc".to_string())
17+
env::var("CC").unwrap_or("".to_string())
1818
);
1919
println!("cargo:rerun-if-changed-env=TARGET")
2020
}

ctest-next/src/runner.rs

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,20 +31,24 @@ pub fn compile_test<P: AsRef<Path>>(
3131
canonicalize(crate_path)?.display()
3232
)?;
3333
writeln!(file, "include!(r#\"{}.rs\"#);", library_file.display())?;
34-
let output = Command::new(rustc)
35-
.arg(&rust_file)
34+
let mut cmd = Command::new(rustc);
35+
cmd.arg(&rust_file)
3636
.arg(format!("-Lnative={}", output_dir.display()))
3737
.arg(format!(
3838
"-lstatic={}",
3939
library_file.file_stem().unwrap().to_str().unwrap()
4040
))
4141
.arg("--target")
4242
.arg(env::var("TARGET_PLATFORM").unwrap())
43-
.arg(format!("-Clinker={}", env::var("LINKER").unwrap()))
4443
.arg("-o")
4544
.arg(&binary_path)
46-
.arg("-Aunused")
47-
.output()?;
45+
.arg("-Aunused");
46+
47+
let linker = env::var("LINKER").unwrap();
48+
if !linker.is_empty() {
49+
cmd.arg(format!("-Clinker={}", linker));
50+
}
51+
let output = cmd.output()?;
4852

4953
if !output.status.success() {
5054
return Err(std::str::from_utf8(&output.stderr)?.into());

0 commit comments

Comments
 (0)