mirror of
https://github.com/ziglang/zig.git
synced 2026-01-20 14:25:16 +00:00
link-tests: add test case for parsing weak imports
This commit is contained in:
parent
351031b6c7
commit
72769f6cec
@ -79,6 +79,11 @@ fn addWasmCases(cases: *tests.StandaloneContext) void {
|
||||
}
|
||||
|
||||
fn addMachOCases(cases: *tests.StandaloneContext) void {
|
||||
cases.addBuildFile("test/link/macho/bugs/13056/build.zig", .{
|
||||
.build_modes = true,
|
||||
.requires_macos_sdk = true,
|
||||
});
|
||||
|
||||
cases.addBuildFile("test/link/macho/bugs/13457/build.zig", .{
|
||||
.build_modes = true,
|
||||
});
|
||||
|
||||
29
test/link/macho/bugs/13056/build.zig
Normal file
29
test/link/macho/bugs/13056/build.zig
Normal file
@ -0,0 +1,29 @@
|
||||
const std = @import("std");
|
||||
const Builder = std.build.Builder;
|
||||
|
||||
pub fn build(b: *Builder) void {
|
||||
const mode = b.standardReleaseOptions();
|
||||
|
||||
const target: std.zig.CrossTarget = .{ .os_tag = .macos };
|
||||
const target_info = std.zig.system.NativeTargetInfo.detect(target) catch unreachable;
|
||||
const sdk = std.zig.system.darwin.getDarwinSDK(b.allocator, target_info.target) orelse
|
||||
@panic("macOS SDK is required to run the test");
|
||||
|
||||
const test_step = b.step("test", "Test the program");
|
||||
|
||||
const exe = b.addExecutable("test", null);
|
||||
b.default_step.dependOn(&exe.step);
|
||||
exe.addIncludePath(std.fs.path.join(b.allocator, &.{ sdk.path, "/usr/include" }) catch unreachable);
|
||||
exe.addIncludePath(std.fs.path.join(b.allocator, &.{ sdk.path, "/usr/include/c++/v1" }) catch unreachable);
|
||||
exe.addCSourceFile("test.cpp", &.{
|
||||
"-nostdlib++",
|
||||
"-nostdinc++",
|
||||
});
|
||||
exe.addObjectFile(std.fs.path.join(b.allocator, &.{ sdk.path, "/usr/lib/libc++.tbd" }) catch unreachable);
|
||||
exe.setBuildMode(mode);
|
||||
|
||||
const run_cmd = exe.run();
|
||||
run_cmd.expectStdErrEqual("x: 5\n");
|
||||
|
||||
test_step.dependOn(&run_cmd.step);
|
||||
}
|
||||
10
test/link/macho/bugs/13056/test.cpp
Normal file
10
test/link/macho/bugs/13056/test.cpp
Normal file
@ -0,0 +1,10 @@
|
||||
// test.cpp
|
||||
#include <new>
|
||||
#include <cstdio>
|
||||
|
||||
int main() {
|
||||
int *x = new int;
|
||||
*x = 5;
|
||||
fprintf(stderr, "x: %d\n", *x);
|
||||
delete x;
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user