tests: ignore `testdata` folders while scanning for tests and .v files
parent
1747e546bf
commit
bf623e191f
|
@ -358,12 +358,19 @@ pub fn prepare_test_session(zargs string, folder string, oskipped []string, main
|
|||
mut mains := []string{}
|
||||
mut skipped := oskipped.clone()
|
||||
next_file: for f in files {
|
||||
if f.contains('modules') || f.contains('preludes') {
|
||||
fnormalised := f.replace('\\', '/')
|
||||
// NB: a `testdata` folder, is the preferred name of a folder, containing V code,
|
||||
// that you *do not want* the test framework to find incidentally for various reasons,
|
||||
// for example module import tests, or subtests, that are compiled/run by other parent tests
|
||||
// in specific configurations, etc.
|
||||
if fnormalised.contains('testdata/') || fnormalised.contains('modules/')
|
||||
|| f.contains('preludes/') {
|
||||
continue
|
||||
}
|
||||
$if windows {
|
||||
// skip pico and process/command examples on windows
|
||||
if f.ends_with('examples\\pico\\pico.v') || f.ends_with('examples\\process\\command.v') {
|
||||
if fnormalised.ends_with('examples/pico/pico.v')
|
||||
|| fnormalised.ends_with('examples/process/command.v') {
|
||||
continue
|
||||
}
|
||||
}
|
||||
|
|
19
doc/docs.md
19
doc/docs.md
|
@ -3219,6 +3219,25 @@ To test an entire module, use `v test mymodule`. You can also use `v test .` to
|
|||
everything inside your current folder (and subfolders). You can pass the `-stats`
|
||||
option to see more details about the individual tests run.
|
||||
|
||||
You can put additional test data, including .v source files in a folder, named
|
||||
`testdata`, right next to your _test.v files. V's test framework will *ignore*
|
||||
such folders, while scanning for tests to run. This is usefull, if you want to
|
||||
put .v files with invalid V source code, or other tests, including known
|
||||
failing ones, that should be run in a specific way/options by a parent _test.v
|
||||
file.
|
||||
|
||||
NB: the path to the V compiler, is available through @VEXE, so a _test.v
|
||||
file, can easily run *other* test files like this:
|
||||
```v oksyntax
|
||||
import os
|
||||
|
||||
fn test_subtest() {
|
||||
res := os.execute('${@VEXE} other_test.v')
|
||||
assert res.exit_code == 1
|
||||
assert res.output.contains('other_test.v does not exist')
|
||||
}
|
||||
```
|
||||
|
||||
## Memory management
|
||||
|
||||
V avoids doing unnecessary allocations in the first place by using value types,
|
||||
|
|
Loading…
Reference in New Issue