Skip to content

Commit

Permalink
-Dskip-release now also skips build example tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Hejsil committed Jul 18, 2018
1 parent 843529d commit b7be082
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 8 deletions.
2 changes: 1 addition & 1 deletion build.zig
Expand Up @@ -92,7 +92,7 @@ pub fn build(b: *Builder) !void {
test_step.dependOn(tests.addPkgTests(b, test_filter, "std/special/compiler_rt/index.zig", "compiler-rt", "Run the compiler_rt tests", modes));

test_step.dependOn(tests.addCompareOutputTests(b, test_filter, modes));
test_step.dependOn(tests.addBuildExampleTests(b, test_filter));
test_step.dependOn(tests.addBuildExampleTests(b, test_filter, modes));
test_step.dependOn(tests.addCompileErrorTests(b, test_filter, modes));
test_step.dependOn(tests.addAssembleAndLinkTests(b, test_filter, modes));
test_step.dependOn(tests.addRuntimeSafetyTests(b, test_filter, modes));
Expand Down
11 changes: 4 additions & 7 deletions test/tests.zig
Expand Up @@ -89,12 +89,13 @@ pub fn addCompileErrorTests(b: *build.Builder, test_filter: ?[]const u8, modes:
return cases.step;
}

pub fn addBuildExampleTests(b: *build.Builder, test_filter: ?[]const u8) *build.Step {
pub fn addBuildExampleTests(b: *build.Builder, test_filter: ?[]const u8, modes: []const Mode) *build.Step {
const cases = b.allocator.create(BuildExamplesContext{
.b = b,
.step = b.step("test-build-examples", "Build the examples"),
.test_index = 0,
.test_filter = test_filter,
.modes = modes,
}) catch unreachable;

build_examples.addCases(cases);
Expand Down Expand Up @@ -697,6 +698,7 @@ pub const BuildExamplesContext = struct {
step: *build.Step,
test_index: usize,
test_filter: ?[]const u8,
modes: []const Mode,

pub fn addC(self: *BuildExamplesContext, root_src: []const u8) void {
self.addAllArgs(root_src, true);
Expand Down Expand Up @@ -739,12 +741,7 @@ pub const BuildExamplesContext = struct {
pub fn addAllArgs(self: *BuildExamplesContext, root_src: []const u8, link_libc: bool) void {
const b = self.b;

for ([]Mode{
Mode.Debug,
Mode.ReleaseSafe,
Mode.ReleaseFast,
Mode.ReleaseSmall,
}) |mode| {
for (self.modes) |mode| {
const annotated_case_name = fmt.allocPrint(self.b.allocator, "build {} ({})", root_src, @tagName(mode)) catch unreachable;
if (self.test_filter) |filter| {
if (mem.indexOf(u8, annotated_case_name, filter) == null) continue;
Expand Down

0 comments on commit b7be082

Please sign in to comment.