test: allow testing files from a relative directory (#11391)

pull/11407/head
Dialga 2021-09-06 12:11:58 +12:00 committed by GitHub
parent 438bdd1b0b
commit 2cfc6e007d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 5 deletions

View File

@ -212,8 +212,7 @@ pub fn (mut ts TestSession) test() {
ts.init()
mut remaining_files := []string{}
for dot_relative_file in ts.files {
relative_file := dot_relative_file.replace('./', '')
file := os.real_path(relative_file)
file := os.real_path(dot_relative_file)
$if windows {
if file.contains('sqlite') || file.contains('httpbin') {
continue
@ -267,8 +266,7 @@ fn worker_trunner(mut p pool.PoolProcessor, idx int, thread_id int) voidptr {
p.set_thread_context(idx, tls_bench)
}
tls_bench.no_cstep = true
dot_relative_file := p.get_item<string>(idx)
mut relative_file := dot_relative_file.replace('./', '')
mut relative_file := os.real_path(p.get_item<string>(idx))
mut cmd_options := [ts.vargs]
if relative_file.contains('global') && !ts.vargs.contains('fmt') {
cmd_options << ' -enable-globals'

View File

@ -37,10 +37,13 @@ fn new_tdir() string {
fn cleanup_tdir() {
println('... removing tdir: $tdir')
os.rmdir_all(tdir) or { panic(err) }
os.rmdir_all(tdir) or { eprintln(err) }
}
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 }') ?
@ -51,6 +54,10 @@ fn main() {
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)}')
}
fn check_ok(cmd string) string {