Repository navigation
tests: build the harness on os.exec so make test compiles on current V - #218
Merged
Merged
Conversation
Merged
Contributor
|
Conflicts. |
`make test` is `v -Wimpure-v -W test .`, and on current V it could not compile 31 of the 49 test files: common/testing/testrig.v:211: error: function `execute` has been deprecated; use os.exec with an argument array; command strings can allow shell injection -W turns a deprecation into an error, so every test file that went through the harness, and every file that called os.execute itself, was failing to build rather than running. That is what the three Linux workflows do, and what this unblocks. os.exec takes an argument array, so a command line has to be split somewhere. Every command in this repository is written as a string by the tests, so this adds the one place that does it: split_args.v whitespace between words, single and double quotes, and nothing else Not a shell, on purpose. A backslash is an ordinary character everywhere in it, because on this platform a backslash is nearly always part of a path and a shell's rule of eating it would take the volume off `C:\Users\me\file.txt`. The shapes it does have to handle are the ones the tests actually write, and each is pinned by a test taken from a real call site: --output-delimiter="|" comm_test.v sh -c "exit 42" timeout_test.v tr -d '\r' sum_test.v C:\Users\me\coreutils\test.txt the reason it is not a shell An unterminated quote is not an error: the rest of the line becomes one word, so a test that made the mistake fails on what the program said rather than on a parse in this file. 124 call sites, 22 files. `v -Wimpure-v -W test .` on Windows: before 31 files could not be built at all after 2 and the suite goes from 25 files failing to 17, with those 17 being real test failures rather than build failures. The two that still do not build are fixed elsewhere: tail's string_to_i64_test.v is vlang#207 and sum's is vlang#215. Nothing that a test asserts. The commands are the same strings, the arguments are the same arguments, and no test was reworded; the difference is only that the split is done in V rather than by a shell. Twenty files under src/ and the three under common/testing/ and no other.
metif12
force-pushed
the
fix/test-harness-exec
branch
from
October 5, 2026 18:09
43ed842 to
2eb299a
Compare
Contributor
|
There's a warning in the CI that appears to be related to this... |
Contributor
Author
|
Found and fixed, in #228.
mut cmd := [@VEXE, '-Wimpure-v']
cmd << vargs
cmd << ['-o', '${curdir}/bin/${dir}', './${dir}']
os.exec_or_panic(cmd)Verified: the whole script builds clean under Two more
So |
Contributor
|
Still has conflicts to fix. |
# Conflicts: # src/cksum/cksum_test.v # src/sum/sum_test.v # src/wc/wc_test.v
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
tests: build the harness on os.exec so
make testcompiles on current Vmake testisv -Wimpure-v -W test ., and on current V it could not compile 31 ofthe 49 test files:
-W turns a deprecation into an error, so every test file that went through the
harness, and every file that called os.execute itself, was failing to build rather
than running. That is what the three Linux workflows do, and what this unblocks.
What changed
os.exec takes an argument array, so a command line has to be split somewhere. Every
command in this repository is written as a string by the tests, so this adds the one
place that does it:
Not a shell, on purpose. A backslash is an ordinary character everywhere in it,
because on this platform a backslash is nearly always part of a path and a shell's
rule of eating it would take the volume off
C:\Users\me\file.txt. The shapes itdoes have to handle are the ones the tests actually write, and each is pinned by a
test taken from a real call site:
An unterminated quote is not an error: the rest of the line becomes one word, so a
test that made the mistake fails on what the program said rather than on a parse in
this file.
Numbers
124 call sites, 22 files.
v -Wimpure-v -W test .on Windows:and the suite goes from 25 files failing to 17, with those 17 being real test
failures rather than build failures. The two that still do not build are fixed
elsewhere: tail's string_to_i64_test.v is #207 and sum's is #215.
What did not change
Nothing that a test asserts. The commands are the same strings, the arguments are the
same arguments, and no test was reworded; the difference is only that the split is
done in V rather than by a shell. Twenty files under src/ and the three under
common/testing/ and no other.