From cf4081e2ddf150af61c6003f486914cc2dbe8f85 Mon Sep 17 00:00:00 2001 From: Alexander Medvednikov Date: Sat, 28 Aug 2021 12:51:37 +0300 Subject: [PATCH] all: more chdir/chmod fixes --- vlib/builtin/linux_bare/old/syscallwrapper_test.v | 2 +- vlib/os/os.c.v | 2 +- vlib/v/compiler_errors_test.v | 4 ++-- vlib/v/doc/doc_private_fn_test.v | 2 +- vlib/v/fmt/fmt_keep_test.v | 2 +- vlib/v/fmt/fmt_vlib_test.v | 2 +- vlib/v/gen/js/jsgen_test.v | 2 +- vlib/v/gen/js/program_test.v | 2 +- vlib/v/gen/native/tests/native_test.v | 2 +- .../multiple_paths_in_vmodules/vmodules_overrides_test.v | 4 ++-- vlib/v/tests/run_project_folders_test.v | 2 +- vlib/v/tests/valgrind/valgrind_test.v | 2 +- 12 files changed, 14 insertions(+), 14 deletions(-) diff --git a/vlib/builtin/linux_bare/old/syscallwrapper_test.v b/vlib/builtin/linux_bare/old/syscallwrapper_test.v index cbaf355413..1bd79c9f1d 100644 --- a/vlib/builtin/linux_bare/old/syscallwrapper_test.v +++ b/vlib/builtin/linux_bare/old/syscallwrapper_test.v @@ -12,7 +12,7 @@ fn test_syscallwrappers() { dot_checks := vdir + '/.checks' assert os.is_dir(dot_checks) - os.chdir(dot_checks) + os.chdir(dot_checks) or {} checks_v := 'checks.v' assert os.exists(checks_v) rc := os.execute_or_exit('v run $checks_v') diff --git a/vlib/os/os.c.v b/vlib/os/os.c.v index e6024a13d9..12369d07ee 100644 --- a/vlib/os/os.c.v +++ b/vlib/os/os.c.v @@ -886,7 +886,7 @@ pub fn flush() { // chmod change file access attributes of `path` to `mode`. // Octals like `0o600` can be used. -pub fn chmod(path string, mode int)? { +pub fn chmod(path string, mode int) ? { if C.chmod(&char(path.str), mode) != 0 { return error_with_code('chmod failed: ' + posix_get_error_msg(C.errno), C.errno) } diff --git a/vlib/v/compiler_errors_test.v b/vlib/v/compiler_errors_test.v index 0bb0effed4..1c502b2009 100644 --- a/vlib/v/compiler_errors_test.v +++ b/vlib/v/compiler_errors_test.v @@ -9,7 +9,7 @@ import runtime import benchmark const skip_files = [ - 'non_existing.vv' /* minimize commit diff churn, do not remove */, + 'non_existing.vv', // minimize commit diff churn, do not remove ] const skip_on_ubuntu_musl = [ @@ -51,7 +51,7 @@ mut: fn test_all() { vexe := os.getenv('VEXE') vroot := os.dir(vexe) - os.chdir(vroot) + os.chdir(vroot) or {} checker_dir := 'vlib/v/checker/tests' parser_dir := 'vlib/v/parser/tests' scanner_dir := 'vlib/v/scanner/tests' diff --git a/vlib/v/doc/doc_private_fn_test.v b/vlib/v/doc/doc_private_fn_test.v index 1dd2487326..107d76f0cf 100644 --- a/vlib/v/doc/doc_private_fn_test.v +++ b/vlib/v/doc/doc_private_fn_test.v @@ -3,7 +3,7 @@ module doc import os fn testsuite_begin() { - os.chdir(@VMODROOT) + os.chdir(@VMODROOT) or {} eprintln('>> @VMODROOT: ' + @VMODROOT) } diff --git a/vlib/v/fmt/fmt_keep_test.v b/vlib/v/fmt/fmt_keep_test.v index 74078b4b35..be00fa9750 100644 --- a/vlib/v/fmt/fmt_keep_test.v +++ b/vlib/v/fmt/fmt_keep_test.v @@ -29,7 +29,7 @@ fn test_fmt() { exit(error_missing_vexe) } vroot := os.dir(vexe) - os.chdir(vroot) + os.chdir(vroot) or {} basepath := os.join_path(vroot, '') tmpfolder := os.temp_dir() diff_cmd := diff.find_working_diff_command() or { '' } diff --git a/vlib/v/fmt/fmt_vlib_test.v b/vlib/v/fmt/fmt_vlib_test.v index 00eecb08e2..0715d5f518 100644 --- a/vlib/v/fmt/fmt_vlib_test.v +++ b/vlib/v/fmt/fmt_vlib_test.v @@ -33,7 +33,7 @@ fn test_vlib_fmt() { tmpfolder := os.temp_dir() diff_cmd := diff.find_working_diff_command() or { '' } mut fmt_bench := benchmark.new_benchmark() - os.chdir(vroot) + os.chdir(vroot) or {} input_files := os.walk_ext('vlib/v/', '.v').filter(!it.contains('/tests/')) fmt_bench.set_total_expected_steps(input_files.len) for istep, ipath in input_files { diff --git a/vlib/v/gen/js/jsgen_test.v b/vlib/v/gen/js/jsgen_test.v index 06316e8449..d3033e0002 100644 --- a/vlib/v/gen/js/jsgen_test.v +++ b/vlib/v/gen/js/jsgen_test.v @@ -17,7 +17,7 @@ const there_is_grep_available = is_grep_working() fn test_example_compilation() { vexe := os.getenv('VEXE') - os.chdir(os.dir(vexe)) + os.chdir(os.dir(vexe)) or {} os.mkdir_all(output_dir) or { panic(err) } files := find_test_files() for file in files { diff --git a/vlib/v/gen/js/program_test.v b/vlib/v/gen/js/program_test.v index 8ba06ed125..9682732e6c 100644 --- a/vlib/v/gen/js/program_test.v +++ b/vlib/v/gen/js/program_test.v @@ -37,7 +37,7 @@ fn test_node_exists() { fn test_running_programs_compiled_with_the_js_backend() ? { os.setenv('VCOLORS', 'never', true) - os.chdir(vroot) + os.chdir(vroot) or {} test_dir := 'vlib/v/gen/js/tests/testdata' main_files := get_main_files_in_dir(test_dir) fails := check_path(test_dir, main_files) ? diff --git a/vlib/v/gen/native/tests/native_test.v b/vlib/v/gen/native/tests/native_test.v index 7ed5507c3d..9ff8998368 100644 --- a/vlib/v/gen/native/tests/native_test.v +++ b/vlib/v/gen/native/tests/native_test.v @@ -22,7 +22,7 @@ fn test_native() { // wrkdir := os.join_path(os.temp_dir(), 'vtests', 'native') os.mkdir_all(wrkdir) or { panic(err) } - os.chdir(wrkdir) + os.chdir(wrkdir) or {} tests := files.filter(it.ends_with('.vv')) if tests.len == 0 { println('no native tests found') diff --git a/vlib/v/tests/multiple_paths_in_vmodules/vmodules_overrides_test.v b/vlib/v/tests/multiple_paths_in_vmodules/vmodules_overrides_test.v index c498792bfb..2cf744de21 100644 --- a/vlib/v/tests/multiple_paths_in_vmodules/vmodules_overrides_test.v +++ b/vlib/v/tests/multiple_paths_in_vmodules/vmodules_overrides_test.v @@ -16,7 +16,7 @@ fn test_vexe_is_set() { } fn test_compiling_without_vmodules_fails() { - os.chdir(vroot) + os.chdir(vroot) or {} os.setenv('VMODULES', '', true) res := os.execute('"$vexe" run "$mainvv"') assert res.exit_code == 1 @@ -24,7 +24,7 @@ fn test_compiling_without_vmodules_fails() { } fn test_compiling_with_vmodules_works() { - os.chdir(vroot) + os.chdir(vroot) or {} vmpaths := ['path1', 'path2', 'path3'].map(os.join_path(basepath, it)) os.setenv('VMODULES', vmpaths.join(os.path_delimiter), true) res := os.execute('"$vexe" run "$mainvv"') diff --git a/vlib/v/tests/run_project_folders_test.v b/vlib/v/tests/run_project_folders_test.v index 089d18354e..866def9889 100644 --- a/vlib/v/tests/run_project_folders_test.v +++ b/vlib/v/tests/run_project_folders_test.v @@ -11,7 +11,7 @@ fn test_vexe_exists() { } fn test_v_profile_works() ? { - os.chdir(vroot) + os.chdir(vroot) or {} folders_root := os.join_path(vroot, 'vlib/v/tests/run_project_folders') folder_names := os.ls(folders_root) ? mut folder_paths := []string{} diff --git a/vlib/v/tests/valgrind/valgrind_test.v b/vlib/v/tests/valgrind/valgrind_test.v index 620c47ec39..fc18276222 100644 --- a/vlib/v/tests/valgrind/valgrind_test.v +++ b/vlib/v/tests/valgrind/valgrind_test.v @@ -57,7 +57,7 @@ fn test_all() { // wrkdir := os.join_path(os.temp_dir(), 'vtests', 'valgrind') os.mkdir_all(wrkdir) or { panic(err) } - os.chdir(wrkdir) + os.chdir(wrkdir) or {} // only_ordinary_v_files := files.filter(it.ends_with('.v') && !it.ends_with('_test.v')) tests := vtest.filter_vtest_only(only_ordinary_v_files, basepath: valgrind_test_path)