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

preludes,builder,cgen: add support for VTEST_RUNNER=tap and -test-runner tap (#12523)

This commit is contained in:
Delyan Angelov
2021-12-16 15:59:46 +02:00
committed by GitHub
parent caac89d6ca
commit 6ff953d936
28 changed files with 665 additions and 178 deletions

View File

@ -40,24 +40,31 @@ fn cleanup_tdir() {
os.rmdir_all(tdir) or { eprintln(err) }
}
fn create_test(tname string, tcontent string) ?string {
tpath := os.join_path(tdir, tname)
os.write_file(tpath, tcontent) ?
eprintln('>>>>>>>> tpath: $tpath | tcontent: $tcontent')
return tpath
}
fn main() {
defer {
os.chdir(os.wd_at_startup) or {}
}
println('> vroot: $vroot | vexe: $vexe | tdir: $tdir')
ok_fpath := os.join_path(tdir, 'single_test.v')
os.write_file(ok_fpath, 'fn test_ok(){ assert true }') ?
check_ok('"$vexe" $ok_fpath')
check_ok('"$vexe" test $ok_fpath')
fail_fpath := os.join_path(tdir, 'failing_test.v')
os.write_file(fail_fpath, 'fn test_fail(){ assert 1 == 2 }') ?
check_fail('"$vexe" $fail_fpath')
check_fail('"$vexe" test $fail_fpath')
check_fail('"$vexe" test $tdir')
ok_fpath := create_test('a_single_ok_test.v', 'fn test_ok(){ assert true }') ?
check_ok('"$vexe" "$ok_fpath"')
check_ok('"$vexe" test "$ok_fpath"')
check_ok('"$vexe" test "$tdir"')
fail_fpath := create_test('a_single_failing_test.v', 'fn test_fail(){ assert 1 == 2 }') ?
check_fail('"$vexe" "$fail_fpath"')
check_fail('"$vexe" test "$fail_fpath"')
check_fail('"$vexe" test "$tdir"')
rel_dir := os.join_path(tdir, rand.ulid())
os.mkdir(rel_dir) ?
os.chdir(rel_dir) ?
check_ok('"$vexe" test ..${os.path_separator + os.base(ok_fpath)}')
check_ok('"$vexe" test "..${os.path_separator + os.base(ok_fpath)}"')
println('> all done')
}
fn check_ok(cmd string) string {