| ... | @@ -89,19 +89,22 @@ pub fn addCase(self: *CompareOutput, case: TestCase) void { | ... | @@ -89,19 +89,22 @@ pub fn addCase(self: *CompareOutput, case: TestCase) void { |
| 89 | | 89 | |
| 90 | switch (case.special) { | 90 | switch (case.special) { |
| 91 | Special.Asm => { | 91 | Special.Asm => { |
| 92 | const annotated_case_name = fmt.allocPrint(self.b.allocator, "run assemble-and-link {s}", .{ | 92 | const annotated_case_name = b.fmt("run assemble-and-link {s}", .{ |
| 93 | case.name, | 93 | case.name, |
| 94 | }) catch @panic("OOM"); | 94 | }); |
| 95 | for (self.test_filters) |test_filter| { | 95 | for (self.test_filters) |test_filter| { |
| 96 | if (mem.indexOf(u8, annotated_case_name, test_filter)) |_| break; | 96 | if (mem.indexOf(u8, annotated_case_name, test_filter)) |_| break; |
| 97 | } else if (self.test_filters.len > 0) return; | 97 | } else if (self.test_filters.len > 0) return; |
| 98 | | 98 | |
| 99 | const exe = b.addExecutable(.{ | 99 | const exe = b.addExecutable(.{ |
| 100 | .name = "test", | 100 | .name = "test", |
| 101 | .target = b.graph.host, | 101 | .root_module = b.createModule(.{ |
| 102 | .optimize = .Debug, | 102 | .root_source_file = null, |
| | 103 | .target = b.graph.host, |
| | 104 | .optimize = .Debug, |
| | 105 | }), |
| 103 | }); | 106 | }); |
| 104 | exe.addAssemblyFile(first_file); | 107 | exe.root_module.addAssemblyFile(first_file); |
| 105 | | 108 | |
| 106 | const run = b.addRunArtifact(exe); | 109 | const run = b.addRunArtifact(exe); |
| 107 | run.setName(annotated_case_name); | 110 | run.setName(annotated_case_name); |
| ... | @@ -112,22 +115,22 @@ pub fn addCase(self: *CompareOutput, case: TestCase) void { | ... | @@ -112,22 +115,22 @@ pub fn addCase(self: *CompareOutput, case: TestCase) void { |
| 112 | }, | 115 | }, |
| 113 | Special.None => { | 116 | Special.None => { |
| 114 | for (self.optimize_modes) |optimize| { | 117 | for (self.optimize_modes) |optimize| { |
| 115 | const annotated_case_name = fmt.allocPrint(self.b.allocator, "run compare-output {s} ({s})", .{ | 118 | const annotated_case_name = b.fmt("run compare-output {s} ({s})", .{ |
| 116 | case.name, @tagName(optimize), | 119 | case.name, @tagName(optimize), |
| 117 | }) catch @panic("OOM"); | 120 | }); |
| 118 | for (self.test_filters) |test_filter| { | 121 | for (self.test_filters) |test_filter| { |
| 119 | if (mem.indexOf(u8, annotated_case_name, test_filter)) |_| break; | 122 | if (mem.indexOf(u8, annotated_case_name, test_filter)) |_| break; |
| 120 | } else if (self.test_filters.len > 0) return; | 123 | } else if (self.test_filters.len > 0) return; |
| 121 | | 124 | |
| 122 | const exe = b.addExecutable(.{ | 125 | const exe = b.addExecutable(.{ |
| 123 | .name = "test", | 126 | .name = "test", |
| 124 | .root_source_file = first_file, | 127 | .root_module = b.createModule(.{ |
| 125 | .optimize = optimize, | 128 | .root_source_file = first_file, |
| 126 | .target = b.graph.host, | 129 | .optimize = optimize, |
| | 130 | .target = b.graph.host, |
| | 131 | }), |
| 127 | }); | 132 | }); |
| 128 | if (case.link_libc) { | 133 | if (case.link_libc) exe.root_module.link_libc = true; |
| 129 | exe.linkSystemLibrary("c"); | | |
| 130 | } | | |
| 131 | | 134 | |
| 132 | const run = b.addRunArtifact(exe); | 135 | const run = b.addRunArtifact(exe); |
| 133 | run.setName(annotated_case_name); | 136 | run.setName(annotated_case_name); |
| ... | @@ -140,20 +143,20 @@ pub fn addCase(self: *CompareOutput, case: TestCase) void { | ... | @@ -140,20 +143,20 @@ pub fn addCase(self: *CompareOutput, case: TestCase) void { |
| 140 | Special.RuntimeSafety => { | 143 | Special.RuntimeSafety => { |
| 141 | // TODO iterate over self.optimize_modes and test this in both | 144 | // TODO iterate over self.optimize_modes and test this in both |
| 142 | // debug and release safe mode | 145 | // debug and release safe mode |
| 143 | const annotated_case_name = fmt.allocPrint(self.b.allocator, "run safety {s}", .{case.name}) catch @panic("OOM"); | 146 | const annotated_case_name = b.fmt("run safety {s}", .{case.name}); |
| 144 | for (self.test_filters) |test_filter| { | 147 | for (self.test_filters) |test_filter| { |
| 145 | if (mem.indexOf(u8, annotated_case_name, test_filter)) |_| break; | 148 | if (mem.indexOf(u8, annotated_case_name, test_filter)) |_| break; |
| 146 | } else if (self.test_filters.len > 0) return; | 149 | } else if (self.test_filters.len > 0) return; |
| 147 | | 150 | |
| 148 | const exe = b.addExecutable(.{ | 151 | const exe = b.addExecutable(.{ |
| 149 | .name = "test", | 152 | .name = "test", |
| 150 | .root_source_file = first_file, | 153 | .root_module = b.createModule(.{ |
| 151 | .target = b.graph.host, | 154 | .root_source_file = first_file, |
| 152 | .optimize = .Debug, | 155 | .target = b.graph.host, |
| | 156 | .optimize = .Debug, |
| | 157 | }), |
| 153 | }); | 158 | }); |
| 154 | if (case.link_libc) { | 159 | if (case.link_libc) exe.root_module.link_libc = true; |
| 155 | exe.linkSystemLibrary("c"); | | |
| 156 | } | | |
| 157 | | 160 | |
| 158 | const run = b.addRunArtifact(exe); | 161 | const run = b.addRunArtifact(exe); |
| 159 | run.setName(annotated_case_name); | 162 | run.setName(annotated_case_name); |
| ... | @@ -168,7 +171,6 @@ pub fn addCase(self: *CompareOutput, case: TestCase) void { | ... | @@ -168,7 +171,6 @@ pub fn addCase(self: *CompareOutput, case: TestCase) void { |
| 168 | const CompareOutput = @This(); | 171 | const CompareOutput = @This(); |
| 169 | const std = @import("std"); | 172 | const std = @import("std"); |
| 170 | const ArrayList = std.ArrayList; | 173 | const ArrayList = std.ArrayList; |
| 171 | const fmt = std.fmt; | | |
| 172 | const mem = std.mem; | 174 | const mem = std.mem; |
| 173 | const fs = std.fs; | 175 | const fs = std.fs; |
| 174 | const OptimizeMode = std.builtin.OptimizeMode; | 176 | const OptimizeMode = std.builtin.OptimizeMode; |