diff --git a/cmd/tools/vtest-self.v b/cmd/tools/vtest-self.v index e8e8198498..4766bdf4d1 100644 --- a/cmd/tools/vtest-self.v +++ b/cmd/tools/vtest-self.v @@ -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 diff --git a/vlib/v/tests/failing_tests_test.v b/vlib/v/tests/failing_tests_test.v new file mode 100644 index 0000000000..de764e1f2c --- /dev/null +++ b/vlib/v/tests/failing_tests_test.v @@ -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') +} diff --git a/vlib/v/tests/testdata/tests_returning_options_failing_test.v b/vlib/v/tests/testdata/tests_returning_options_failing_test.v new file mode 100644 index 0000000000..a180006cb7 --- /dev/null +++ b/vlib/v/tests/testdata/tests_returning_options_failing_test.v @@ -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() ? +}