| ... | @@ -2250,23 +2250,57 @@ const link_targets = blk: { | ... | @@ -2250,23 +2250,57 @@ const link_targets = blk: { |
| 2250 | }; | 2250 | }; |
| 2251 | }; | 2251 | }; |
| 2252 | | 2252 | |
| 2253 | /// Unlike `test_targets` and `c_abi_targets`, these targets are just simple strings which we pass | 2253 | const IncrementalTarget = struct { |
| 2254 | /// directly to `incr-check`. They include the target triple and the compiler backend. | 2254 | target: std.Target.Query, |
| | 2255 | backend: enum { selfhosted, llvm, cbe }, |
| | 2256 | }; |
| | 2257 | |
| | 2258 | /// These are passed to `incr-check` as `<target>-<backend>` strings. |
| 2255 | /// | 2259 | /// |
| 2256 | /// If only one specific test is failing on a target, instead of entirely disabling the target here, | 2260 | /// If only one specific test is failing on a target, instead of entirely disabling the target here, |
| 2257 | /// you can skip the target for that specific test only by adding a line like this to the manifest: | 2261 | /// you can skip the target for that specific test only by adding a line like this to the manifest: |
| 2258 | /// #skip_target=x86_64-linux-selfhosted | 2262 | /// #skip_target=x86_64-linux-selfhosted |
| 2259 | const incremental_targets: []const []const u8 = &.{ | 2263 | const incremental_targets = &[_]IncrementalTarget{ |
| 2260 | // Avoid adding more CBE or LLVM targets without good reason: they're a lot slower than others | 2264 | // Avoid adding more CBE or LLVM targets without good reason: they're a lot slower than others |
| 2261 | // to run due to the output (C source code or LLVM IR) being built non-incrementally (by Clang | 2265 | // to run due to the output (C source code or LLVM IR) being built non-incrementally (by Clang |
| 2262 | // or LLVM). We just have a couple here to make sure that it works. | 2266 | // or LLVM). We just have a couple here to make sure that it works. |
| 2263 | "x86_64-linux-cbe", | 2267 | .{ |
| 2264 | "x86_64-linux-llvm", | 2268 | .target = .{ |
| | 2269 | .cpu_arch = .x86_64, |
| | 2270 | .os_tag = .linux, |
| | 2271 | }, |
| | 2272 | .backend = .cbe, |
| | 2273 | }, |
| | 2274 | .{ |
| | 2275 | .target = .{ |
| | 2276 | .cpu_arch = .x86_64, |
| | 2277 | .os_tag = .linux, |
| | 2278 | }, |
| | 2279 | .backend = .llvm, |
| | 2280 | }, |
| 2265 | | 2281 | |
| 2266 | "x86_64-linux-selfhosted", | 2282 | .{ |
| | 2283 | .target = .{ |
| | 2284 | .cpu_arch = .x86_64, |
| | 2285 | .os_tag = .linux, |
| | 2286 | }, |
| | 2287 | .backend = .selfhosted, |
| | 2288 | }, |
| 2267 | // https://codeberg.org/ziglang/zig/issues/31773 | 2289 | // https://codeberg.org/ziglang/zig/issues/31773 |
| 2268 | //"x86_64-windows-selfhosted", | 2290 | // .{ |
| 2269 | "wasm32-wasi-selfhosted", | 2291 | // .target = .{ |
| | 2292 | // .cpu_arch = .x86_64, |
| | 2293 | // .os_tag = .windows, |
| | 2294 | // }, |
| | 2295 | // .backend = .selfhosted, |
| | 2296 | // }, |
| | 2297 | .{ |
| | 2298 | .target = .{ |
| | 2299 | .cpu_arch = .wasm32, |
| | 2300 | .os_tag = .wasi, |
| | 2301 | }, |
| | 2302 | .backend = .selfhosted, |
| | 2303 | }, |
| 2270 | }; | 2304 | }; |
| 2271 | | 2305 | |
| 2272 | fn compatible32bitArch(host: *const std.Target) ?std.Target.Cpu.Arch { | 2306 | fn compatible32bitArch(host: *const std.Target) ?std.Target.Cpu.Arch { |
| ... | @@ -3290,11 +3324,24 @@ pub fn addDebuggerTests(b: *std.Build, options: DebuggerContext.Options) ?*Step | ... | @@ -3290,11 +3324,24 @@ pub fn addDebuggerTests(b: *std.Build, options: DebuggerContext.Options) ?*Step |
| 3290 | return step; | 3324 | return step; |
| 3291 | } | 3325 | } |
| 3292 | | 3326 | |
| | 3327 | const IncrementalTestOptions = struct { |
| | 3328 | test_filters: []const []const u8, |
| | 3329 | test_target_filters: []const []const u8, |
| | 3330 | skip_non_native: bool, |
| | 3331 | skip_wasm: bool, |
| | 3332 | skip_freebsd: bool, |
| | 3333 | skip_netbsd: bool, |
| | 3334 | skip_openbsd: bool, |
| | 3335 | skip_windows: bool, |
| | 3336 | skip_darwin: bool, |
| | 3337 | skip_linux: bool, |
| | 3338 | skip_llvm: bool, |
| | 3339 | }; |
| | 3340 | |
| 3293 | pub fn addIncrementalTests( | 3341 | pub fn addIncrementalTests( |
| 3294 | b: *std.Build, | 3342 | b: *std.Build, |
| 3295 | test_step: *Step, | 3343 | test_step: *Step, |
| 3296 | test_filters: []const []const u8, | 3344 | options: IncrementalTestOptions, |
| 3297 | test_target_filters: []const []const u8, | | |
| 3298 | ) !void { | 3345 | ) !void { |
| 3299 | const io = b.graph.io; | 3346 | const io = b.graph.io; |
| 3300 | | 3347 | |
| ... | @@ -3316,9 +3363,9 @@ pub fn addIncrementalTests( | ... | @@ -3316,9 +3363,9 @@ pub fn addIncrementalTests( |
| 3316 | while (try it.next(io)) |entry| { | 3363 | while (try it.next(io)) |entry| { |
| 3317 | if (std.mem.endsWith(u8, entry.basename, ".swp")) continue; | 3364 | if (std.mem.endsWith(u8, entry.basename, ".swp")) continue; |
| 3318 | | 3365 | |
| 3319 | for (test_filters) |test_filter| { | 3366 | for (options.test_filters) |test_filter| { |
| 3320 | if (std.mem.find(u8, entry.path, test_filter)) |_| break; | 3367 | if (std.mem.find(u8, entry.path, test_filter)) |_| break; |
| 3321 | } else if (test_filters.len > 0) continue; | 3368 | } else if (options.test_filters.len > 0) continue; |
| 3322 | | 3369 | |
| 3323 | switch (entry.kind) { | 3370 | switch (entry.kind) { |
| 3324 | .file => {}, | 3371 | .file => {}, |
| ... | @@ -3329,13 +3376,35 @@ pub fn addIncrementalTests( | ... | @@ -3329,13 +3376,35 @@ pub fn addIncrementalTests( |
| 3329 | } | 3376 | } |
| 3330 | b.dependOnFileContents(b.path(b.pathJoin(&.{ "test", "incremental", entry.path }))); | 3377 | b.dependOnFileContents(b.path(b.pathJoin(&.{ "test", "incremental", entry.path }))); |
| 3331 | | 3378 | |
| 3332 | for (incremental_targets) |target_str| { | 3379 | for (incremental_targets) |test_target| { |
| 3333 | if (test_target_filters.len > 0) { | 3380 | const resolved_target = b.resolveTargetQuery(test_target.target); |
| 3334 | for (test_target_filters) |filter| { | 3381 | |
| 3335 | if (std.mem.find(u8, target_str, filter) != null) break; | 3382 | if (options.skip_non_native and !isNative(&resolved_target, &b.graph.host.result)) |
| | 3383 | continue; |
| | 3384 | |
| | 3385 | const target = &resolved_target.result; |
| | 3386 | |
| | 3387 | if (options.skip_wasm and target.cpu.arch.isWasm()) continue; |
| | 3388 | |
| | 3389 | if (options.skip_freebsd and target.os.tag == .freebsd) continue; |
| | 3390 | if (options.skip_netbsd and target.os.tag == .netbsd) continue; |
| | 3391 | if (options.skip_openbsd and target.os.tag == .openbsd) continue; |
| | 3392 | if (options.skip_windows and target.os.tag == .windows) continue; |
| | 3393 | if (options.skip_darwin and target.os.tag.isDarwin()) continue; |
| | 3394 | if (options.skip_linux and target.os.tag == .linux) continue; |
| | 3395 | |
| | 3396 | if (options.skip_llvm and test_target.backend == .llvm) continue; |
| | 3397 | |
| | 3398 | const triple_txt = resolved_target.query.zigTriple(b.allocator) catch @panic("OOM"); |
| | 3399 | |
| | 3400 | if (options.test_target_filters.len > 0) { |
| | 3401 | for (options.test_target_filters) |filter| { |
| | 3402 | if (std.mem.find(u8, triple_txt, filter) != null) break; |
| 3336 | } else continue; | 3403 | } else continue; |
| 3337 | } | 3404 | } |
| 3338 | | 3405 | |
| | 3406 | const target_str = b.fmt("{s}-{t}", .{ triple_txt, test_target.backend }); |
| | 3407 | |
| 3339 | const run = b.addRunArtifact(incr_check); | 3408 | const run = b.addRunArtifact(incr_check); |
| 3340 | run.setName(b.fmt("incr-check {s} '{s}'", .{ target_str, entry.basename })); | 3409 | run.setName(b.fmt("incr-check {s} '{s}'", .{ target_str, entry.basename })); |
| 3341 | | 3410 | |