add test step
Some checks failed
AWS-Zig Build / build-zig-0.11.0-amd64-host (push) Failing after 2m49s

This commit is contained in:
Emil Lerch 2023-08-14 22:45:46 -07:00
parent b603822679
commit cbb6116a61
Signed by: lobo
GPG Key ID: A7B62D657EF764F8
2 changed files with 17 additions and 1 deletions

View File

@ -23,7 +23,6 @@ jobs:
- run: tar x -C /usr/local -f zig-linux-${ARCH}-${ZIG_VERSION}.tar.xz - run: tar x -C /usr/local -f zig-linux-${ARCH}-${ZIG_VERSION}.tar.xz
- run: ln -s /usr/local/zig-linux-${ARCH}-${ZIG_VERSION}/zig /usr/local/bin/zig - run: ln -s /usr/local/zig-linux-${ARCH}-${ZIG_VERSION}/zig /usr/local/bin/zig
- run: apt update && apt install --no-install-recommends git - run: apt update && apt install --no-install-recommends git
- run: (cd codegen && zig build test)
- run: zig build test - run: zig build test
- run: zig build -Dtarget=arm-linux - run: zig build -Dtarget=arm-linux
- run: zig build -Dtarget=x86_64-windows - run: zig build -Dtarget=x86_64-windows

View File

@ -58,6 +58,22 @@ pub fn build(b: *Builder) !void {
const run_step = b.step("run", "Run the app"); const run_step = b.step("run", "Run the app");
run_step.dependOn(&run_cmd.step); run_step.dependOn(&run_cmd.step);
// Creates a step for unit testing. This only builds the test executable
// but does not run it.
const unit_tests = b.addTest(.{
.root_source_file = .{ .path = "src/main.zig" },
.target = target,
.optimize = optimize,
});
const run_unit_tests = b.addRunArtifact(unit_tests);
// Similar to creating the run step earlier, this exposes a `test` step to
// the `zig build --help` menu, providing a way for the user to request
// running the unit tests.
const test_step = b.step("test", "Run unit tests");
test_step.dependOn(&run_unit_tests.step);
{ {
const cg = b.step("gen", "Generate zig service code from smithy models"); const cg = b.step("gen", "Generate zig service code from smithy models");
@ -101,6 +117,7 @@ pub fn build(b: *Builder) !void {
cg.dependOn(&cg_cmd.step); cg.dependOn(&cg_cmd.step);
exe.step.dependOn(cg); exe.step.dependOn(cg);
unit_tests.step.dependOn(cg);
} }
b.installArtifact(exe); b.installArtifact(exe);