tests: improve error message on `v test file.v`

pull/8101/head
Delyan Angelov 2021-01-13 21:52:05 +02:00
parent 0d25091afd
commit 30e96528b0
No known key found for this signature in database
GPG Key ID: 66886C0F12D595ED
1 changed files with 16 additions and 10 deletions

View File

@ -7,15 +7,7 @@ import testing
fn main() {
args := os.args.clone()
if os.args.last() == 'test' {
println('Usage:')
println(' A)')
println(' v test folder/ : run all v tests in the given folder.')
println(' v -stats test folder/ : the same, but print more stats.')
println(' B)')
println(' v test file_test.v : run test functions in a given test file.')
println(' v -stats test file_test.v : as above, but with more stats.')
println(' NB: you can also give many and mixed folder/ file_test.v arguments after test.')
println('')
show_usage()
return
}
args_to_executable := args[1..]
@ -37,7 +29,9 @@ fn main() {
ts.files << os.walk_ext(targ.trim_right(os.path_separator), '_test.v')
continue
}
println('Unrecognized test file $targ .')
eprintln('\nUnrecognized test file `$targ` .\n `v test` can only be used with folders and/or _test.v files.\n')
show_usage()
exit(1)
}
testing.header('Testing...')
ts.test()
@ -46,3 +40,15 @@ fn main() {
exit(1)
}
}
fn show_usage() {
println('Usage:')
println(' A)')
println(' v test folder/ : run all v tests in the given folder.')
println(' v -stats test folder/ : the same, but print more stats.')
println(' B)')
println(' v test file_test.v : run test functions in a given test file.')
println(' v -stats test file_test.v : as above, but with more stats.')
println(' NB: you can also give many and mixed folder/ file_test.v arguments after `v test` .')
println('')
}