Skip to content

Commit 5ac2233

Browse files
feat: configure test-files to run all intrinsics in the same process
1 parent 09a537e commit 5ac2233

File tree

2 files changed

+7
-21
lines changed

2 files changed

+7
-21
lines changed

crates/intrinsic-test/src/common/gen_c.rs

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -147,22 +147,14 @@ pub fn write_main_cpp<'a>(
147147
}
148148

149149
writeln!(w, "int main(int argc, char **argv) {{")?;
150-
writeln!(w, " std::string intrinsic_name = argv[1];")?;
151-
152-
writeln!(w, " if (false) {{")?;
153150

154151
for intrinsic in intrinsics {
155-
writeln!(w, " }} else if (intrinsic_name == \"{intrinsic}\") {{")?;
156-
writeln!(w, " return run_{intrinsic}();")?;
152+
writeln!(w, " std::cout << \"############\" << std::endl;")?;
153+
writeln!(w, " std::cout << \"{intrinsic}\" << std::endl;")?;
154+
writeln!(w, " run_{intrinsic}();\n")?;
157155
}
158156

159-
writeln!(w, " }} else {{")?;
160-
writeln!(
161-
w,
162-
" std::cerr << \"Unknown command: \" << intrinsic_name << \"\\n\";"
163-
)?;
164-
writeln!(w, " return -1;")?;
165-
writeln!(w, " }}")?;
157+
writeln!(w, " return 0;")?;
166158

167159
writeln!(w, "}}")?;
168160

crates/intrinsic-test/src/common/gen_rust.rs

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -86,18 +86,12 @@ pub fn write_main_rs<'a>(
8686

8787
writeln!(w, "fn main() {{")?;
8888

89-
writeln!(w, " match std::env::args().nth(1).unwrap().as_str() {{")?;
90-
9189
for binary in intrinsics {
92-
writeln!(w, " \"{binary}\" => run_{binary}(),")?;
90+
writeln!(w, " println!(\"############\");")?;
91+
writeln!(w, " println!(\"{binary}\");")?;
92+
writeln!(w, " run_{binary}();\n")?;
9393
}
9494

95-
writeln!(
96-
w,
97-
" other => panic!(\"unknown intrinsic `{{}}`\", other),"
98-
)?;
99-
100-
writeln!(w, " }}")?;
10195
writeln!(w, "}}")?;
10296

10397
Ok(())

0 commit comments

Comments
 (0)