diff options
author | Dave Gauer <dave@ratfactor.com> | 2021-02-14 18:36:09 -0500 |
---|---|---|
committer | Dave Gauer <dave@ratfactor.com> | 2021-02-14 18:36:09 -0500 |
commit | 6ccd55729e5de45524337084b03eb5a89b9f3ac1 (patch) | |
tree | f6251d12905c2f7007415540173864c5a886b193 /build.zig | |
parent | 95c8ea3cb3bde9427e2364e450a6cf443cdaba5e (diff) | |
download | ziglings-6ccd55729e5de45524337084b03eb5a89b9f3ac1.tar.gz ziglings-6ccd55729e5de45524337084b03eb5a89b9f3ac1.tar.bz2 ziglings-6ccd55729e5de45524337084b03eb5a89b9f3ac1.tar.xz ziglings-6ccd55729e5de45524337084b03eb5a89b9f3ac1.zip |
Added testing ability
For the full details, see patches/README.md :-)
Diffstat (limited to 'build.zig')
-rw-r--r-- | build.zig | 13 |
1 files changed, 9 insertions, 4 deletions
@@ -330,15 +330,17 @@ pub fn build(b: *Builder) void { var prev_chain_verify = verify_all; + const use_healed = b.option(bool, "healed", "Run exercises from patches/healed") orelse false; + for (exercises) |ex| { const base_name = ex.baseName(); const file_path = std.fs.path.join(b.allocator, &[_][]const u8{ - "exercises", ex.main_file, + if (use_healed) "patches/healed" else "exercises", ex.main_file, }) catch unreachable; const build_step = b.addExecutable(base_name, file_path); build_step.install(); - const verify_step = ZiglingStep.create(b, ex); + const verify_step = ZiglingStep.create(b, ex, use_healed); const key = ex.key(); @@ -375,13 +377,15 @@ const ZiglingStep = struct { step: Step, exercise: Exercise, builder: *Builder, + use_healed: bool, - pub fn create(builder: *Builder, exercise: Exercise) *@This() { + pub fn create(builder: *Builder, exercise: Exercise, use_healed: bool) *@This() { const self = builder.allocator.create(@This()) catch unreachable; self.* = .{ .step = Step.init(.Custom, exercise.main_file, builder.allocator, make), .exercise = exercise, .builder = builder, + .use_healed = use_healed, }; return self; } @@ -490,7 +494,8 @@ const ZiglingStep = struct { zig_args.append(@tagName(builder.color)) catch unreachable; } - const zig_file = std.fs.path.join(builder.allocator, &[_][]const u8{ "exercises", self.exercise.main_file }) catch unreachable; + const zig_file = std.fs.path.join(builder.allocator, &[_][]const u8{ + if (self.use_healed) "patches/healed" else "exercises", self.exercise.main_file }) catch unreachable; zig_args.append(builder.pathFromRoot(zig_file)) catch unreachable; zig_args.append("--cache-dir") catch unreachable; |