mirror of
https://github.com/lightpanda-io/browser.git
synced 2025-10-28 14:43:28 +00:00
Add a new unittest build step
Preserves all existing behavior (i.e. make test and zig build test are not changed in any way). The new 'unittest' only runs unit tests and is fast to build. It takes ~1.7 to build unittest, vs ~11.09 to build test. This is really the main goal, and hopefully any unit test which are (a) fast and (b) don't impact build times will be run here. The test runner is based on: https://gist.github.com/karlseguin/c6bea5b35e4e8d26af6f81c22cb5d76b It allow filtering, i.e. `make unittest F="parse query dup"`. 'unittest' does memory leak detection when tests use std.testing.allocator. Fixed a memory leak in url/query which was detected/reported with by the new 'unittest'. In order to avoid having 3 src/test_xyx.zig files, I merged the existing test_runner.zig and run_tests.zig into a single main_tests.zig. (this change is superfluous, but I thought it was cleaner this way. Happy to revert this).
This commit is contained in:
25
build.zig
25
build.zig
@@ -98,8 +98,8 @@ pub fn build(b: *std.Build) !void {
|
||||
|
||||
// compile
|
||||
const tests = b.addTest(.{
|
||||
.root_source_file = b.path("src/run_tests.zig"),
|
||||
.test_runner = b.path("src/test_runner.zig"),
|
||||
.root_source_file = b.path("src/main_tests.zig"),
|
||||
.test_runner = b.path("src/main_tests.zig"),
|
||||
.target = target,
|
||||
.optimize = mode,
|
||||
});
|
||||
@@ -119,6 +119,27 @@ pub fn build(b: *std.Build) !void {
|
||||
const test_step = b.step("test", "Run unit tests");
|
||||
test_step.dependOn(&run_tests.step);
|
||||
|
||||
// unittest
|
||||
// ----
|
||||
|
||||
// compile
|
||||
const unit_tests = b.addTest(.{
|
||||
.root_source_file = b.path("src/unit_tests.zig"),
|
||||
.test_runner = b.path("src/unit_tests.zig"),
|
||||
.target = target,
|
||||
.optimize = mode,
|
||||
});
|
||||
try common(b, unit_tests, options);
|
||||
|
||||
const run_unit_tests = b.addRunArtifact(unit_tests);
|
||||
if (b.args) |args| {
|
||||
run_unit_tests.addArgs(args);
|
||||
}
|
||||
|
||||
// step
|
||||
const unit_test_step = b.step("unittest", "Run unit tests");
|
||||
unit_test_step.dependOn(&run_unit_tests.step);
|
||||
|
||||
// wpt
|
||||
// -----
|
||||
|
||||
|
||||
Reference in New Issue
Block a user