From 0cc4dc615b536eb5e927558f1391060ecf97b0ea Mon Sep 17 00:00:00 2001 From: Jakub Konka Date: Sat, 13 Jan 2024 19:15:56 +0100 Subject: [PATCH] test/link/macho: test hello world in Zig --- test/link/macho.zig | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/test/link/macho.zig b/test/link/macho.zig index dd7b178f27..e4a0cc6cb8 100644 --- a/test/link/macho.zig +++ b/test/link/macho.zig @@ -10,6 +10,7 @@ pub fn testAll(b: *Build, build_opts: BuildOptions) *Step { macho_step.dependOn(testDeadStrip(b, .{ .target = default_target })); macho_step.dependOn(testEntryPointDylib(b, .{ .target = default_target })); + macho_step.dependOn(testHelloZig(b, .{ .target = default_target })); macho_step.dependOn(testLargeBss(b, .{ .target = default_target })); macho_step.dependOn(testMhExecuteHeader(b, .{ .target = default_target })); macho_step.dependOn(testSectionBoundarySymbols(b, .{ .target = default_target })); @@ -163,6 +164,23 @@ fn testEntryPointDylib(b: *Build, opts: Options) *Step { return test_step; } +fn testHelloZig(b: *Build, opts: Options) *Step { + const test_step = addTestStep(b, "macho-hello-zig", opts); + + const exe = addExecutable(b, opts, .{ .name = "main", .zig_source_bytes = + \\const std = @import("std"); + \\pub fn main() void { + \\ std.io.getStdOut().writer().print("Hello world!\n", .{}) catch unreachable; + \\} + }); + + const run = addRunArtifact(exe); + run.expectStdOutEqual("Hello world!\n"); + test_step.dependOn(&run.step); + + return test_step; +} + fn testLargeBss(b: *Build, opts: Options) *Step { const test_step = addTestStep(b, "macho-large-bss", opts);