feature. See also
. The project being documented here (as the example) is the Zig library itself.
Fuzz.init
pub fn init(
maker: *Maker,
all_steps: []const Configuration.Step.Index,
root_prog_node: std.Progress.Node,
mode: Mode,
) error
File
Code
pub fn init(
maker: *Maker,
all_steps: []const Configuration.Step.Index,
root_prog_node: std.Progress.Node,
mode: Mode,
) error{ OutOfMemory, Canceled }!Fuzz {
const graph = maker.graph;
const gpa = graph.cache.gpa;
const io = graph.io;
const conf = &maker.scanned_config.configuration;
const run_steps: []const Configuration.Step.Index = steps: {
var steps: std.ArrayList(Configuration.Step.Index) = .empty;
defer steps.deinit(gpa);
const rebuild_node = root_prog_node.start("Rebuilding Unit Tests", 0);
defer rebuild_node.end();
var rebuild_group: Io.Group = .init;
defer rebuild_group.cancel(io);
for (all_steps) |step_index| {
const conf_run = step_index.ptr(conf).extended.cast(conf, Configuration.Step.Run) orelse continue;
if (conf_run.producer.value == null) continue;
const run = &maker.stepByIndex(step_index).extended.run;
if (run.fuzz_tests.items.len == 0) continue;
try steps.append(gpa, step_index);
rebuild_group.async(io, rebuildTestsWorkerRun, .{ maker, step_index, rebuild_node });
}
if (steps.items.len == 0) fatal("no fuzz tests found", .{});
rebuild_node.setEstimatedTotalItems(steps.items.len);
const run_steps = try gpa.dupe(Configuration.Step.Index, steps.items);
try rebuild_group.await(io);
break :steps run_steps;
};
errdefer gpa.free(run_steps);
for (run_steps) |run_index| {
const run = &maker.stepByIndex(run_index).extended.run;
assert(run.fuzz_tests.items.len > 0);
if (run.rebuilt_executable == null)
fatal("one or more unit tests failed to be rebuilt in fuzz mode", .{});
}
return .{
.maker = maker,
.mode = mode,
.run_steps = run_steps,
.group = .init,
.root_prog_node = root_prog_node,
.prog_node = .none,
.coverage_files = .empty,
.coverage_mutex = .init,
.queue_mutex = .init,
.queue_cond = .init,
.msg_queue = .empty,
};
}