| author | |
| committer | |
| log | 6ac0d2d9d6a28dc79f78ed9a4e66f5145d6d7765 |
| tree | 86537a7b1ae513f80518283d5ff978b0a08840ea |
| parent | ff534d22676b8a934acf1931f91d70c554a4bdca |
Before this commit:
```
$ zig test lib/std/fs/test.zig --main-pkg-path lib/std --zig-lib-dir lib
2170 passed; 37 skipped; 0 failed.
```
After this commit:
```
$ zig test lib/std/fs/test.zig --main-pkg-path lib/std --zig-lib-dir lib
All 45 tests passed.
```
This matches stage1 behavior:
```
$ zig test -fstage1 lib/std/fs/test.zig --main-pkg-path lib/std --zig-lib-dir lib
All 45 tests passed.
```
All tests are still run if `zig test` is run directly on `lib/std/std.zig`:
```
$ zig test lib/std/std.zig --main-pkg-path lib/std --zig-lib-dir lib
2170 passed; 37 skipped; 0 failed.
```
`zig build test-std` is unaffected by this change.
Closes #129263 files changed, 8 insertions(+), 8 deletions(-)
src/Autodoc.zig+1-1| ... | ... | @@ -853,7 +853,7 @@ fn walkInstruction( |
| 853 | 853 | var path = str_tok.get(file.zir); |
| 854 | 854 | |
| 855 | 855 | const maybe_other_package: ?*Package = blk: { |
| 856 | if (self.module.main_pkg_in_std and std.mem.eql(u8, path, "std")) { | |
| 856 | if (self.module.main_pkg_is_std and std.mem.eql(u8, path, "std")) { | |
| 857 | 857 | path = "root"; |
| 858 | 858 | break :blk self.module.main_pkg; |
| 859 | 859 | } else { |
src/Compilation.zig+4-4| ... | ... | @@ -1588,10 +1588,10 @@ pub fn create(gpa: Allocator, options: InitOptions) !*Compilation { |
| 1588 | 1588 | try main_pkg.add(gpa, "root", root_pkg); |
| 1589 | 1589 | try main_pkg.addAndAdopt(gpa, "std", std_pkg); |
| 1590 | 1590 | |
| 1591 | const main_pkg_in_std = m: { | |
| 1591 | const main_pkg_is_std = m: { | |
| 1592 | 1592 | const std_path = try std.fs.path.resolve(arena, &[_][]const u8{ |
| 1593 | 1593 | std_pkg.root_src_directory.path orelse ".", |
| 1594 | std.fs.path.dirname(std_pkg.root_src_path) orelse ".", | |
| 1594 | std_pkg.root_src_path, | |
| 1595 | 1595 | }); |
| 1596 | 1596 | defer arena.free(std_path); |
| 1597 | 1597 | const main_path = try std.fs.path.resolve(arena, &[_][]const u8{ |
| ... | ... | @@ -1599,7 +1599,7 @@ pub fn create(gpa: Allocator, options: InitOptions) !*Compilation { |
| 1599 | 1599 | main_pkg.root_src_path, |
| 1600 | 1600 | }); |
| 1601 | 1601 | defer arena.free(main_path); |
| 1602 | break :m mem.startsWith(u8, main_path, std_path); | |
| 1602 | break :m mem.eql(u8, main_path, std_path); | |
| 1603 | 1603 | }; |
| 1604 | 1604 | |
| 1605 | 1605 | // Pre-open the directory handles for cached ZIR code so that it does not need |
| ... | ... | @@ -1638,7 +1638,7 @@ pub fn create(gpa: Allocator, options: InitOptions) !*Compilation { |
| 1638 | 1638 | .gpa = gpa, |
| 1639 | 1639 | .comp = comp, |
| 1640 | 1640 | .main_pkg = main_pkg, |
| 1641 | .main_pkg_in_std = main_pkg_in_std, | |
| 1641 | .main_pkg_is_std = main_pkg_is_std, | |
| 1642 | 1642 | .root_pkg = root_pkg, |
| 1643 | 1643 | .zig_cache_artifact_directory = zig_cache_artifact_directory, |
| 1644 | 1644 | .global_zir_cache = global_zir_cache, |
src/Module.zig+3-3| ... | ... | @@ -142,7 +142,7 @@ job_queued_update_builtin_zig: bool = true, |
| 142 | 142 | /// This makes it so that we can run `zig test` on the standard library. |
| 143 | 143 | /// Otherwise, the logic for scanning test decls skips all of them because |
| 144 | 144 | /// `main_pkg != std_pkg`. |
| 145 | main_pkg_in_std: bool, | |
| 145 | main_pkg_is_std: bool, | |
| 146 | 146 | |
| 147 | 147 | compile_log_text: ArrayListUnmanaged(u8) = .{}, |
| 148 | 148 | |
| ... | ... | @@ -5174,7 +5174,7 @@ fn scanDecl(iter: *ScanDeclIter, decl_sub_index: usize, flags: u4) Allocator.Err |
| 5174 | 5174 | // the test name filter. |
| 5175 | 5175 | if (!comp.bin_file.options.is_test) break :blk false; |
| 5176 | 5176 | if (decl_pkg != mod.main_pkg) { |
| 5177 | if (!mod.main_pkg_in_std) break :blk false; | |
| 5177 | if (!mod.main_pkg_is_std) break :blk false; | |
| 5178 | 5178 | const std_pkg = mod.main_pkg.table.get("std").?; |
| 5179 | 5179 | if (std_pkg != decl_pkg) break :blk false; |
| 5180 | 5180 | } |
| ... | ... | @@ -5185,7 +5185,7 @@ fn scanDecl(iter: *ScanDeclIter, decl_sub_index: usize, flags: u4) Allocator.Err |
| 5185 | 5185 | if (!is_named_test) break :blk false; |
| 5186 | 5186 | if (!comp.bin_file.options.is_test) break :blk false; |
| 5187 | 5187 | if (decl_pkg != mod.main_pkg) { |
| 5188 | if (!mod.main_pkg_in_std) break :blk false; | |
| 5188 | if (!mod.main_pkg_is_std) break :blk false; | |
| 5189 | 5189 | const std_pkg = mod.main_pkg.table.get("std").?; |
| 5190 | 5190 | if (std_pkg != decl_pkg) break :blk false; |
| 5191 | 5191 | } |