From 105655857f02c8bd59f5c0250f124a064df400cf Mon Sep 17 00:00:00 2001 From: Jakub Konka Date: Sun, 14 Jan 2024 10:23:11 +0100 Subject: [PATCH] test/link/macho: upgrade weak framework test --- test/link.zig | 4 --- test/link/macho.zig | 20 ++++++++++++++ test/link/macho/weak_framework/build.zig | 34 ------------------------ test/link/macho/weak_framework/main.c | 3 --- 4 files changed, 20 insertions(+), 41 deletions(-) delete mode 100644 test/link/macho/weak_framework/build.zig delete mode 100644 test/link/macho/weak_framework/main.c diff --git a/test/link.zig b/test/link.zig index fd5fc0fd4c..909d1d406e 100644 --- a/test/link.zig +++ b/test/link.zig @@ -171,8 +171,4 @@ pub const cases = [_]Case{ .build_root = "test/link/macho/unwind_info", .import = @import("link/macho/unwind_info/build.zig"), }, - .{ - .build_root = "test/link/macho/weak_framework", - .import = @import("link/macho/weak_framework/build.zig"), - }, }; diff --git a/test/link/macho.zig b/test/link/macho.zig index 5b4d0a3a28..bebf4d6d91 100644 --- a/test/link/macho.zig +++ b/test/link/macho.zig @@ -32,6 +32,7 @@ pub fn testAll(b: *Build, build_opts: BuildOptions) *Step { if (build_opts.has_macos_sdk) { macho_step.dependOn(testHeaderpad(b, .{ .target = b.host })); macho_step.dependOn(testNeededFramework(b, .{ .target = b.host })); + macho_step.dependOn(testWeakFramework(b, .{ .target = b.host })); } } @@ -767,6 +768,25 @@ fn testWeakBind(b: *Build, opts: Options) *Step { return test_step; } +fn testWeakFramework(b: *Build, opts: Options) *Step { + const test_step = addTestStep(b, "macho-weak-framework", opts); + + const exe = addExecutable(b, opts, .{ .name = "main", .c_source_bytes = "int main() { return 0; }" }); + exe.root_module.linkFramework("Cocoa", .{ .weak = true }); + + const run = addRunArtifact(exe); + run.expectExitCode(0); + test_step.dependOn(&run.step); + + const check = exe.checkObject(); + check.checkInHeaders(); + check.checkExact("cmd LOAD_WEAK_DYLIB"); + check.checkContains("Cocoa"); + test_step.dependOn(&check.step); + + return test_step; +} + fn testWeakLibrary(b: *Build, opts: Options) *Step { const test_step = addTestStep(b, "macho-weak-library", opts); diff --git a/test/link/macho/weak_framework/build.zig b/test/link/macho/weak_framework/build.zig deleted file mode 100644 index 2a430443d4..0000000000 --- a/test/link/macho/weak_framework/build.zig +++ /dev/null @@ -1,34 +0,0 @@ -const std = @import("std"); - -pub const requires_symlinks = true; -pub const requires_macos_sdk = 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 exe = b.addExecutable(.{ - .name = "test", - .optimize = optimize, - .target = b.host, - }); - exe.addCSourceFile(.{ .file = .{ .path = "main.c" }, .flags = &[0][]const u8{} }); - exe.linkLibC(); - exe.linkFrameworkWeak("Cocoa"); - - const check = exe.checkObject(); - check.checkInHeaders(); - check.checkExact("cmd LOAD_WEAK_DYLIB"); - check.checkContains("Cocoa"); - test_step.dependOn(&check.step); - - const run_cmd = b.addRunArtifact(exe); - test_step.dependOn(&run_cmd.step); -} diff --git a/test/link/macho/weak_framework/main.c b/test/link/macho/weak_framework/main.c deleted file mode 100644 index ca68d24cc7..0000000000 --- a/test/link/macho/weak_framework/main.c +++ /dev/null @@ -1,3 +0,0 @@ -int main(int argc, char* argv[]) { - return 0; -}