all: update chmod/chdir usages

pull/11328/head
Alexander Medvednikov 2021-08-28 10:23:01 +03:00
parent 29f550158e
commit f731060caf
7 changed files with 19 additions and 19 deletions

View File

@ -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(['<', '&lt;', '>', '&gt;'])
@ -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') ?

View File

@ -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)

View File

@ -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.')

View File

@ -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)
}

View File

@ -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

View File

@ -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)
}

View File

@ -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 {