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

tests: unify all temporary files/folders under $VTMP/v, that can be cleaned by v wipe-cache (#15774)

This commit is contained in:
Delyan Angelov
2022-09-16 04:56:19 +03:00
committed by GitHub
parent 7e69619add
commit f922ed0941
28 changed files with 210 additions and 144 deletions

View File

@@ -106,7 +106,7 @@ fn test_create_file() ? {
fn test_is_file() {
// Setup
work_dir := os.join_path_single(os.getwd(), 'is_file_test')
work_dir := os.join_path_single(tfolder, 'is_file_test')
os.mkdir_all(work_dir) or { panic(err) }
tfile := os.join_path_single(work_dir, 'tmp_file')
// Test things that shouldn't be a file
@@ -309,7 +309,7 @@ fn test_cp() {
}
fn test_mv() {
work_dir := os.join_path_single(os.getwd(), 'mv_test')
work_dir := os.join_path_single(tfolder, 'mv_test')
os.mkdir_all(work_dir) or { panic(err) }
// Setup test files
tfile1 := os.join_path_single(work_dir, 'file')
@@ -404,7 +404,7 @@ fn test_realpath_non_existing() {
fn test_realpath_existing() {
existing_file_name := 'existing_file.txt'
existing_file := os.join_path_single(os.temp_dir(), existing_file_name)
existing_file := os.join_path_single(tfolder, existing_file_name)
os.rm(existing_file) or {}
os.write_file(existing_file, 'abc') or {}
assert os.exists(existing_file)

View File

@@ -6,12 +6,14 @@ import time
const (
vexe = os.getenv('VEXE')
vroot = os.dir(vexe)
test_os_process = os.join_path(os.temp_dir(), 'v', 'test_os_process.exe')
tfolder = os.join_path(os.temp_dir(), 'v', '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')
)
fn testsuite_begin() ? {
os.rm(test_os_process) or {}
os.rmdir_all(tfolder) or {}
os.mkdir_all(tfolder)?
if os.getenv('WINE_TEST_OS_PROCESS_EXE') != '' {
// Make it easier to run the test under wine emulation, by just
// prebuilding the executable with:
@@ -24,6 +26,10 @@ fn testsuite_begin() ? {
assert os.exists(test_os_process)
}
fn testsuite_end() ? {
os.rmdir_all(tfolder) or {}
}
fn test_getpid() {
pid := os.getpid()
eprintln('current pid: $pid')