authorgravatar for kubkon@jakubkonka.comJakub Konka <kubkon@jakubkonka.com> 2023-09-25 21:28:06+02:00
committergravatar for kubkon@jakubkonka.comJakub Konka <kubkon@jakubkonka.com> 2023-09-26 21:07:47+02:00
log7617486f1d3d79f08d9d7a8641674c2525e83235
tree917adfc644bb6ce53cf0483b45502638b35b6059
parentb01b972999f024a694734fa9861827e5dc15a88b

elf: skip running exe on foreign hosts


1 files changed, 10 insertions(+), 3 deletions(-)

test/link/elf.zig+10-3
...@@ -29,7 +29,7 @@ fn testEmptyObject(b: *Build, opts: Options) *Step {...@@ -29,7 +29,7 @@ fn testEmptyObject(b: *Build, opts: Options) *Step {
29 addCSourceBytes(exe, "");29 addCSourceBytes(exe, "");
30 exe.is_linking_libc = true;30 exe.is_linking_libc = true;
3131
32 const run = b.addRunArtifact(exe);32 const run = addRunArtifact(exe);
33 run.expectExitCode(0);33 run.expectExitCode(0);
34 test_step.dependOn(&run.step);34 test_step.dependOn(&run.step);
3535
...@@ -49,7 +49,7 @@ fn testLinkingC(b: *Build, opts: Options) *Step {...@@ -49,7 +49,7 @@ fn testLinkingC(b: *Build, opts: Options) *Step {
49 );49 );
50 exe.is_linking_libc = true;50 exe.is_linking_libc = true;
5151
52 const run = b.addRunArtifact(exe);52 const run = addRunArtifact(exe);
53 run.expectStdOutEqual("Hello World!\n");53 run.expectStdOutEqual("Hello World!\n");
54 test_step.dependOn(&run.step);54 test_step.dependOn(&run.step);
5555
...@@ -75,7 +75,7 @@ fn testLinkingZig(b: *Build, opts: Options) *Step {...@@ -75,7 +75,7 @@ fn testLinkingZig(b: *Build, opts: Options) *Step {
75 \\}75 \\}
76 );76 );
7777
78 const run = b.addRunArtifact(exe);78 const run = addRunArtifact(exe);
79 run.expectStdErrEqual("Hello World!\n");79 run.expectStdErrEqual("Hello World!\n");
80 test_step.dependOn(&run.step);80 test_step.dependOn(&run.step);
8181
...@@ -120,6 +120,13 @@ fn addExecutable(b: *Build, opts: Options) *Compile {...@@ -120,6 +120,13 @@ fn addExecutable(b: *Build, opts: Options) *Compile {
120 });120 });
121}121}
122122
123fn addRunArtifact(comp: *Compile) *Run {
124 const b = comp.step.owner;
125 const run = b.addRunArtifact(comp);
126 run.skip_foreign_checks = true;
127 return run;
128}
129
123fn addZigSourceBytes(comp: *Compile, bytes: []const u8) void {130fn addZigSourceBytes(comp: *Compile, bytes: []const u8) void {
124 const b = comp.step.owner;131 const b = comp.step.owner;
125 const file = WriteFile.create(b).add("a.zig", bytes);132 const file = WriteFile.create(b).add("a.zig", bytes);