authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2022-08-17 22:17:19-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2022-08-19 16:45:16-07:00
logc4466496ffb53fe83644ea2b0e43f9f46a3361b8
tree04333a3cc145a4b1b085011baa317e2ea9787297
parent5be2e8f941f78a5d1fda3ab4a2b4aa9487f1b519

build: hook up -Dskip-stage2-tests and remove test-toolchain


3 files changed, 30 insertions(+), 27 deletions(-)

build.zig+22-26
...@@ -15,6 +15,7 @@ const stack_size = 32 * 1024 * 1024;...@@ -15,6 +15,7 @@ const stack_size = 32 * 1024 * 1024;
1515
16pub fn build(b: *Builder) !void {16pub fn build(b: *Builder) !void {
17 b.setPreferredReleaseMode(.ReleaseFast);17 b.setPreferredReleaseMode(.ReleaseFast);
18 const test_step = b.step("test", "Run all the tests");
18 const mode = b.standardReleaseOptions();19 const mode = b.standardReleaseOptions();
19 const target = b.standardTargetOptions(.{});20 const target = b.standardTargetOptions(.{});
20 const single_threaded = b.option(bool, "single-threaded", "Build artifacts that run in single threaded mode");21 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 {...@@ -39,8 +40,6 @@ pub fn build(b: *Builder) !void {
39 const docs_step = b.step("docs", "Build documentation");40 const docs_step = b.step("docs", "Build documentation");
40 docs_step.dependOn(&docgen_cmd.step);41 docs_step.dependOn(&docgen_cmd.step);
4142
42 const toolchain_step = b.step("test-toolchain", "Run the tests for the toolchain");
43
44 var test_cases = b.addTest("src/test.zig");43 var test_cases = b.addTest("src/test.zig");
45 test_cases.stack_size = stack_size;44 test_cases.stack_size = stack_size;
46 test_cases.setBuildMode(mode);45 test_cases.setBuildMode(mode);
...@@ -149,7 +148,7 @@ pub fn build(b: *Builder) !void {...@@ -149,7 +148,7 @@ pub fn build(b: *Builder) !void {
149 exe.setBuildMode(mode);148 exe.setBuildMode(mode);
150 exe.setTarget(target);149 exe.setTarget(target);
151 if (!skip_stage2_tests) {150 if (!skip_stage2_tests) {
152 toolchain_step.dependOn(&exe.step);151 test_step.dependOn(&exe.step);
153 }152 }
154153
155 b.default_step.dependOn(&exe.step);154 b.default_step.dependOn(&exe.step);
...@@ -415,7 +414,7 @@ pub fn build(b: *Builder) !void {...@@ -415,7 +414,7 @@ pub fn build(b: *Builder) !void {
415 const test_cases_step = b.step("test-cases", "Run the main compiler test cases");414 const test_cases_step = b.step("test-cases", "Run the main compiler test cases");
416 test_cases_step.dependOn(&test_cases.step);415 test_cases_step.dependOn(&test_cases.step);
417 if (!skip_stage2_tests) {416 if (!skip_stage2_tests) {
418 toolchain_step.dependOn(test_cases_step);417 test_step.dependOn(test_cases_step);
419 }418 }
420419
421 var chosen_modes: [4]builtin.Mode = undefined;420 var chosen_modes: [4]builtin.Mode = undefined;
...@@ -439,11 +438,11 @@ pub fn build(b: *Builder) !void {...@@ -439,11 +438,11 @@ pub fn build(b: *Builder) !void {
439 const modes = chosen_modes[0..chosen_mode_index];438 const modes = chosen_modes[0..chosen_mode_index];
440439
441 // run stage1 `zig fmt` on this build.zig file just to make sure it works440 // 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);
443 const fmt_step = b.step("test-fmt", "Run zig fmt against build.zig to make sure it works");442 const fmt_step = b.step("test-fmt", "Run zig fmt against build.zig to make sure it works");
444 fmt_step.dependOn(&fmt_build_zig.step);443 fmt_step.dependOn(&fmt_build_zig.step);
445444
446 toolchain_step.dependOn(tests.addPkgTests(445 test_step.dependOn(tests.addPkgTests(
447 b,446 b,
448 test_filter,447 test_filter,
449 "test/behavior.zig",448 "test/behavior.zig",
...@@ -454,10 +453,10 @@ pub fn build(b: *Builder) !void {...@@ -454,10 +453,10 @@ pub fn build(b: *Builder) !void {
454 skip_non_native,453 skip_non_native,
455 skip_libc,454 skip_libc,
456 skip_stage1,455 skip_stage1,
457 false,456 skip_stage2_tests,
458 ));457 ));
459458
460 toolchain_step.dependOn(tests.addPkgTests(459 test_step.dependOn(tests.addPkgTests(
461 b,460 b,
462 test_filter,461 test_filter,
463 "lib/compiler_rt.zig",462 "lib/compiler_rt.zig",
...@@ -468,10 +467,10 @@ pub fn build(b: *Builder) !void {...@@ -468,10 +467,10 @@ pub fn build(b: *Builder) !void {
468 skip_non_native,467 skip_non_native,
469 true, // skip_libc468 true, // skip_libc
470 skip_stage1,469 skip_stage1,
471 true, // TODO get these all passing470 skip_stage2_tests or true, // TODO get these all passing
472 ));471 ));
473472
474 toolchain_step.dependOn(tests.addPkgTests(473 test_step.dependOn(tests.addPkgTests(
475 b,474 b,
476 test_filter,475 test_filter,
477 "lib/c.zig",476 "lib/c.zig",
...@@ -482,35 +481,36 @@ pub fn build(b: *Builder) !void {...@@ -482,35 +481,36 @@ pub fn build(b: *Builder) !void {
482 skip_non_native,481 skip_non_native,
483 true, // skip_libc482 true, // skip_libc
484 skip_stage1,483 skip_stage1,
485 true, // TODO get these all passing484 skip_stage2_tests or true, // TODO get these all passing
486 ));485 ));
487486
488 toolchain_step.dependOn(tests.addCompareOutputTests(b, test_filter, modes));487 test_step.dependOn(tests.addCompareOutputTests(b, test_filter, modes));
489 toolchain_step.dependOn(tests.addStandaloneTests(488 test_step.dependOn(tests.addStandaloneTests(
490 b,489 b,
491 test_filter,490 test_filter,
492 modes,491 modes,
493 skip_non_native,492 skip_non_native,
494 enable_macos_sdk,493 enable_macos_sdk,
495 target,494 target,
495 skip_stage2_tests,
496 b.enable_darling,496 b.enable_darling,
497 b.enable_qemu,497 b.enable_qemu,
498 b.enable_rosetta,498 b.enable_rosetta,
499 b.enable_wasmtime,499 b.enable_wasmtime,
500 b.enable_wine,500 b.enable_wine,
501 ));501 ));
502 toolchain_step.dependOn(tests.addLinkTests(b, test_filter, modes, enable_macos_sdk));502 test_step.dependOn(tests.addLinkTests(b, test_filter, modes, enable_macos_sdk, skip_stage2_tests));
503 toolchain_step.dependOn(tests.addStackTraceTests(b, test_filter, modes));503 test_step.dependOn(tests.addStackTraceTests(b, test_filter, modes));
504 toolchain_step.dependOn(tests.addCliTests(b, test_filter, modes));504 test_step.dependOn(tests.addCliTests(b, test_filter, modes));
505 toolchain_step.dependOn(tests.addAssembleAndLinkTests(b, test_filter, modes));505 test_step.dependOn(tests.addAssembleAndLinkTests(b, test_filter, modes));
506 toolchain_step.dependOn(tests.addTranslateCTests(b, test_filter));506 test_step.dependOn(tests.addTranslateCTests(b, test_filter));
507 if (!skip_run_translated_c) {507 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));
509 }509 }
510 // tests for this feature are disabled until we have the self-hosted compiler available510 // 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(
514 b,514 b,
515 test_filter,515 test_filter,
516 "lib/std/std.zig",516 "lib/std/std.zig",
...@@ -522,11 +522,7 @@ pub fn build(b: *Builder) !void {...@@ -522,11 +522,7 @@ pub fn build(b: *Builder) !void {
522 skip_libc,522 skip_libc,
523 skip_stage1,523 skip_stage1,
524 true, // TODO get these all passing524 true, // TODO get these all passing
525 );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);
530}526}
531527
532const exe_cflags = [_][]const u8{528const exe_cflags = [_][]const u8{
ci/azure/pipelines.yml+2-1
...@@ -88,7 +88,8 @@ jobs:...@@ -88,7 +88,8 @@ jobs:
88 & "$ZIGINSTALLDIR\bin\zig.exe" build test `88 & "$ZIGINSTALLDIR\bin\zig.exe" build test `
89 --search-prefix "$ZIGPREFIXPATH" `89 --search-prefix "$ZIGPREFIXPATH" `
90 -Dstatic-llvm `90 -Dstatic-llvm `
91 -Dskip-non-native91 -Dskip-non-native `
92 -Dskip-stage2-tests
92 CheckLastExitCode93 CheckLastExitCode
9394
94 name: test95 name: test
test/tests.zig+6
...@@ -462,6 +462,7 @@ pub fn addStandaloneTests(...@@ -462,6 +462,7 @@ pub fn addStandaloneTests(
462 skip_non_native: bool,462 skip_non_native: bool,
463 enable_macos_sdk: bool,463 enable_macos_sdk: bool,
464 target: std.zig.CrossTarget,464 target: std.zig.CrossTarget,
465 omit_stage2: bool,
465 enable_darling: bool,466 enable_darling: bool,
466 enable_qemu: bool,467 enable_qemu: bool,
467 enable_rosetta: bool,468 enable_rosetta: bool,
...@@ -478,6 +479,7 @@ pub fn addStandaloneTests(...@@ -478,6 +479,7 @@ pub fn addStandaloneTests(
478 .skip_non_native = skip_non_native,479 .skip_non_native = skip_non_native,
479 .enable_macos_sdk = enable_macos_sdk,480 .enable_macos_sdk = enable_macos_sdk,
480 .target = target,481 .target = target,
482 .omit_stage2 = omit_stage2,
481 .enable_darling = enable_darling,483 .enable_darling = enable_darling,
482 .enable_qemu = enable_qemu,484 .enable_qemu = enable_qemu,
483 .enable_rosetta = enable_rosetta,485 .enable_rosetta = enable_rosetta,
...@@ -495,6 +497,7 @@ pub fn addLinkTests(...@@ -495,6 +497,7 @@ pub fn addLinkTests(
495 test_filter: ?[]const u8,497 test_filter: ?[]const u8,
496 modes: []const Mode,498 modes: []const Mode,
497 enable_macos_sdk: bool,499 enable_macos_sdk: bool,
500 omit_stage2: bool,
498) *build.Step {501) *build.Step {
499 const cases = b.allocator.create(StandaloneContext) catch unreachable;502 const cases = b.allocator.create(StandaloneContext) catch unreachable;
500 cases.* = StandaloneContext{503 cases.* = StandaloneContext{
...@@ -506,6 +509,7 @@ pub fn addLinkTests(...@@ -506,6 +509,7 @@ pub fn addLinkTests(
506 .skip_non_native = true,509 .skip_non_native = true,
507 .enable_macos_sdk = enable_macos_sdk,510 .enable_macos_sdk = enable_macos_sdk,
508 .target = .{},511 .target = .{},
512 .omit_stage2 = omit_stage2,
509 };513 };
510 link.addCases(cases);514 link.addCases(cases);
511 return cases.step;515 return cases.step;
...@@ -973,6 +977,7 @@ pub const StandaloneContext = struct {...@@ -973,6 +977,7 @@ pub const StandaloneContext = struct {
973 skip_non_native: bool,977 skip_non_native: bool,
974 enable_macos_sdk: bool,978 enable_macos_sdk: bool,
975 target: std.zig.CrossTarget,979 target: std.zig.CrossTarget,
980 omit_stage2: bool,
976 enable_darling: bool = false,981 enable_darling: bool = false,
977 enable_qemu: bool = false,982 enable_qemu: bool = false,
978 enable_rosetta: bool = false,983 enable_rosetta: bool = false,
...@@ -997,6 +1002,7 @@ pub const StandaloneContext = struct {...@@ -997,6 +1002,7 @@ pub const StandaloneContext = struct {
997 const b = self.b;1002 const b = self.b;
9981003
999 if (features.requires_macos_sdk and !self.enable_macos_sdk) return;1004 if (features.requires_macos_sdk and !self.enable_macos_sdk) return;
1005 if (features.requires_stage2 and self.omit_stage2) return;
10001006
1001 const annotated_case_name = b.fmt("build {s}", .{build_file});1007 const annotated_case_name = b.fmt("build {s}", .{build_file});
1002 if (self.test_filter) |filter| {1008 if (self.test_filter) |filter| {