From c4466496ffb53fe83644ea2b0e43f9f46a3361b8 Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Wed, 17 Aug 2022 22:17:19 -0700 Subject: [PATCH] build: hook up -Dskip-stage2-tests and remove test-toolchain --- build.zig | 48 +++++++++++++++++++----------------------- ci/azure/pipelines.yml | 3 ++- test/tests.zig | 6 ++++++ 3 files changed, 30 insertions(+), 27 deletions(-) diff --git a/build.zig b/build.zig index bb3db637d6..c8e757dc4e 100644 --- a/build.zig +++ b/build.zig @@ -15,6 +15,7 @@ const stack_size = 32 * 1024 * 1024; pub fn build(b: *Builder) !void { b.setPreferredReleaseMode(.ReleaseFast); + const test_step = b.step("test", "Run all the tests"); const mode = b.standardReleaseOptions(); const target = b.standardTargetOptions(.{}); const single_threaded = b.option(bool, "single-threaded", "Build artifacts that run in single threaded mode"); @@ -39,8 +40,6 @@ pub fn build(b: *Builder) !void { const docs_step = b.step("docs", "Build documentation"); docs_step.dependOn(&docgen_cmd.step); - const toolchain_step = b.step("test-toolchain", "Run the tests for the toolchain"); - var test_cases = b.addTest("src/test.zig"); test_cases.stack_size = stack_size; test_cases.setBuildMode(mode); @@ -149,7 +148,7 @@ pub fn build(b: *Builder) !void { exe.setBuildMode(mode); exe.setTarget(target); if (!skip_stage2_tests) { - toolchain_step.dependOn(&exe.step); + test_step.dependOn(&exe.step); } b.default_step.dependOn(&exe.step); @@ -415,7 +414,7 @@ pub fn build(b: *Builder) !void { const test_cases_step = b.step("test-cases", "Run the main compiler test cases"); test_cases_step.dependOn(&test_cases.step); if (!skip_stage2_tests) { - toolchain_step.dependOn(test_cases_step); + test_step.dependOn(test_cases_step); } var chosen_modes: [4]builtin.Mode = undefined; @@ -439,11 +438,11 @@ pub fn build(b: *Builder) !void { const modes = chosen_modes[0..chosen_mode_index]; // run stage1 `zig fmt` on this build.zig file just to make sure it works - toolchain_step.dependOn(&fmt_build_zig.step); + test_step.dependOn(&fmt_build_zig.step); const fmt_step = b.step("test-fmt", "Run zig fmt against build.zig to make sure it works"); fmt_step.dependOn(&fmt_build_zig.step); - toolchain_step.dependOn(tests.addPkgTests( + test_step.dependOn(tests.addPkgTests( b, test_filter, "test/behavior.zig", @@ -454,10 +453,10 @@ pub fn build(b: *Builder) !void { skip_non_native, skip_libc, skip_stage1, - false, + skip_stage2_tests, )); - toolchain_step.dependOn(tests.addPkgTests( + test_step.dependOn(tests.addPkgTests( b, test_filter, "lib/compiler_rt.zig", @@ -468,10 +467,10 @@ pub fn build(b: *Builder) !void { skip_non_native, true, // skip_libc skip_stage1, - true, // TODO get these all passing + skip_stage2_tests or true, // TODO get these all passing )); - toolchain_step.dependOn(tests.addPkgTests( + test_step.dependOn(tests.addPkgTests( b, test_filter, "lib/c.zig", @@ -482,35 +481,36 @@ pub fn build(b: *Builder) !void { skip_non_native, true, // skip_libc skip_stage1, - true, // TODO get these all passing + skip_stage2_tests or true, // TODO get these all passing )); - toolchain_step.dependOn(tests.addCompareOutputTests(b, test_filter, modes)); - toolchain_step.dependOn(tests.addStandaloneTests( + test_step.dependOn(tests.addCompareOutputTests(b, test_filter, modes)); + test_step.dependOn(tests.addStandaloneTests( b, test_filter, modes, skip_non_native, enable_macos_sdk, target, + skip_stage2_tests, b.enable_darling, b.enable_qemu, b.enable_rosetta, b.enable_wasmtime, b.enable_wine, )); - toolchain_step.dependOn(tests.addLinkTests(b, test_filter, modes, enable_macos_sdk)); - toolchain_step.dependOn(tests.addStackTraceTests(b, test_filter, modes)); - toolchain_step.dependOn(tests.addCliTests(b, test_filter, modes)); - toolchain_step.dependOn(tests.addAssembleAndLinkTests(b, test_filter, modes)); - toolchain_step.dependOn(tests.addTranslateCTests(b, test_filter)); + test_step.dependOn(tests.addLinkTests(b, test_filter, modes, enable_macos_sdk, skip_stage2_tests)); + test_step.dependOn(tests.addStackTraceTests(b, test_filter, modes)); + test_step.dependOn(tests.addCliTests(b, test_filter, modes)); + test_step.dependOn(tests.addAssembleAndLinkTests(b, test_filter, modes)); + test_step.dependOn(tests.addTranslateCTests(b, test_filter)); if (!skip_run_translated_c) { - toolchain_step.dependOn(tests.addRunTranslatedCTests(b, test_filter, target)); + test_step.dependOn(tests.addRunTranslatedCTests(b, test_filter, target)); } // tests for this feature are disabled until we have the self-hosted compiler available - // toolchain_step.dependOn(tests.addGenHTests(b, test_filter)); + // test_step.dependOn(tests.addGenHTests(b, test_filter)); - const std_step = tests.addPkgTests( + test_step.dependOn(tests.addPkgTests( b, test_filter, "lib/std/std.zig", @@ -522,11 +522,7 @@ pub fn build(b: *Builder) !void { skip_libc, skip_stage1, true, // TODO get these all passing - ); - - const test_step = b.step("test", "Run all the tests"); - test_step.dependOn(toolchain_step); - test_step.dependOn(std_step); + )); } const exe_cflags = [_][]const u8{ diff --git a/ci/azure/pipelines.yml b/ci/azure/pipelines.yml index 090c133e63..e6b65233bd 100644 --- a/ci/azure/pipelines.yml +++ b/ci/azure/pipelines.yml @@ -88,7 +88,8 @@ jobs: & "$ZIGINSTALLDIR\bin\zig.exe" build test ` --search-prefix "$ZIGPREFIXPATH" ` -Dstatic-llvm ` - -Dskip-non-native + -Dskip-non-native ` + -Dskip-stage2-tests CheckLastExitCode name: test diff --git a/test/tests.zig b/test/tests.zig index bd3c1c5dec..5a58daecaa 100644 --- a/test/tests.zig +++ b/test/tests.zig @@ -462,6 +462,7 @@ pub fn addStandaloneTests( skip_non_native: bool, enable_macos_sdk: bool, target: std.zig.CrossTarget, + omit_stage2: bool, enable_darling: bool, enable_qemu: bool, enable_rosetta: bool, @@ -478,6 +479,7 @@ pub fn addStandaloneTests( .skip_non_native = skip_non_native, .enable_macos_sdk = enable_macos_sdk, .target = target, + .omit_stage2 = omit_stage2, .enable_darling = enable_darling, .enable_qemu = enable_qemu, .enable_rosetta = enable_rosetta, @@ -495,6 +497,7 @@ pub fn addLinkTests( test_filter: ?[]const u8, modes: []const Mode, enable_macos_sdk: bool, + omit_stage2: bool, ) *build.Step { const cases = b.allocator.create(StandaloneContext) catch unreachable; cases.* = StandaloneContext{ @@ -506,6 +509,7 @@ pub fn addLinkTests( .skip_non_native = true, .enable_macos_sdk = enable_macos_sdk, .target = .{}, + .omit_stage2 = omit_stage2, }; link.addCases(cases); return cases.step; @@ -973,6 +977,7 @@ pub const StandaloneContext = struct { skip_non_native: bool, enable_macos_sdk: bool, target: std.zig.CrossTarget, + omit_stage2: bool, enable_darling: bool = false, enable_qemu: bool = false, enable_rosetta: bool = false, @@ -997,6 +1002,7 @@ pub const StandaloneContext = struct { const b = self.b; if (features.requires_macos_sdk and !self.enable_macos_sdk) return; + if (features.requires_stage2 and self.omit_stage2) return; const annotated_case_name = b.fmt("build {s}", .{build_file}); if (self.test_filter) |filter| {