| 1 | :100644 100644 e09b8f18abe0652043301349ece259daec0c6241 8f265f9eb61ae03e0b5ab80545fa1ce9aab961aa M	src/Compilation.zig |
| 2 | :100644 100644 af972ccb8665085991070de3235a6da537423dc6 81eb1b00428e9e2c3ef5fdf8b532255ed2e66867 M	test/standalone.zig |
| 3 | :000000 100644 0000000000000000000000000000000000000000 f5e07d8903268bec8527dd555c7c6955af5ff879 A	test/standalone/issue_13970/build.zig |
| 4 | :000000 100644 0000000000000000000000000000000000000000 e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 A	test/standalone/issue_13970/empty.zig |
| 5 | :000000 100644 0000000000000000000000000000000000000000 e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 A	test/standalone/issue_13970/src/empty.zig |
| 6 | :000000 100644 0000000000000000000000000000000000000000 d71320d46a61a74ccc3e5908ab46c4d0a1fea69a A	test/standalone/issue_13970/src/main.zig |
| 7 | :000000 100644 0000000000000000000000000000000000000000 4f6037b38dab0c9b800046b0477dc64f3c3b55e8 A	test/standalone/issue_13970/src/package.zig |
| 8 | :000000 100644 0000000000000000000000000000000000000000 e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 A	test/standalone/issue_13970/test_root/empty.zig |
| 9 | |
| 10 | diff --git a/src/Compilation.zig b/src/Compilation.zig |
| 11 | index e09b8f18abe0652043301349ece259daec0c6241..8f265f9eb61ae03e0b5ab80545fa1ce9aab961aa 100644 |
| 12 | --- a/src/Compilation.zig |
| 13 | +++ b/src/Compilation.zig |
| 14 | @@ -1621,8 +1621,11 @@ pub fn create(gpa: Allocator, options: InitOptions) !*Compilation { |
| 15 | const root_pkg = if (options.is_test) root_pkg: { |
| 16 | // TODO: we currently have two packages named 'root' here, which is weird. This |
| 17 | // should be changed as part of the resolution of #12201 |
| 18 | - const test_pkg = if (options.test_runner_path) |test_runner| |
| 19 | - try Package.create(gpa, "root", null, test_runner) |
| 20 | + const test_pkg = if (options.test_runner_path) |test_runner| test_pkg: { |
| 21 | + const test_dir = std.fs.path.dirname(test_runner); |
| 22 | + const basename = std.fs.path.basename(test_runner); |
| 23 | + break :test_pkg try Package.create(gpa, "root", test_dir, basename); |
| 24 | + } |
| 25 | else |
| 26 | try Package.createWithDir( |
| 27 | gpa, |
| 28 | diff --git a/test/standalone.zig b/test/standalone.zig |
| 29 | index af972ccb8665085991070de3235a6da537423dc6..81eb1b00428e9e2c3ef5fdf8b532255ed2e66867 100644 |
| 30 | --- a/test/standalone.zig |
| 31 | +++ b/test/standalone.zig |
| 32 | @@ -27,6 +27,7 @@ pub fn addCases(cases: *tests.StandaloneContext) void { |
| 33 | cases.add("test/standalone/noreturn_call/inline.zig"); |
| 34 | cases.add("test/standalone/noreturn_call/as_arg.zig"); |
| 35 | cases.addBuildFile("test/standalone/test_runner_path/build.zig", .{ .requires_stage2 = true }); |
| 36 | + cases.addBuildFile("test/standalone/issue_13970/build.zig", .{}); |
| 37 | cases.addBuildFile("test/standalone/main_pkg_path/build.zig", .{}); |
| 38 | cases.addBuildFile("test/standalone/shared_library/build.zig", .{}); |
| 39 | cases.addBuildFile("test/standalone/mix_o_files/build.zig", .{}); |
| 40 | diff --git a/test/standalone/issue_13970/build.zig b/test/standalone/issue_13970/build.zig |
| 41 | new file mode 100644 |
| 42 | index 0000000000000000000000000000000000000000..f5e07d8903268bec8527dd555c7c6955af5ff879 |
| 43 | --- /dev/null |
| 44 | +++ b/test/standalone/issue_13970/build.zig |
| 45 | @@ -0,0 +1,21 @@ |
| 46 | +const std = @import("std"); |
| 47 | + |
| 48 | +pub fn build(b: *std.Build) void { |
| 49 | + const test1 = b.addTest(.{ |
| 50 | + .root_source_file = .{ .path = "test_root/empty.zig" }, |
| 51 | + }); |
| 52 | + const test2 = b.addTest(.{ |
| 53 | + .root_source_file = .{ .path = "src/empty.zig" }, |
| 54 | + }); |
| 55 | + const test3 = b.addTest(.{ |
| 56 | + .root_source_file = .{ .path = "empty.zig" }, |
| 57 | + }); |
| 58 | + test1.setTestRunner("src/main.zig"); |
| 59 | + test2.setTestRunner("src/main.zig"); |
| 60 | + test3.setTestRunner("src/main.zig"); |
| 61 | + |
| 62 | + const test_step = b.step("test", "Test package path resolution of custom test runner"); |
| 63 | + test_step.dependOn(&test1.step); |
| 64 | + test_step.dependOn(&test2.step); |
| 65 | + test_step.dependOn(&test3.step); |
| 66 | +} |
| 67 | diff --git a/test/standalone/issue_13970/empty.zig b/test/standalone/issue_13970/empty.zig |
| 68 | new file mode 100644 |
| 69 | index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 |
| 70 | diff --git a/test/standalone/issue_13970/src/empty.zig b/test/standalone/issue_13970/src/empty.zig |
| 71 | new file mode 100644 |
| 72 | index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 |
| 73 | diff --git a/test/standalone/issue_13970/src/main.zig b/test/standalone/issue_13970/src/main.zig |
| 74 | new file mode 100644 |
| 75 | index 0000000000000000000000000000000000000000..d71320d46a61a74ccc3e5908ab46c4d0a1fea69a |
| 76 | --- /dev/null |
| 77 | +++ b/test/standalone/issue_13970/src/main.zig |
| 78 | @@ -0,0 +1,8 @@ |
| 79 | +const std = @import("std"); |
| 80 | +const package = @import("package.zig"); |
| 81 | +const root = @import("root"); |
| 82 | +const builtin = @import("builtin"); |
| 83 | + |
| 84 | +pub fn main() !void { |
| 85 | + _ = package.decl; |
| 86 | +} |
| 87 | diff --git a/test/standalone/issue_13970/src/package.zig b/test/standalone/issue_13970/src/package.zig |
| 88 | new file mode 100644 |
| 89 | index 0000000000000000000000000000000000000000..4f6037b38dab0c9b800046b0477dc64f3c3b55e8 |
| 90 | --- /dev/null |
| 91 | +++ b/test/standalone/issue_13970/src/package.zig |
| 92 | @@ -0,0 +1 @@ |
| 93 | +pub const decl = 0; |
| 94 | diff --git a/test/standalone/issue_13970/test_root/empty.zig b/test/standalone/issue_13970/test_root/empty.zig |
| 95 | new file mode 100644 |
| 96 | index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 |