build: add mode paramater to testStep functions

This commit is contained in:
alichraghi 2022-07-20 16:31:57 +04:30 committed by Stephen Gutekanst
parent 77aecbe806
commit e6adc3e350
8 changed files with 43 additions and 19 deletions

View file

@ -18,10 +18,8 @@ pub fn build(b: *std.build.Builder) void {
}; };
const options = Options{ .gpu_dawn_options = gpu_dawn_options }; const options = Options{ .gpu_dawn_options = gpu_dawn_options };
// TODO: re-enable tests
const main_tests = b.addTest("src/main.zig"); const main_tests = b.addTest("src/main.zig");
main_tests.setBuildMode(mode); main_tests.setBuildMode(mode);
main_tests.setTarget(target);
main_tests.addPackage(pkg); main_tests.addPackage(pkg);
main_tests.addPackage(gpu.pkg); main_tests.addPackage(gpu.pkg);
main_tests.addPackage(glfw.pkg); main_tests.addPackage(glfw.pkg);
@ -29,6 +27,16 @@ pub fn build(b: *std.build.Builder) void {
const test_step = b.step("test", "Run library tests"); const test_step = b.step("test", "Run library tests");
test_step.dependOn(&main_tests.step); test_step.dependOn(&main_tests.step);
const test_mach_step = b.step("test-mach", "Run Mach Core library tests");
test_mach_step.dependOn(&main_tests.step);
test_mach_step.dependOn(&gpu.testStep(b, mode, @bitCast(gpu.Options, options)).step);
test_mach_step.dependOn(&gpu_dawn.testStep(b, mode).step);
test_mach_step.dependOn(&glfw.testStep(b, mode).step);
test_mach_step.dependOn(&ecs.testStep(b, mode).step);
test_mach_step.dependOn(&freetype.testStep(b, mode).step);
test_mach_step.dependOn(&sysaudio.testStep(b, mode, .{}).step);
test_mach_step.dependOn(&sysjs.testStep(b, mode).step);
// TODO(build-system): https://github.com/hexops/mach/issues/229#issuecomment-1100958939 // TODO(build-system): https://github.com/hexops/mach/issues/229#issuecomment-1100958939
ensureGit(b.allocator); ensureGit(b.allocator);
ensureDependencySubmodule(b.allocator, "examples/libs/zmath") catch unreachable; ensureDependencySubmodule(b.allocator, "examples/libs/zmath") catch unreachable;

View file

@ -1,12 +1,15 @@
const std = @import("std"); const std = @import("std");
pub fn build(b: *std.build.Builder) void { pub fn build(b: *std.build.Builder) void {
const mode = b.standardReleaseOptions();
const test_step = b.step("test", "Run library tests"); const test_step = b.step("test", "Run library tests");
test_step.dependOn(&testStep(b).step); test_step.dependOn(&testStep(b, mode).step);
} }
pub fn testStep(b: *std.build.Builder) *std.build.LibExeObjStep { pub fn testStep(b: *std.build.Builder, mode: std.builtin.Mode) *std.build.LibExeObjStep {
return b.addTest(thisDir() ++ "/src/main.zig"); const main_tests = b.addTest(thisDir() ++ "/src/main.zig");
main_tests.setBuildMode(mode);
return main_tests;
} }
pub const pkg = std.build.Pkg{ pub const pkg = std.build.Pkg{

View file

@ -49,7 +49,7 @@ pub fn build(b: *std.build.Builder) !void {
const target = b.standardTargetOptions(.{}); const target = b.standardTargetOptions(.{});
const test_step = b.step("test", "Run library tests"); const test_step = b.step("test", "Run library tests");
test_step.dependOn(&testStep(b).step); test_step.dependOn(&testStep(b, mode).step);
inline for ([_][]const u8{ inline for ([_][]const u8{
"single-glyph", "single-glyph",
@ -80,19 +80,22 @@ pub fn build(b: *std.build.Builder) !void {
} }
} }
pub fn testStep(b: *Builder) *std.build.LibExeObjStep { pub fn testStep(b: *Builder, mode: std.builtin.Mode) *std.build.LibExeObjStep {
const freetype_tests = b.addTestSource(pkg.source); const freetype_tests = b.addTestSource(pkg.source);
freetype_tests.setBuildMode(mode);
freetype_tests.addPackage(c_pkg); freetype_tests.addPackage(c_pkg);
freetype_tests.addPackage(utils_pkg); freetype_tests.addPackage(utils_pkg);
link(b, freetype_tests, .{}); link(b, freetype_tests, .{});
const harfbuzz_tests = b.addTestSource(harfbuzz_pkg.source); const harfbuzz_tests = b.addTestSource(harfbuzz_pkg.source);
harfbuzz_tests.setBuildMode(mode);
harfbuzz_tests.addPackage(c_pkg); harfbuzz_tests.addPackage(c_pkg);
harfbuzz_tests.addPackage(utils_pkg); harfbuzz_tests.addPackage(utils_pkg);
harfbuzz_tests.addPackage(pkg); harfbuzz_tests.addPackage(pkg);
link(b, harfbuzz_tests, .{ .harfbuzz = .{} }); link(b, harfbuzz_tests, .{ .harfbuzz = .{} });
const main_tests = b.addTest(thisDir() ++ "/test/main.zig"); const main_tests = b.addTest(thisDir() ++ "/test/main.zig");
main_tests.setBuildMode(mode);
main_tests.addPackage(c_pkg); main_tests.addPackage(c_pkg);
// Remove once the stage2 compiler fixes pkg std not found // Remove once the stage2 compiler fixes pkg std not found

View file

@ -4,12 +4,14 @@ const Builder = std.build.Builder;
const system_sdk = @import("system_sdk.zig"); const system_sdk = @import("system_sdk.zig");
pub fn build(b: *Builder) void { pub fn build(b: *Builder) void {
const mode = b.standardReleaseOptions();
const test_step = b.step("test", "Run library tests"); const test_step = b.step("test", "Run library tests");
test_step.dependOn(&testStep(b).step); test_step.dependOn(&testStep(b, mode).step);
} }
pub fn testStep(b: *Builder) *std.build.LibExeObjStep { pub fn testStep(b: *Builder, mode: std.builtin.Mode) *std.build.LibExeObjStep {
const main_tests = b.addTest(thisDir() ++ "/src/main.zig"); const main_tests = b.addTest(thisDir() ++ "/src/main.zig");
main_tests.setBuildMode(mode);
link(b, main_tests, .{}); link(b, main_tests, .{});
return main_tests; return main_tests;
} }

View file

@ -18,7 +18,7 @@ pub fn build(b: *Builder) void {
link(b, lib, options); link(b, lib, options);
const test_step = b.step("test", "Run library tests"); const test_step = b.step("test", "Run library tests");
test_step.dependOn(&testStep(b).step); test_step.dependOn(&testStep(b, mode).step);
const dawn_example = b.addExecutable("dawn-example", "src/dawn/hello_triangle.zig"); const dawn_example = b.addExecutable("dawn-example", "src/dawn/hello_triangle.zig");
dawn_example.setBuildMode(mode); dawn_example.setBuildMode(mode);
@ -34,8 +34,10 @@ pub fn build(b: *Builder) void {
dawn_example_run_step.dependOn(&dawn_example_run_cmd.step); dawn_example_run_step.dependOn(&dawn_example_run_cmd.step);
} }
pub fn testStep(b: *std.build.Builder) *std.build.LibExeObjStep { pub fn testStep(b: *std.build.Builder, mode: std.builtin.Mode) *std.build.LibExeObjStep {
return b.addTest(thisDir() ++ "/src/main.zig"); const main_tests = b.addTest(thisDir() ++ "/src/main.zig");
main_tests.setBuildMode(mode);
return main_tests;
} }
pub const LinuxWindowManager = enum { pub const LinuxWindowManager = enum {

View file

@ -11,7 +11,7 @@ pub fn build(b: *std.build.Builder) void {
}; };
const test_step = b.step("test", "Run library tests"); const test_step = b.step("test", "Run library tests");
test_step.dependOn(&testStep(b, .{ .gpu_dawn_options = gpu_dawn_options }).step); test_step.dependOn(&testStep(b, mode, .{ .gpu_dawn_options = gpu_dawn_options }).step);
const example = b.addExecutable("gpu-hello-triangle", "examples/main.zig"); const example = b.addExecutable("gpu-hello-triangle", "examples/main.zig");
example.setTarget(target); example.setTarget(target);
@ -28,8 +28,9 @@ pub fn build(b: *std.build.Builder) void {
example_run_step.dependOn(&example_run_cmd.step); example_run_step.dependOn(&example_run_cmd.step);
} }
pub fn testStep(b: *std.build.Builder, options: Options) *std.build.LibExeObjStep { pub fn testStep(b: *std.build.Builder, mode: std.builtin.Mode, options: Options) *std.build.LibExeObjStep {
const main_tests = b.addTest(thisDir() ++ "/src/main.zig"); const main_tests = b.addTest(thisDir() ++ "/src/main.zig");
main_tests.setBuildMode(mode);
link(b, main_tests, options); link(b, main_tests, options);
return main_tests; return main_tests;
} }

View file

@ -22,7 +22,7 @@ pub fn build(b: *Builder) void {
const target = b.standardTargetOptions(.{}); const target = b.standardTargetOptions(.{});
const test_step = b.step("test", "Run library tests"); const test_step = b.step("test", "Run library tests");
test_step.dependOn(&testStep(b, .{}).step); test_step.dependOn(&testStep(b, mode, .{}).step);
inline for ([_][]const u8{ inline for ([_][]const u8{
"soundio-sine-wave", "soundio-sine-wave",
@ -48,11 +48,13 @@ pub fn build(b: *Builder) void {
} }
} }
pub fn testStep(b: *std.build.Builder, options: Options) *std.build.LibExeObjStep { pub fn testStep(b: *std.build.Builder, mode: std.builtin.Mode, options: Options) *std.build.LibExeObjStep {
const soundio_tests = b.addTest(thisDir() ++ "/soundio/main.zig"); const soundio_tests = b.addTest(thisDir() ++ "/soundio/main.zig");
soundio_tests.setBuildMode(mode);
link(b, soundio_tests, options); link(b, soundio_tests, options);
const main_tests = b.addTest(thisDir() ++ "/src/main.zig"); const main_tests = b.addTest(thisDir() ++ "/src/main.zig");
main_tests.setBuildMode(mode);
main_tests.addPackage(soundio_pkg); main_tests.addPackage(soundio_pkg);
main_tests.step.dependOn(&soundio_tests.step); main_tests.step.dependOn(&soundio_tests.step);
link(b, main_tests, options); link(b, main_tests, options);

View file

@ -1,12 +1,15 @@
const std = @import("std"); const std = @import("std");
pub fn build(b: *std.build.Builder) void { pub fn build(b: *std.build.Builder) void {
const mode = b.standardReleaseOptions();
const test_step = b.step("test", "Run library tests"); const test_step = b.step("test", "Run library tests");
test_step.dependOn(&testStep(b).step); test_step.dependOn(&testStep(b, mode).step);
} }
pub fn testStep(b: *std.build.Builder) *std.build.LibExeObjStep { pub fn testStep(b: *std.build.Builder, mode: std.builtin.Mode) *std.build.LibExeObjStep {
return b.addTest(thisDir() ++ "/src/main.zig"); const main_tests = b.addTest(thisDir() ++ "/src/main.zig");
main_tests.setBuildMode(mode);
return main_tests;
} }
pub const pkg = std.build.Pkg{ pub const pkg = std.build.Pkg{