tests: add vlib/v/tests/failing_tests_test.v, support `testdata` in `v test-self` too
							parent
							
								
									0254a1ac76
								
							
						
					
					
						commit
						b28def7c11
					
				| 
						 | 
					@ -123,7 +123,7 @@ fn main() {
 | 
				
			||||||
	all_test_files := os.walk_ext(os.join_path(vroot, 'vlib'), '_test.v')
 | 
						all_test_files := os.walk_ext(os.join_path(vroot, 'vlib'), '_test.v')
 | 
				
			||||||
	testing.eheader(title)
 | 
						testing.eheader(title)
 | 
				
			||||||
	mut tsession := testing.new_test_session(cmd_prefix, true)
 | 
						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
 | 
						tsession.skip_files << skip_test_files
 | 
				
			||||||
	mut werror := false
 | 
						mut werror := false
 | 
				
			||||||
	mut sanitize_memory := false
 | 
						mut sanitize_memory := false
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -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')
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -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() ?
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
		Loading…
	
		Reference in New Issue