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

Fix crash when passing missing file to zig test #21061

Closed
wants to merge 2 commits into from

Conversation

quantumhu
Copy link

@quantumhu quantumhu commented Aug 13, 2024

Resolves #20954

Error message looks like this:

$ zig test tt.zig                                   
error: unable to load file './tt.zig': FileNotFound

$ zig test ./tt.zig
error: unable to load file './tt.zig': FileNotFound

$ zig test /test-folder/tt.zig 
error: unable to access directory '/test-folder': FileNotFound

$ zig test ./test-folder/tt.zig
error: unable to access directory 'test-folder': FileNotFound

@squeek502
Copy link
Collaborator

squeek502 commented Aug 13, 2024

This is a possible fix, but it feels like the wrong fix. Using access to check for the existence of a file is something Zig tries to avoid.

The underlying problem as far as I can tell is that addModuleErrorMsg was made to depend on the AST of the file, but obviously there's no AST for a file that doesn't exist. The dependency on the AST was introduced in ded5c75 (cc @mlugg).

@mlugg
Copy link
Member

mlugg commented Aug 13, 2024

Ah, yes, we will need to bypass the AST code path for whole file errors. Sorry!

@mlugg mlugg closed this Aug 13, 2024
@quantumhu quantumhu deleted the issue-20954 branch August 17, 2024 00:52
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

Successfully merging this pull request may close these issues.

zig test on a missing file crashes the compiler
3 participants