ci: fix `v build-examples` and `v build-tools`

pull/11327/head
Delyan Angelov 2021-08-28 12:44:03 +03:00
parent 8a49a06201
commit 2b92ccecb5
No known key found for this signature in database
GPG Key ID: 66886C0F12D595ED
12 changed files with 21 additions and 18 deletions

View File

@ -42,7 +42,7 @@ fn main() {
vexe := pref.vexe_path() vexe := pref.vexe_path()
vroot := os.dir(vexe) vroot := os.dir(vexe)
util.set_vroot_folder(vroot) util.set_vroot_folder(vroot)
os.chdir(vroot) os.chdir(vroot) ?
cmd := diff.find_working_diff_command() or { '' } cmd := diff.find_working_diff_command() or { '' }
mut app := App{ mut app := App{
diff_cmd: cmd diff_cmd: cmd

View File

@ -215,7 +215,7 @@ fn (mut gen_vc GenVC) generate() {
} }
} }
// cd to gen_vc dir // cd to gen_vc dir
os.chdir(gen_vc.options.work_dir) os.chdir(gen_vc.options.work_dir) or {}
// if we are not running with the --serve flag (webhook server) // if we are not running with the --serve flag (webhook server)
// rather than deleting and re-downloading the repo each time // rather than deleting and re-downloading the repo each time
// first check to see if the local v repo is behind master // first check to see if the local v repo is behind master

View File

