Skip to content
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

custom zig test flags? #396

Closed
nnnewb opened this issue Feb 8, 2025 · 1 comment
Closed

custom zig test flags? #396

nnnewb opened this issue Feb 8, 2025 · 1 comment

Comments

@nnnewb
Copy link

nnnewb commented Feb 8, 2025

I’m working on a hobby project with mixed Zig and C programming.

The "Run Test" button provided by the vscode-zig extension fails to compile when the project requires linking to C libraries.

Run Test

Command failed: C:\Users\PC\scoop\shims\zig.EXE test --test-filter keyword d:\projects\starlight\src\parser\tokenizer.zig
D:\projects\starlight\src\parser\tokenizer.zig:1:11: error: C import failed
D:\projects\starlight\src\parser\tokenizer.zig:1:11: note: libc headers not available; compilation does not link against libc
C:\Users\PC\AppData\Local\zig\o\e3f7f0f004f28d89132de840b129a16d\cimport.h:1:10: error: 'parser/token.h' file not found

Debug Test

Command failed: C:\Users\PC\scoop\shims\zig.EXE test d:\projects\starlight\src\parser\tokenizer.zig --test-filter keyword --test-no-exec -femit-bin=d:\projects\starlight\zig-out\tmp-debug-build\bin\test-tokenizer
D:\projects\starlight\src\parser\tokenizer.zig:1:11: error: C import failed
D:\projects\starlight\src\parser\tokenizer.zig:1:11: note: libc headers not available; compilation does not link against libc
C:\Users\PC\AppData\Local\zig\o\d88f36432145d60ca7a16061bebdc714\cimport.h:1:10: error: 'parser/token.h' file not found

However, running the command zig test -lc -Isrc src/parser/tokenizer.zig src/parser/lexer.c in the command line compiles and runs the tests without any issues.

PS D:\projects\starlight> zig test -lc -Isrc src/parser/tokenizer.zig src/parser/lexer.c
All 4 tests passed.

I noticed the vscode-zig extension doesn't support custom flags for zig test. Could you please consider adding this feature? It would be very helpful.

@Vexu
Copy link
Member

Vexu commented Feb 8, 2025

This should be implemented by running the tests with the build system which is tracked in #390.

@Vexu Vexu closed this as not planned Won't fix, can't repro, duplicate, stale Feb 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants