Skip to content

Commit 813ddbf

Browse files
Correctly split between release and debug lang tests run
1 parent 86fbc24 commit 813ddbf

File tree

1 file changed

+30
-26
lines changed

1 file changed

+30
-26
lines changed

tests/lang_tests.rs

Lines changed: 30 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -46,11 +46,7 @@ fn compile_and_run_cmds(
4646
}
4747
}
4848

49-
fn main() {
50-
let tempdir = TempDir::new().expect("temp dir");
51-
let current_dir = current_dir().expect("current dir");
52-
let current_dir = current_dir.to_str().expect("current dir").to_string();
53-
49+
fn run_tests(tempdir: PathBuf, current_dir: String, is_debug: bool) {
5450
fn rust_filter(path: &Path) -> bool {
5551
path.is_file() && path.extension().expect("extension").to_str().expect("to_str") == "rs"
5652
}
@@ -69,8 +65,12 @@ fn main() {
6965
}
7066
rust_filter(filename)
7167
}
72-
// TODO(antoyo): find a way to send this via a cli argument.
73-
let test_target = std::env::var("CG_GCC_TEST_TARGET").ok();
68+
69+
if is_debug {
70+
println!("=== [DEBUG] lang tests ===");
71+
} else {
72+
println!("=== [RELEASE] lang tests ===");
73+
}
7474

7575
LangTester::new()
7676
.test_dir("tests/run")
@@ -102,6 +102,8 @@ fn main() {
102102
exe.to_str().expect("to_str").into(),
103103
path.to_str().expect("to_str").into(),
104104
];
105+
// TODO(antoyo): find a way to send this via a cli argument.
106+
let test_target = std::env::var("CG_GCC_TEST_TARGET").ok();
105107

106108
if let Some(ref target) = test_target {
107109
compiler_args.extend_from_slice(&["--target".into(), target.into()]);
@@ -115,32 +117,34 @@ fn main() {
115117
compiler_args.push(flag.into());
116118
}
117119
}
118-
let mut debug_args = compiler_args.clone();
119-
let mut release_args = compiler_args;
120120

121-
if test_target.is_some() {
122-
// m68k doesn't have lubsan for now
123-
debug_args
121+
if is_debug {
122+
compiler_args
124123
.extend_from_slice(&["-C".to_string(), "llvm-args=sanitize-undefined".into()]);
124+
if test_target.is_none() {
125+
// m68k doesn't have lubsan for now
126+
compiler_args.extend_from_slice(&["-C".into(), "link-args=-lubsan".into()]);
127+
}
125128
} else {
126-
debug_args.extend_from_slice(&[
127-
"-C".to_string(),
128-
"llvm-args=sanitize-undefined".into(),
129+
compiler_args.extend_from_slice(&[
130+
"-C".into(),
131+
"opt-level=3".into(),
129132
"-C".into(),
130-
"link-args=-lubsan".into(),
133+
"lto=no".into(),
131134
]);
132135
}
133136

134-
release_args.extend_from_slice(&[
135-
"-C".into(),
136-
"opt-level=3".into(),
137-
"-C".into(),
138-
"lto=no".into(),
139-
]);
140-
141-
let mut parts = compile_and_run_cmds(debug_args, &test_target, &exe);
142-
parts.extend(compile_and_run_cmds(release_args, &test_target, &exe));
143-
parts
137+
compile_and_run_cmds(compiler_args, &test_target, &exe)
144138
})
145139
.run();
146140
}
141+
142+
fn main() {
143+
let tempdir = TempDir::new().expect("temp dir");
144+
let current_dir = current_dir().expect("current dir");
145+
let current_dir = current_dir.to_str().expect("current dir").to_string();
146+
147+
let tempdir_path: PathBuf = tempdir.as_ref().into();
148+
run_tests(tempdir_path.clone(), current_dir.clone(), true);
149+
run_tests(tempdir_path, current_dir, false);
150+
}

0 commit comments

Comments
 (0)