Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,8 @@ We follow [Semantic Versioning](https://semver.org/):

### Release Steps

1. Update version in `build.zig.zon`
1. Update version in `build.zig.zon`. This is the authoritative package
version; the build injects it into `zig-test --version` automatically.
2. Update CHANGELOG.md
3. Create git tag: `git tag -a v1.2.3 -m "Release 1.2.3"`
4. Push tag: `git push origin v1.2.3`
Expand Down
4 changes: 2 additions & 2 deletions FEATURES_SUMMARY.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Zig Test Framework - Features Summary

**Framework Version:** 2.3.0
**Framework Version:** See `build.zig.zon` (the authoritative version source)
**Last Updated:** 2025-10-26
**Status:** Production Ready

Expand Down Expand Up @@ -537,5 +537,5 @@ The framework is ready for production use and provides a comprehensive testing s
---

**Last Updated:** 2025-10-26
**Framework Version:** 2.3.0
**Framework Version:** See `build.zig.zon` (the authoritative version source)
**Status:** Production Ready ✅
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,11 @@ Add to your `build.zig.zon`:
```zig
.{
.name = "my-project",
.version = "0.1.0",
.version = "0.1.0", // Your project's version
.dependencies = .{
.@"zig-test-framework" = .{
.url = "https://github.com/zig-utils/zig-test-framework/archive/refs/tags/v0.1.0.tar.gz",
// Replace with actual hash after publishing
.url = "https://github.com/zig-utils/zig-test-framework/archive/refs/tags/vX.Y.Z.tar.gz",
// Replace X.Y.Z and the hash with the release you use
},
},
}
Expand Down
23 changes: 23 additions & 0 deletions build.zig
Original file line number Diff line number Diff line change
@@ -1,19 +1,37 @@
const std = @import("std");
const manifest_source = @embedFile("build.zig.zon");
const package_version = manifestVersion(manifest_source);

fn manifestVersion(source: []const u8) []const u8 {
const marker = ".version = \"";
const marker_start = std.mem.indexOf(u8, source, marker) orelse
@compileError("build.zig.zon must declare .version");
const start = marker_start + marker.len;
const end_offset = std.mem.indexOfScalar(u8, source[start..], '"') orelse
@compileError("build.zig.zon contains an unterminated .version");
return source[start .. start + end_offset];
}

pub fn build(b: *std.Build) void {
const target = b.standardTargetOptions(.{});
const optimize = b.standardOptimizeOption(.{});

const build_options = b.addOptions();
build_options.addOption([]const u8, "version", package_version);

// Create the main library module
const lib_module = b.addModule("zig_test_framework", .{
.root_source_file = b.path("src/lib.zig"),
.target = target,
.link_libc = true,
});
lib_module.addOptions("build_options", build_options);

// Create the test runner executable
const exe = b.addExecutable(.{
.name = "zig-test",
.version = std.SemanticVersion.parse(package_version) catch
@panic("build.zig.zon contains an invalid semantic version"),
.root_module = b.createModule(.{
.root_source_file = b.path("src/main.zig"),
.target = target,
Expand Down Expand Up @@ -258,6 +276,11 @@ pub fn build(b: *std.Build) void {
run_invalid_config.expectExitCode(2);
test_step.dependOn(&run_invalid_config.step);

const run_version = b.addRunArtifact(exe);
run_version.addArg("--version");
run_version.expectStdErrEqual(b.fmt("Zig Test Framework v{s}\n", .{package_version}));
test_step.dependOn(&run_version.step);

// Examples
const basic_example = b.addExecutable(.{
.name = "basic_example",
Expand Down
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
{
"name": "zig-test-framework",
"version": "0.2.0",
"scripts": {
"release": "pantry release patch --yes",
"release:minor": "pantry release minor --yes",
Expand Down
10 changes: 8 additions & 2 deletions src/cli.zig
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
const std = @import("std");
const build_options = @import("build_options");
const config_mod = @import("config.zig");
const test_runner = @import("test_runner.zig");

Expand Down Expand Up @@ -44,6 +45,8 @@ pub const CLIOptions = struct {
timeout: ?u64 = null, // Global timeout in milliseconds
};

pub const version = build_options.version;

pub const CLIError = error{
InvalidArgument,
MissingValue,
Expand Down Expand Up @@ -383,8 +386,7 @@ pub const CLI = struct {
/// Print version information
pub fn printVersion(self: Self) void {
_ = self;
std.debug.print("Zig Test Framework v2.5.0\n", .{});
std.debug.print("Features: Parallel, Coverage, UI, Snapshots, Watch, Memory Profiling, TAP/JUnit, Progress Indicators, Timeout\n", .{});
std.debug.print("Zig Test Framework v{s}\n", .{version});
}

/// Convert CLI options to RunnerOptions
Expand Down Expand Up @@ -423,6 +425,10 @@ test "CLI parse version" {
try std.testing.expect(cli.options.version);
}

test "CLI build version is valid semantic version metadata" {
_ = try std.SemanticVersion.parse(version);
}

test "CLI parse bail" {
var cli = CLI.init(std.testing.allocator);
const args = [_][]const u8{ "zig-test", "--bail" };
Expand Down
4 changes: 2 additions & 2 deletions src/main.zig
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const std = @import("std");
const lib = @import("lib.zig");
const compat = @import("compat.zig");
const lib = @import("zig_test_framework");
const compat = lib.compat;

// Global signal handler state
var shutdown_requested = std.atomic.Value(bool).init(false);
Expand Down
Loading