-
Notifications
You must be signed in to change notification settings - Fork 65
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: run test through filtered 'zig build test' instead of 'zig test' if build.zig is present. #399
base: master
Are you sure you want to change the base?
Conversation
…' if build.zig is present.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As I said in the linked issue this should use test-unit
instead of just test
since that may be running much more extensive testing than what we want (see for example the main Zig repo). It should also use a -Dtest-filter
argument to actually filter to a specific test.
I think the best choice is to not hardcode any particular invocation and instead add an entry in the settings that allows users to specify how they want their tests to be invoked. Ideally this should be a per-project setting, although I'm not sure if and how that's achievable with vscode, but at the very least making it parametric lets users adapt to whatever convention they happen to be using at a given time. So, in practice, my suggestion would be:
With this system in place people will be able to adapt to whatever convention they prefer:
and so forth. @Vexu let us know if you have any objection to this approach, pinging also @Techatrix |
Sure, that works too. The
All options can be configured per workspace. |
So I pushed the change @kristoff-it suggested, which hopefully is a step in the right direction. I am not 100% sure about leaving the I'd like to clarify with an example (note that I am not super familiar with zig so forgive me if I am saying something silly): Let's say that I have three categories of tests:
For the sake of the example, let's say test-unit are found in the aaa.zig file, test-integration are in the bbb.zig file, and test-expensive are in the ccc.zig file. I then set my Thanks! |
By having the const special_step = b.step("test-special", "Checks test-path to select proper step");
const test_path = b.option([]const u8, "test-path", "path to file with the test") orelse "aaa.zig";
if (std.mem.eql(u8, test_path, "aaa.zig")) {
special_step.dependOn(test_unit);
} else if (std.mem.eql(u8, test_path, "bbb.zig")) {
special_step.dependOn(test_integration);
} else if (std.mem.eql(u8, test_path, "ccc.zig")) {
special_step.dependOn(test_expensive);
} else {
std.debug.print("invalid test path {s}\n", .{test_path});
std.process.exit(1);
} |
Hi! This PR introduces the ability to run a single test through the Code Lens button leveraging the build.zig file, if present. If not, it will fallback to the previous mechanism.
The reason for this is leveraging the full configuration encoded in the build script, as opposed run on a specific file, which could not work under certain conditions such as importing a file from outside the current module (eg: https://github.com/omissis/zig-langchain/blob/main/src/openai/OpenAI.zig#L2).
By running through
zig build test --summary all -- TESTNAME
, such test can be run in isolation during development, allowing for a tight feedback loop.This is probably tackling what asked for in #390