| ... | ... | @@ -3582,3 +3582,58 @@ test "LibExeObjStep.addPackage" { |
| 3582 | 3582 | const dupe = exe.packages.items[0]; |
| 3583 | 3583 | try std.testing.expectEqualStrings(pkg_top.name, dupe.name); |
| 3584 | 3584 | } |
| 3585 | |
| 3586 | test "build_runner issue 10381" { |
| 3587 | if (builtin.os.tag == .wasi) return error.SkipZigTest; |
| 3588 | |
| 3589 | const progstr = |
| 3590 | \\ pub fn main() u8 { |
| 3591 | \\ return 1; |
| 3592 | \\ } |
| 3593 | ; |
| 3594 | |
| 3595 | const buildstr = |
| 3596 | \\ const std = @import("std"); |
| 3597 | \\ pub fn build(b: *std.build.Builder) void { |
| 3598 | \\ const exe = b.addExecutable("source", "source.zig"); |
| 3599 | \\ exe.install(); |
| 3600 | \\ const run_cmd = exe.run(); |
| 3601 | \\ run_cmd.step.dependOn(b.getInstallStep()); |
| 3602 | \\ const run_step = b.step("run", "Run"); |
| 3603 | \\ run_step.dependOn(&run_cmd.step); |
| 3604 | \\ } |
| 3605 | ; |
| 3606 | |
| 3607 | const testing = std.testing; |
| 3608 | const allocator = testing.allocator; |
| 3609 | |
| 3610 | var it = try std.process.argsWithAllocator(allocator); |
| 3611 | defer it.deinit(); |
| 3612 | const testargs = try testing.getTestArgs(&it); |
| 3613 | |
| 3614 | var tmpdir = testing.tmpDir(.{ .no_follow = true }); |
| 3615 | defer tmpdir.cleanup(); |
| 3616 | const tmpdir_path = try tmpdir.getFullPath(allocator); |
| 3617 | defer allocator.free(tmpdir_path); |
| 3618 | |
| 3619 | try tmpdir.dir.writeFile("source.zig", progstr); |
| 3620 | try tmpdir.dir.writeFile("build.zig", buildstr); |
| 3621 | |
| 3622 | const cwd_path = try std.process.getCwdAlloc(allocator); |
| 3623 | defer allocator.free(cwd_path); |
| 3624 | const lib_dir = try std.fs.path.join(allocator, &.{ cwd_path, "lib" }); |
| 3625 | defer allocator.free(lib_dir); |
| 3626 | |
| 3627 | const result = try testing.runZigBuild(testargs.zigexec, .{ |
| 3628 | .subcmd = "run", |
| 3629 | .cwd = tmpdir_path, |
| 3630 | .lib_dir = lib_dir, |
| 3631 | }); |
| 3632 | defer { |
| 3633 | allocator.free(result.stdout); |
| 3634 | allocator.free(result.stderr); |
| 3635 | } |
| 3636 | |
| 3637 | try testing.expectEqual(result.term, .{ .Exited = 1 }); |
| 3638 | try testing.expect(std.mem.indexOf(u8, result.stderr, "error: UnexpectedExitCode") == null); |
| 3639 | } |