| ... | ... | @@ -20,7 +20,7 @@ const enable_wasmtime: bool = build_options.enable_wasmtime; |
| 20 | 20 | const enable_darling: bool = build_options.enable_darling; |
| 21 | 21 | const enable_rosetta: bool = build_options.enable_rosetta; |
| 22 | 22 | const glibc_runtimes_dir: ?[]const u8 = build_options.glibc_runtimes_dir; |
| 23 | | const skip_stage1 = build_options.skip_stage1; |
| 23 | const skip_stage1 = builtin.zig_backend != .stage1 or build_options.skip_stage1; |
| 24 | 24 | |
| 25 | 25 | const hr = "=" ** 80; |
| 26 | 26 | |
| ... | ... | @@ -233,11 +233,11 @@ const TestManifest = struct { |
| 233 | 233 | fn ConfigValueIterator(comptime T: type) type { |
| 234 | 234 | return struct { |
| 235 | 235 | inner: std.mem.SplitIterator(u8), |
| 236 | | parse_fn: ParseFn(T), |
| 237 | 236 | |
| 238 | 237 | fn next(self: *@This()) !?T { |
| 239 | 238 | const next_raw = self.inner.next() orelse return null; |
| 240 | | return try self.parse_fn(next_raw); |
| 239 | const parseFn = getDefaultParser(T); |
| 240 | return try parseFn(next_raw); |
| 241 | 241 | } |
| 242 | 242 | }; |
| 243 | 243 | } |
| ... | ... | @@ -313,27 +313,17 @@ const TestManifest = struct { |
| 313 | 313 | return manifest; |
| 314 | 314 | } |
| 315 | 315 | |
| 316 | | fn getConfigForKeyCustomParser( |
| 316 | fn getConfigForKey( |
| 317 | 317 | self: TestManifest, |
| 318 | 318 | key: []const u8, |
| 319 | 319 | comptime T: type, |
| 320 | | parse_fn: ParseFn(T), |
| 321 | 320 | ) ConfigValueIterator(T) { |
| 322 | 321 | const bytes = self.config_map.get(key) orelse TestManifestConfigDefaults.get(self.@"type", key); |
| 323 | 322 | return ConfigValueIterator(T){ |
| 324 | 323 | .inner = std.mem.split(u8, bytes, ","), |
| 325 | | .parse_fn = parse_fn, |
| 326 | 324 | }; |
| 327 | 325 | } |
| 328 | 326 | |
| 329 | | fn getConfigForKey( |
| 330 | | self: TestManifest, |
| 331 | | key: []const u8, |
| 332 | | comptime T: type, |
| 333 | | ) ConfigValueIterator(T) { |
| 334 | | return self.getConfigForKeyCustomParser(key, T, getDefaultParser(T)); |
| 335 | | } |
| 336 | | |
| 337 | 327 | fn getConfigForKeyAlloc( |
| 338 | 328 | self: TestManifest, |
| 339 | 329 | allocator: Allocator, |
| ... | ... | @@ -377,6 +367,15 @@ const TestManifest = struct { |
| 377 | 367 | } |
| 378 | 368 | |
| 379 | 369 | fn getDefaultParser(comptime T: type) ParseFn(T) { |
| 370 | if (T == CrossTarget) return struct { |
| 371 | fn parse(str: []const u8) anyerror!T { |
| 372 | var opts = CrossTarget.ParseOptions{ |
| 373 | .arch_os_abi = str, |
| 374 | }; |
| 375 | return try CrossTarget.parse(opts); |
| 376 | } |
| 377 | }.parse; |
| 378 | |
| 380 | 379 | switch (@typeInfo(T)) { |
| 381 | 380 | .Int => return struct { |
| 382 | 381 | fn parse(str: []const u8) anyerror!T { |
| ... | ... | @@ -397,14 +396,7 @@ const TestManifest = struct { |
| 397 | 396 | }; |
| 398 | 397 | } |
| 399 | 398 | }.parse, |
| 400 | | .Struct => if (comptime std.mem.eql(u8, @typeName(T), "CrossTarget")) return struct { |
| 401 | | fn parse(str: []const u8) anyerror!T { |
| 402 | | var opts = CrossTarget.ParseOptions{ |
| 403 | | .arch_os_abi = str, |
| 404 | | }; |
| 405 | | return try CrossTarget.parse(opts); |
| 406 | | } |
| 407 | | }.parse else @compileError("no default parser for " ++ @typeName(T)), |
| 399 | .Struct => @compileError("no default parser for " ++ @typeName(T)), |
| 408 | 400 | else => @compileError("no default parser for " ++ @typeName(T)), |
| 409 | 401 | } |
| 410 | 402 | } |
| ... | ... | @@ -884,8 +876,6 @@ pub const TestContext = struct { |
| 884 | 876 | src: [:0]const u8, |
| 885 | 877 | expected_errors: []const []const u8, |
| 886 | 878 | ) void { |
| 887 | | if (skip_stage1) return; |
| 888 | | |
| 889 | 879 | const case = ctx.addObj(name, .{}); |
| 890 | 880 | case.backend = .stage1; |
| 891 | 881 | case.addError(src, expected_errors); |
| ... | ... | @@ -897,8 +887,6 @@ pub const TestContext = struct { |
| 897 | 887 | src: [:0]const u8, |
| 898 | 888 | expected_errors: []const []const u8, |
| 899 | 889 | ) void { |
| 900 | | if (skip_stage1) return; |
| 901 | | |
| 902 | 890 | const case = ctx.addTest(name, .{}); |
| 903 | 891 | case.backend = .stage1; |
| 904 | 892 | case.addError(src, expected_errors); |
| ... | ... | @@ -910,8 +898,6 @@ pub const TestContext = struct { |
| 910 | 898 | src: [:0]const u8, |
| 911 | 899 | expected_errors: []const []const u8, |
| 912 | 900 | ) void { |
| 913 | | if (skip_stage1) return; |
| 914 | | |
| 915 | 901 | const case = ctx.addExe(name, .{}); |
| 916 | 902 | case.backend = .stage1; |
| 917 | 903 | case.addError(src, expected_errors); |
| ... | ... | @@ -1143,8 +1129,6 @@ pub const TestContext = struct { |
| 1143 | 1129 | |
| 1144 | 1130 | // Cross-product to get all possible test combinations |
| 1145 | 1131 | for (backends) |backend| { |
| 1146 | | if (backend == .stage1 and skip_stage1) continue; |
| 1147 | | |
| 1148 | 1132 | for (targets) |target| { |
| 1149 | 1133 | const name = try std.fmt.allocPrint(ctx.arena, "{s} ({s}, {s})", .{ |
| 1150 | 1134 | name_prefix, |
| ... | ... | @@ -1276,6 +1260,9 @@ pub const TestContext = struct { |
| 1276 | 1260 | if (!build_options.have_llvm and case.backend == .llvm) |
| 1277 | 1261 | continue; |
| 1278 | 1262 | |
| 1263 | if (skip_stage1 and case.backend == .stage1) |
| 1264 | continue; |
| 1265 | |
| 1279 | 1266 | if (build_options.test_filter) |test_filter| { |
| 1280 | 1267 | if (std.mem.indexOf(u8, case.name, test_filter) == null) continue; |
| 1281 | 1268 | } |