tests: cleanup legacy temp path (#19716)

This commit is contained in:
Turiiya 2023-10-31 14:16:19 +01:00 committed by GitHub
parent 3708061d61
commit e465f7490c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
35 changed files with 69 additions and 65 deletions

View File

@ -26,7 +26,7 @@ fn get_vexe_path() string {
} }
fn new_tdir() 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.rmdir_all(dir) or {}
os.mkdir_all(dir) or { panic(err) } os.mkdir_all(dir) or { panic(err) }
C.atexit(cleanup_tdir) C.atexit(cleanup_tdir)

View File

@ -1,8 +1,9 @@
import os import os
const vexe = @VEXE const (
vexe = @VEXE
const tfolder = os.join_path(os.vtmp_dir(), 'v', 'vbump') tfolder = os.join_path(os.vtmp_dir(), 'vbump')
)
fn testsuite_begin() { fn testsuite_begin() {
os.mkdir_all(tfolder) or {} os.mkdir_all(tfolder) or {}

View File

@ -21,7 +21,7 @@ const (
show_progress = os.getenv('GITHUB_JOB') == '' && '-silent' !in os.args show_progress = os.getenv('GITHUB_JOB') == '' && '-silent' !in os.args
non_option_args = cmdline.only_non_options(os.args[2..]) non_option_args = cmdline.only_non_options(os.args[2..])
is_verbose = os.getenv('VERBOSE') != '' 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') != '' should_autofix = os.getenv('VAUTOFIX') != ''
vexe = @VEXE vexe = @VEXE
) )

View File

@ -1,8 +1,9 @@
import os import os
const vexe = @VEXE const (
vexe = @VEXE
const tfolder = os.join_path(os.vtmp_dir(), 'v', 'vcomplete_test') tfolder = os.join_path(os.vtmp_dir(), 'vcomplete_test')
)
enum Shell { enum Shell {
bash bash

View File

@ -58,7 +58,7 @@ Examples:
Compare screenshots in `/tmp/src` to existing screenshots in `/tmp/dst` Compare screenshots in `/tmp/src` to existing screenshots in `/tmp/dst`
v gret --compare-only /tmp/src /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() runtime_os = os.user_os()
v_root = os.real_path(@VMODROOT) v_root = os.real_path(@VMODROOT)
) )

View File

@ -35,7 +35,7 @@ const (
is_stdin_a_pipe = os.is_atty(0) == 0 is_stdin_a_pipe = os.is_atty(0) == 0
vexe = os.getenv('VEXE') vexe = os.getenv('VEXE')
vstartup = os.getenv('VSTARTUP') 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 { enum FnType {

View File

@ -5,7 +5,7 @@ const (
// tfolder will contain all the temporary files/subfolders made by // tfolder will contain all the temporary files/subfolders made by
// the different tests. It would be removed in testsuite_end(), so // the different tests. It would be removed in testsuite_end(), so
// individual os tests do not need to clean up after themselves. // 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() { fn testsuite_begin() {

View File

@ -1,9 +1,10 @@
import os import os
import net.unix import net.unix
const tfolder = os.join_path(os.vtmp_dir(), 'v', 'unix_test') const (
tfolder = os.join_path(os.vtmp_dir(), 'unix_test')
const test_port = os.join_path(tfolder, 'unix_domain_socket') test_port = os.join_path(tfolder, 'unix_domain_socket')
)
fn testsuite_begin() { fn testsuite_begin() {
os.mkdir_all(tfolder) or {} os.mkdir_all(tfolder) or {}

View File

@ -2,12 +2,11 @@ import os
import net.unix import net.unix
import net import net
// ensure that `net` is used, i.e. no warnings const (
const use_net = net.no_timeout 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')
const tfolder = os.join_path(os.vtmp_dir(), 'v', 'net_and_unix_together') test_port = os.join_path(tfolder, 'unix_domain_socket')
)
const test_port = os.join_path(tfolder, 'unix_domain_socket')
fn testsuite_begin() { fn testsuite_begin() {
os.mkdir_all(tfolder) or {} os.mkdir_all(tfolder) or {}

View File

@ -6,9 +6,10 @@ struct User {
name string [unique] name string [unique]
} }
const db_folder = os.join_path(os.vtmp_dir(), 'v', 'orm_sql') const (
db_folder = os.join_path(os.vtmp_dir(), 'orm_sql')
const db_path = os.join_path(db_folder, 'sql_statement_or_blocks.db') db_path = os.join_path(db_folder, 'sql_statement_or_blocks.db')
)
fn testsuite_begin() { fn testsuite_begin() {
os.mkdir_all(db_folder) or {} os.mkdir_all(db_folder) or {}

View File

@ -1,8 +1,9 @@
import os import os
const tfolder = os.join_path(os.vtmp_dir(), 'v', 'tests', 'os_file_test') const (
tfolder = os.join_path(os.vtmp_dir(), 'tests', 'os_file_test')
const tfile = os.join_path_single(tfolder, 'test_file') tfile = os.join_path_single(tfolder, 'test_file')
)
fn testsuite_begin() { fn testsuite_begin() {
os.rmdir_all(tfolder) or {} os.rmdir_all(tfolder) or {}

View File

@ -1,7 +1,7 @@
import os import os
fn test_find_abs_path_of_executable() { 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 {} os.rmdir_all(tfolder) or {}
assert !os.is_dir(tfolder) assert !os.is_dir(tfolder)
os.mkdir_all(tfolder)! os.mkdir_all(tfolder)!

View File

@ -4,7 +4,7 @@ const (
// tfolder will contain all the temporary files/subfolders made by // tfolder will contain all the temporary files/subfolders made by
// the different tests. It would be removed in testsuite_end(), so // the different tests. It would be removed in testsuite_end(), so
// individual os tests do not need to clean up after themselves. // 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() { fn testsuite_begin() {

View File

@ -5,7 +5,7 @@ const (
// tfolder will contain all the temporary files/subfolders made by // tfolder will contain all the temporary files/subfolders made by
// the different tests. It would be removed in testsuite_end(), so // the different tests. It would be removed in testsuite_end(), so
// individual os tests do not need to clean up after themselves. // 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 // os.args has to be *already initialized* with the program's argc/argv at this point

View File

@ -6,7 +6,7 @@ import time
const ( const (
vexe = os.getenv('VEXE') vexe = os.getenv('VEXE')
vroot = os.dir(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 = os.join_path(tfolder, 'test_os_process.exe')
test_os_process_source = os.join_path(vroot, 'cmd/tools/test_os_process.v') test_os_process_source = os.join_path(vroot, 'cmd/tools/test_os_process.v')
) )

View File

@ -1,7 +1,7 @@
import os import os
import stbi import stbi
const tfolder = os.join_path(os.vtmp_dir(), 'v', 'stbi') const tfolder = os.join_path(os.vtmp_dir(), 'stbi')
fn testsuite_begin() { fn testsuite_begin() {
os.mkdir_all(tfolder) or {} os.mkdir_all(tfolder) or {}

View File

@ -37,7 +37,7 @@ const (
] ]
tests_folder = os.join_path('test-suite', 'tests') tests_folder = os.join_path('test-suite', 'tests')
jq = os.find_abs_path_of_executable('jq') or { '' } 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 // From: https://stackoverflow.com/a/38266731/1904615
jq_normalize = r'# Apply f to composite entities recursively using keys[], and to atoms jq_normalize = r'# Apply f to composite entities recursively using keys[], and to atoms
def sorted_walk(f): def sorted_walk(f):

View File

@ -27,7 +27,7 @@ const (
//'integer/long.toml', // TODO https://github.com/vlang/v/issues/9507 //'integer/long.toml', // TODO https://github.com/vlang/v/issues/9507
jq = os.find_abs_path_of_executable('jq') or { '' } 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 // From: https://stackoverflow.com/a/38266731/1904615
jq_normalize = r'# Apply f to composite entities recursively using keys[], and to atoms jq_normalize = r'# Apply f to composite entities recursively using keys[], and to atoms
def sorted_walk(f): def sorted_walk(f):

View File

@ -43,7 +43,7 @@ const (
jq = os.find_abs_path_of_executable('jq') or { '' } jq = os.find_abs_path_of_executable('jq') or { '' }
python = os.find_abs_path_of_executable('python') 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 // From: https://stackoverflow.com/a/38266731/1904615
jq_normalize = r'# Apply f to composite entities recursively using keys[], and to atoms jq_normalize = r'# Apply f to composite entities recursively using keys[], and to atoms
def sorted_walk(f): def sorted_walk(f):

View File

@ -68,7 +68,7 @@ fn test_toml() {
} }
fn test_toml_file() { 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') test_file := os.join_path(out_path, 'toml_example.toml')
os.mkdir_all(out_path) or { assert false } os.mkdir_all(out_path) or { assert false }
defer { defer {

View File

@ -2,9 +2,10 @@ module main
import os 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() { fn testsuite_begin() {
os.mkdir_all(test_path) or {} os.mkdir_all(test_path) or {}

View File

@ -9,7 +9,7 @@ fn interpreter_wrap(a string) string {
} }
fn interp_test(expression string, expected 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 {} os.mkdir_all(tmpdir) or {}
defer { defer {
os.rmdir_all(tmpdir) or {} os.rmdir_all(tmpdir) or {}

View File

@ -23,7 +23,7 @@ fn mm(s string) string {
fn test_out_files() { fn test_out_files() {
println(term.colorize(term.green, '> testing whether .out files match:')) println(term.colorize(term.green, '> testing whether .out files match:'))
os.chdir(vroot) or {} 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)! os.mkdir_all(output_path)!
defer { defer {
os.rmdir_all(output_path) or {} os.rmdir_all(output_path) or {}
@ -97,7 +97,7 @@ fn test_out_files() {
fn test_c_must_have_files() { fn test_c_must_have_files() {
println(term.colorize(term.green, '> testing whether `.c.must_have` files match:')) println(term.colorize(term.green, '> testing whether `.c.must_have` files match:'))
os.chdir(vroot) or {} 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)! os.mkdir_all(output_path)!
defer { defer {
os.rmdir_all(output_path) or {} os.rmdir_all(output_path) or {}

View File

@ -19,7 +19,7 @@ fn test_golang() {
dir := os.join_path(vroot, 'vlib/v/gen/golang/tests') dir := os.join_path(vroot, 'vlib/v/gen/golang/tests')
files := os.ls(dir) or { panic(err) } 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) } os.mkdir_all(wrkdir) or { panic(err) }
defer { defer {
os.rmdir_all(wrkdir) or {} os.rmdir_all(wrkdir) or {}

View File

@ -2,7 +2,7 @@ import os
const ( const (
test_dir = os.join_path('vlib', 'v', 'gen', 'js', 'tests') 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' v_options = '-b js -w'
node_options = '' node_options = ''
) )

View File

@ -21,7 +21,7 @@ fn test_native() {
dir := os.join_path(vroot, 'vlib', 'v', 'gen', 'native', 'tests') dir := os.join_path(vroot, 'vlib', 'v', 'gen', 'native', 'tests')
files := os.ls(dir) or { panic(err) } 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) } os.mkdir_all(wrkdir) or { panic(err) }
defer { defer {
os.rmdir_all(wrkdir) or {} os.rmdir_all(wrkdir) or {}

View File

@ -29,7 +29,7 @@ fn test_wasm() {
dir := os.join_path(vroot, 'vlib/v/gen/wasm/tests') dir := os.join_path(vroot, 'vlib/v/gen/wasm/tests')
files := os.ls(dir) or { panic(err) } 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) } os.mkdir_all(wrkdir) or { panic(err) }
defer { defer {
os.rmdir_all(wrkdir) or {} os.rmdir_all(wrkdir) or {}

View File

@ -33,7 +33,7 @@ TODO: Cleanup this when/if v has better process control/communication primitives
*/ */
const ( const (
vexe = os.getenv('VEXE') 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') main_source_file = os.join_path(vtmp_folder, 'main.v')
tmp_file = os.join_path(vtmp_folder, 'mymodule', 'generated_live_module.tmp') tmp_file = os.join_path(vtmp_folder, 'mymodule', 'generated_live_module.tmp')
source_file = os.join_path(vtmp_folder, 'mymodule', 'mymodule.v') source_file = os.join_path(vtmp_folder, 'mymodule', 'mymodule.v')

View File

@ -3,9 +3,10 @@
import os import os
import time import time
const vexe = @VEXE const (
vexe = @VEXE
const tfolder = os.join_path(os.vtmp_dir(), 'v', 'custom_compile') tfolder = os.join_path(os.vtmp_dir(), 'custom_compile')
)
fn testsuite_begin() { fn testsuite_begin() {
os.mkdir_all(tfolder) or {} os.mkdir_all(tfolder) or {}

View File

@ -1,11 +1,11 @@
import os import os
import time import time
const crun_folder = os.join_path(os.vtmp_dir(), 'v', 'crun_folder') const (
vexe = os.getenv('VEXE')
const vprogram_file = os.join_path(crun_folder, 'vprogram.vv') crun_folder = os.join_path(os.vtmp_dir(), 'crun_folder')
vprogram_file = os.join_path(crun_folder, 'vprogram.vv')
const vexe = os.getenv('VEXE') )
fn testsuite_begin() { fn testsuite_begin() {
os.setenv('VCACHE', crun_folder, true) os.setenv('VCACHE', crun_folder, true)

View File

@ -67,7 +67,7 @@ fn test_all() {
mut files := os.ls(dir) or { panic(err) } mut files := os.ls(dir) or { panic(err) }
files.sort() 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.mkdir_all(wrkdir) or { panic(err) }
os.chdir(wrkdir) or {} os.chdir(wrkdir) or {}
// //

View File

@ -170,7 +170,7 @@ fn test_closure_return_${styp}_${i}() ! {
code := v_code.str() code := v_code.str()
println('Compiling V code (${code.count('\n')} lines) ...') 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.mkdir_all(wrkdir)!
os.chdir(wrkdir)! os.chdir(wrkdir)!
full_path_to_target := os.join_path(wrkdir, 'closure_return_test.v') full_path_to_target := os.join_path(wrkdir, 'closure_return_test.v')

View File

@ -1,10 +1,10 @@
import os import os
const vexe = os.getenv('VEXE') const (
vexe = os.getenv('VEXE')
const turn_off_vcolors = os.setenv('VCOLORS', 'never', true) turn_off_vcolors = os.setenv('VCOLORS', 'never', true)
vtmp_folder = os.join_path(os.vtmp_dir(), 'tests', 'run_v_code')
const vtmp_folder = os.join_path(os.vtmp_dir(), 'v', 'tests', 'run_v_code') )
fn test_vexe_is_set() { fn test_vexe_is_set() {
assert vexe != '' assert vexe != ''

View File

@ -1,9 +1,7 @@
import os import os
import v.vcache import v.vcache
const ( const vcache_folder = os.join_path(os.vtmp_dir(), 'cache_folder')
vcache_folder = os.join_path(os.vtmp_dir(), 'v', 'cache_folder')
)
fn check_cache_entry_fpath_invariants(x string, extension string) { fn check_cache_entry_fpath_invariants(x string, extension string) {
a := x.replace(vcache_folder + os.path_separator, '').split(os.path_separator) a := x.replace(vcache_folder + os.path_separator, '').split(os.path_separator)

View File

@ -1,7 +1,7 @@
import vweb.assets import vweb.assets
import os 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() { fn testsuite_begin() {
os.mkdir_all(base_cache_dir) or {} os.mkdir_all(base_cache_dir) or {}