╭─────────────╮ │scroll to top│ ╰─────────────╯ ╭ tests.zig ────────────────────────────────────────────────────╮ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ╰───────────────────────────────────────────────────────────────╯
╭ find file ─ ─ ─ ─ ─ ─ ─ ─ ─ ─╮ ╭────╮ ╭ clone ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ╮ │ │ │http│ ssh │ │ ╰ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─╯ ╰────╯ ╰ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ╯
3410 while (try it.next(io)) |entry| { 3411 if (std.mem.endsWith(u8, entry.basename, ".swp")) continue; 3412 3413 for (options.test_filters) |test_filter| { 3414 if (std.mem.find(u8, entry.path, test_filter)) |_| break; 3415 } else if (options.test_filters.len > 0) continue; 3416 3417 switch (entry.kind) { 3418 .file => {}, 3419 .directory => { 3420 b.dependOnDirectoryContents(b.path(b.pathJoin(&.{ "test", "incremental", entry.path }))); 3421 }, 3422 else => continue, 3423 } 3424 b.dependOnFileContents(b.path(b.pathJoin(&.{ "test", "incremental", entry.path }))); 3425 3426 for (incremental_targets) |test_target| { 3427 const resolved_target = b.resolveTargetQuery(test_target.target); 3428 3429 if (options.skip_non_native and !isNative(&resolved_target, &b.graph.host.result)) 3430 continue; 3431 3432 const target = &resolved_target.result; 3433 3434 if (options.skip_wasm and target.cpu.arch.isWasm()) continue; 3435 3436 if (options.skip_freebsd and target.os.tag == .freebsd) continue; 3437 if (options.skip_netbsd and target.os.tag == .netbsd) continue; 3438 if (options.skip_openbsd and target.os.tag == .openbsd) continue; 3439 if (options.skip_windows and target.os.tag == .windows) continue; 3440 if (options.skip_darwin and target.os.tag.isDarwin()) continue; 3441 if (options.skip_linux and target.os.tag == .linux) continue; 3442 3443 if (options.skip_llvm and test_target.backend == .llvm) continue; 3444 3445 const target_str = b.fmt("{s}-{t}", .{ 3446 resolved_target.query.zigTriple(b.allocator) catch @panic("OOM"), 3447 test_target.backend, 3448 }); 3449 3450 if (options.test_target_filters.len > 0) { 3451 for (options.test_target_filters) |filter| { 3452 if (std.mem.find(u8, target_str, filter) != null) break; 3453 } else continue; 3454 } 3455 3456 const run = b.addRunArtifact(incr_check); 3457 run.setName(b.fmt("incr-check {s} '{s}'", .{ target_str, entry.basename })); 3458 3459 run.addArg(b.graph.zig_exe); 3460 run.addFileArg(b.path("test/incremental/").path(b, entry.path)); 3461 3462 run.addArg("--zig-lib-dir"); 3463 run.addDirectoryArg(.zig_lib); 3464 3465 run.addArgs(&.{ "--target", target_str }); 3466 3467 run.addArg("--quiet"); // don't fill stderr telling us about skipped tests etc 3468 3469 run.addThirdPartyEnabledArgDarling(.{ .enabled = "-fdarling" }); 3470 run.addThirdPartyEnabledArgQemu(.{ .enabled = "-fqemu" }); 3471 run.addThirdPartyEnabledArgRosetta(.{ .enabled = "-frosetta" }); 3472 run.addThirdPartyEnabledArgWasmtime(.{ .enabled = "-fwasmtime" }); 3473 run.addThirdPartyEnabledArgWine(.{ .enabled = "-fwine" }); 3474 3475 run.addCheck(.{ .expect_term = .{ .exited = 0 } }); 3476 test_step.dependOn(&run.step); 3477 } 3478 } 3479 } 3480 3481 pub fn addLlvmIrTests(b: *std.Build, options: LlvmIrContext.Options) ?*Step { 3482 const step = b.step("test-llvm-ir", "Run the LLVM IR tests"); 3483 3484 if (!options.enable_llvm) { 3485 step.dependOn(&b.addFail("test-llvm-ir requires -Denable-llvm").step); 3486 return null; 3487 } 3488 3489 var context: LlvmIrContext = .{ 3490 .b = b, 3491 .options = options, 3492 .root_step = step, 3493 }; 3494 3495 llvm_ir.addCases(&context); 3496 3497 return step; 3498 } 3499 3500 const libc_test_nsz_targets: []const std.Target.Query = &.{ 3501 .{ 3502 .cpu_arch = .arm, 3503 .os_tag = .linux, 3504 .abi = .musleabi, 3505 }, 3506 .{ 3507 .cpu_arch = .arm, 3508 .os_tag = .linux, 3509 .abi = .musleabihf, 3510 }, 3511 .{ 3512 .cpu_arch = .armeb, 3513 .os_tag = .linux, 3514 .abi = .musleabi, 3515 }, 3516 .{ 3517 .cpu_arch = .armeb, 3518 .os_tag = .linux, 3519 .abi = .musleabihf, 3520 }, 3521 .{ 3522 .cpu_arch = .thumb, 3523 .os_tag = .linux, 3524 .abi = .musleabi, 3525 }, 3526 .{ 3527 .cpu_arch = .thumb, 3528 .os_tag = .linux, 3529 .abi = .musleabihf, 3530 }, 3531 .{ 3532 .cpu_arch = .thumbeb, 3533 .os_tag = .linux, 3534 .abi = .musleabi, 3535 }, 3536 .{ 3537 .cpu_arch = .thumbeb, 3538 .os_tag = .linux, 3539 .abi = .musleabihf, 3540 }, 3541 .{ 3542 .cpu_arch = .aarch64, 3543 .os_tag = .linux, 3544 .abi = .musl, 3545 }, 3546 .{ 3547 .cpu_arch = .aarch64_be, 3548 .os_tag = .linux, 3549 .abi = .musl, 3550 }, 3551 // .{ 3552 // .cpu_arch = .hexagon, 3553 // .os_tag = .linux, 3554 // .abi = .musl, 3555 // }, 3556 .{ 3557 .cpu_arch = .loongarch64, 3558 .os_tag = .linux, 3559 .abi = .musl, 3560 }, 3561 .{ 3562 .cpu_arch = .loongarch64, 3563 .os_tag = .linux, 3564 .abi = .muslsf, 3565 }, 3566 // .{ 3567 // .cpu_arch = .mips, 3568 // .os_tag = .linux, 3569 // .abi = .musleabi, 3570 // }, 3571 // .{ 3572 // .cpu_arch = .mips, 3573 // .os_tag = .linux, 3574 // .abi = .musleabihf, 3575 // }, 3576 // .{ 3577 // .cpu_arch = .mipsel, 3578 // .os_tag = .linux, 3579 // .abi = .musleabi, 3580 // }, 3581 // .{ 3582 // .cpu_arch = .mipsel, 3583 // .os_tag = .linux, 3584 // .abi = .musleabihf, 3585 // }, 3586 // .{ 3587 // .cpu_arch = .mips64, 3588 // .os_tag = .linux, 3589 // .abi = .muslabi64, 3590 // }, 3591 // .{ 3592 // .cpu_arch = .mips64, 3593 // .os_tag = .linux, 3594 // .abi = .muslabin32, 3595 // }, 3596 // .{ 3597 // .cpu_arch = .mips64el, 3598 // .os_tag = .linux, 3599 // .abi = .muslabi64, 3600 // }, 3601 // .{ 3602 // .cpu_arch = .mips64el, 3603 // .os_tag = .linux, 3604 // .abi = .muslabin32, 3605 // }, 3606 .{ 3607 .cpu_arch = .powerpc, 3608 .os_tag = .linux, 3609 .abi = .musleabi, 3610 }, 3611 .{ 3612 .cpu_arch = .powerpc, 3613 .os_tag = .linux, 3614 .abi = .musleabihf, 3615 }, 3616 .{ 3617 .cpu_arch = .powerpc64, 3618 .os_tag = .linux, 3619 .abi = .musl, 3620 }, 3621 .{ 3622 .cpu_arch = .powerpc64le, 3623 .os_tag = .linux, 3624 .abi = .musl, 3625 }, 3626 .{ 3627 .cpu_arch = .riscv32, 3628 .os_tag = .linux, 3629 .abi = .musl, 3630 }, 3631 .{ 3632 .cpu_arch = .riscv64, 3633 .os_tag = .linux, 3634 .abi = .musl, 3635 }, 3636 .{ 3637 .cpu_arch = .s390x, 3638 .os_tag = .linux, 3639 .abi = .musl, 3640 }, 3641 .{ 3642 .cpu_arch = .wasm32, 3643 .os_tag = .wasi, 3644 .abi = .musl, 3645 }, 3646 .{ 3647 .cpu_arch = .x86, 3648 .os_tag = .linux, 3649 .abi = .musl, 3650 }, 3651 .{ 3652 .cpu_arch = .x86_64, 3653 .os_tag = .linux, 3654 .abi = .musl, 3655 }, 3656 .{ 3657 .cpu_arch = .x86_64, 3658 .os_tag = .linux, 3659 .abi = .muslx32, 3660 }, 3661 }; 3662 3663 pub fn addLibcTestNszTests(b: *std.Build, options: LibcContext.Options) ?*Step { 3664 const step = b.step("test-libc-nsz", "Run external libc-test test cases"); 3665 const opt_libc_test_path = b.option(std.Build.LazyPath, "libc-test-path", "path to libc-test source directory"); 3666 if (opt_libc_test_path) |libc_test_path| { 3667 var context: LibcContext = .{ 3668 .b = b, 3669 .options = options, 3670 .root_step = step, 3671 .libc_test_src_path = libc_test_path.path(b, "src"), 3672 }; 3673 3674 libc.addCases(&context); 3675 3676 for (libc_test_nsz_targets) |target_query| { 3677 const target = b.resolveTargetQuery(target_query); 3678 context.addTarget(target); 3679 } 3680 3681 return step; 3682 } else { 3683 step.dependOn(&b.addFail("The -Dlibc-test-path=... option is required for this step").step); 3684 return null; 3685 } 3686 } 3687