From 6ccd55729e5de45524337084b03eb5a89b9f3ac1 Mon Sep 17 00:00:00 2001 From: Dave Gauer Date: Sun, 14 Feb 2021 18:36:09 -0500 Subject: Added testing ability For the full details, see patches/README.md :-) --- build.zig | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'build.zig') diff --git a/build.zig b/build.zig index e80e98e..a9c4783 100644 --- a/build.zig +++ b/build.zig @@ -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; -- cgit v1.2.3-ZIG