Skip to content

Commit 011666f

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

1 file changed

Lines changed: 37 additions & 27 deletions

File tree

tests/lang_tests.rs

Lines changed: 37 additions & 27 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,40 @@ 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
124-
.extend_from_slice(&["-C".to_string(), "llvm-args=sanitize-undefined".into()]);
121+
if is_debug {
122+
if test_target.is_some() {
123+
// m68k doesn't have lubsan for now
124+
compiler_args
125+
.extend_from_slice(&["-C".to_string(), "llvm-args=sanitize-undefined".into()]);
126+
} else {
127+
compiler_args.extend_from_slice(&[
128+
"-C".to_string(),
129+
"llvm-args=sanitize-undefined".into(),
130+
"-C".into(),
131+
"link-args=-lubsan".into(),
132+
]);
133+
}
125134
} else {
126-
debug_args.extend_from_slice(&[
127-
"-C".to_string(),
128-
"llvm-args=sanitize-undefined".into(),
135+
compiler_args.extend_from_slice(&[
136+
"-C".into(),
137+
"opt-level=3".into(),
129138
"-C".into(),
130-
"link-args=-lubsan".into(),
139+
"lto=no".into(),
131140
]);
132141
}
133142

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
143+
compile_and_run_cmds(compiler_args, &test_target, &exe)
144144
})
145145
.run();
146146
}
147+
148+
fn main() {
149+
let tempdir = TempDir::new().expect("temp dir");
150+
let current_dir = current_dir().expect("current dir");
151+
let current_dir = current_dir.to_str().expect("current dir").to_string();
152+
153+
let tempdir_path: PathBuf = tempdir.as_ref().into();
154+
run_tests(tempdir_path.clone(), current_dir.clone(), false);
155+
run_tests(tempdir_path, current_dir, true);
156+
}

0 commit comments

Comments
 (0)