1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

test: run all tests even if some fail

This commit is contained in:
Adam Stankiewicz 2020-06-13 16:20:45 +02:00 committed by GitHub
parent 183924e2a8
commit f2a75d5223
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 7 additions and 4 deletions

View File

@ -20,9 +20,10 @@ fn cb_assertion_failed(i &VAssertMetaInfo) {
} }
final_filename := if use_relative_paths { i.fpath } else { os.real_path(i.fpath) } final_filename := if use_relative_paths { i.fpath } else { os.real_path(i.fpath) }
final_funcname := i.fn_name.replace('main__', '').replace('__', '.') final_funcname := i.fn_name.replace('main__', '').replace('__', '.')
eprintln('')
eprintln('$final_filename:${i.line_nr+1}: failed assert in ${final_funcname}') eprintln('$final_filename:${i.line_nr+1}: failed assert in ${final_funcname}')
eprintln('Source : ${i.src}') eprintln('Source : ${i.src}')
if i.op != 'call' { if i.op.len > 0 && i.op != 'call' {
eprintln(' left value: ${i.llabel} = ${i.lvalue}') eprintln(' left value: ${i.llabel} = ${i.lvalue}')
eprintln(' right value: ${i.rlabel} = ${i.rvalue}') eprintln(' right value: ${i.rlabel} = ${i.rvalue}')
} }

View File

@ -237,7 +237,7 @@ pub:
} }
fn __print_assert_failure(i &VAssertMetaInfo) { fn __print_assert_failure(i &VAssertMetaInfo) {
eprintln('${i.fpath}:${i.line_nr+1}: FAIL: fn ${i.fn_name}: assert ${i.src}') eprintln('${i.fpath}:${i.line_nr+1}: FAIL: fn ${i.fn_name}: assert ${i.src}')
if i.op != 'call' { if i.op.len > 0 && i.op != 'call' {
eprintln(' left value: ${i.llabel} = ${i.lvalue}') eprintln(' left value: ${i.llabel} = ${i.lvalue}')
eprintln(' right value: ${i.rlabel} = ${i.rvalue}') eprintln(' right value: ${i.rlabel} = ${i.rvalue}')
} }

View File

@ -942,7 +942,7 @@ fn (mut g Gen) gen_assert_stmt(a ast.AssertStmt) {
g.writeln(' g_test_fails++;') g.writeln(' g_test_fails++;')
metaname_fail := g.gen_assert_metainfo(a) metaname_fail := g.gen_assert_metainfo(a)
g.writeln(' cb_assertion_failed(&${metaname_fail});') g.writeln(' cb_assertion_failed(&${metaname_fail});')
g.writeln(' exit(1);') g.writeln(' longjmp(g_jump_buffer, 1);')
g.writeln(' // TODO') g.writeln(' // TODO')
g.writeln(' // Maybe print all vars in a test function if it fails?') g.writeln(' // Maybe print all vars in a test function if it fails?')
g.writeln('}') g.writeln('}')
@ -3605,8 +3605,10 @@ fn (g Gen) type_default(typ table.Type) string {
} }
pub fn (mut g Gen) write_tests_main() { pub fn (mut g Gen) write_tests_main() {
g.includes.writeln('#include <setjmp.h> // write_tests_main')
g.definitions.writeln('int g_test_oks = 0;') g.definitions.writeln('int g_test_oks = 0;')
g.definitions.writeln('int g_test_fails = 0;') g.definitions.writeln('int g_test_fails = 0;')
g.definitions.writeln('jmp_buf g_jump_buffer;')
$if windows { $if windows {
g.writeln('int wmain() {') g.writeln('int wmain() {')
} $else { } $else {
@ -3623,7 +3625,7 @@ pub fn (mut g Gen) write_tests_main() {
if g.pref.is_stats { if g.pref.is_stats {
g.writeln('\tBenchedTests_testing_step_start(&bt, tos_lit("$t"));') g.writeln('\tBenchedTests_testing_step_start(&bt, tos_lit("$t"));')
} }
g.writeln('\t${t}();') g.writeln('\tif (!setjmp(g_jump_buffer)) ${t}();')
if g.pref.is_stats { if g.pref.is_stats {
g.writeln('\tBenchedTests_testing_step_end(&bt);') g.writeln('\tBenchedTests_testing_step_end(&bt);')
} }