From 0c5c0a75df0871253bc33d2c40ded55b03e3886a Mon Sep 17 00:00:00 2001 From: David Rubin Date: Mon, 8 Jul 2024 19:43:53 -0700 Subject: [PATCH] dedup the `compare` exe --- tests/cases.zig | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/tests/cases.zig b/tests/cases.zig index cf9a4b8..afac6b2 100644 --- a/tests/cases.zig +++ b/tests/cases.zig @@ -22,20 +22,28 @@ pub fn addCases( ) !void { parent_step.dependOn(&python.step); + const compare_tool = b.addExecutable(.{ + .name = "compare", + .root_source_file = b.path("tools/compare.zig"), + .target = target, + .optimize = .ReleaseSafe, + .omit_frame_pointer = false, // we need the stack trace + }); + for (test_dirs) |dir| { const files = try getPyFilesInDir(b, b.fmt("tests/{s}", .{dir}), b.allocator); for (files) |file| { - parent_step.dependOn(addCase(b, target, file, osmium, python)); + parent_step.dependOn(addCase(b, target, file, osmium, python, compare_tool)); } } } fn addCase( b: *std.Build, - target: std.Build.ResolvedTarget, file_path: []const u8, osmium: *std.Build.Step.Compile, python: *std.Build.Step.Compile, + compare: *std.Build.Step.Compile, ) *std.Build.Step { const python_run = b.addRunArtifact(python); python_run.addArg(file_path); @@ -48,15 +56,7 @@ fn addCase( osmium_run.addArg(file_path); const osmium_stdout = osmium_run.captureStdOut(); - const compare_tool = b.addExecutable(.{ - .name = "compare", - .root_source_file = b.path("tools/compare.zig"), - .target = target, - .optimize = .ReleaseSafe, - .omit_frame_pointer = false, // we need the stack trace - }); - - const compare_run = b.addRunArtifact(compare_tool); + const compare_run = b.addRunArtifact(compare); compare_run.addFileArg(osmium_stdout); compare_run.addFileArg(python_stdout); compare_run.expectExitCode(0);