zig

fork of https://codeberg.org/ziglang/zig
Log | Files | Refs | README | LICENSE

commit 105655857f02c8bd59f5c0250f124a064df400cf (tree)
parent e96f8b817a889abecc86a71961ba9a95c13c315e
Author: Jakub Konka <kubkon@jakubkonka.com>
Date:   Sun, 14 Jan 2024 10:23:11 +0100

test/link/macho: upgrade weak framework test

Diffstat:
Mtest/link.zig | 4----
Mtest/link/macho.zig | 20++++++++++++++++++++
Dtest/link/macho/weak_framework/build.zig | 34----------------------------------
Dtest/link/macho/weak_framework/main.c | 3---
4 files changed, 20 insertions(+), 41 deletions(-)

diff --git 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 @@ -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 @@ -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 @@ -1,3 +0,0 @@ -int main(int argc, char* argv[]) { - return 0; -}