diff options
| author | Andrew Kelley <andrew@ziglang.org> | 2020-09-28 22:19:00 -0700 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2020-09-28 22:19:00 -0700 |
| commit | ef9582a1ec452aab816b67cd2d0d35ef7356ddae (patch) | |
| tree | af7aefb6f7ec33d9921681b99309ab49cdd6cf39 /src/main.zig | |
| parent | 29fd13009391060a2d6783fb0b91cb075c2e6cce (diff) | |
| download | zig-ef9582a1ec452aab816b67cd2d0d35ef7356ddae.tar.gz zig-ef9582a1ec452aab816b67cd2d0d35ef7356ddae.zip | |
`zig test` and `zig run` do not try to run foreign binaries
Diffstat (limited to 'src/main.zig')
| -rw-r--r-- | src/main.zig | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/src/main.zig b/src/main.zig index d96cfaf526..61ef77cce7 100644 --- a/src/main.zig +++ b/src/main.zig @@ -1618,6 +1618,17 @@ fn buildOutputType( defer argv.deinit(); if (test_exec_args.items.len == 0) { + if (!std.Target.current.canExecBinariesOf(target_info.target)) { + switch (arg_mode) { + .zig_test => { + warn("created {s} but skipping execution because it is non-native", .{exe_path}); + if (!watch) return cleanExit(); + break :run; + }, + .run => fatal("unable to execute {s}: non-native", .{exe_path}), + else => unreachable, + } + } try argv.append(exe_path); } else { for (test_exec_args.items) |arg| { @@ -2128,8 +2139,8 @@ pub fn cmdBuild(gpa: *Allocator, arena: *Allocator, args: []const []const u8) !v error.FileNotFound => { dirname = fs.path.dirname(dirname) orelse { std.log.info("{}", .{ - \\Initialize a 'build.zig' template file with `zig init-lib` or `zig init-exe`, - \\or see `zig --help` for more options. + \\Initialize a 'build.zig' template file with `zig init-lib` or `zig init-exe`, + \\or see `zig --help` for more options. }); fatal("No 'build.zig' file found, in the current directory or any parent directories.", .{}); }; |
