| author | |
| committer | |
| log | b352595aa2ede0c2fd53094da4123aac031335ec |
| tree | aa94a2af3250a50ddf169a8e2c1da0e11f34f730 |
| parent | 82f35c51866826fb71eb6f27d9210bb738d602e9 |
There are several test decls inside `/src` that are not currently being
tested and have bitrotted as a result. This commit revives those tests
and adds the `test-compiler-internals` set of tests which tests
everything reachable from `/src/main.zig`.6 files changed, 29 insertions(+), 31 deletions(-)
build.zig+15-26| ... | @@ -381,32 +381,6 @@ pub fn build(b: *std.Build) !void { | ... | @@ -381,32 +381,6 @@ pub fn build(b: *std.Build) !void { |
| 381 | const test_target_filters = b.option([]const []const u8, "test-target-filter", "Skip tests whose target triple do not match any filter") orelse &[0][]const u8{}; | 381 | const test_target_filters = b.option([]const []const u8, "test-target-filter", "Skip tests whose target triple do not match any filter") orelse &[0][]const u8{}; |
| 382 | const test_slow_targets = b.option(bool, "test-slow-targets", "Enable running module tests for targets that have a slow compiler backend") orelse false; | 382 | const test_slow_targets = b.option(bool, "test-slow-targets", "Enable running module tests for targets that have a slow compiler backend") orelse false; |
| 383 | 383 | ||
| 384 | const test_cases_options = b.addOptions(); | ||
| 385 | |||
| 386 | test_cases_options.addOption(bool, "enable_tracy", false); | ||
| 387 | test_cases_options.addOption(bool, "enable_debug_extensions", enable_debug_extensions); | ||
| 388 | test_cases_options.addOption(bool, "enable_logging", enable_logging); | ||
| 389 | test_cases_options.addOption(bool, "enable_link_snapshots", enable_link_snapshots); | ||
| 390 | test_cases_options.addOption(bool, "skip_non_native", skip_non_native); | ||
| 391 | test_cases_options.addOption(bool, "have_llvm", enable_llvm); | ||
| 392 | test_cases_options.addOption(bool, "llvm_has_m68k", llvm_has_m68k); | ||
| 393 | test_cases_options.addOption(bool, "llvm_has_csky", llvm_has_csky); | ||
| 394 | test_cases_options.addOption(bool, "llvm_has_arc", llvm_has_arc); | ||
| 395 | test_cases_options.addOption(bool, "llvm_has_xtensa", llvm_has_xtensa); | ||
| 396 | test_cases_options.addOption(bool, "force_gpa", force_gpa); | ||
| 397 | test_cases_options.addOption(bool, "enable_qemu", b.enable_qemu); | ||
| 398 | test_cases_options.addOption(bool, "enable_wine", b.enable_wine); | ||
| 399 | test_cases_options.addOption(bool, "enable_wasmtime", b.enable_wasmtime); | ||
| 400 | test_cases_options.addOption(bool, "enable_rosetta", b.enable_rosetta); | ||
| 401 | test_cases_options.addOption(bool, "enable_darling", b.enable_darling); | ||
| 402 | test_cases_options.addOption(u32, "mem_leak_frames", mem_leak_frames * 2); | ||
| 403 | test_cases_options.addOption(bool, "value_tracing", value_tracing); | ||
| 404 | test_cases_options.addOption(?[]const u8, "glibc_runtimes_dir", b.glibc_runtimes_dir); | ||
| 405 | test_cases_options.addOption([:0]const u8, "version", version); | ||
| 406 | test_cases_options.addOption(std.SemanticVersion, "semver", semver); | ||
| 407 | test_cases_options.addOption([]const []const u8, "test_filters", test_filters); | ||
| 408 | test_cases_options.addOption(DevEnv, "dev", if (only_c) .bootstrap else .core); | ||
| 409 | |||
| 410 | var chosen_opt_modes_buf: [4]builtin.OptimizeMode = undefined; | 384 | var chosen_opt_modes_buf: [4]builtin.OptimizeMode = undefined; |
| 411 | var chosen_mode_index: usize = 0; | 385 | var chosen_mode_index: usize = 0; |
| 412 | if (!skip_debug) { | 386 | if (!skip_debug) { |
| ... | @@ -533,6 +507,21 @@ pub fn build(b: *std.Build) !void { | ... | @@ -533,6 +507,21 @@ pub fn build(b: *std.Build) !void { |
| 533 | .max_rss = 5029889638, | 507 | .max_rss = 5029889638, |
| 534 | })); | 508 | })); |
| 535 | 509 | ||
| 510 | test_modules_step.dependOn(tests.addModuleTests(b, .{ | ||
| 511 | .test_filters = test_filters, | ||
| 512 | .test_target_filters = test_target_filters, | ||
| 513 | .test_slow_targets = test_slow_targets, | ||
| 514 | .root_src = "src/main.zig", | ||
| 515 | .name = "compiler-internals", | ||
| 516 | .desc = "Run the compiler internals tests", | ||
| 517 | .optimize_modes = optimization_modes, | ||
| 518 | .include_paths = &.{}, | ||
| 519 | .skip_single_threaded = skip_single_threaded, | ||
| 520 | .skip_non_native = true, | ||
| 521 | .skip_libc = skip_libc, | ||
| 522 | .build_options = exe_options, | ||
| 523 | })); | ||
| 524 | |||
| 536 | test_step.dependOn(test_modules_step); | 525 | test_step.dependOn(test_modules_step); |
| 537 | 526 | ||
| 538 | test_step.dependOn(tests.addCompareOutputTests(b, test_filters, optimization_modes)); | 527 | test_step.dependOn(tests.addCompareOutputTests(b, test_filters, optimization_modes)); |
src/InternPool.zig+1| ... | @@ -9822,6 +9822,7 @@ test "basic usage" { | ... | @@ -9822,6 +9822,7 @@ test "basic usage" { |
| 9822 | const gpa = std.testing.allocator; | 9822 | const gpa = std.testing.allocator; |
| 9823 | 9823 | ||
| 9824 | var ip: InternPool = .empty; | 9824 | var ip: InternPool = .empty; |
| 9825 | try ip.init(gpa, 1); | ||
| 9825 | defer ip.deinit(gpa); | 9826 | defer ip.deinit(gpa); |
| 9826 | 9827 | ||
| 9827 | const i32_type = try ip.get(gpa, .main, .{ .int_type = .{ | 9828 | const i32_type = try ip.get(gpa, .main, .{ .int_type = .{ |
src/Package/Fetch.zig+4-4| ... | @@ -2244,7 +2244,6 @@ const TestFetchBuilder = struct { | ... | @@ -2244,7 +2244,6 @@ const TestFetchBuilder = struct { |
| 2244 | thread_pool: ThreadPool, | 2244 | thread_pool: ThreadPool, |
| 2245 | http_client: std.http.Client, | 2245 | http_client: std.http.Client, |
| 2246 | global_cache_directory: Cache.Directory, | 2246 | global_cache_directory: Cache.Directory, |
| 2247 | progress: std.Progress, | ||
| 2248 | job_queue: Fetch.JobQueue, | 2247 | job_queue: Fetch.JobQueue, |
| 2249 | fetch: Fetch, | 2248 | fetch: Fetch, |
| 2250 | 2249 | ||
| ... | @@ -2260,8 +2259,6 @@ const TestFetchBuilder = struct { | ... | @@ -2260,8 +2259,6 @@ const TestFetchBuilder = struct { |
| 2260 | self.http_client = .{ .allocator = allocator }; | 2259 | self.http_client = .{ .allocator = allocator }; |
| 2261 | self.global_cache_directory = .{ .handle = cache_dir, .path = null }; | 2260 | self.global_cache_directory = .{ .handle = cache_dir, .path = null }; |
| 2262 | 2261 | ||
| 2263 | self.progress = .{ .dont_print_on_dumb = true }; | ||
| 2264 | |||
| 2265 | self.job_queue = .{ | 2262 | self.job_queue = .{ |
| 2266 | .http_client = &self.http_client, | 2263 | .http_client = &self.http_client, |
| 2267 | .thread_pool = &self.thread_pool, | 2264 | .thread_pool = &self.thread_pool, |
| ... | @@ -2281,10 +2278,11 @@ const TestFetchBuilder = struct { | ... | @@ -2281,10 +2278,11 @@ const TestFetchBuilder = struct { |
| 2281 | .lazy_status = .eager, | 2278 | .lazy_status = .eager, |
| 2282 | .parent_package_root = Cache.Path{ .root_dir = Cache.Directory{ .handle = cache_dir, .path = null } }, | 2279 | .parent_package_root = Cache.Path{ .root_dir = Cache.Directory{ .handle = cache_dir, .path = null } }, |
| 2283 | .parent_manifest_ast = null, | 2280 | .parent_manifest_ast = null, |
| 2284 | .prog_node = self.progress.start("Fetch", 0), | 2281 | .prog_node = std.Progress.Node.none, |
| 2285 | .job_queue = &self.job_queue, | 2282 | .job_queue = &self.job_queue, |
| 2286 | .omit_missing_hash_error = true, | 2283 | .omit_missing_hash_error = true, |
| 2287 | .allow_missing_paths_field = false, | 2284 | .allow_missing_paths_field = false, |
| 2285 | .use_latest_commit = true, | ||
| 2288 | 2286 | ||
| 2289 | .package_root = undefined, | 2287 | .package_root = undefined, |
| 2290 | .error_bundle = undefined, | 2288 | .error_bundle = undefined, |
| ... | @@ -2293,6 +2291,8 @@ const TestFetchBuilder = struct { | ... | @@ -2293,6 +2291,8 @@ const TestFetchBuilder = struct { |
| 2293 | .actual_hash = undefined, | 2291 | .actual_hash = undefined, |
| 2294 | .has_build_zig = false, | 2292 | .has_build_zig = false, |
| 2295 | .oom_flag = false, | 2293 | .oom_flag = false, |
| 2294 | .latest_commit = null, | ||
| 2295 | |||
| 2296 | .module = null, | 2296 | .module = null, |
| 2297 | }; | 2297 | }; |
| 2298 | return &self.fetch; | 2298 | return &self.fetch; |
src/link/MachO/dyld_info/Rebase.zig+1-1| ... | @@ -281,7 +281,7 @@ test "rebase - no entries" { | ... | @@ -281,7 +281,7 @@ test "rebase - no entries" { |
| 281 | defer rebase.deinit(gpa); | 281 | defer rebase.deinit(gpa); |
| 282 | 282 | ||
| 283 | try rebase.finalize(gpa); | 283 | try rebase.finalize(gpa); |
| 284 | try testing.expectEqual(@as(u64, 0), rebase.size()); | 284 | try testing.expectEqual(0, rebase.buffer.items.len); |
| 285 | } | 285 | } |
| 286 | 286 | ||
| 287 | test "rebase - single entry" { | 287 | test "rebase - single entry" { |
src/main.zig+4| ... | @@ -34,6 +34,10 @@ const Zcu = @import("Zcu.zig"); | ... | @@ -34,6 +34,10 @@ const Zcu = @import("Zcu.zig"); |
| 34 | const mingw = @import("mingw.zig"); | 34 | const mingw = @import("mingw.zig"); |
| 35 | const dev = @import("dev.zig"); | 35 | const dev = @import("dev.zig"); |
| 36 | 36 | ||
| 37 | test { | ||
| 38 | _ = Package; | ||
| 39 | } | ||
| 40 | |||
| 37 | pub const std_options: std.Options = .{ | 41 | pub const std_options: std.Options = .{ |
| 38 | .wasiCwd = wasi_cwd, | 42 | .wasiCwd = wasi_cwd, |
| 39 | .logFn = log, | 43 | .logFn = log, |
test/tests.zig+4| ... | @@ -1303,6 +1303,7 @@ const ModuleTestOptions = struct { | ... | @@ -1303,6 +1303,7 @@ const ModuleTestOptions = struct { |
| 1303 | skip_libc: bool, | 1303 | skip_libc: bool, |
| 1304 | max_rss: usize = 0, | 1304 | max_rss: usize = 0, |
| 1305 | no_builtin: bool = false, | 1305 | no_builtin: bool = false, |
| 1306 | build_options: ?*std.Build.Step.Options = null, | ||
| 1306 | }; | 1307 | }; |
| 1307 | 1308 | ||
| 1308 | pub fn addModuleTests(b: *std.Build, options: ModuleTestOptions) *Step { | 1309 | pub fn addModuleTests(b: *std.Build, options: ModuleTestOptions) *Step { |
| ... | @@ -1392,6 +1393,9 @@ pub fn addModuleTests(b: *std.Build, options: ModuleTestOptions) *Step { | ... | @@ -1392,6 +1393,9 @@ pub fn addModuleTests(b: *std.Build, options: ModuleTestOptions) *Step { |
| 1392 | .strip = test_target.strip, | 1393 | .strip = test_target.strip, |
| 1393 | }); | 1394 | }); |
| 1394 | if (options.no_builtin) these_tests.no_builtin = true; | 1395 | if (options.no_builtin) these_tests.no_builtin = true; |
| 1396 | if (options.build_options) |build_options| { | ||
| 1397 | these_tests.root_module.addOptions("build_options", build_options); | ||
| 1398 | } | ||
| 1395 | const single_threaded_suffix = if (test_target.single_threaded == true) "-single" else ""; | 1399 | const single_threaded_suffix = if (test_target.single_threaded == true) "-single" else ""; |
| 1396 | const backend_suffix = if (test_target.use_llvm == true) | 1400 | const backend_suffix = if (test_target.use_llvm == true) |
| 1397 | "-llvm" | 1401 | "-llvm" |