master
 1const std = @import("std");
 2
 3pub fn build(b: *std.Build) void {
 4    const test_step = b.step("test", "Test it");
 5    b.default_step = test_step;
 6
 7    const target = b.standardTargetOptions(.{});
 8    const optimize = b.standardOptimizeOption(.{});
 9
10    const create_file_exe = b.addExecutable(.{
11        .name = "create_file",
12        .root_module = b.createModule(.{
13            .root_source_file = b.path("create_file.zig"),
14            .target = target,
15            .optimize = optimize,
16        }),
17    });
18
19    const create_first = b.addRunArtifact(create_file_exe);
20    const first_dir = create_first.addOutputDirectoryArg("first");
21    create_first.addArg("hello1.txt");
22    test_step.dependOn(&b.addCheckFile(first_dir.path(b, "hello1.txt"), .{ .expected_matches = &.{
23        std.fs.path.sep_str ++
24            \\first
25            \\hello1.txt
26            \\Hello, world!
27            \\
28        ,
29    } }).step);
30
31    const create_second = b.addRunArtifact(create_file_exe);
32    const second_dir = create_second.addPrefixedOutputDirectoryArg("--dir=", "second");
33    create_second.addArg("hello2.txt");
34    test_step.dependOn(&b.addCheckFile(second_dir.path(b, "hello2.txt"), .{ .expected_matches = &.{
35        std.fs.path.sep_str ++
36            \\second
37            \\hello2.txt
38            \\Hello, world!
39            \\
40        ,
41    } }).step);
42}