Don't add standalone test cases until we've built stage3

This commit is contained in:
Carl Åstholm 2024-01-16 21:29:54 +01:00 committed by Andrew Kelley
parent d6ecfa7025
commit c3ecc6972e
2 changed files with 17 additions and 10 deletions

View File

@ -20,7 +20,8 @@ pub fn build(b: *std.Build) void {
if (std.mem.eql(u8, dep_hash, pkg_hash)) {
const pkg = @field(all_pkgs, pkg_hash);
if (!@hasDecl(pkg, "build_zig")) {
std.debug.panic("standalone test case '{s}' is missing a 'build.zig' file", .{dep_name});
std.debug.print("standalone test case '{s}' is missing a 'build.zig' file\n", .{dep_name});
std.process.exit(1);
}
const requires_ios_sdk = @hasDecl(pkg.build_zig, "requires_ios_sdk") and
pkg.build_zig.requires_ios_sdk;

View File

@ -710,15 +710,21 @@ pub fn addStandaloneTests(
}
}
const test_cases_dep_name = "standalone_test_cases";
const test_cases_dep = b.dependency(test_cases_dep_name, .{
.@"enable-ios-sdk" = enable_ios_sdk,
.@"enable-macos-sdk" = enable_macos_sdk,
.@"enable-symlinks-windows" = enable_symlinks_windows,
});
const test_cases_dep_step = test_cases_dep.builder.default_step;
test_cases_dep_step.name = b.dupe(test_cases_dep_name);
step.dependOn(test_cases_dep.builder.default_step);
// We can only use dependencies if the compiler was built with support for package management.
// (zig2 doesn't support it, but we still need to construct a build graph to build stage3.)
const package_management_available = b.available_deps.len != 0;
if (package_management_available) {
const test_cases_dep_name = "standalone_test_cases";
const test_cases_dep = b.dependency(test_cases_dep_name, .{
.@"enable-ios-sdk" = enable_ios_sdk,
.@"enable-macos-sdk" = enable_macos_sdk,
.@"enable-symlinks-windows" = enable_symlinks_windows,
});
const test_cases_dep_step = test_cases_dep.builder.default_step;
test_cases_dep_step.name = b.dupe(test_cases_dep_name);
step.dependOn(test_cases_dep.builder.default_step);
}
return step;
}