Fix local C headers when rex runs inside their folder
The header's folder was an empty path there, so a bare -I swallowed the '-' (stdin) argument and cc failed with 'no input files'. Pass the header's absolute folder instead. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
a68c720755
commit
36eacc0011
2 files changed
+18
-1
No files matched your search
@@ -311,3 +311,16 @@ fn a_wrapper_file_can_have_the_headers_name() {
|
||||
]);
|
||||
assert_eq!(out, "shapes.Size{w: 2, h: 3} 6.0\n");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_local_header_from_inside_its_folder() {
|
||||
// `rex run main.rex` in the folder itself: the header's folder is the empty path there
|
||||
let dir = folder(&[
|
||||
("consts.h", "#define ANSWER 42\nstatic inline int twice(int n) { return n * 2; }\n"),
|
||||
("main.rex", "import \"consts.h\"\n\nfunc main() {\n print(consts.twice(consts.ANSWER))\n}\n"),
|
||||
]);
|
||||
let o = Command::new(env!("CARGO_BIN_EXE_rex")).args(["run", "main.rex"]).current_dir(&dir).output().unwrap();
|
||||
let _ = std::fs::remove_dir_all(&dir);
|
||||
assert!(o.status.success(), "{}", String::from_utf8_lossy(&o.stderr));
|
||||
assert_eq!(String::from_utf8_lossy(&o.stdout), "84\n");
|
||||
}
|
||||
Reference in new issue
Block a user