Last active
March 31, 2024 22:19
-
-
Save permutationlock/52b4abb68443456fc3728781180fe137 to your computer and use it in GitHub Desktop.
Run gdb on test step using build.zig
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const std = @import("std"); | |
const builtin = @import("builtin"); | |
const Builder = std.build.Builder; | |
pub fn build(b: *Builder) !void { | |
const target = b.standardTargetOptions(.{}); | |
const optimize = b.standardOptimizeOption(.{}); | |
const main_tests = b.addTest(.{ | |
.root_source_file = .{ .path = "main.zig" }, | |
.target = target, | |
.optimize = optimize, | |
}); | |
// run test step | |
const run_tests = b.addRunArtifact(main_tests); | |
const test_step = b.step("test", "Run unit tests"); | |
test_step.dependOn(&run_tests.step); | |
// debug test step | |
const gdb_command = b.addSystemCommand(&[_][]const u8{ "gdb" }); | |
gdb_command.addFileArg(main_tests.getEmittedBin()); | |
gdb_command.step.dependOn(&main_tests.step); | |
const debug_test_step = b.step("debug_test", "Run gdb on tests"); | |
debug_test_step.dependOn(&gdb_command.step); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment