diff --git a/lib/compiler/Maker/Step.zig b/lib/compiler/Maker/Step.zig index 5c618660ce787ce8913b9dfb597f0bf882856b7e..5854bbbf25305e46eb3483e89948caa843f9f408 100644 --- a/lib/compiler/Maker/Step.zig +++ b/lib/compiler/Maker/Step.zig @@ -18,6 +18,7 @@ const assert = std.debug.assert; const WebServer = @import("WebServer.zig"); const Maker = @import("../Maker.zig"); +pub const CheckFile = @import("Step/CheckFile.zig"); pub const Compile = @import("Step/Compile.zig"); pub const FindProgram = @import("Step/FindProgram.zig"); pub const Fmt = @import("Step/Fmt.zig"); @@ -75,7 +76,7 @@ comptime { } pub const Extended = union(enum) { - check_file: Todo, + check_file: CheckFile, compile: Compile, config_header: Todo, fail: Fail, diff --git a/lib/compiler/Maker/Step/CheckFile.zig b/lib/compiler/Maker/Step/CheckFile.zig index 0ed23c05e01952091d0c02ff26a642446e9ae1a0..ab563a6092ee759f1e636eab9cee1b3b6759d203 100644 --- a/lib/compiler/Maker/Step/CheckFile.zig +++ b/lib/compiler/Maker/Step/CheckFile.zig @@ -13,6 +13,7 @@ pub fn make( maker: *Maker, progress_node: std.Progress.Node, ) Step.ExtendedMakeError!void { + _ = check_file; _ = progress_node; const graph = maker.graph; const arena = maker.graph.arena; // TODO don't leak into process arena @@ -20,7 +21,7 @@ pub fn make( const step = maker.stepByIndex(step_index); const conf = &maker.scanned_config.configuration; const conf_step = step_index.ptr(conf); - const conf_cf = conf_step.extended.get(conf.extra).install_file; + const conf_cf = conf_step.extended.get(conf.extra).check_file; const lazy_path = conf_cf.file.get(conf); try step.singleUnchangingWatchInput(maker, arena, lazy_path); @@ -29,11 +30,12 @@ pub fn make( const limit: Io.Limit = if (conf_cf.max_bytes.value) |x| .limited(x) else .unlimited; const contents = src_path.root_dir.handle.readFileAlloc(io, src_path.sub_path, arena, limit) catch |err| - return step.fail("failed to read {f}: {t}", .{ src_path, err }); + return step.fail(maker, "failed to read {f}: {t}", .{ src_path, err }); - for (check_file.expected_matches) |expected_match| { + for (conf_cf.expected_matches.slice) |expected_match_index| { + const expected_match = expected_match_index.slice(conf); if (std.mem.find(u8, contents, expected_match) == null) { - return step.fail( + return step.fail(maker, \\ \\========= expected to find: =================== \\{s} @@ -44,16 +46,17 @@ pub fn make( } } - if (check_file.expected_exact) |expected_exact| { + if (conf_cf.expected_exact.value) |expected_exact_index| { + const expected_exact = expected_exact_index.slice(conf); if (!std.mem.eql(u8, expected_exact, contents)) { - return step.fail( + return step.fail(maker, \\ \\========= expected: ===================== \\{s} \\========= but found: ==================== \\{s} \\========= from the following file: ====== - \\{s} + \\{f} , .{ expected_exact, contents, src_path }); } }