@ -85,7 +85,10 @@ fn modfn(mname string, fname string) string {
pub fn chdir(path string) { pub fn chdir(path string) {
verbose_trace_strong(modfn(@MOD, @FN), 'cd $path') verbose_trace_strong(modfn(@MOD, @FN), 'cd $path')
os.chdir(path) os.chdir(path) or {
verbose_trace(modfn(@MOD, @FN), '## failed.')
return
}
} }
pub fn mkdir(path string) ? { pub fn mkdir(path string) ? {

View File

@ -22,12 +22,12 @@ fn get_v_build_output(is_verbose bool, is_yes bool, file_path string) string {
mut vexe := os.getenv('VEXE') mut vexe := os.getenv('VEXE')
// prepare a V compiler with -g to have better backtraces if possible // prepare a V compiler with -g to have better backtraces if possible
wd := os.getwd() wd := os.getwd()
os.chdir(vroot) os.chdir(vroot) or {}
verbose_flag := if is_verbose { '-v' } else { '' } verbose_flag := if is_verbose { '-v' } else { '' }
vdbg_path := $if windows { '$vroot/vdbg.exe' } $else { '$vroot/vdbg' } vdbg_path := $if windows { '$vroot/vdbg.exe' } $else { '$vroot/vdbg' }
vdbg_compilation_cmd := '"$vexe" $verbose_flag -g -o "$vdbg_path" cmd/v' vdbg_compilation_cmd := '"$vexe" $verbose_flag -g -o "$vdbg_path" cmd/v'
vdbg_result := os.execute(vdbg_compilation_cmd) vdbg_result := os.execute(vdbg_compilation_cmd)
os.chdir(wd) os.chdir(wd) or {}
if vdbg_result.exit_code == 0 { if vdbg_result.exit_code == 0 {
vexe = vdbg_path vexe = vdbg_path
} else { } else {

View File

@ -23,7 +23,7 @@ fn main() {
args_string := os.args[1..].join(' ') args_string := os.args[1..].join(' ')
vexe := os.getenv('VEXE') vexe := os.getenv('VEXE')
vroot := os.dir(vexe) vroot := os.dir(vexe)
os.chdir(vroot) os.chdir(vroot) ?
folder := os.join_path('cmd', 'tools') folder := os.join_path('cmd', 'tools')
tfolder := os.join_path(vroot, 'cmd', 'tools') tfolder := os.join_path(vroot, 'cmd', 'tools')
main_label := 'Building $folder ...' main_label := 'Building $folder ...'

View File

@ -45,7 +45,7 @@ fn test_v_init() ? {
defer { defer {
os.rmdir_all(dir) or {} os.rmdir_all(dir) or {}
} }
os.chdir(dir) os.chdir(dir) ?
init_and_check() ? init_and_check() ?
} }
@ -57,7 +57,7 @@ fn test_v_init_in_git_dir() ? {
defer { defer {
os.rmdir_all(dir) or {} os.rmdir_all(dir) or {}
} }
os.chdir(dir) os.chdir(dir) ?
os.execute_or_exit('git init .') os.execute_or_exit('git init .')
init_and_check() ? init_and_check() ?
} }
@ -70,7 +70,7 @@ fn test_v_init_no_overwrite_gitignore() ? {
defer { defer {
os.rmdir_all(dir) or {} os.rmdir_all(dir) or {}
} }
os.chdir(dir) os.chdir(dir) ?
vexe := @VEXE vexe := @VEXE
os.execute_or_exit('$vexe init') os.execute_or_exit('$vexe init')

View File

@ -333,7 +333,7 @@ fn vpm_update(m []string) {
mut errors := 0 mut errors := 0
for name in module_names { for name in module_names {
final_module_path := valid_final_path_of_existing_module(name) or { continue } final_module_path := valid_final_path_of_existing_module(name) or { continue }
os.chdir(final_module_path) os.chdir(final_module_path) or {}
println('Updating module "$name"...') println('Updating module "$name"...')
verbose_println(' work folder: $final_module_path') verbose_println(' work folder: $final_module_path')
vcs := vcs_used_in_dir(final_module_path) or { continue } vcs := vcs_used_in_dir(final_module_path) or { continue }
@ -361,7 +361,7 @@ fn get_outdated() ?[]string {
mut outdated := []string{} mut outdated := []string{}
for name in module_names { for name in module_names {
final_module_path := valid_final_path_of_existing_module(name) or { continue } final_module_path := valid_final_path_of_existing_module(name) or { continue }
os.chdir(final_module_path) os.chdir(final_module_path) or {}
vcs := vcs_used_in_dir(final_module_path) or { continue } vcs := vcs_used_in_dir(final_module_path) or { continue }
vcs_cmd_steps := supported_vcs_outdated_steps[vcs[0]] vcs_cmd_steps := supported_vcs_outdated_steps[vcs[0]]
mut outputs := []string{} mut outputs := []string{}

View File

@ -11,7 +11,7 @@ fn main() {
vexe := pref.vexe_path() vexe := pref.vexe_path()
vroot := os.dir(vexe) vroot := os.dir(vexe)
recompilation.must_be_enabled(vroot, 'Please install V from source, to use `v self` .') recompilation.must_be_enabled(vroot, 'Please install V from source, to use `v self` .')
os.chdir(vroot) os.chdir(vroot) ?
os.setenv('VCOLORS', 'always', true) os.setenv('VCOLORS', 'always', true)
args := os.args[1..].filter(it != 'self') args := os.args[1..].filter(it != 'self')
jargs := args.join(' ') jargs := args.join(' ')

View File

@ -156,7 +156,7 @@ fn get_all_commands() []Command {
fn (mut cmd Command) run() { fn (mut cmd Command) run() {
// Changing the current directory is needed for some of the compiler tests, // Changing the current directory is needed for some of the compiler tests,
// vlib/v/tests/local_test.v and vlib/v/tests/repl/repl_test.v // vlib/v/tests/local_test.v and vlib/v/tests/repl/repl_test.v
os.chdir(vroot) os.chdir(vroot) or {}
if cmd.label != '' { if cmd.label != '' {
println(term.header_left(cmd.label, '*')) println(term.header_left(cmd.label, '*'))
} }

View File

@ -64,7 +64,7 @@ fn main() {
} }
fn tsession(vargs string, tool_source string, tool_cmd string, tool_args string, flist []string, slist []string) testing.TestSession { fn tsession(vargs string, tool_source string, tool_cmd string, tool_args string, flist []string, slist []string) testing.TestSession {
os.chdir(vroot) os.chdir(vroot) or {}
title_message := 'running $tool_cmd over most .v files' title_message := 'running $tool_cmd over most .v files'
testing.eheader(title_message) testing.eheader(title_message)
mut test_session := testing.new_test_session('$vargs $tool_args', false) mut test_session := testing.new_test_session('$vargs $tool_args', false)

View File

@ -6,7 +6,7 @@ import v.pref
fn main() { fn main() {
vexe := pref.vexe_path() vexe := pref.vexe_path()
vroot := os.dir(vexe) vroot := os.dir(vexe)
os.chdir(vroot) os.chdir(vroot) ?
os.setenv('VCOLORS', 'always', true) os.setenv('VCOLORS', 'always', true)
self_idx := os.args.index('tracev') self_idx := os.args.index('tracev')
args := os.args[1..self_idx] args := os.args[1..self_idx]

View File

@ -21,14 +21,14 @@ fn test_vexe() {
} }
fn test_can_compile_library() { fn test_can_compile_library() {
os.chdir(cfolder) os.chdir(cfolder) or {}
os.rm(library_file_name) or {} os.rm(library_file_name) or {}
v_compile('-d no_backtrace -o library -shared modules/library/library.v') v_compile('-d no_backtrace -o library -shared modules/library/library.v')
assert os.is_file(library_file_name) assert os.is_file(library_file_name)
} }
fn test_can_compile_main_program() { fn test_can_compile_main_program() {
os.chdir(cfolder) os.chdir(cfolder) or {}
assert os.is_file(library_file_name) assert os.is_file(library_file_name)
result := v_compile('run use.v') result := v_compile('run use.v')
// dump(result) // dump(result)
@ -37,7 +37,7 @@ fn test_can_compile_main_program() {
} }
fn test_can_compile_and_use_library_with_skip_unused() { fn test_can_compile_and_use_library_with_skip_unused() {
os.chdir(cfolder) os.chdir(cfolder) or {}
os.rm(library_file_name) or {} os.rm(library_file_name) or {}
v_compile('-skip-unused -d no_backtrace -o library -shared modules/library/library.v') v_compile('-skip-unused -d no_backtrace -o library -shared modules/library/library.v')
assert os.is_file(library_file_name) assert os.is_file(library_file_name)