diff options
| author | Ryan Liptak <squeek502@hotmail.com> | 2022-09-23 05:32:04 -0700 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2022-10-05 04:21:16 -0400 |
| commit | 6ac0d2d9d6a28dc79f78ed9a4e66f5145d6d7765 (patch) | |
| tree | 86537a7b1ae513f80518283d5ff978b0a08840ea /src/Compilation.zig | |
| parent | ff534d22676b8a934acf1931f91d70c554a4bdca (diff) | |
| download | zig-6ac0d2d9d6a28dc79f78ed9a4e66f5145d6d7765.tar.gz zig-6ac0d2d9d6a28dc79f78ed9a4e66f5145d6d7765.zip | |
Fix all std lib tests being run for any file within the std package
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 #12926
Diffstat (limited to 'src/Compilation.zig')
| -rw-r--r-- | src/Compilation.zig | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/src/Compilation.zig b/src/Compilation.zig index 90f830384d..7c4c369a6b 100644 --- a/src/Compilation.zig +++ b/src/Compilation.zig @@ -1588,10 +1588,10 @@ pub fn create(gpa: Allocator, options: InitOptions) !*Compilation { try main_pkg.add(gpa, "root", root_pkg); try main_pkg.addAndAdopt(gpa, "std", std_pkg); - const main_pkg_in_std = m: { + const main_pkg_is_std = m: { const std_path = try std.fs.path.resolve(arena, &[_][]const u8{ std_pkg.root_src_directory.path orelse ".", - std.fs.path.dirname(std_pkg.root_src_path) orelse ".", + std_pkg.root_src_path, }); defer arena.free(std_path); const main_path = try std.fs.path.resolve(arena, &[_][]const u8{ @@ -1599,7 +1599,7 @@ pub fn create(gpa: Allocator, options: InitOptions) !*Compilation { main_pkg.root_src_path, }); defer arena.free(main_path); - break :m mem.startsWith(u8, main_path, std_path); + break :m mem.eql(u8, main_path, std_path); }; // 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 { .gpa = gpa, .comp = comp, .main_pkg = main_pkg, - .main_pkg_in_std = main_pkg_in_std, + .main_pkg_is_std = main_pkg_is_std, .root_pkg = root_pkg, .zig_cache_artifact_directory = zig_cache_artifact_directory, .global_zir_cache = global_zir_cache, |
