From f731060cafbb6a9cc71d97c881e5617d59893b26 Mon Sep 17 00:00:00 2001 From: Alexander Medvednikov Date: Sat, 28 Aug 2021 10:23:01 +0300 Subject: [PATCH] all: update chmod/chdir usages --- cmd/tools/fast/fast.v | 8 ++++---- cmd/tools/vdoctor.v | 2 +- vlib/io/util/util_test.v | 4 ++-- vlib/os/file_test.v | 4 ++-- vlib/os/glob_test.v | 10 +++++----- vlib/os/inode_test.v | 4 ++-- vlib/os/os_test.v | 6 +++--- 7 files changed, 19 insertions(+), 19 deletions(-) diff --git a/cmd/tools/fast/fast.v b/cmd/tools/fast/fast.v index a4b4650380..3b0b282172 100644 --- a/cmd/tools/fast/fast.v +++ b/cmd/tools/fast/fast.v @@ -16,7 +16,7 @@ const vdir = @VEXEROOT fn main() { dump(fast_dir) dump(vdir) - os.chdir(fast_dir) + os.chdir(fast_dir) ? if !os.exists('$vdir/v') && !os.is_dir('$vdir/vlib') { println('fast.html generator needs to be located in `v/cmd/tools/fast`') } @@ -49,7 +49,7 @@ fn main() { // println('Checking out ${commit}...') // exec('git checkout $commit') println(' Building vprod...') - os.chdir(vdir) + os.chdir(vdir) ? if os.args.contains('-noprod') { exec('./v -o vprod cmd/v') // for faster debugging } else { @@ -82,7 +82,7 @@ fn main() { commit_date := exec('git log -n1 --pretty="format:%at" $commit') date := time.unix(commit_date.int()) // - os.chdir(fast_dir) + os.chdir(fast_dir) ? mut out := os.create('table.html') ? // Place the new row on top html_message := message.replace_each(['<', '<', '>', '>']) @@ -120,7 +120,7 @@ fn main() { // Upload the result to github pages if os.args.contains('-upload') { println('uploading...') - os.chdir('website') + os.chdir('website') ? os.execute_or_exit('git checkout gh-pages') os.cp('../index.html', 'index.html') ? os.rm('../index.html') ? diff --git a/cmd/tools/vdoctor.v b/cmd/tools/vdoctor.v index 7eb8901342..05ebfb3e88 100644 --- a/cmd/tools/vdoctor.v +++ b/cmd/tools/vdoctor.v @@ -102,7 +102,7 @@ fn (mut a App) collect_info() { vmodules := os.vmodules_dir() vexe := os.getenv('VEXE') vroot := os.dir(vexe) - os.chdir(vroot) + os.chdir(vroot) or {} a.line('getwd', getwd) a.line('vmodules', vmodules) a.line('vroot', vroot) diff --git a/vlib/io/util/util_test.v b/vlib/io/util/util_test.v index 1072cb58b8..18f01649d1 100644 --- a/vlib/io/util/util_test.v +++ b/vlib/io/util/util_test.v @@ -13,12 +13,12 @@ fn testsuite_begin() { os.rmdir_all(tfolder) or {} assert !os.is_dir(tfolder) os.mkdir_all(tfolder) or { panic(err) } - os.chdir(tfolder) + os.chdir(tfolder) or {} assert os.is_dir(tfolder) } fn testsuite_end() { - os.chdir(os.wd_at_startup) + os.chdir(os.wd_at_startup) or {} os.rmdir_all(tfolder) or {} assert !os.is_dir(tfolder) // eprintln('testsuite_end , tfolder = $tfolder removed.') diff --git a/vlib/os/file_test.v b/vlib/os/file_test.v index 648c81c03c..3339ad828e 100644 --- a/vlib/os/file_test.v +++ b/vlib/os/file_test.v @@ -49,12 +49,12 @@ fn testsuite_begin() ? { os.rmdir_all(tfolder) or {} assert !os.is_dir(tfolder) os.mkdir_all(tfolder) ? - os.chdir(tfolder) + os.chdir(tfolder) ? assert os.is_dir(tfolder) } fn testsuite_end() ? { - os.chdir(os.wd_at_startup) + os.chdir(os.wd_at_startup) ? os.rmdir_all(tfolder) ? assert !os.is_dir(tfolder) } diff --git a/vlib/os/glob_test.v b/vlib/os/glob_test.v index c47311bbf7..889900c63c 100644 --- a/vlib/os/glob_test.v +++ b/vlib/os/glob_test.v @@ -1,7 +1,7 @@ import os fn deep_glob() ? { - os.chdir(@VMODROOT) + os.chdir(@VMODROOT) ? matches := os.glob('vlib/v/*/*.v') or { panic(err) } assert matches.len > 10 assert 'vlib/v/ast/ast.v' in matches @@ -16,7 +16,7 @@ fn deep_glob() ? { } fn redeep_glob() ? { - os.chdir(@VMODROOT) + os.chdir(@VMODROOT) ? matches := os.glob('vlib/v/**/*.v') or { panic(err) } assert matches.len > 10 assert 'vlib/v/ast/ast.v' in matches @@ -39,7 +39,7 @@ fn test_glob_can_find_v_files_3_levels_deep() ? { } fn test_glob_can_find_files_in_current_folder() ? { - os.chdir(@VMODROOT) + os.chdir(@VMODROOT) ? matches := os.glob('*') ? assert '.gitignore' in matches assert 'make.bat' in matches @@ -53,7 +53,7 @@ fn test_glob_can_find_files_in_current_folder() ? { } fn test_glob_can_be_used_with_multiple_patterns() ? { - os.chdir(@VMODROOT) + os.chdir(@VMODROOT) ? matches := os.glob('*', 'cmd/tools/*') ? assert 'README.md' in matches assert 'Makefile' in matches @@ -66,7 +66,7 @@ fn test_glob_can_be_used_with_multiple_patterns() ? { } fn test_glob_star() ? { - os.chdir(@VMODROOT) + os.chdir(@VMODROOT) ? matches := os.glob('*ake*') ? assert 'Makefile' in matches assert 'make.bat' in matches diff --git a/vlib/os/inode_test.v b/vlib/os/inode_test.v index 8cd8307583..f716bc2765 100644 --- a/vlib/os/inode_test.v +++ b/vlib/os/inode_test.v @@ -12,12 +12,12 @@ fn testsuite_begin() { rmdir_all(os.tfolder) or {} assert !is_dir(os.tfolder) mkdir_all(os.tfolder) or { panic(err) } - chdir(os.tfolder) + chdir(os.tfolder) or {} assert is_dir(os.tfolder) } fn testsuite_end() { - chdir(wd_at_startup) + chdir(wd_at_startup) or {} rmdir_all(os.tfolder) or { panic(err) } assert !is_dir(os.tfolder) } diff --git a/vlib/os/os_test.v b/vlib/os/os_test.v index 88cdd584be..2fff68ec2d 100644 --- a/vlib/os/os_test.v +++ b/vlib/os/os_test.v @@ -478,11 +478,11 @@ fn test_is_executable_writable_readable() { } f.close() $if !windows { - os.chmod(file_name, 0o600) // mark as readable && writable, but NOT executable + os.chmod(file_name, 0o600) or {} // mark as readable && writable, but NOT executable assert os.is_writable(file_name) assert os.is_readable(file_name) assert !os.is_executable(file_name) - os.chmod(file_name, 0o700) // mark as executable too + os.chmod(file_name, 0o700) or {} // mark as executable too assert os.is_executable(file_name) } $else { assert os.is_writable(file_name) @@ -640,7 +640,7 @@ fn test_posix_set_bit() { } $else { fpath := '/tmp/permtest' os.create(fpath) or { panic("Couldn't create file") } - os.chmod(fpath, 0o0777) + os.chmod(fpath, 0o0777) or { panic(err) } c_fpath := &char(fpath.str) mut s := C.stat{} unsafe {