aboutsummaryrefslogtreecommitdiff
path: root/test/src/Cases.zig
diff options
context:
space:
mode:
authorJacob Young <jacobly0@users.noreply.github.com>2023-07-19 18:19:48 -0400
committerJacob Young <jacobly0@users.noreply.github.com>2023-07-19 23:20:25 -0400
commite7ea7d3480bd015053d34474a23cdf407a6a545f (patch)
treefc98a4630e04378699dbf7c51513e59f385524f0 /test/src/Cases.zig
parentce859cfcb8c87b83c55209b5321ee86b9e5e80a7 (diff)
downloadzig-e7ea7d3480bd015053d34474a23cdf407a6a545f.tar.gz
zig-e7ea7d3480bd015053d34474a23cdf407a6a545f.zip
test: fix cbe execution tests
Diffstat (limited to 'test/src/Cases.zig')
-rw-r--r--test/src/Cases.zig33
1 files changed, 31 insertions, 2 deletions
diff --git a/test/src/Cases.zig b/test/src/Cases.zig
index b1f11129e4..92ec3cb35f 100644
--- a/test/src/Cases.zig
+++ b/test/src/Cases.zig
@@ -467,6 +467,9 @@ pub fn lowerToBuildSteps(
cases_dir_path: []const u8,
incremental_exe: *std.Build.Step.Compile,
) void {
+ const host = std.zig.system.NativeTargetInfo.detect(.{}) catch |err|
+ std.debug.panic("unable to detect notive host: {s}\n", .{@errorName(err)});
+
for (self.incremental_cases.items) |incr_case| {
if (true) {
// TODO: incremental tests are disabled for now, as incremental compilation bugs were
@@ -569,8 +572,34 @@ pub fn lowerToBuildSteps(
artifact.expect_errors = expected_msgs;
parent_step.dependOn(&artifact.step);
},
- .Execution => |expected_stdout| {
- const run = b.addRunArtifact(artifact);
+ .Execution => |expected_stdout| no_exec: {
+ const run = if (case.target.ofmt == .c) run_step: {
+ const target_info = std.zig.system.NativeTargetInfo.detect(case.target) catch |err|
+ std.debug.panic("unable to detect notive host: {s}\n", .{@errorName(err)});
+ if (host.getExternalExecutor(target_info, .{ .link_libc = true }) != .native) {
+ // We wouldn't be able to run the compiled C code.
+ break :no_exec;
+ }
+ const run_c = b.addSystemCommand(&.{
+ b.zig_exe,
+ "run",
+ "-cflags",
+ "-Ilib",
+ "-std=c99",
+ "-pedantic",
+ "-Werror",
+ "-Wno-dollar-in-identifier-extension",
+ "-Wno-incompatible-library-redeclaration", // https://github.com/ziglang/zig/issues/875
+ "-Wno-incompatible-pointer-types",
+ "-Wno-overlength-strings",
+ "--",
+ "-lc",
+ "-target",
+ case.target.zigTriple(b.allocator) catch @panic("OOM"),
+ });
+ run_c.addArtifactArg(artifact);
+ break :run_step run_c;
+ } else b.addRunArtifact(artifact);
run.skip_foreign_checks = true;
if (!case.is_test) {
run.expectStdOutEqual(expected_stdout);