From bf0af2c036d105e39aea944363642d659d5bf093 Mon Sep 17 00:00:00 2001 From: Pierre Tachoire Date: Wed, 11 Oct 2023 10:43:28 +0200 Subject: [PATCH] wpt: accept test name argument --- Makefile | 2 +- src/main_wpt.zig | 22 ++++++++++++++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 2bdb239d..49162725 100644 --- a/Makefile +++ b/Makefile @@ -49,7 +49,7 @@ shell: ## Run WPT tests wpt: @printf "\e[36mBuilding wpt...\e[0m\n" - @$(ZIG) build wpt -Dengine=v8 || (printf "\e[33mBuild ERROR\e[0m\n"; exit 1;) + @$(ZIG) build wpt -Dengine=v8 -- $(filter-out $@,$(MAKECMDGOALS)) || (printf "\e[33mBuild ERROR\e[0m\n"; exit 1;) ## Test test: diff --git a/src/main_wpt.zig b/src/main_wpt.zig index dacc5568..210cf3fd 100644 --- a/src/main_wpt.zig +++ b/src/main_wpt.zig @@ -70,6 +70,11 @@ pub fn main() !void { defer _ = gpa.deinit(); const alloc = gpa.allocator(); + const args = try std.process.argsAlloc(alloc); + defer std.process.argsFree(alloc, args); + + const filter = args[1..]; + // initialize VM JS lib. const vm = jsruntime.VM.init(); defer vm.deinit(); @@ -91,6 +96,23 @@ pub fn main() !void { var run: usize = 0; var failures: usize = 0; for (list.items) |tc| { + if (filter.len > 0) { + var match = false; + for (filter) |f| { + if (std.mem.startsWith(u8, tc, f)) { + match = true; + break; + } + if (std.mem.endsWith(u8, tc, f)) { + match = true; + break; + } + } + if (!match) { + continue; + } + } + run += 1; // create an arena and deinit it for each test case.