diff options
| author | Jakub Konka <kubkon@jakubkonka.com> | 2022-09-17 17:22:47 +0200 |
|---|---|---|
| committer | Jakub Konka <kubkon@jakubkonka.com> | 2022-09-17 18:43:24 +0200 |
| commit | 2c3d87b168bf522f538e78325fdae71c320e6e20 (patch) | |
| tree | fae55c865e9cfea0aff848b65e0de3a9c2e456ab /test | |
| parent | 5391541f11570dc444bfb79e5cf0e89aa872d0b8 (diff) | |
| download | zig-2c3d87b168bf522f538e78325fdae71c320e6e20.tar.gz zig-2c3d87b168bf522f538e78325fdae71c320e6e20.zip | |
macho: test empty translation units
Diffstat (limited to 'test')
| -rw-r--r-- | test/link.zig | 4 | ||||
| -rw-r--r-- | test/link/macho/empty/build.zig | 22 | ||||
| -rw-r--r-- | test/link/macho/empty/empty.c | 0 | ||||
| -rw-r--r-- | test/link/macho/empty/main.c | 6 |
4 files changed, 32 insertions, 0 deletions
diff --git a/test/link.zig b/test/link.zig index d1dcbbc292..a798b700cd 100644 --- a/test/link.zig +++ b/test/link.zig @@ -74,6 +74,10 @@ fn addMachOCases(cases: *tests.StandaloneContext) void { .build_modes = true, }); + cases.addBuildFile("test/link/macho/empty/build.zig", .{ + .build_modes = true, + }); + cases.addBuildFile("test/link/macho/entry/build.zig", .{ .build_modes = true, }); diff --git a/test/link/macho/empty/build.zig b/test/link/macho/empty/build.zig new file mode 100644 index 0000000000..14a9af8040 --- /dev/null +++ b/test/link/macho/empty/build.zig @@ -0,0 +1,22 @@ +const std = @import("std"); +const Builder = std.build.Builder; +const LibExeObjectStep = std.build.LibExeObjStep; + +pub fn build(b: *Builder) void { + const mode = b.standardReleaseOptions(); + const target: std.zig.CrossTarget = .{ .os_tag = .macos }; + + const test_step = b.step("test", "Test the program"); + test_step.dependOn(b.getInstallStep()); + + const exe = b.addExecutable("test", null); + exe.addCSourceFile("main.c", &[0][]const u8{}); + exe.addCSourceFile("empty.c", &[0][]const u8{}); + exe.setBuildMode(mode); + exe.setTarget(target); + exe.linkLibC(); + + const run_cmd = exe.run(); + run_cmd.expectStdOutEqual("Hello!\n"); + test_step.dependOn(&run_cmd.step); +} diff --git a/test/link/macho/empty/empty.c b/test/link/macho/empty/empty.c new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/test/link/macho/empty/empty.c diff --git a/test/link/macho/empty/main.c b/test/link/macho/empty/main.c new file mode 100644 index 0000000000..9f1eea37b4 --- /dev/null +++ b/test/link/macho/empty/main.c @@ -0,0 +1,6 @@ +#include <stdio.h> + +int main(int argc, char* argv[]) { + printf("Hello!\n"); + return 0; +} |
