Skip to content

Commit d5d829e

Browse files
committed
build: hook up -Dskip-stage2-tests and remove test-toolchain
1 parent 798886f commit d5d829e

File tree

3 files changed

+30
-27
lines changed

3 files changed

+30
-27
lines changed

build.zig

Lines changed: 22 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ const stack_size = 32 * 1024 * 1024;
1515

1616
pub fn build(b: *Builder) !void {
1717
b.setPreferredReleaseMode(.ReleaseFast);
18+
const test_step = b.step("test", "Run all the tests");
1819
const mode = b.standardReleaseOptions();
1920
const target = b.standardTargetOptions(.{});
2021
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 {
3940
const docs_step = b.step("docs", "Build documentation");
4041
docs_step.dependOn(&docgen_cmd.step);
4142

42-
const toolchain_step = b.step("test-toolchain", "Run the tests for the toolchain");
43-
4443
var test_cases = b.addTest("src/test.zig");
4544
test_cases.stack_size = stack_size;
4645
test_cases.setBuildMode(mode);
@@ -149,7 +148,7 @@ pub fn build(b: *Builder) !void {
149148
exe.setBuildMode(mode);
150149
exe.setTarget(target);
151150
if (!skip_stage2_tests) {
152-
toolchain_step.dependOn(&exe.step);
151+
test_step.dependOn(&exe.step);
153152
}
154153

155154
b.default_step.dependOn(&exe.step);
@@ -415,7 +414,7 @@ pub fn build(b: *Builder) !void {
415414
const test_cases_step = b.step("test-cases", "Run the main compiler test cases");
416415
test_cases_step.dependOn(&test_cases.step);
417416
if (!skip_stage2_tests) {
418-
toolchain_step.dependOn(test_cases_step);
417+
test_step.dependOn(test_cases_step);
419418
}
420419

421420
var chosen_modes: [4]builtin.Mode = undefined;
@@ -439,11 +438,11 @@ pub fn build(b: *Builder) !void {
439438
const modes = chosen_modes[0..chosen_mode_index];
440439

441440
// run stage1 `zig fmt` on this build.zig file just to make sure it works
442-
toolchain_step.dependOn(&fmt_build_zig.step);
441+
test_step.dependOn(&fmt_build_zig.step);
443442
const fmt_step = b.step("test-fmt", "Run zig fmt against build.zig to make sure it works");
444443
fmt_step.dependOn(&fmt_build_zig.step);
445444

446-
toolchain_step.dependOn(tests.addPkgTests(
445+
test_step.dependOn(tests.addPkgTests(
447446
b,
448447
test_filter,
449448
"test/behavior.zig",
@@ -454,10 +453,10 @@ pub fn build(b: *Builder) !void {
454453
skip_non_native,
455454
skip_libc,
456455
skip_stage1,
457-
false,
456+
skip_stage2_tests,
458457
));
459458

460-
toolchain_step.dependOn(tests.addPkgTests(
459+
test_step.dependOn(tests.addPkgTests(
461460
b,
462461
test_filter,
463462
"lib/compiler_rt.zig",
@@ -468,10 +467,10 @@ pub fn build(b: *Builder) !void {
468467
skip_non_native,
469468
true, // skip_libc
470469
skip_stage1,
471-
true, // TODO get these all passing
470+
skip_stage2_tests or true, // TODO get these all passing
472471
));
473472

474-
toolchain_step.dependOn(tests.addPkgTests(
473+
test_step.dependOn(tests.addPkgTests(
475474
b,
476475
test_filter,
477476
"lib/c.zig",
@@ -482,35 +481,36 @@ pub fn build(b: *Builder) !void {
482481
skip_non_native,
483482
true, // skip_libc
484483
skip_stage1,
485-
true, // TODO get these all passing
484+
skip_stage2_tests or true, // TODO get these all passing
486485
));
487486

488-
toolchain_step.dependOn(tests.addCompareOutputTests(b, test_filter, modes));
489-
toolchain_step.dependOn(tests.addStandaloneTests(
487+
test_step.dependOn(tests.addCompareOutputTests(b, test_filter, modes));
488+
test_step.dependOn(tests.addStandaloneTests(
490489
b,
491490
test_filter,
492491
modes,
493492
skip_non_native,
494493
enable_macos_sdk,
495494
target,
495+
skip_stage2_tests,
496496
b.enable_darling,
497497
b.enable_qemu,
498498
b.enable_rosetta,
499499
b.enable_wasmtime,
500500
b.enable_wine,
501501
));
502-
toolchain_step.dependOn(tests.addLinkTests(b, test_filter, modes, enable_macos_sdk));
503-
toolchain_step.dependOn(tests.addStackTraceTests(b, test_filter, modes));
504-
toolchain_step.dependOn(tests.addCliTests(b, test_filter, modes));
505-
toolchain_step.dependOn(tests.addAssembleAndLinkTests(b, test_filter, modes));
506-
toolchain_step.dependOn(tests.addTranslateCTests(b, test_filter));
502+
test_step.dependOn(tests.addLinkTests(b, test_filter, modes, enable_macos_sdk, skip_stage2_tests));
503+
test_step.dependOn(tests.addStackTraceTests(b, test_filter, modes));
504+
test_step.dependOn(tests.addCliTests(b, test_filter, modes));
505+
test_step.dependOn(tests.addAssembleAndLinkTests(b, test_filter, modes));
506+
test_step.dependOn(tests.addTranslateCTests(b, test_filter));
507507
if (!skip_run_translated_c) {
508-
toolchain_step.dependOn(tests.addRunTranslatedCTests(b, test_filter, target));
508+
test_step.dependOn(tests.addRunTranslatedCTests(b, test_filter, target));
509509
}
510510
// tests for this feature are disabled until we have the self-hosted compiler available
511-
// toolchain_step.dependOn(tests.addGenHTests(b, test_filter));
511+
// test_step.dependOn(tests.addGenHTests(b, test_filter));
512512

513-
const std_step = tests.addPkgTests(
513+
test_step.dependOn(tests.addPkgTests(
514514
b,
515515
test_filter,
516516
"lib/std/std.zig",
@@ -522,11 +522,7 @@ pub fn build(b: *Builder) !void {
522522
skip_libc,
523523
skip_stage1,
524524
true, // TODO get these all passing
525-
);
526-
527-
const test_step = b.step("test", "Run all the tests");
528-
test_step.dependOn(toolchain_step);
529-
test_step.dependOn(std_step);
525+
));
530526
}
531527

532528
const exe_cflags = [_][]const u8{

ci/azure/pipelines.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,8 @@ jobs:
8787
& "$ZIGINSTALLDIR\bin\zig.exe" build test `
8888
--search-prefix "$ZIGPREFIXPATH" `
8989
-Dstatic-llvm `
90-
-Dskip-non-native
90+
-Dskip-non-native `
91+
-Dskip-stage2-tests
9192
CheckLastExitCode
9293
9394
name: test

test/tests.zig

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -462,6 +462,7 @@ pub fn addStandaloneTests(
462462
skip_non_native: bool,
463463
enable_macos_sdk: bool,
464464
target: std.zig.CrossTarget,
465+
omit_stage2: bool,
465466
enable_darling: bool,
466467
enable_qemu: bool,
467468
enable_rosetta: bool,
@@ -478,6 +479,7 @@ pub fn addStandaloneTests(
478479
.skip_non_native = skip_non_native,
479480
.enable_macos_sdk = enable_macos_sdk,
480481
.target = target,
482+
.omit_stage2 = omit_stage2,
481483
.enable_darling = enable_darling,
482484
.enable_qemu = enable_qemu,
483485
.enable_rosetta = enable_rosetta,
@@ -495,6 +497,7 @@ pub fn addLinkTests(
495497
test_filter: ?[]const u8,
496498
modes: []const Mode,
497499
enable_macos_sdk: bool,
500+
omit_stage2: bool,
498501
) *build.Step {
499502
const cases = b.allocator.create(StandaloneContext) catch unreachable;
500503
cases.* = StandaloneContext{
@@ -506,6 +509,7 @@ pub fn addLinkTests(
506509
.skip_non_native = true,
507510
.enable_macos_sdk = enable_macos_sdk,
508511
.target = .{},
512+
.omit_stage2 = omit_stage2,
509513
};
510514
link.addCases(cases);
511515
return cases.step;
@@ -973,6 +977,7 @@ pub const StandaloneContext = struct {
973977
skip_non_native: bool,
974978
enable_macos_sdk: bool,
975979
target: std.zig.CrossTarget,
980+
omit_stage2: bool,
976981
enable_darling: bool = false,
977982
enable_qemu: bool = false,
978983
enable_rosetta: bool = false,
@@ -997,6 +1002,7 @@ pub const StandaloneContext = struct {
9971002
const b = self.b;
9981003

9991004
if (features.requires_macos_sdk and !self.enable_macos_sdk) return;
1005+
if (features.requires_stage2 and self.omit_stage2) return;
10001006

10011007
const annotated_case_name = b.fmt("build {s}", .{build_file});
10021008
if (self.test_filter) |filter| {

0 commit comments

Comments
 (0)