Skip to content

Commit

Permalink
tests: cleanup legacy temp path (#19716)
Browse files Browse the repository at this point in the history
  • Loading branch information
ttytm committed Oct 31, 2023
1 parent 3708061 commit e465f74
Show file tree
Hide file tree
Showing 35 changed files with 69 additions and 65 deletions.
2 changes: 1 addition & 1 deletion cmd/tools/test_if_v_test_system_works.v
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ fn get_vexe_path() string {
}

fn new_tdir() string {
dir := os.join_path(os.vtmp_dir(), 'v', rand.ulid())
dir := os.join_path(os.vtmp_dir(), rand.ulid())
os.rmdir_all(dir) or {}
os.mkdir_all(dir) or { panic(err) }
C.atexit(cleanup_tdir)
Expand Down
7 changes: 4 additions & 3 deletions cmd/tools/vbump_test.v
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import os

const vexe = @VEXE

const tfolder = os.join_path(os.vtmp_dir(), 'v', 'vbump')
const (
vexe = @VEXE
tfolder = os.join_path(os.vtmp_dir(), 'vbump')
)

fn testsuite_begin() {
os.mkdir_all(tfolder) or {}
Expand Down
2 changes: 1 addition & 1 deletion cmd/tools/vcheck-md.v
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const (
show_progress = os.getenv('GITHUB_JOB') == '' && '-silent' !in os.args
non_option_args = cmdline.only_non_options(os.args[2..])
is_verbose = os.getenv('VERBOSE') != ''
vcheckfolder = os.join_path(os.vtmp_dir(), 'v', 'vcheck_${os.getuid()}')
vcheckfolder = os.join_path(os.vtmp_dir(), 'vcheck_${os.getuid()}')
should_autofix = os.getenv('VAUTOFIX') != ''
vexe = @VEXE
)
Expand Down
7 changes: 4 additions & 3 deletions cmd/tools/vcomplete_test.v
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import os

const vexe = @VEXE

const tfolder = os.join_path(os.vtmp_dir(), 'v', 'vcomplete_test')
const (
vexe = @VEXE
tfolder = os.join_path(os.vtmp_dir(), 'vcomplete_test')
)

enum Shell {
bash
Expand Down
2 changes: 1 addition & 1 deletion cmd/tools/vgret.v
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ Examples:
Compare screenshots in `/tmp/src` to existing screenshots in `/tmp/dst`
v gret --compare-only /tmp/src /tmp/dst
'
tmp_dir = os.join_path(os.vtmp_dir(), 'v', tool_name)
tmp_dir = os.join_path(os.vtmp_dir(), tool_name)
runtime_os = os.user_os()
v_root = os.real_path(@VMODROOT)
)
Expand Down
2 changes: 1 addition & 1 deletion cmd/tools/vrepl.v
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ const (
is_stdin_a_pipe = os.is_atty(0) == 0
vexe = os.getenv('VEXE')
vstartup = os.getenv('VSTARTUP')
repl_folder = os.join_path(os.vtmp_dir(), 'v', 'repl')
repl_folder = os.join_path(os.vtmp_dir(), 'repl')
)

enum FnType {
Expand Down
2 changes: 1 addition & 1 deletion vlib/io/util/util_test.v
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const (
// tfolder will contain all the temporary files/subfolders made by
// the different tests. It would be removed in testsuite_end(), so
// individual os tests do not need to clean up after themselves.
tfolder = os.join_path(os.vtmp_dir(), 'v', 'tests', 'io_util_test')
tfolder = os.join_path(os.vtmp_dir(), 'tests', 'io_util_test')
)

fn testsuite_begin() {
Expand Down
7 changes: 4 additions & 3 deletions vlib/net/unix/unix_test.v
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import os
import net.unix

const tfolder = os.join_path(os.vtmp_dir(), 'v', 'unix_test')

const test_port = os.join_path(tfolder, 'unix_domain_socket')
const (
tfolder = os.join_path(os.vtmp_dir(), 'unix_test')
test_port = os.join_path(tfolder, 'unix_domain_socket')
)

fn testsuite_begin() {
os.mkdir_all(tfolder) or {}
Expand Down
11 changes: 5 additions & 6 deletions vlib/net/unix/use_net_and_net_unix_together_test.v
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,11 @@ import os
import net.unix
import net

// ensure that `net` is used, i.e. no warnings
const use_net = net.no_timeout

const tfolder = os.join_path(os.vtmp_dir(), 'v', 'net_and_unix_together')

const test_port = os.join_path(tfolder, 'unix_domain_socket')
const (
use_net = net.no_timeout // ensure that `net` is used, i.e. no warnings
tfolder = os.join_path(os.vtmp_dir(), 'net_and_unix_together')
test_port = os.join_path(tfolder, 'unix_domain_socket')
)

fn testsuite_begin() {
os.mkdir_all(tfolder) or {}
Expand Down
7 changes: 4 additions & 3 deletions vlib/orm/orm_sql_or_blocks_test.v
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@ struct User {
name string [unique]
}

const db_folder = os.join_path(os.vtmp_dir(), 'v', 'orm_sql')

const db_path = os.join_path(db_folder, 'sql_statement_or_blocks.db')
const (
db_folder = os.join_path(os.vtmp_dir(), 'orm_sql')
db_path = os.join_path(db_folder, 'sql_statement_or_blocks.db')
)

fn testsuite_begin() {
os.mkdir_all(db_folder) or {}
Expand Down
7 changes: 4 additions & 3 deletions vlib/os/file_test.v
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import os

const tfolder = os.join_path(os.vtmp_dir(), 'v', 'tests', 'os_file_test')

const tfile = os.join_path_single(tfolder, 'test_file')
const (
tfolder = os.join_path(os.vtmp_dir(), 'tests', 'os_file_test')
tfile = os.join_path_single(tfolder, 'test_file')
)

fn testsuite_begin() {
os.rmdir_all(tfolder) or {}
Expand Down
2 changes: 1 addition & 1 deletion vlib/os/find_abs_path_of_executable_test.v
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import os

fn test_find_abs_path_of_executable() {
tfolder := os.join_path(os.vtmp_dir(), 'v', 'tests', 'filepath_test')
tfolder := os.join_path(os.vtmp_dir(), 'tests', 'filepath_test')
os.rmdir_all(tfolder) or {}
assert !os.is_dir(tfolder)
os.mkdir_all(tfolder)!
Expand Down
2 changes: 1 addition & 1 deletion vlib/os/inode_test.v
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const (
// tfolder will contain all the temporary files/subfolders made by
// the different tests. It would be removed in testsuite_end(), so
// individual os tests do not need to clean up after themselves.
tfolder = os.join_path(os.vtmp_dir(), 'v', 'tests', 'inode_test')
tfolder = os.join_path(os.vtmp_dir(), 'tests', 'inode_test')
)

fn testsuite_begin() {
Expand Down
2 changes: 1 addition & 1 deletion vlib/os/os_test.v
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const (
// tfolder will contain all the temporary files/subfolders made by
// the different tests. It would be removed in testsuite_end(), so
// individual os tests do not need to clean up after themselves.
tfolder = os.join_path(os.vtmp_dir(), 'v', 'tests', 'os_test')
tfolder = os.join_path(os.vtmp_dir(), 'tests', 'os_test')
)

// os.args has to be *already initialized* with the program's argc/argv at this point
Expand Down
2 changes: 1 addition & 1 deletion vlib/os/process_test.v
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import time
const (
vexe = os.getenv('VEXE')
vroot = os.dir(vexe)
tfolder = os.join_path(os.vtmp_dir(), 'v', 'tests', 'os_process')
tfolder = os.join_path(os.vtmp_dir(), 'tests', 'os_process')
test_os_process = os.join_path(tfolder, 'test_os_process.exe')
test_os_process_source = os.join_path(vroot, 'cmd/tools/test_os_process.v')
)
Expand Down
2 changes: 1 addition & 1 deletion vlib/stbi/stbi_test.v
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import os
import stbi

const tfolder = os.join_path(os.vtmp_dir(), 'v', 'stbi')
const tfolder = os.join_path(os.vtmp_dir(), 'stbi')

fn testsuite_begin() {
os.mkdir_all(tfolder) or {}
Expand Down
2 changes: 1 addition & 1 deletion vlib/toml/tests/alexcrichton_toml_rs_test.v
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ const (
]
tests_folder = os.join_path('test-suite', 'tests')
jq = os.find_abs_path_of_executable('jq') or { '' }
compare_work_dir_root = os.join_path(os.vtmp_dir(), 'v', 'toml', 'alexcrichton')
compare_work_dir_root = os.join_path(os.vtmp_dir(), 'toml', 'alexcrichton')
// From: https://stackoverflow.com/a/38266731/1904615
jq_normalize = r'# Apply f to composite entities recursively using keys[], and to atoms
def sorted_walk(f):
Expand Down
2 changes: 1 addition & 1 deletion vlib/toml/tests/burntsushi_toml_test.v
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ const (
//'integer/long.toml', // TODO https://github.com/vlang/v/issues/9507

jq = os.find_abs_path_of_executable('jq') or { '' }
compare_work_dir_root = os.join_path(os.vtmp_dir(), 'v', 'toml', 'burntsushi')
compare_work_dir_root = os.join_path(os.vtmp_dir(), 'toml', 'burntsushi')
// From: https://stackoverflow.com/a/38266731/1904615
jq_normalize = r'# Apply f to composite entities recursively using keys[], and to atoms
def sorted_walk(f):
Expand Down
2 changes: 1 addition & 1 deletion vlib/toml/tests/iarna_toml_spec_test.v
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ const (

jq = os.find_abs_path_of_executable('jq') or { '' }
python = os.find_abs_path_of_executable('python') or { '' }
compare_work_dir_root = os.join_path(os.vtmp_dir(), 'v', 'toml', 'iarna')
compare_work_dir_root = os.join_path(os.vtmp_dir(), 'toml', 'iarna')
// From: https://stackoverflow.com/a/38266731/1904615
jq_normalize = r'# Apply f to composite entities recursively using keys[], and to atoms
def sorted_walk(f):
Expand Down
2 changes: 1 addition & 1 deletion vlib/toml/tests/toml_test.v
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ fn test_toml() {
}

fn test_toml_file() {
out_path := os.join_path(os.vtmp_dir(), 'v', 'toml_tests')
out_path := os.join_path(os.vtmp_dir(), 'toml_tests')
test_file := os.join_path(out_path, 'toml_example.toml')
os.mkdir_all(out_path) or { assert false }
defer {
Expand Down
7 changes: 4 additions & 3 deletions vlib/v/builder/builder_test.v
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@ module main

import os

const test_path = os.join_path(os.vtmp_dir(), 'v', 'run_check')

const vexe = @VEXE
const (
vexe = @VEXE
test_path = os.join_path(os.vtmp_dir(), 'run_check')
)

fn testsuite_begin() {
os.mkdir_all(test_path) or {}
Expand Down
2 changes: 1 addition & 1 deletion vlib/v/builder/interpreterbuilder/v_interpret_test.v
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ fn interpreter_wrap(a string) string {
}

fn interp_test(expression string, expected string) ! {
tmpdir := os.join_path(os.vtmp_dir(), 'v', 'interpret_test_${rand.ulid()}')
tmpdir := os.join_path(os.vtmp_dir(), 'interpret_test_${rand.ulid()}')
os.mkdir_all(tmpdir) or {}
defer {
os.rmdir_all(tmpdir) or {}
Expand Down
4 changes: 2 additions & 2 deletions vlib/v/gen/c/coutput_test.v
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ fn mm(s string) string {
fn test_out_files() {
println(term.colorize(term.green, '> testing whether .out files match:'))
os.chdir(vroot) or {}
output_path := os.join_path(os.vtmp_dir(), 'v', 'coutput', 'out')
output_path := os.join_path(os.vtmp_dir(), 'coutput', 'out')
os.mkdir_all(output_path)!
defer {
os.rmdir_all(output_path) or {}
Expand Down Expand Up @@ -97,7 +97,7 @@ fn test_out_files() {
fn test_c_must_have_files() {
println(term.colorize(term.green, '> testing whether `.c.must_have` files match:'))
os.chdir(vroot) or {}
output_path := os.join_path(os.vtmp_dir(), 'v', 'coutput', 'c_must_have')
output_path := os.join_path(os.vtmp_dir(), 'coutput', 'c_must_have')
os.mkdir_all(output_path)!
defer {
os.rmdir_all(output_path) or {}
Expand Down
2 changes: 1 addition & 1 deletion vlib/v/gen/golang/tests/golang_test.v
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ fn test_golang() {
dir := os.join_path(vroot, 'vlib/v/gen/golang/tests')
files := os.ls(dir) or { panic(err) }
//
wrkdir := os.join_path(os.vtmp_dir(), 'v', 'tests', 'golang')
wrkdir := os.join_path(os.vtmp_dir(), 'tests', 'golang')
os.mkdir_all(wrkdir) or { panic(err) }
defer {
os.rmdir_all(wrkdir) or {}
Expand Down
2 changes: 1 addition & 1 deletion vlib/v/gen/js/jsgen_test.v
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import os

const (
test_dir = os.join_path('vlib', 'v', 'gen', 'js', 'tests')
output_dir = os.join_path(os.vtmp_dir(), 'v', '_js_tests/')
output_dir = os.join_path(os.vtmp_dir(), '_js_tests/')
v_options = '-b js -w'
node_options = ''
)
Expand Down
2 changes: 1 addition & 1 deletion vlib/v/gen/native/tests/native_test.v
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ fn test_native() {
dir := os.join_path(vroot, 'vlib', 'v', 'gen', 'native', 'tests')
files := os.ls(dir) or { panic(err) }
//
wrkdir := os.join_path(os.vtmp_dir(), 'v', 'tests', 'native')
wrkdir := os.join_path(os.vtmp_dir(), 'tests', 'native')
os.mkdir_all(wrkdir) or { panic(err) }
defer {
os.rmdir_all(wrkdir) or {}
Expand Down
2 changes: 1 addition & 1 deletion vlib/v/gen/wasm/tests/wasm_test.v
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ fn test_wasm() {
dir := os.join_path(vroot, 'vlib/v/gen/wasm/tests')
files := os.ls(dir) or { panic(err) }
//
wrkdir := os.join_path(os.vtmp_dir(), 'v', 'tests', 'wasm')
wrkdir := os.join_path(os.vtmp_dir(), 'tests', 'wasm')
os.mkdir_all(wrkdir) or { panic(err) }
defer {
os.rmdir_all(wrkdir) or {}
Expand Down
2 changes: 1 addition & 1 deletion vlib/v/live/live_test.v
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ TODO: Cleanup this when/if v has better process control/communication primitives
*/
const (
vexe = os.getenv('VEXE')
vtmp_folder = os.join_path(os.vtmp_dir(), 'v', 'tests', 'live')
vtmp_folder = os.join_path(os.vtmp_dir(), 'tests', 'live')
main_source_file = os.join_path(vtmp_folder, 'main.v')
tmp_file = os.join_path(vtmp_folder, 'mymodule', 'generated_live_module.tmp')
source_file = os.join_path(vtmp_folder, 'mymodule', 'mymodule.v')
Expand Down
7 changes: 4 additions & 3 deletions vlib/v/pref/options_test.v
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@
import os
import time

const vexe = @VEXE

const tfolder = os.join_path(os.vtmp_dir(), 'v', 'custom_compile')
const (
vexe = @VEXE
tfolder = os.join_path(os.vtmp_dir(), 'custom_compile')
)

fn testsuite_begin() {
os.mkdir_all(tfolder) or {}
Expand Down
10 changes: 5 additions & 5 deletions vlib/v/slow_tests/crun_mode/crun_test.v
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import os
import time

const crun_folder = os.join_path(os.vtmp_dir(), 'v', 'crun_folder')

const vprogram_file = os.join_path(crun_folder, 'vprogram.vv')

const vexe = os.getenv('VEXE')
const (
vexe = os.getenv('VEXE')
crun_folder = os.join_path(os.vtmp_dir(), 'crun_folder')
vprogram_file = os.join_path(crun_folder, 'vprogram.vv')
)

fn testsuite_begin() {
os.setenv('VCACHE', crun_folder, true)
Expand Down
2 changes: 1 addition & 1 deletion vlib/v/slow_tests/valgrind/valgrind_test.v
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ fn test_all() {
mut files := os.ls(dir) or { panic(err) }
files.sort()
//
wrkdir := os.join_path(os.vtmp_dir(), 'v', 'tests', 'valgrind')
wrkdir := os.join_path(os.vtmp_dir(), 'tests', 'valgrind')
os.mkdir_all(wrkdir) or { panic(err) }
os.chdir(wrkdir) or {}
//
Expand Down
2 changes: 1 addition & 1 deletion vlib/v/tests/closure_generator_test.v
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ fn test_closure_return_${styp}_${i}() ! {

code := v_code.str()
println('Compiling V code (${code.count('\n')} lines) ...')
wrkdir := os.join_path(os.vtmp_dir(), 'v', 'tests', 'closures')
wrkdir := os.join_path(os.vtmp_dir(), 'tests', 'closures')
os.mkdir_all(wrkdir)!
os.chdir(wrkdir)!
full_path_to_target := os.join_path(wrkdir, 'closure_return_test.v')
Expand Down
10 changes: 5 additions & 5 deletions vlib/v/tests/run_v_code_from_stdin_test.v
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import os

const vexe = os.getenv('VEXE')

const turn_off_vcolors = os.setenv('VCOLORS', 'never', true)

const vtmp_folder = os.join_path(os.vtmp_dir(), 'v', 'tests', 'run_v_code')
const (
vexe = os.getenv('VEXE')
turn_off_vcolors = os.setenv('VCOLORS', 'never', true)
vtmp_folder = os.join_path(os.vtmp_dir(), 'tests', 'run_v_code')
)

fn test_vexe_is_set() {
assert vexe != ''
Expand Down
4 changes: 1 addition & 3 deletions vlib/v/vcache/vcache_test.v
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
import os
import v.vcache

const (
vcache_folder = os.join_path(os.vtmp_dir(), 'v', 'cache_folder')
)
const vcache_folder = os.join_path(os.vtmp_dir(), 'cache_folder')

fn check_cache_entry_fpath_invariants(x string, extension string) {
a := x.replace(vcache_folder + os.path_separator, '').split(os.path_separator)
Expand Down
2 changes: 1 addition & 1 deletion vlib/vweb/assets/assets_test.v
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import vweb.assets
import os

const base_cache_dir = os.join_path(os.vtmp_dir(), 'v', 'assets_test_cache')
const base_cache_dir = os.join_path(os.vtmp_dir(), 'assets_test_cache')

fn testsuite_begin() {
os.mkdir_all(base_cache_dir) or {}
Expand Down

0 comments on commit e465f74

Please sign in to comment.