tests: add vlib/v/tests/failing_tests_test.v, support `testdata` in `v test-self` too

pull/10336/head
Delyan Angelov 2021-06-02 22:13:53 +03:00
parent 0254a1ac76
commit b28def7c11
No known key found for this signature in database
GPG Key ID: 66886C0F12D595ED
3 changed files with 42 additions and 1 deletions

View File

@ -123,7 +123,7 @@ fn main() {
all_test_files := os.walk_ext(os.join_path(vroot, 'vlib'), '_test.v')
testing.eheader(title)
mut tsession := testing.new_test_session(cmd_prefix, true)
tsession.files << all_test_files
tsession.files << all_test_files.filter(!it.contains('testdata' + os.path_separator))
tsession.skip_files << skip_test_files
mut werror := false
mut sanitize_memory := false

View File

@ -0,0 +1,21 @@
import os
fn vroot_path(relpath string) string {
return os.real_path(os.join_path(@VMODROOT, relpath))
}
fn vexecute(relpath string) os.Result {
return os.execute('${@VEXE} ' + vroot_path(relpath))
}
fn testsuite_begin() {
os.setenv('VCOLORS', 'never', true)
}
fn test_returning_options() {
res := vexecute('vlib/v/tests/testdata/tests_returning_options_failing_test.v')
assert res.exit_code == 1
dump(res)
assert res.output.contains('tests_returning_options_failing_test.v:13: fn test_example failed propagation with error: failing test with return, err: oh no')
assert res.output.contains('tests_returning_options_failing_test.v:19: fn test_example_2 failed propagation with error: oh no')
}

View File

@ -0,0 +1,20 @@
fn example() ? {
return error('oh no')
}
fn test_simple() {
assert true
assert true
}
fn test_example() ? {
assert true
assert true
example() or { return error('failing test with return, err: $err') }
}
fn test_example_2() ? {
assert true
assert true
example() ?
}