From 8e6a52d5a6c9d0de356113494390a9d888d8ee1a Mon Sep 17 00:00:00 2001 From: Zendril Date: Tue, 4 Feb 2025 21:13:33 -0500 Subject: [PATCH] tracking, skipping and reset all wired in --- build.zig | 31 +++++++++++++++++++++++++++---- 1 file changed, 27 insertions(+), 4 deletions(-) diff --git a/build.zig b/build.zig index ccb16ac..2bc948b 100644 --- a/build.zig +++ b/build.zig @@ -267,10 +267,33 @@ pub fn build(b: *Build) !void { b.default_step = ziglings_step; var prev_step = &header_step.step; - // read the file to find the latest complete, use that in the for loop - // for (exercises[(s - 1)..]) |ex| { - for (exercises) |ex| { - // print("here {s}\n", .{ex.main_file}); + + var starting_exercise: u32 = 0; + + if (std.fs.cwd().openFile(".progress.txt", .{})) |progress_file| { + defer progress_file.close(); + + const progress_file_size = try progress_file.getEndPos(); + + var gpa = std.heap.GeneralPurposeAllocator(.{}){}; + defer _ = gpa.deinit(); + const allocator = gpa.allocator(); + const contents = try progress_file.readToEndAlloc(allocator, progress_file_size); + defer allocator.free(contents); + + starting_exercise = try std.fmt.parseInt(u32, contents, 10); + } else |err| { + switch (err) { + // This is fine, may be the first time tests are run or progress have been reset + std.fs.File.OpenError.FileNotFound => {}, + else => { + print("Unable to open progress file, Error: {}\n", .{err}); + return err; + }, + } + } + + for (exercises[starting_exercise..]) |ex| { const verify_stepn = ZiglingStep.create(b, ex, work_path, .normal); verify_stepn.step.dependOn(prev_step);