Open JalonSolov opened 7 months ago
v -Wimpure-v test x_test.v
... will run the test x_test.v
, ignore the warnings, then report whether the test passed (which it does).
v -Wimpure-v -W test x_test.v
... will turn the warnings into errors, then report the compilation failure.
v -Wimpure-v x_test.v
will show you the warnings.
For example:
./v -Wimpure-v -W test vlib/compress/zstd/
reveals that vlib/compress/zstd/zstd.v
should be renamed to vlib/compress/zstd/zstd.c.v
.
I think -Wimpure-v
should work without -W test
... which I never knew existed.
In any case, if -Wimpure-v
is turned on by default, it will definitely affect all modes.
It does work without -W
. It just produces warnings, and warnings do not cause compilation to fail.
-W
just turns warnings into errors, and errors make the compilation fail.
-prod
would have worked too.
v test .
just passes all the options before test
as compile flags to the underlying v file_test.v
etc commands.
Try for example: v -Wimpure-v x_test.v
, i.e. running the test directly by v
, not by v test
, and you will see the warnings.
Yes, I understand, but I'm saying it should "just work" without having to know a special sequence of things to type. v -Wimpure-v <followed by anything else>
should always activate that message.
But it does already. v test
just does not display notices, warnings, and the output of running individual _test.v
files to you, unless it failed to compile it, or when it ran, but exited with status code != 0.
Currently -Wimpure-v
, generates warnings. Warnings do not stop compilation -> v test
will compile, and then it will run the test, which will succeed, and v test
will just discard the output (including the warnings).
If what you are arguing for, is towards making v test
display warnings and notices by default, then that is reasonable, even though I think that it can be confusing, since in most cases, they do not matter much for tests.
I think this is a special case, and should be displayed in all cases. Otherwise, it can cause confusion as to why tests won't work with other backends, unless you open the source and scan for C.
.
FYI coreutils CI failed due to this issue. For example: https://github.com/vlang/coreutils/actions/runs/10865356775/job/30151722872
Describe the bug
Adding
-Wimpure-v
will give a warning if C code is used in plain .v files:However, this is only when compiling. When C code is used in a test file, there is no warning given.
Reproduction Steps
x.v
x_test.v
Expected Behavior
Warnings for both
.v
and_test.v
when-Wimpure-v
is specified.Current Behavior
Possible Solution
Test files with backend specific code can't be used when testing other backends, so they should be put in backend specific files.
Additional Information/Context
No response
V version
V 0.4.4 804a7bd
Environment details (OS name and version, etc.)