| ... | @@ -1641,6 +1641,7 @@ pub const TestStep = struct { | ... | @@ -1641,6 +1641,7 @@ pub const TestStep = struct { |
| 1641 | lib_paths: ArrayList([]const u8), | 1641 | lib_paths: ArrayList([]const u8), |
| 1642 | object_files: ArrayList([]const u8), | 1642 | object_files: ArrayList([]const u8), |
| 1643 | no_rosegment: bool, | 1643 | no_rosegment: bool, |
| | 1644 | output_path: ?[]const u8, |
| 1644 | | 1645 | |
| 1645 | pub fn init(builder: *Builder, root_src: []const u8) TestStep { | 1646 | pub fn init(builder: *Builder, root_src: []const u8) TestStep { |
| 1646 | const step_name = builder.fmt("test {}", root_src); | 1647 | const step_name = builder.fmt("test {}", root_src); |
| ... | @@ -1659,6 +1660,7 @@ pub const TestStep = struct { | ... | @@ -1659,6 +1660,7 @@ pub const TestStep = struct { |
| 1659 | .lib_paths = ArrayList([]const u8).init(builder.allocator), | 1660 | .lib_paths = ArrayList([]const u8).init(builder.allocator), |
| 1660 | .object_files = ArrayList([]const u8).init(builder.allocator), | 1661 | .object_files = ArrayList([]const u8).init(builder.allocator), |
| 1661 | .no_rosegment = false, | 1662 | .no_rosegment = false, |
| | 1663 | .output_path = null, |
| 1662 | }; | 1664 | }; |
| 1663 | } | 1665 | } |
| 1664 | | 1666 | |
| ... | @@ -1682,6 +1684,24 @@ pub const TestStep = struct { | ... | @@ -1682,6 +1684,24 @@ pub const TestStep = struct { |
| 1682 | self.build_mode = mode; | 1684 | self.build_mode = mode; |
| 1683 | } | 1685 | } |
| 1684 | | 1686 | |
| | 1687 | pub fn setOutputPath(self: *TestStep, file_path: []const u8) void { |
| | 1688 | self.output_path = file_path; |
| | 1689 | |
| | 1690 | // catch a common mistake |
| | 1691 | if (mem.eql(u8, self.builder.pathFromRoot(file_path), self.builder.pathFromRoot("."))) { |
| | 1692 | debug.panic("setOutputPath wants a file path, not a directory\n"); |
| | 1693 | } |
| | 1694 | } |
| | 1695 | |
| | 1696 | pub fn getOutputPath(self: *TestStep) []const u8 { |
| | 1697 | if (self.output_path) |output_path| { |
| | 1698 | return output_path; |
| | 1699 | } else { |
| | 1700 | const basename = self.builder.fmt("test{}", self.target.exeFileExt()); |
| | 1701 | return os.path.join(self.builder.allocator, self.builder.cache_root, basename) catch unreachable; |
| | 1702 | } |
| | 1703 | } |
| | 1704 | |
| 1685 | pub fn linkSystemLibrary(self: *TestStep, name: []const u8) void { | 1705 | pub fn linkSystemLibrary(self: *TestStep, name: []const u8) void { |
| 1686 | self.link_libs.put(name) catch unreachable; | 1706 | self.link_libs.put(name) catch unreachable; |
| 1687 | } | 1707 | } |
| ... | @@ -1746,6 +1766,10 @@ pub const TestStep = struct { | ... | @@ -1746,6 +1766,10 @@ pub const TestStep = struct { |
| 1746 | builtin.Mode.ReleaseSmall => try zig_args.append("--release-small"), | 1766 | builtin.Mode.ReleaseSmall => try zig_args.append("--release-small"), |
| 1747 | } | 1767 | } |
| 1748 | | 1768 | |
| | 1769 | const output_path = builder.pathFromRoot(self.getOutputPath()); |
| | 1770 | try zig_args.append("--output"); |
| | 1771 | try zig_args.append(output_path); |
| | 1772 | |
| 1749 | switch (self.target) { | 1773 | switch (self.target) { |
| 1750 | Target.Native => {}, | 1774 | Target.Native => {}, |
| 1751 | Target.Cross => |cross_target| { | 1775 | Target.Cross => |cross_target| { |