Skip to content

Commit 2c3d87b

Browse files
committed
macho: test empty translation units
1 parent 5391541 commit 2c3d87b

File tree

4 files changed

+32
-0
lines changed

4 files changed

+32
-0
lines changed

test/link.zig

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,10 @@ fn addMachOCases(cases: *tests.StandaloneContext) void {
7474
.build_modes = true,
7575
});
7676

77+
cases.addBuildFile("test/link/macho/empty/build.zig", .{
78+
.build_modes = true,
79+
});
80+
7781
cases.addBuildFile("test/link/macho/entry/build.zig", .{
7882
.build_modes = true,
7983
});

test/link/macho/empty/build.zig

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
const std = @import("std");
2+
const Builder = std.build.Builder;
3+
const LibExeObjectStep = std.build.LibExeObjStep;
4+
5+
pub fn build(b: *Builder) void {
6+
const mode = b.standardReleaseOptions();
7+
const target: std.zig.CrossTarget = .{ .os_tag = .macos };
8+
9+
const test_step = b.step("test", "Test the program");
10+
test_step.dependOn(b.getInstallStep());
11+
12+
const exe = b.addExecutable("test", null);
13+
exe.addCSourceFile("main.c", &[0][]const u8{});
14+
exe.addCSourceFile("empty.c", &[0][]const u8{});
15+
exe.setBuildMode(mode);
16+
exe.setTarget(target);
17+
exe.linkLibC();
18+
19+
const run_cmd = exe.run();
20+
run_cmd.expectStdOutEqual("Hello!\n");
21+
test_step.dependOn(&run_cmd.step);
22+
}

test/link/macho/empty/empty.c

Whitespace-only changes.

test/link/macho/empty/main.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#include <stdio.h>
2+
3+
int main(int argc, char* argv[]) {
4+
printf("Hello!\n");
5+
return 0;
6+
}

0 commit comments

Comments
 (0)