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:
@ -1,6 +1,6 @@
|
||||
import os
|
||||
|
||||
const test_path = 'vcreate_test'
|
||||
const test_path = os.join_path(os.temp_dir(), 'v', 'vcreate_test')
|
||||
|
||||
fn init_and_check() ? {
|
||||
os.execute_or_exit('${os.quoted_path(@VEXE)} init')
|
||||
@ -59,42 +59,27 @@ fn init_and_check() ? {
|
||||
].join_lines()
|
||||
}
|
||||
|
||||
fn test_v_init() ? {
|
||||
dir := os.join_path(os.temp_dir(), test_path)
|
||||
os.rmdir_all(dir) or {}
|
||||
os.mkdir(dir) or {}
|
||||
defer {
|
||||
os.rmdir_all(dir) or {}
|
||||
}
|
||||
os.chdir(dir)?
|
||||
fn prepare_test_path() ? {
|
||||
os.rmdir_all(test_path) or {}
|
||||
os.mkdir_all(test_path) or {}
|
||||
os.chdir(test_path)?
|
||||
}
|
||||
|
||||
fn test_v_init() ? {
|
||||
prepare_test_path()?
|
||||
init_and_check()?
|
||||
}
|
||||
|
||||
fn test_v_init_in_git_dir() ? {
|
||||
dir := os.join_path(os.temp_dir(), test_path)
|
||||
os.rmdir_all(dir) or {}
|
||||
os.mkdir(dir) or {}
|
||||
defer {
|
||||
os.rmdir_all(dir) or {}
|
||||
}
|
||||
os.chdir(dir)?
|
||||
prepare_test_path()?
|
||||
os.execute_or_exit('git init .')
|
||||
init_and_check()?
|
||||
}
|
||||
|
||||
fn test_v_init_no_overwrite_gitignore() ? {
|
||||
dir := os.join_path(os.temp_dir(), test_path)
|
||||
os.rmdir_all(dir) or {}
|
||||
os.mkdir(dir) or {}
|
||||
os.write_file('$dir/.gitignore', 'blah')?
|
||||
defer {
|
||||
os.rmdir_all(dir) or {}
|
||||
}
|
||||
os.chdir(dir)?
|
||||
|
||||
prepare_test_path()?
|
||||
os.write_file('.gitignore', 'blah')?
|
||||
os.execute_or_exit('${os.quoted_path(@VEXE)} init')
|
||||
|
||||
assert os.read_file('.gitignore')? == 'blah'
|
||||
}
|
||||
|
||||
@ -110,19 +95,15 @@ trim_trailing_whitespace = true
|
||||
indent_style = tab
|
||||
indent_size = 4
|
||||
'
|
||||
|
||||
dir := os.join_path(os.temp_dir(), test_path)
|
||||
os.rmdir_all(dir) or {}
|
||||
os.mkdir(dir) or {}
|
||||
os.write_file('$dir/.gitattributes', git_attributes_content)?
|
||||
os.write_file('$dir/.editorconfig', editor_config_content)?
|
||||
defer {
|
||||
os.rmdir_all(dir) or {}
|
||||
}
|
||||
os.chdir(dir)?
|
||||
|
||||
prepare_test_path()?
|
||||
os.write_file('.gitattributes', git_attributes_content)?
|
||||
os.write_file('.editorconfig', editor_config_content)?
|
||||
os.execute_or_exit('${os.quoted_path(@VEXE)} init')
|
||||
|
||||
assert os.read_file('.gitattributes')? == git_attributes_content
|
||||
assert os.read_file('.editorconfig')? == editor_config_content
|
||||
}
|
||||
|
||||
fn testsuite_end() {
|
||||
os.rmdir_all(test_path) or {}
|
||||
}
|
||||
|
Reference in New Issue
Block a user