diff options
| author | Zendril <kenneth.s.brooks@gmail.com> | 2025-02-04 21:13:33 -0500 |
|---|---|---|
| committer | Zendril <kenneth.s.brooks@gmail.com> | 2025-02-04 21:13:33 -0500 |
| commit | 8e6a52d5a6c9d0de356113494390a9d888d8ee1a (patch) | |
| tree | 50c099e97fe44ff76ba80aefeeccfb573b1e8c4d /build.zig | |
| parent | e54b30f3d3a4b05d7eb35f066efd3a00c86a4b4f (diff) | |
tracking, skipping and reset all wired in
Diffstat (limited to 'build.zig')
| -rw-r--r-- | build.zig | 31 |
1 files changed, 27 insertions, 4 deletions
@@ -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); |
