-
-
Notifications
You must be signed in to change notification settings - Fork 311
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix and test build runner package collection issues
- Loading branch information
Showing
14 changed files
with
348 additions
and
78 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
* text=auto | ||
*.zig text=auto eol=lf | ||
*.zon text=auto eol=lf | ||
*.json text=auto eol=lf |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
const std = @import("std"); | ||
|
||
pub fn addCases( | ||
b: *std.Build, | ||
test_step: *std.Build.Step, | ||
test_filters: []const []const u8, | ||
) void { | ||
const build_runner = b.path("src/build_runner/master.zig"); | ||
const cases_dir = b.path("tests/build_runner_cases"); | ||
const cases_path_from_root = b.pathFromRoot("tests/build_runner_cases"); | ||
|
||
const check_exe = b.addExecutable(.{ | ||
.name = "build_runner_check", | ||
.root_source_file = b.path("tests/build_runner_check.zig"), | ||
.target = b.graph.host, | ||
}); | ||
|
||
// https://github.com/ziglang/zig/issues/20605 | ||
var dir = std.fs.openDirAbsolute(b.pathFromRoot(cases_path_from_root), .{ .iterate = true }) catch |err| | ||
std.debug.panic("failed to open '{s}': {}", .{ cases_path_from_root, err }); | ||
defer dir.close(); | ||
|
||
var it = dir.iterate(); | ||
|
||
while (true) { | ||
const entry = it.next() catch |err| | ||
std.debug.panic("failed to walk directory '{s}': {}", .{ cases_path_from_root, err }) orelse break; | ||
|
||
if (entry.kind != .file) continue; | ||
if (!std.mem.eql(u8, std.fs.path.extension(entry.name), ".zig")) continue; | ||
|
||
for (test_filters) |test_filter| { | ||
if (std.mem.indexOf(u8, entry.name, test_filter) != null) break; | ||
} else if (test_filters.len > 0) continue; | ||
|
||
const build_file = cases_dir.path(b, entry.name); | ||
const build_config_json_path = b.fmt("{s}/{s}.json", .{ cases_path_from_root, std.fs.path.stem(entry.name) }); | ||
const expected_build_config_json = cases_dir.path(b, build_config_json_path); | ||
|
||
const build_cmd = std.Build.Step.Run.create(b, b.fmt("run build runner ({s})", .{entry.name})); | ||
build_cmd.addFileArg(.{ .cwd_relative = b.graph.zig_exe }); | ||
build_cmd.addArg("build"); | ||
build_cmd.addArg("--build-file"); | ||
build_cmd.addFileArg(build_file); | ||
build_cmd.addArg("--build-runner"); | ||
build_cmd.addFileArg(build_runner); | ||
build_cmd.addArg("--cache-dir"); | ||
build_cmd.addDirectoryArg(.{ .cwd_relative = b.fmt("{}", .{b.cache_root}) }); | ||
build_cmd.addArg("--global-cache-dir"); | ||
build_cmd.addDirectoryArg(.{ .cwd_relative = b.fmt("{}", .{b.graph.global_cache_root}) }); | ||
|
||
const actual_build_config_json = build_cmd.captureStdOut(); | ||
|
||
const run_diff = b.addRunArtifact(check_exe); | ||
run_diff.setName(b.fmt("run {s} ({s})", .{ check_exe.name, entry.name })); | ||
run_diff.addFileArg(expected_build_config_json); | ||
run_diff.addFileArg(actual_build_config_json); | ||
run_diff.addDirectoryArg(cases_dir); | ||
|
||
test_step.dependOn(&run_diff.step); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{ | ||
"deps_build_roots": [], | ||
"packages": [ | ||
{ | ||
"name": "root", | ||
"path": "root.zig" | ||
} | ||
], | ||
"include_dirs": [], | ||
"top_level_steps": [ | ||
"install", | ||
"uninstall" | ||
], | ||
"available_options": {} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
const std = @import("std"); | ||
|
||
pub fn build(b: *std.Build) void { | ||
_ = b.addModule("foo", .{ | ||
.root_source_file = b.path("root.zig"), | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
"deps_build_roots": [], | ||
"packages": [], | ||
"include_dirs": [], | ||
"top_level_steps": [ | ||
"install", | ||
"uninstall" | ||
], | ||
"available_options": {} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
const std = @import("std"); | ||
|
||
pub fn build(b: *std.Build) void { | ||
_ = b; | ||
} |
Oops, something went wrong.