mirror of
https://github.com/ziglang/zig.git
synced 2025-12-15 18:53:07 +00:00
add standalone test for depending on the main module
This commit is contained in:
parent
d5c1e7f7b1
commit
2b63ba31e9
@ -258,6 +258,10 @@ pub const build_cases = [_]BuildCase{
|
|||||||
.build_root = "test/standalone/ios",
|
.build_root = "test/standalone/ios",
|
||||||
.import = @import("standalone/ios/build.zig"),
|
.import = @import("standalone/ios/build.zig"),
|
||||||
},
|
},
|
||||||
|
.{
|
||||||
|
.build_root = "test/standalone/depend_on_main_mod",
|
||||||
|
.import = @import("standalone/depend_on_main_mod/build.zig"),
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
const std = @import("std");
|
const std = @import("std");
|
||||||
|
|||||||
28
test/standalone/depend_on_main_mod/build.zig
Normal file
28
test/standalone/depend_on_main_mod/build.zig
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
const std = @import("std");
|
||||||
|
|
||||||
|
pub fn build(b: *std.Build) void {
|
||||||
|
const test_step = b.step("test", "Test it");
|
||||||
|
b.default_step = test_step;
|
||||||
|
|
||||||
|
const target = b.standardTargetOptions(.{});
|
||||||
|
const optimize = b.standardOptimizeOption(.{});
|
||||||
|
|
||||||
|
const exe = b.addExecutable(.{
|
||||||
|
.name = "depend_on_main_mod",
|
||||||
|
.root_source_file = .{ .path = "src/main.zig" },
|
||||||
|
.target = target,
|
||||||
|
.optimize = optimize,
|
||||||
|
});
|
||||||
|
|
||||||
|
const foo_module = b.addModule("foo", .{
|
||||||
|
.root_source_file = .{ .path = "src/foo.zig" },
|
||||||
|
});
|
||||||
|
|
||||||
|
foo_module.addImport("root2", &exe.root_module);
|
||||||
|
exe.root_module.addImport("foo", foo_module);
|
||||||
|
|
||||||
|
const run_cmd = b.addRunArtifact(exe);
|
||||||
|
run_cmd.expectExitCode(0);
|
||||||
|
|
||||||
|
test_step.dependOn(&run_cmd.step);
|
||||||
|
}
|
||||||
6
test/standalone/depend_on_main_mod/src/foo.zig
Normal file
6
test/standalone/depend_on_main_mod/src/foo.zig
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
const std = @import("std");
|
||||||
|
const assert = std.debug.assert;
|
||||||
|
|
||||||
|
pub fn run() void {
|
||||||
|
comptime assert(@import("root") == @import("root2"));
|
||||||
|
}
|
||||||
5
test/standalone/depend_on_main_mod/src/main.zig
Normal file
5
test/standalone/depend_on_main_mod/src/main.zig
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
const std = @import("std");
|
||||||
|
|
||||||
|
pub fn main() !void {
|
||||||
|
@import("foo").run();
|
||||||
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user