Commit 3874df839d

Jakub Konka <kubkon@jakubkonka.com>
2023-03-31 23:06:00
link-test: add test for entry in a static archive for MachO
1 parent 6f83a74
Changed files (3)
test
link
macho
entry_in_archive
test/link/macho/entry_in_archive/build.zig
@@ -0,0 +1,35 @@
+const std = @import("std");
+
+pub const requires_symlinks = true;
+
+pub fn build(b: *std.Build) void {
+    const test_step = b.step("test", "Test it");
+    b.default_step = test_step;
+
+    add(b, test_step, .Debug);
+    add(b, test_step, .ReleaseFast);
+    add(b, test_step, .ReleaseSmall);
+    add(b, test_step, .ReleaseSafe);
+}
+
+fn add(b: *std.Build, test_step: *std.Build.Step, optimize: std.builtin.OptimizeMode) void {
+    const lib = b.addStaticLibrary(.{
+        .name = "main",
+        .optimize = optimize,
+        .target = .{ .os_tag = .macos },
+    });
+    lib.addCSourceFile("main.c", &.{});
+    lib.linkLibC();
+
+    const exe = b.addExecutable(.{
+        .name = "main",
+        .optimize = optimize,
+        .target = .{ .os_tag = .macos },
+    });
+    exe.linkLibrary(lib);
+    exe.linkLibC();
+
+    const run = exe.run();
+    run.expectExitCode(0);
+    test_step.dependOn(&run.step);
+}
test/link/macho/entry_in_archive/main.c
@@ -0,0 +1,5 @@
+#include <stdio.h>
+
+int main(int argc, char* argv[]) {
+  return 0;
+}
test/link.zig
@@ -104,6 +104,10 @@ pub const cases = [_]Case{
         .build_root = "test/link/macho/entry",
         .import = @import("link/macho/entry/build.zig"),
     },
+    .{
+        .build_root = "test/link/macho/entry_in_archive",
+        .import = @import("link/macho/entry_in_archive/build.zig"),
+    },
     .{
         .build_root = "test/link/macho/headerpad",
         .import = @import("link/macho/headerpad/build.zig"),