os: add os.quoted_path/1, use it consistently for running V itself
parent
85ec0248e9
commit
fa6f7d4c83
|
@ -8,7 +8,7 @@ const vroot = @VMODROOT
|
||||||
fn get_vdoctor_output(is_verbose bool) string {
|
fn get_vdoctor_output(is_verbose bool) string {
|
||||||
vexe := os.getenv('VEXE')
|
vexe := os.getenv('VEXE')
|
||||||
verbose_flag := if is_verbose { '-v' } else { '' }
|
verbose_flag := if is_verbose { '-v' } else { '' }
|
||||||
result := os.execute('$vexe $verbose_flag doctor')
|
result := os.execute('${os.quoted_path(vexe)} $verbose_flag doctor')
|
||||||
if result.exit_code != 0 {
|
if result.exit_code != 0 {
|
||||||
eprintln('unable to get `v doctor` output: $result.output')
|
eprintln('unable to get `v doctor` output: $result.output')
|
||||||
return ''
|
return ''
|
||||||
|
@ -24,7 +24,7 @@ fn get_v_build_output(is_verbose bool, is_yes bool, file_path string) string {
|
||||||
os.chdir(vroot) or {}
|
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 := '${os.quoted_path(vexe)} $verbose_flag -g -o ${os.quoted_path(vdbg_path)} cmd/v'
|
||||||
vdbg_result := os.execute(vdbg_compilation_cmd)
|
vdbg_result := os.execute(vdbg_compilation_cmd)
|
||||||
os.chdir(wd) or {}
|
os.chdir(wd) or {}
|
||||||
if vdbg_result.exit_code == 0 {
|
if vdbg_result.exit_code == 0 {
|
||||||
|
@ -33,7 +33,7 @@ fn get_v_build_output(is_verbose bool, is_yes bool, file_path string) string {
|
||||||
eprintln('unable to compile V in debug mode: $vdbg_result.output\ncommand: $vdbg_compilation_cmd\n')
|
eprintln('unable to compile V in debug mode: $vdbg_result.output\ncommand: $vdbg_compilation_cmd\n')
|
||||||
}
|
}
|
||||||
//
|
//
|
||||||
mut result := os.execute('"$vexe" $verbose_flag "$file_path"')
|
mut result := os.execute('${os.quoted_path(vexe)} $verbose_flag ${os.quoted_path(file_path)}')
|
||||||
defer {
|
defer {
|
||||||
os.rm(vdbg_path) or {
|
os.rm(vdbg_path) or {
|
||||||
if is_verbose {
|
if is_verbose {
|
||||||
|
@ -56,7 +56,7 @@ fn get_v_build_output(is_verbose bool, is_yes bool, file_path string) string {
|
||||||
run := is_yes
|
run := is_yes
|
||||||
|| ask('It looks like the compilation went well, do you want to run the file?')
|
|| ask('It looks like the compilation went well, do you want to run the file?')
|
||||||
if run {
|
if run {
|
||||||
result = os.execute('"$vexe" $verbose_flag run "$file_path"')
|
result = os.execute('${os.quoted_path(vexe)} $verbose_flag run ${os.quoted_path(file_path)}')
|
||||||
if result.exit_code == 0 && !is_yes {
|
if result.exit_code == 0 && !is_yes {
|
||||||
confirm_or_exit('It looks like the file ran correctly as well, are you sure you want to continue?')
|
confirm_or_exit('It looks like the file ran correctly as well, are you sure you want to continue?')
|
||||||
}
|
}
|
||||||
|
|
|
@ -69,22 +69,19 @@ fn run_individual_test(case BumpTestCase) ? {
|
||||||
|
|
||||||
os.rm(test_file) or {}
|
os.rm(test_file) or {}
|
||||||
os.write_file(test_file, case.contents) ?
|
os.write_file(test_file, case.contents) ?
|
||||||
|
//
|
||||||
|
os.execute_or_exit('${os.quoted_path(vexe)} bump --patch ${os.quoted_path(test_file)}')
|
||||||
|
patch_lines := os.read_lines(test_file) ?
|
||||||
|
assert patch_lines[case.line] == case.expected_patch
|
||||||
|
|
||||||
{
|
os.execute_or_exit('${os.quoted_path(vexe)} bump --minor ${os.quoted_path(test_file)}')
|
||||||
os.execute_or_exit('$vexe bump --patch $test_file')
|
minor_lines := os.read_lines(test_file) ?
|
||||||
patch_lines := os.read_lines(test_file) ?
|
assert minor_lines[case.line] == case.expected_minor
|
||||||
assert patch_lines[case.line] == case.expected_patch
|
|
||||||
}
|
os.execute_or_exit('${os.quoted_path(vexe)} bump --major ${os.quoted_path(test_file)}')
|
||||||
{
|
major_lines := os.read_lines(test_file) ?
|
||||||
os.execute_or_exit('$vexe bump --minor $test_file')
|
assert major_lines[case.line] == case.expected_major
|
||||||
minor_lines := os.read_lines(test_file) ?
|
//
|
||||||
assert minor_lines[case.line] == case.expected_minor
|
|
||||||
}
|
|
||||||
{
|
|
||||||
os.execute_or_exit('$vexe bump --major $test_file')
|
|
||||||
major_lines := os.read_lines(test_file) ?
|
|
||||||
assert major_lines[case.line] == case.expected_major
|
|
||||||
}
|
|
||||||
os.rm(test_file) ?
|
os.rm(test_file) ?
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -3,8 +3,7 @@ import os
|
||||||
const test_path = 'vcreate_test'
|
const test_path = 'vcreate_test'
|
||||||
|
|
||||||
fn init_and_check() ? {
|
fn init_and_check() ? {
|
||||||
vexe := @VEXE
|
os.execute_or_exit('${os.quoted_path(@VEXE)} init')
|
||||||
os.execute_or_exit('$vexe init')
|
|
||||||
|
|
||||||
assert os.read_file('vcreate_test.v') ? == [
|
assert os.read_file('vcreate_test.v') ? == [
|
||||||
'module main\n',
|
'module main\n',
|
||||||
|
@ -92,8 +91,7 @@ fn test_v_init_no_overwrite_gitignore() ? {
|
||||||
}
|
}
|
||||||
os.chdir(dir) ?
|
os.chdir(dir) ?
|
||||||
|
|
||||||
vexe := @VEXE
|
os.execute_or_exit('${os.quoted_path(@VEXE)} init')
|
||||||
os.execute_or_exit('$vexe init')
|
|
||||||
|
|
||||||
assert os.read_file('.gitignore') ? == 'blah'
|
assert os.read_file('.gitignore') ? == 'blah'
|
||||||
}
|
}
|
||||||
|
@ -121,8 +119,7 @@ indent_size = 4
|
||||||
}
|
}
|
||||||
os.chdir(dir) ?
|
os.chdir(dir) ?
|
||||||
|
|
||||||
vexe := @VEXE
|
os.execute_or_exit('${os.quoted_path(@VEXE)} init')
|
||||||
os.execute_or_exit('$vexe init')
|
|
||||||
|
|
||||||
assert os.read_file('.gitattributes') ? == git_attributes_content
|
assert os.read_file('.gitattributes') ? == git_attributes_content
|
||||||
assert os.read_file('.editorconfig') ? == editor_config_content
|
assert os.read_file('.editorconfig') ? == editor_config_content
|
||||||
|
|
|
@ -35,7 +35,7 @@ fn check_path(vexe string, dir string, tests []string) int {
|
||||||
for path in paths {
|
for path in paths {
|
||||||
program := path
|
program := path
|
||||||
print(path + ' ')
|
print(path + ' ')
|
||||||
res := os.execute('$vexe doc $program')
|
res := os.execute('${os.quoted_path(vexe)} doc ${os.quoted_path(program)}')
|
||||||
if res.exit_code < 0 {
|
if res.exit_code < 0 {
|
||||||
panic(res.output)
|
panic(res.output)
|
||||||
}
|
}
|
||||||
|
@ -46,7 +46,7 @@ fn check_path(vexe string, dir string, tests []string) int {
|
||||||
print_compare(expected, found)
|
print_compare(expected, found)
|
||||||
}
|
}
|
||||||
|
|
||||||
res_comments := os.execute('$vexe doc -comments $program')
|
res_comments := os.execute('${os.quoted_path(vexe)} doc -comments ${os.quoted_path(program)}')
|
||||||
if res_comments.exit_code < 0 {
|
if res_comments.exit_code < 0 {
|
||||||
panic(res_comments.output)
|
panic(res_comments.output)
|
||||||
}
|
}
|
||||||
|
|
|
@ -505,7 +505,7 @@ fn parse_arguments(args []string) Config {
|
||||||
fn main() {
|
fn main() {
|
||||||
if os.args.len < 2 || '-h' in os.args || '-help' in os.args || '--help' in os.args
|
if os.args.len < 2 || '-h' in os.args || '-help' in os.args || '--help' in os.args
|
||||||
|| os.args[1..] == ['doc', 'help'] {
|
|| os.args[1..] == ['doc', 'help'] {
|
||||||
os.system('$vexe help doc')
|
os.system('${os.quoted_path(vexe)} help doc')
|
||||||
exit(0)
|
exit(0)
|
||||||
}
|
}
|
||||||
args := os.args[2..].clone()
|
args := os.args[2..].clone()
|
||||||
|
|
|
@ -92,7 +92,11 @@ fn main() {
|
||||||
exit(0)
|
exit(0)
|
||||||
}
|
}
|
||||||
mut cli_args_no_files := []string{}
|
mut cli_args_no_files := []string{}
|
||||||
for a in os.args {
|
for idx, a in os.args {
|
||||||
|
if idx == 0 {
|
||||||
|
cli_args_no_files << os.quoted_path(a)
|
||||||
|
continue
|
||||||
|
}
|
||||||
if a !in files {
|
if a !in files {
|
||||||
cli_args_no_files << a
|
cli_args_no_files << a
|
||||||
}
|
}
|
||||||
|
|
|
@ -381,7 +381,7 @@ fn repl_run_vfile(file string) ?os.Result {
|
||||||
$if trace_repl_temp_files ? {
|
$if trace_repl_temp_files ? {
|
||||||
eprintln('>> repl_run_vfile file: $file')
|
eprintln('>> repl_run_vfile file: $file')
|
||||||
}
|
}
|
||||||
s := os.execute('"$vexe" -repl run "$file"')
|
s := os.execute('${os.quoted_path(vexe)} -repl run ${os.quoted_path(file)}')
|
||||||
if s.exit_code < 0 {
|
if s.exit_code < 0 {
|
||||||
rerror(s.output)
|
rerror(s.output)
|
||||||
return error(s.output)
|
return error(s.output)
|
||||||
|
|
|
@ -21,7 +21,7 @@ fn main() {
|
||||||
jargs := args.join(' ')
|
jargs := args.join(' ')
|
||||||
obinary := cmdline.option(args, '-o', '')
|
obinary := cmdline.option(args, '-o', '')
|
||||||
sargs := if obinary != '' { jargs } else { '$jargs -o v2' }
|
sargs := if obinary != '' { jargs } else { '$jargs -o v2' }
|
||||||
cmd := '$vexe $sargs cmd/v'
|
cmd := '${os.quoted_path(vexe)} $sargs ${os.quoted_path('cmd/v')}'
|
||||||
options := if args.len > 0 { '($sargs)' } else { '' }
|
options := if args.len > 0 { '($sargs)' } else { '' }
|
||||||
println('V self compiling ${options}...')
|
println('V self compiling ${options}...')
|
||||||
compile(vroot, cmd)
|
compile(vroot, cmd)
|
||||||
|
|
|
@ -13,5 +13,5 @@ fn main() {
|
||||||
args_str := args.join(' ')
|
args_str := args.join(' ')
|
||||||
options := if args.len > 0 { '($args_str)' } else { '' }
|
options := if args.len > 0 { '($args_str)' } else { '' }
|
||||||
println('Compiling a `tracev` executable ${options}...')
|
println('Compiling a `tracev` executable ${options}...')
|
||||||
os.system('"$vexe" -cg -d trace_parser -d trace_checker -d trace_gen -o tracev $args_str cmd/v')
|
os.system('${os.quoted_path(vexe)} -cg -d trace_parser -d trace_checker -d trace_gen -o tracev $args_str cmd/v')
|
||||||
}
|
}
|
||||||
|
|
|
@ -69,7 +69,7 @@ fn (app App) update_from_master() {
|
||||||
fn (app App) recompile_v() {
|
fn (app App) recompile_v() {
|
||||||
// NB: app.vexe is more reliable than just v (which may be a symlink)
|
// NB: app.vexe is more reliable than just v (which may be a symlink)
|
||||||
opts := if app.is_prod { '-prod' } else { '' }
|
opts := if app.is_prod { '-prod' } else { '' }
|
||||||
vself := '"$app.vexe" $opts self'
|
vself := '${os.quoted_path(app.vexe)} $opts self'
|
||||||
app.vprintln('> recompiling v itself with `$vself` ...')
|
app.vprintln('> recompiling v itself with `$vself` ...')
|
||||||
self_result := os.execute(vself)
|
self_result := os.execute(vself)
|
||||||
if self_result.exit_code == 0 {
|
if self_result.exit_code == 0 {
|
||||||
|
@ -83,7 +83,7 @@ fn (app App) recompile_v() {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn (app App) recompile_vup() {
|
fn (app App) recompile_vup() {
|
||||||
vup_result := os.execute('"$app.vexe" -g cmd/tools/vup.v')
|
vup_result := os.execute('${os.quoted_path(app.vexe)} -g cmd/tools/vup.v')
|
||||||
if vup_result.exit_code != 0 {
|
if vup_result.exit_code != 0 {
|
||||||
eprintln('recompiling vup.v failed:')
|
eprintln('recompiling vup.v failed:')
|
||||||
eprintln(vup_result.output)
|
eprintln(vup_result.output)
|
||||||
|
@ -106,7 +106,7 @@ fn (app App) make(vself string) {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn (app App) show_current_v_version() {
|
fn (app App) show_current_v_version() {
|
||||||
vout := os.execute('"$app.vexe" version')
|
vout := os.execute('${os.quoted_path(app.vexe)} version')
|
||||||
if vout.exit_code >= 0 {
|
if vout.exit_code >= 0 {
|
||||||
mut vversion := vout.output.trim_space()
|
mut vversion := vout.output.trim_space()
|
||||||
if vout.exit_code == 0 {
|
if vout.exit_code == 0 {
|
||||||
|
@ -153,7 +153,7 @@ fn (app App) get_git() {
|
||||||
eprintln('Unable to install git automatically: please install git manually')
|
eprintln('Unable to install git automatically: please install git manually')
|
||||||
panic(res_download.output)
|
panic(res_download.output)
|
||||||
}
|
}
|
||||||
res_git32 := os.execute('$os.getwd()/git32.exe')
|
res_git32 := os.execute(os.quoted_path(os.join_path_single(os.getwd(), 'git32.exe')))
|
||||||
if res_git32.exit_code != 0 {
|
if res_git32.exit_code != 0 {
|
||||||
eprintln('Unable to install git automatically: please install git manually')
|
eprintln('Unable to install git automatically: please install git manually')
|
||||||
panic(res_git32.output)
|
panic(res_git32.output)
|
||||||
|
|
|
@ -35,7 +35,7 @@ fn check_path(vexe string, dir string, tests []string) int {
|
||||||
program := path
|
program := path
|
||||||
print(path + ' ')
|
print(path + ' ')
|
||||||
// -force is needed so that `v vet` would not skip the regression files
|
// -force is needed so that `v vet` would not skip the regression files
|
||||||
res := os.execute('$vexe vet -force -nocolor $program')
|
res := os.execute('${os.quoted_path(vexe)} vet -force -nocolor ${os.quoted_path(program)}')
|
||||||
if res.exit_code < 0 {
|
if res.exit_code < 0 {
|
||||||
panic(res.output)
|
panic(res.output)
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,22 +1,21 @@
|
||||||
import os
|
import os
|
||||||
|
|
||||||
|
const vexe = os.getenv('VEXE')
|
||||||
|
|
||||||
fn test_help() {
|
fn test_help() {
|
||||||
vexe := os.getenv('VEXE')
|
res := os.execute('${os.quoted_path(vexe)} help')
|
||||||
res := os.execute('"$vexe" help')
|
|
||||||
assert res.exit_code == 0
|
assert res.exit_code == 0
|
||||||
assert res.output.starts_with('V is a tool for managing V source code.')
|
assert res.output.starts_with('V is a tool for managing V source code.')
|
||||||
}
|
}
|
||||||
|
|
||||||
fn test_help_as_short_option() {
|
fn test_help_as_short_option() {
|
||||||
vexe := os.getenv('VEXE')
|
res := os.execute('${os.quoted_path(vexe)} -h')
|
||||||
res := os.execute('"$vexe" -h')
|
|
||||||
assert res.exit_code == 0
|
assert res.exit_code == 0
|
||||||
assert res.output.starts_with('V is a tool for managing V source code.')
|
assert res.output.starts_with('V is a tool for managing V source code.')
|
||||||
}
|
}
|
||||||
|
|
||||||
fn test_help_as_long_option() {
|
fn test_help_as_long_option() {
|
||||||
vexe := os.getenv('VEXE')
|
res := os.execute('${os.quoted_path(vexe)} --help')
|
||||||
res := os.execute('"$vexe" --help')
|
|
||||||
assert res.exit_code == 0
|
assert res.exit_code == 0
|
||||||
assert res.output.starts_with('V is a tool for managing V source code.')
|
assert res.output.starts_with('V is a tool for managing V source code.')
|
||||||
}
|
}
|
||||||
|
|
|
@ -3803,7 +3803,7 @@ file, can easily run *other* test files like this:
|
||||||
import os
|
import os
|
||||||
|
|
||||||
fn test_subtest() {
|
fn test_subtest() {
|
||||||
res := os.execute('${@VEXE} other_test.v')
|
res := os.execute('${os.quoted_path(@VEXE)} other_test.v')
|
||||||
assert res.exit_code == 1
|
assert res.exit_code == 1
|
||||||
assert res.output.contains('other_test.v does not exist')
|
assert res.output.contains('other_test.v does not exist')
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,7 +6,7 @@ fn main() {
|
||||||
exit(1)
|
exit(1)
|
||||||
}
|
}
|
||||||
cc := os.args[1]
|
cc := os.args[1]
|
||||||
if os.execute('$cc -v').exit_code != 0 {
|
if os.execute('${os.quoted_path(cc)} -v').exit_code != 0 {
|
||||||
eprintln('please specify a valid C++ compiler')
|
eprintln('please specify a valid C++ compiler')
|
||||||
exit(1)
|
exit(1)
|
||||||
}
|
}
|
||||||
|
@ -54,7 +54,7 @@ fn get_cc_info(cc string) (string, string, string) {
|
||||||
'none'
|
'none'
|
||||||
}
|
}
|
||||||
|
|
||||||
lines := os.execute('$cc -v').output.split('\n')
|
lines := os.execute('${os.quoted_path(cc)} -v').output.split('\n')
|
||||||
|
|
||||||
// gcc and clang both have the same way way to say what version they have and what the host target triple is
|
// gcc and clang both have the same way way to say what version they have and what the host target triple is
|
||||||
cc_version := lines.filter(it.contains('$cc_type version '))[0].all_after('$cc_type version ').all_before('.')
|
cc_version := lines.filter(it.contains('$cc_type version '))[0].all_after('$cc_type version ').all_before('.')
|
||||||
|
@ -69,7 +69,7 @@ fn get_cc_info(cc string) (string, string, string) {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_search_paths(cc string) []string {
|
fn get_search_paths(cc string) []string {
|
||||||
result := os.execute('$cc -v -x c++ /dev/null').output
|
result := os.execute('${os.quoted_path(cc)} -v -x c++ /dev/null').output
|
||||||
lines := result.split('\n')
|
lines := result.split('\n')
|
||||||
search_path := lines[lines.index('#include <...> search starts here:') + 1..lines.index('End of search list.')]
|
search_path := lines[lines.index('#include <...> search starts here:') + 1..lines.index('End of search list.')]
|
||||||
return search_path.map(os.real_path(it.all_before('(').trim_space()))
|
return search_path.map(os.real_path(it.all_before('(').trim_space()))
|
||||||
|
|
|
@ -7,7 +7,7 @@ const simple_flag_app_executable = os.real_path(os.join_path(os.cache_dir(), 'si
|
||||||
fn testsuite_begin() {
|
fn testsuite_begin() {
|
||||||
os.chdir(@VMODROOT) or {}
|
os.chdir(@VMODROOT) or {}
|
||||||
os.rm(simple_flag_app_executable) or {}
|
os.rm(simple_flag_app_executable) or {}
|
||||||
res := os.execute('${@VEXE} -o $simple_flag_app_executable $source')
|
res := os.execute('${os.quoted_path(@VEXE)} -o ${os.quoted_path(simple_flag_app_executable)} ${os.quoted_path(source)}')
|
||||||
assert res.exit_code == 0
|
assert res.exit_code == 0
|
||||||
assert os.execute(simple_flag_app_executable).exit_code == 0
|
assert os.execute(simple_flag_app_executable).exit_code == 0
|
||||||
}
|
}
|
||||||
|
@ -19,7 +19,7 @@ fn testsuite_end() {
|
||||||
|
|
||||||
fn check_program(opts string, extension string) {
|
fn check_program(opts string, extension string) {
|
||||||
result := source.replace('.v', extension)
|
result := source.replace('.v', extension)
|
||||||
res := os.execute('$simple_flag_app_executable $opts')
|
res := os.execute('${os.quoted_path(simple_flag_app_executable)} $opts')
|
||||||
lines := os.read_lines(result) or { panic(err) }
|
lines := os.read_lines(result) or { panic(err) }
|
||||||
assert res.exit_code == 0
|
assert res.exit_code == 0
|
||||||
assert res.output.split_into_lines() == lines
|
assert res.output.split_into_lines() == lines
|
||||||
|
|
|
@ -7,9 +7,9 @@ const the_executable = os.real_path(os.join_path(os.cache_dir(), 'flag_usage_exa
|
||||||
fn testsuite_begin() {
|
fn testsuite_begin() {
|
||||||
os.chdir(@VMODROOT) or {}
|
os.chdir(@VMODROOT) or {}
|
||||||
os.rm(the_executable) or {}
|
os.rm(the_executable) or {}
|
||||||
res := os.execute('${@VEXE} -o $the_executable $the_source')
|
res := os.execute('${os.quoted_path(@VEXE)} -o ${os.quoted_path(the_executable)} ${os.quoted_path(the_source)}')
|
||||||
assert res.exit_code == 0
|
assert res.exit_code == 0
|
||||||
assert os.execute(the_executable).exit_code == 0
|
assert os.execute(os.quoted_path(the_executable)).exit_code == 0
|
||||||
C.atexit(fn () {
|
C.atexit(fn () {
|
||||||
os.rm(the_executable) or {}
|
os.rm(the_executable) or {}
|
||||||
})
|
})
|
||||||
|
@ -21,7 +21,7 @@ fn normalise_lines(lines []string) string {
|
||||||
|
|
||||||
fn check_program(opts string, extension string) {
|
fn check_program(opts string, extension string) {
|
||||||
result := the_source.replace('.v', extension)
|
result := the_source.replace('.v', extension)
|
||||||
res := os.execute('$the_executable $opts')
|
res := os.execute('${os.quoted_path(the_executable)} $opts')
|
||||||
assert res.exit_code == 0
|
assert res.exit_code == 0
|
||||||
assert normalise_lines(res.output.split_into_lines()) == normalise_lines(os.read_lines(result) or {
|
assert normalise_lines(res.output.split_into_lines()) == normalise_lines(os.read_lines(result) or {
|
||||||
panic(err)
|
panic(err)
|
||||||
|
|
|
@ -745,3 +745,12 @@ pub fn execute_or_exit(cmd string) Result {
|
||||||
}
|
}
|
||||||
return res
|
return res
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// quoted path - return a quoted version of the path, depending on the platform.
|
||||||
|
pub fn quoted_path(path string) string {
|
||||||
|
$if windows {
|
||||||
|
return '"$path"'
|
||||||
|
} $else {
|
||||||
|
return "'$path'"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -851,7 +851,7 @@ fn test_execute() ? {
|
||||||
defer {
|
defer {
|
||||||
os.rm(print0script) or {}
|
os.rm(print0script) or {}
|
||||||
}
|
}
|
||||||
result := os.execute('"' + @VEXE + '" run "$print0script"')
|
result := os.execute('${os.quoted_path(@VEXE)} run ${os.quoted_path(print0script)}')
|
||||||
hexresult := result.output.bytes().hex()
|
hexresult := result.output.bytes().hex()
|
||||||
// println('exit_code: $result.exit_code')
|
// println('exit_code: $result.exit_code')
|
||||||
// println('output: |$result.output|')
|
// println('output: |$result.output|')
|
||||||
|
|
|
@ -18,7 +18,7 @@ fn testsuite_begin() ? {
|
||||||
// WINE_TEST_OS_PROCESS_EXE=x.exe ./v -os windows vlib/os/process_test.v
|
// WINE_TEST_OS_PROCESS_EXE=x.exe ./v -os windows vlib/os/process_test.v
|
||||||
os.cp(os.getenv('WINE_TEST_OS_PROCESS_EXE'), test_os_process) ?
|
os.cp(os.getenv('WINE_TEST_OS_PROCESS_EXE'), test_os_process) ?
|
||||||
} else {
|
} else {
|
||||||
os.system('$vexe -o $test_os_process $test_os_process_source')
|
os.system('${os.quoted_path(vexe)} -o ${os.quoted_path(test_os_process)} ${os.quoted_path(test_os_process_source)}')
|
||||||
}
|
}
|
||||||
assert os.exists(test_os_process)
|
assert os.exists(test_os_process)
|
||||||
}
|
}
|
||||||
|
|
|
@ -43,7 +43,7 @@ pub fn (mut v Builder) find_win_cc() ? {
|
||||||
$if !windows {
|
$if !windows {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
ccompiler_version_res := os.execute('$v.pref.ccompiler -v')
|
ccompiler_version_res := os.execute('${os.quoted_path(v.pref.ccompiler)} -v')
|
||||||
if ccompiler_version_res.exit_code != 0 {
|
if ccompiler_version_res.exit_code != 0 {
|
||||||
if v.pref.is_verbose {
|
if v.pref.is_verbose {
|
||||||
println('$v.pref.ccompiler not found, looking for msvc...')
|
println('$v.pref.ccompiler not found, looking for msvc...')
|
||||||
|
@ -54,7 +54,7 @@ pub fn (mut v Builder) find_win_cc() ? {
|
||||||
}
|
}
|
||||||
vpath := os.dir(pref.vexe_path())
|
vpath := os.dir(pref.vexe_path())
|
||||||
thirdparty_tcc := os.join_path(vpath, 'thirdparty', 'tcc', 'tcc.exe')
|
thirdparty_tcc := os.join_path(vpath, 'thirdparty', 'tcc', 'tcc.exe')
|
||||||
tcc_version_res := os.execute('$thirdparty_tcc -v')
|
tcc_version_res := os.execute('${os.quoted_path(thirdparty_tcc)} -v')
|
||||||
if tcc_version_res.exit_code != 0 {
|
if tcc_version_res.exit_code != 0 {
|
||||||
if v.pref.is_verbose {
|
if v.pref.is_verbose {
|
||||||
println('tcc not found')
|
println('tcc not found')
|
||||||
|
@ -207,7 +207,7 @@ fn (mut v Builder) setup_ccompiler_options(ccompiler string) {
|
||||||
ccoptions.guessed_compiler = v.pref.ccompiler
|
ccoptions.guessed_compiler = v.pref.ccompiler
|
||||||
if ccoptions.guessed_compiler == 'cc' && v.pref.is_prod {
|
if ccoptions.guessed_compiler == 'cc' && v.pref.is_prod {
|
||||||
// deliberately guessing only for -prod builds for performance reasons
|
// deliberately guessing only for -prod builds for performance reasons
|
||||||
ccversion := os.execute('cc --version')
|
ccversion := os.execute('${os.quoted_path('cc')} --version')
|
||||||
if ccversion.exit_code == 0 {
|
if ccversion.exit_code == 0 {
|
||||||
if ccversion.output.contains('This is free software;')
|
if ccversion.output.contains('This is free software;')
|
||||||
&& ccversion.output.contains('Free Software Foundation, Inc.') {
|
&& ccversion.output.contains('Free Software Foundation, Inc.') {
|
||||||
|
@ -548,7 +548,8 @@ pub fn (mut v Builder) cc() {
|
||||||
$if trace_stdatomic_gen ? {
|
$if trace_stdatomic_gen ? {
|
||||||
eprintln('> creating $cpp_atomic_h_path ...')
|
eprintln('> creating $cpp_atomic_h_path ...')
|
||||||
}
|
}
|
||||||
os.execute('$vexe run ${@VEXEROOT}/thirdparty/stdatomic/nix/cpp/gen.v $ccompiler')
|
cppgenv := '${@VEXEROOT}/thirdparty/stdatomic/nix/cpp/gen.v'
|
||||||
|
os.execute('${os.quoted_path(vexe)} run ${os.quoted_path(cppgenv)} ${os.quoted_path(ccompiler)}')
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -566,13 +567,14 @@ pub fn (mut v Builder) cc() {
|
||||||
all_args := v.all_args(v.ccoptions)
|
all_args := v.all_args(v.ccoptions)
|
||||||
v.dump_c_options(all_args)
|
v.dump_c_options(all_args)
|
||||||
str_args := all_args.join(' ')
|
str_args := all_args.join(' ')
|
||||||
mut cmd := '$ccompiler $str_args'
|
mut cmd := '${os.quoted_path(ccompiler)} $str_args'
|
||||||
mut response_file := ''
|
mut response_file := ''
|
||||||
mut response_file_content := str_args
|
mut response_file_content := str_args
|
||||||
if !v.pref.no_rsp {
|
if !v.pref.no_rsp {
|
||||||
response_file = '${v.out_name_c}.rsp'
|
response_file = '${v.out_name_c}.rsp'
|
||||||
response_file_content = str_args.replace('\\', '\\\\')
|
response_file_content = str_args.replace('\\', '\\\\')
|
||||||
cmd = '$ccompiler "@$response_file"'
|
rspexpr := '@$response_file'
|
||||||
|
cmd = '${os.quoted_path(ccompiler)} ${os.quoted_path(rspexpr)}'
|
||||||
os.write_file(response_file, response_file_content) or {
|
os.write_file(response_file, response_file_content) or {
|
||||||
verror('Unable to write to C response file "$response_file"')
|
verror('Unable to write to C response file "$response_file"')
|
||||||
}
|
}
|
||||||
|
@ -729,7 +731,7 @@ fn (mut b Builder) cc_linux_cross() {
|
||||||
cc_args << '-c "$b.out_name_c"'
|
cc_args << '-c "$b.out_name_c"'
|
||||||
cc_args << libs
|
cc_args << libs
|
||||||
b.dump_c_options(cc_args)
|
b.dump_c_options(cc_args)
|
||||||
cc_cmd := 'cc ' + cc_args.join(' ')
|
cc_cmd := '${os.quoted_path('cc')} ' + cc_args.join(' ')
|
||||||
if b.pref.show_cc {
|
if b.pref.show_cc {
|
||||||
println(cc_cmd)
|
println(cc_cmd)
|
||||||
}
|
}
|
||||||
|
@ -747,7 +749,8 @@ fn (mut b Builder) cc_linux_cross() {
|
||||||
linker_args << cflags.c_options_only_object_files()
|
linker_args << cflags.c_options_only_object_files()
|
||||||
// -ldl
|
// -ldl
|
||||||
b.dump_c_options(linker_args)
|
b.dump_c_options(linker_args)
|
||||||
linker_cmd := '$sysroot/ld.lld ' + linker_args.join(' ')
|
ldlld := '$sysroot/ld.lld'
|
||||||
|
linker_cmd := '${os.quoted_path(ldlld)} ' + linker_args.join(' ')
|
||||||
// s = s.replace('SYSROOT', sysroot) // TODO $ inter bug
|
// s = s.replace('SYSROOT', sysroot) // TODO $ inter bug
|
||||||
// s = s.replace('-o hi', '-o ' + c.pref.out_name)
|
// s = s.replace('-o hi', '-o ' + c.pref.out_name)
|
||||||
if b.pref.show_cc {
|
if b.pref.show_cc {
|
||||||
|
@ -914,10 +917,11 @@ fn (mut v Builder) build_thirdparty_obj_file(path string, moduleflags []cflag.CF
|
||||||
mut all_options := []string{}
|
mut all_options := []string{}
|
||||||
all_options << v.pref.third_party_option
|
all_options << v.pref.third_party_option
|
||||||
all_options << moduleflags.c_options_before_target()
|
all_options << moduleflags.c_options_before_target()
|
||||||
all_options << '-o "$opath"'
|
all_options << '-o ${os.quoted_path(opath)}'
|
||||||
all_options << '-c "$cfile"'
|
all_options << '-c ${os.quoted_path(cfile)}'
|
||||||
cc_options := v.thirdparty_object_args(v.ccoptions, all_options).join(' ')
|
cc_options := v.thirdparty_object_args(v.ccoptions, all_options).join(' ')
|
||||||
cmd := '$v.pref.ccompiler $cc_options'
|
|
||||||
|
cmd := '${os.quoted_path(v.pref.ccompiler)} $cc_options'
|
||||||
$if trace_thirdparty_obj_files ? {
|
$if trace_thirdparty_obj_files ? {
|
||||||
println('>>> build_thirdparty_obj_files cmd: $cmd')
|
println('>>> build_thirdparty_obj_files cmd: $cmd')
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,7 +18,7 @@ fn interp_test(expression string, expected string) ? {
|
||||||
tmpfile := os.join_path(tmpdir, 'input.v')
|
tmpfile := os.join_path(tmpdir, 'input.v')
|
||||||
outfile := os.join_path(tmpdir, 'output.txt')
|
outfile := os.join_path(tmpdir, 'output.txt')
|
||||||
os.write_file(tmpfile, interpreter_wrap(expression)) ?
|
os.write_file(tmpfile, interpreter_wrap(expression)) ?
|
||||||
if os.system('"$vexe" interpret $tmpfile > $outfile') != 0 {
|
if os.system('${os.quoted_path(vexe)} interpret ${os.quoted_path(tmpfile)} > ${os.quoted_path(outfile)}') != 0 {
|
||||||
eprintln('>>> Failed to interpret V expression: |$expression|')
|
eprintln('>>> Failed to interpret V expression: |$expression|')
|
||||||
return error('v interp')
|
return error('v interp')
|
||||||
}
|
}
|
||||||
|
|
|
@ -134,7 +134,7 @@ fn main() {
|
||||||
|
|
||||||
path := @FILE.all_before(@FILE.all_after_last('/')) + '../infix.v'
|
path := @FILE.all_before(@FILE.all_after_last('/')) + '../infix.v'
|
||||||
os.write_file(path, b.str()) or { panic(err) }
|
os.write_file(path, b.str()) or { panic(err) }
|
||||||
res := os.execute(@VEXE + ' fmt -w ' + path)
|
res := os.execute(os.quoted_path(@VEXE) + ' fmt -w ' + os.quoted_path(path))
|
||||||
if res.exit_code != 0 {
|
if res.exit_code != 0 {
|
||||||
eprintln('v fmt failed!')
|
eprintln('v fmt failed!')
|
||||||
panic(res.output)
|
panic(res.output)
|
||||||
|
|
|
@ -101,7 +101,7 @@ fn write_bin2v_keep_content() ? {
|
||||||
img0 := os.join_path('vlib', 'v', 'embed_file', 'tests', 'v.png')
|
img0 := os.join_path('vlib', 'v', 'embed_file', 'tests', 'v.png')
|
||||||
img1 := os.join_path('tutorials', 'building_a_simple_web_blog_with_vweb', 'img', 'time.png')
|
img1 := os.join_path('tutorials', 'building_a_simple_web_blog_with_vweb', 'img', 'time.png')
|
||||||
os.rm(b2v_keep_path) ?
|
os.rm(b2v_keep_path) ?
|
||||||
res := os.execute('$vexe bin2v -w $b2v_keep_path $img0 $img1')
|
res := os.execute('${os.quoted_path(vexe)} bin2v -w ${os.quoted_path(b2v_keep_path)} ${os.quoted_path(img0)} ${os.quoted_path(img1)}')
|
||||||
if res.exit_code != 0 {
|
if res.exit_code != 0 {
|
||||||
restore_bin2v_placeholder() or {}
|
restore_bin2v_placeholder() or {}
|
||||||
return error_with_code(res.output.trim_space(), res.exit_code)
|
return error_with_code(res.output.trim_space(), res.exit_code)
|
||||||
|
|
|
@ -39,12 +39,12 @@ fn test_out_files() ? {
|
||||||
pexe := os.join_path(output_path, '${basename}.exe')
|
pexe := os.join_path(output_path, '${basename}.exe')
|
||||||
//
|
//
|
||||||
file_options := get_file_options(path)
|
file_options := get_file_options(path)
|
||||||
alloptions := '-o "$pexe" $file_options.vflags'
|
alloptions := '-o ${os.quoted_path(pexe)} $file_options.vflags'
|
||||||
print(mm('v $alloptions run $relpath') + ' == ${mm(out_relpath)} ')
|
print(mm('v $alloptions run $relpath') + ' == ${mm(out_relpath)} ')
|
||||||
//
|
//
|
||||||
compilation := os.execute('"$vexe" $alloptions "$path"')
|
compilation := os.execute('${os.quoted_path(vexe)} $alloptions ${os.quoted_path(path)}')
|
||||||
ensure_compilation_succeeded(compilation)
|
ensure_compilation_succeeded(compilation)
|
||||||
res := os.execute(pexe)
|
res := os.execute(os.quoted_path(pexe))
|
||||||
if res.exit_code < 0 {
|
if res.exit_code < 0 {
|
||||||
println('nope')
|
println('nope')
|
||||||
panic(res.output)
|
panic(res.output)
|
||||||
|
@ -113,7 +113,7 @@ fn test_c_must_have_files() ? {
|
||||||
description := mm('v $alloptions $relpath') +
|
description := mm('v $alloptions $relpath') +
|
||||||
' matches all line patterns in ${mm(must_have_relpath)} '
|
' matches all line patterns in ${mm(must_have_relpath)} '
|
||||||
print(description)
|
print(description)
|
||||||
cmd := '$vexe $alloptions $path'
|
cmd := '${os.quoted_path(vexe)} $alloptions ${os.quoted_path(path)}'
|
||||||
compilation := os.execute(cmd)
|
compilation := os.execute(cmd)
|
||||||
ensure_compilation_succeeded(compilation)
|
ensure_compilation_succeeded(compilation)
|
||||||
expected_lines := os.read_lines(must_have_path) or { [] }
|
expected_lines := os.read_lines(must_have_path) or { [] }
|
||||||
|
|
|
@ -31,7 +31,7 @@ fn (mut g Gen) gen_embed_file_init(mut node ast.ComptimeCall) {
|
||||||
cache_path := os.join_path(cache_dir, cache_key)
|
cache_path := os.join_path(cache_dir, cache_key)
|
||||||
|
|
||||||
vexe := pref.vexe_path()
|
vexe := pref.vexe_path()
|
||||||
result := os.execute('"$vexe" compress $node.embed_file.compression_type "$node.embed_file.apath" "$cache_path"')
|
result := os.execute('${os.quoted_path(vexe)} compress $node.embed_file.compression_type ${os.quoted_path(node.embed_file.apath)} ${os.quoted_path(cache_path)}')
|
||||||
if result.exit_code != 0 {
|
if result.exit_code != 0 {
|
||||||
eprintln('unable to compress file "$node.embed_file.rpath": $result.output')
|
eprintln('unable to compress file "$node.embed_file.rpath": $result.output')
|
||||||
node.embed_file.bytes = file_bytes
|
node.embed_file.bytes = file_bytes
|
||||||
|
|
|
@ -33,7 +33,8 @@ fn test_example_compilation() {
|
||||||
println('add node option: --enable-source-maps') // requieres node >=12.12.0
|
println('add node option: --enable-source-maps') // requieres node >=12.12.0
|
||||||
node_options_file += ' --enable-source-maps' // activate souremap generation
|
node_options_file += ' --enable-source-maps' // activate souremap generation
|
||||||
}
|
}
|
||||||
v_code := os.system('$vexe $v_options_file -o $output_dir${file}.js $path')
|
jsfile := os.join_path_single(output_dir, '${file}.js')
|
||||||
|
v_code := os.system('${os.quoted_path(vexe)} $v_options_file -o ${os.quoted_path(jsfile)} ${os.quoted_path(path)}')
|
||||||
if v_code != 0 {
|
if v_code != 0 {
|
||||||
assert false
|
assert false
|
||||||
}
|
}
|
||||||
|
@ -43,7 +44,7 @@ fn test_example_compilation() {
|
||||||
println(' ... skipping running $file, there is no NodeJS present')
|
println(' ... skipping running $file, there is no NodeJS present')
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
js_code := os.system('node $output_dir${file}.js')
|
js_code := os.system('node ${os.quoted_path(jsfile)}')
|
||||||
if js_code != 0 {
|
if js_code != 0 {
|
||||||
assert false
|
assert false
|
||||||
}
|
}
|
||||||
|
@ -51,7 +52,7 @@ fn test_example_compilation() {
|
||||||
assert js_code == 0
|
assert js_code == 0
|
||||||
if should_create_source_map {
|
if should_create_source_map {
|
||||||
if there_is_grep_available {
|
if there_is_grep_available {
|
||||||
grep_code_sourcemap_found := os.system('grep -q -E "//#\\ssourceMappingURL=data:application/json;base64,[-A-Za-z0-9+/=]+$" $output_dir${file}.js')
|
grep_code_sourcemap_found := os.system('grep -q -E "//#\\ssourceMappingURL=data:application/json;base64,[-A-Za-z0-9+/=]+$" ${os.quoted_path(jsfile)}')
|
||||||
assert grep_code_sourcemap_found == 0
|
assert grep_code_sourcemap_found == 0
|
||||||
println('file has a source map embeded')
|
println('file has a source map embeded')
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -60,7 +60,7 @@ fn check_path(dir string, tests []string) ?int {
|
||||||
os.write_file(program_out, '') ?
|
os.write_file(program_out, '') ?
|
||||||
}
|
}
|
||||||
print(program + ' ')
|
print(program + ' ')
|
||||||
res := os.execute('$vexe -b js_node run $program')
|
res := os.execute('${os.quoted_path(vexe)} -b js_node run ${os.quoted_path(program)}')
|
||||||
if res.exit_code < 0 {
|
if res.exit_code < 0 {
|
||||||
panic(res.output)
|
panic(res.output)
|
||||||
}
|
}
|
||||||
|
|
|
@ -151,9 +151,9 @@ fn setup_cycles_environment() {
|
||||||
fn test_live_program_can_be_compiled() {
|
fn test_live_program_can_be_compiled() {
|
||||||
setup_cycles_environment()
|
setup_cycles_environment()
|
||||||
eprintln('Compiling...')
|
eprintln('Compiling...')
|
||||||
os.system('$vexe -nocolor -live -o $genexe_file $source_file')
|
os.system('${os.quoted_path(vexe)} -nocolor -live -o ${os.quoted_path(genexe_file)} ${os.quoted_path(source_file)}')
|
||||||
//
|
//
|
||||||
cmd := '$genexe_file > /dev/null &'
|
cmd := '${os.quoted_path(genexe_file)} > /dev/null &'
|
||||||
eprintln('Running with: $cmd')
|
eprintln('Running with: $cmd')
|
||||||
res := os.system(cmd)
|
res := os.system(cmd)
|
||||||
assert res == 0
|
assert res == 0
|
||||||
|
|
|
@ -40,7 +40,7 @@ fn custom_compile(fname string, cflags_options string) Results {
|
||||||
mut res := Results{}
|
mut res := Results{}
|
||||||
res.exe = os.join_path(os.temp_dir(), fname)
|
res.exe = os.join_path(os.temp_dir(), fname)
|
||||||
res.sw = time.new_stopwatch()
|
res.sw = time.new_stopwatch()
|
||||||
res.compilation = os.execute('"$vexe" -cflags "$cflags_options" -o "$res.exe" examples/hello_world.v')
|
res.compilation = os.execute('${os.quoted_path(vexe)} -cflags "$cflags_options" -o ${os.quoted_path(res.exe)} examples/hello_world.v')
|
||||||
res.delta = res.sw.elapsed().microseconds()
|
res.delta = res.sw.elapsed().microseconds()
|
||||||
res.file_size = os.file_size(res.exe)
|
res.file_size = os.file_size(res.exe)
|
||||||
println('> $fname build took: $res.delta ms with "$cflags_options", file size: $res.file_size')
|
println('> $fname build took: $res.delta ms with "$cflags_options", file size: $res.file_size')
|
||||||
|
|
|
@ -162,7 +162,7 @@ fn test_closure_return_${styp}_${i}() ? {
|
||||||
os.chdir(wrkdir) ?
|
os.chdir(wrkdir) ?
|
||||||
os.write_file('closure_return_test.v', code) ?
|
os.write_file('closure_return_test.v', code) ?
|
||||||
vexe := os.getenv('VEXE')
|
vexe := os.getenv('VEXE')
|
||||||
res := os.execute('"$vexe" -keepc -cg -showcc closure_return_test.v')
|
res := os.execute('${os.quoted_path(vexe)} -keepc -cg -showcc closure_return_test.v')
|
||||||
if res.exit_code != 0 {
|
if res.exit_code != 0 {
|
||||||
eprintln(res.output)
|
eprintln(res.output)
|
||||||
assert false
|
assert false
|
||||||
|
|
|
@ -16,7 +16,7 @@ fn run_test(cc_used string) {
|
||||||
else { '' }
|
else { '' }
|
||||||
}
|
}
|
||||||
|
|
||||||
assert os.system('"${@VEXE}" $cc_flag -o create_win_${cc_used}.dll -shared create_win_dll.v') == 0
|
assert os.system('${os.quoted_path(@VEXE)} $cc_flag -o create_win_${cc_used}.dll -shared create_win_dll.v') == 0
|
||||||
assert os.exists('create_win_${cc_used}.dll')
|
assert os.exists('create_win_${cc_used}.dll')
|
||||||
handle := dl.open('create_win_${cc_used}.dll', 0)
|
handle := dl.open('create_win_${cc_used}.dll', 0)
|
||||||
assert handle != 0
|
assert handle != 0
|
||||||
|
|
|
@ -5,7 +5,9 @@ fn vroot_path(relpath string) string {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn vexecute(relpath string) os.Result {
|
fn vexecute(relpath string) os.Result {
|
||||||
return os.execute('${@VEXE} -test-runner normal ' + vroot_path(relpath))
|
vexe := @VEXE
|
||||||
|
return os.execute('${os.quoted_path(vexe)} -test-runner normal ' +
|
||||||
|
os.quoted_path(vroot_path(relpath)))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn testsuite_begin() {
|
fn testsuite_begin() {
|
||||||
|
|
|
@ -26,26 +26,27 @@ fn test_all() {
|
||||||
for path in paths {
|
for path in paths {
|
||||||
print(path + ' ')
|
print(path + ' ')
|
||||||
program := path
|
program := path
|
||||||
compilation := os.execute('$vexe -o test -cflags "-w" -cg $program')
|
tname := rand.ulid()
|
||||||
|
compilation := os.execute('${os.quoted_path(vexe)} -o $tname -cflags "-w" -cg ${os.quoted_path(program)}')
|
||||||
if compilation.exit_code < 0 {
|
if compilation.exit_code < 0 {
|
||||||
panic(compilation.output)
|
panic(compilation.output)
|
||||||
}
|
}
|
||||||
if compilation.exit_code != 0 {
|
if compilation.exit_code != 0 {
|
||||||
panic('compilation failed: $compilation.output')
|
panic('compilation failed: $compilation.output')
|
||||||
}
|
}
|
||||||
res := os.execute('./test')
|
res := os.execute('./$tname')
|
||||||
if res.exit_code < 0 {
|
if res.exit_code < 0 {
|
||||||
println('nope')
|
println('nope')
|
||||||
panic(res.output)
|
panic(res.output)
|
||||||
}
|
}
|
||||||
$if windows {
|
$if windows {
|
||||||
os.rm('./test.exe') or {}
|
os.rm('./${tname}.exe') or {}
|
||||||
$if msvc {
|
$if msvc {
|
||||||
os.rm('./test.ilk') or {}
|
os.rm('./${tname}.ilk') or {}
|
||||||
os.rm('./test.pdb') or {}
|
os.rm('./${tname}.pdb') or {}
|
||||||
}
|
}
|
||||||
} $else {
|
} $else {
|
||||||
os.rm('./test') or {}
|
os.rm('./$tname') or {}
|
||||||
}
|
}
|
||||||
// println('============')
|
// println('============')
|
||||||
// println(res.output)
|
// println(res.output)
|
||||||
|
|
|
@ -18,7 +18,7 @@ fn test_vexe_is_set() {
|
||||||
fn test_compiling_without_vmodules_fails() {
|
fn test_compiling_without_vmodules_fails() {
|
||||||
os.chdir(vroot) or {}
|
os.chdir(vroot) or {}
|
||||||
os.setenv('VMODULES', '', true)
|
os.setenv('VMODULES', '', true)
|
||||||
cmd := '"$vexe" run "$mainvv"'
|
cmd := '${os.quoted_path(vexe)} run ${os.quoted_path(mainvv)}'
|
||||||
dump(cmd)
|
dump(cmd)
|
||||||
res := os.execute(cmd)
|
res := os.execute(cmd)
|
||||||
assert res.exit_code == 1
|
assert res.exit_code == 1
|
||||||
|
@ -30,7 +30,7 @@ fn test_compiling_with_vmodules_works() {
|
||||||
os.chdir(vroot) or {}
|
os.chdir(vroot) or {}
|
||||||
vmpaths := ['path1', 'path2', 'path3'].map(os.join_path(basepath, it))
|
vmpaths := ['path1', 'path2', 'path3'].map(os.join_path(basepath, it))
|
||||||
os.setenv('VMODULES', vmpaths.join(os.path_delimiter), true)
|
os.setenv('VMODULES', vmpaths.join(os.path_delimiter), true)
|
||||||
res := os.execute('"$vexe" run "$mainvv"')
|
res := os.execute('${os.quoted_path(vexe)} run ${os.quoted_path(mainvv)}')
|
||||||
assert res.exit_code == 0
|
assert res.exit_code == 0
|
||||||
assert res.output.trim_space() == "['x', 'y', 'z']"
|
assert res.output.trim_space() == "['x', 'y', 'z']"
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,7 +12,7 @@ fn test_vexe_exists() {
|
||||||
fn test_v_profile_works() {
|
fn test_v_profile_works() {
|
||||||
os.chdir(vroot) or {}
|
os.chdir(vroot) or {}
|
||||||
program_source := os.join_path(vroot, 'vlib/v/tests/profile/profile_test_1.v')
|
program_source := os.join_path(vroot, 'vlib/v/tests/profile/profile_test_1.v')
|
||||||
res := os.execute('"$vexe" -profile - run $program_source')
|
res := os.execute('${os.quoted_path(vexe)} -profile - run ${os.quoted_path(program_source)}')
|
||||||
// eprintln('res: $res')
|
// eprintln('res: $res')
|
||||||
assert res.exit_code == 0
|
assert res.exit_code == 0
|
||||||
assert res.output.len > 0
|
assert res.output.len > 0
|
||||||
|
@ -25,7 +25,7 @@ fn test_v_profile_works() {
|
||||||
fn test_v_profile_on_off_api_works() {
|
fn test_v_profile_on_off_api_works() {
|
||||||
os.chdir(vroot) or {}
|
os.chdir(vroot) or {}
|
||||||
program_source := os.join_path(vroot, 'vlib/v/tests/profile/profile_test_2.v')
|
program_source := os.join_path(vroot, 'vlib/v/tests/profile/profile_test_2.v')
|
||||||
res := os.execute('"$vexe" -profile - run $program_source')
|
res := os.execute('${os.quoted_path(vexe)} -profile - run ${os.quoted_path(program_source)}')
|
||||||
// eprintln('res: $res')
|
// eprintln('res: $res')
|
||||||
assert res.exit_code == 0
|
assert res.exit_code == 0
|
||||||
assert res.output.len > 0
|
assert res.output.len > 0
|
||||||
|
@ -37,7 +37,7 @@ fn test_v_profile_on_off_api_works() {
|
||||||
assert abc_count == 1
|
assert abc_count == 1
|
||||||
|
|
||||||
// test that `-d no_profile_startup` *also* works:
|
// test that `-d no_profile_startup` *also* works:
|
||||||
res2 := os.execute('"$vexe" -d no_profile_startup -profile - run $program_source')
|
res2 := os.execute('${os.quoted_path(vexe)} -d no_profile_startup -profile - run ${os.quoted_path(program_source)}')
|
||||||
assert res2.exit_code == 0
|
assert res2.exit_code == 0
|
||||||
assert res2.output.len > 0
|
assert res2.output.len > 0
|
||||||
assert !res2.output.contains(' builtin_init')
|
assert !res2.output.contains(' builtin_init')
|
||||||
|
|
|
@ -25,7 +25,7 @@ fn test_v_profile_works() ? {
|
||||||
local_path := folder_path.replace(vroot + os.path_separator, '').replace('\\',
|
local_path := folder_path.replace(vroot + os.path_separator, '').replace('\\',
|
||||||
'/')
|
'/')
|
||||||
println('..... v run $local_path/')
|
println('..... v run $local_path/')
|
||||||
res := os.execute('"$vexe" run $folder_path')
|
res := os.execute('${os.quoted_path(vexe)} run ${os.quoted_path(folder_path)}')
|
||||||
// eprintln('res: $res')
|
// eprintln('res: $res')
|
||||||
assert res.exit_code == 0
|
assert res.exit_code == 0
|
||||||
assert res.output.len > 0
|
assert res.output.len > 0
|
||||||
|
|
|
@ -155,7 +155,7 @@ pub fn launch_tool(is_verbose bool, tool_name string, args []string) {
|
||||||
for emodule in emodules {
|
for emodule in emodules {
|
||||||
check_module_is_installed(emodule, is_verbose) or { panic(err) }
|
check_module_is_installed(emodule, is_verbose) or { panic(err) }
|
||||||
}
|
}
|
||||||
mut compilation_command := '"$vexe" -skip-unused '
|
mut compilation_command := "'$vexe' -skip-unused "
|
||||||
if tool_name in ['vself', 'vup', 'vdoctor', 'vsymlink'] {
|
if tool_name in ['vself', 'vup', 'vdoctor', 'vsymlink'] {
|
||||||
// These tools will be called by users in cases where there
|
// These tools will be called by users in cases where there
|
||||||
// is high chance of there being a problem somewhere. Thus
|
// is high chance of there being a problem somewhere. Thus
|
||||||
|
@ -164,7 +164,7 @@ pub fn launch_tool(is_verbose bool, tool_name string, args []string) {
|
||||||
// .v line numbers, to ease diagnostic in #bugs and issues.
|
// .v line numbers, to ease diagnostic in #bugs and issues.
|
||||||
compilation_command += ' -g '
|
compilation_command += ' -g '
|
||||||
}
|
}
|
||||||
compilation_command += '"$tool_source"'
|
compilation_command += "'$tool_source'"
|
||||||
if is_verbose {
|
if is_verbose {
|
||||||
println('Compiling $tool_name with: "$compilation_command"')
|
println('Compiling $tool_name with: "$compilation_command"')
|
||||||
}
|
}
|
||||||
|
@ -178,7 +178,7 @@ pub fn launch_tool(is_verbose bool, tool_name string, args []string) {
|
||||||
exit(os.system('"$tool_exe" $tool_args'))
|
exit(os.system('"$tool_exe" $tool_args'))
|
||||||
} $else $if js {
|
} $else $if js {
|
||||||
// no way to implement os.execvp in JS backend
|
// no way to implement os.execvp in JS backend
|
||||||
exit(os.system('"$tool_exe" $tool_args'))
|
exit(os.system('\'$tool_exe\' $tool_args'))
|
||||||
} $else {
|
} $else {
|
||||||
os.execvp(tool_exe, args) or { panic(err) }
|
os.execvp(tool_exe, args) or { panic(err) }
|
||||||
}
|
}
|
||||||
|
@ -251,14 +251,7 @@ fn tool_source2name_and_exe(tool_source string) (string, string) {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn quote_path(s string) string {
|
pub fn quote_path(s string) string {
|
||||||
mut qs := s
|
return os.quoted_path(s)
|
||||||
if qs.contains('&') {
|
|
||||||
qs = qs.replace('&', '\\&')
|
|
||||||
}
|
|
||||||
if qs.contains(' ') {
|
|
||||||
return '"$qs"'
|
|
||||||
}
|
|
||||||
return qs
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn args_quote_paths(args []string) string {
|
pub fn args_quote_paths(args []string) string {
|
||||||
|
@ -355,7 +348,7 @@ pub fn check_module_is_installed(modulename string, is_verbose bool) ?bool {
|
||||||
}
|
}
|
||||||
if os.exists(mod_v_file) {
|
if os.exists(mod_v_file) {
|
||||||
vexe := pref.vexe_path()
|
vexe := pref.vexe_path()
|
||||||
update_cmd := '"$vexe" update "$modulename"'
|
update_cmd := "'$vexe' update '$modulename'"
|
||||||
if is_verbose {
|
if is_verbose {
|
||||||
eprintln('check_module_is_installed: updating with $update_cmd ...')
|
eprintln('check_module_is_installed: updating with $update_cmd ...')
|
||||||
}
|
}
|
||||||
|
@ -455,7 +448,7 @@ pub fn prepare_tool_when_needed(source_name string) {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn recompile_file(vexe string, file string) {
|
pub fn recompile_file(vexe string, file string) {
|
||||||
cmd := '$vexe $file'
|
cmd := "'$vexe' '$file'"
|
||||||
$if trace_recompilation ? {
|
$if trace_recompilation ? {
|
||||||
println('recompilation command: $cmd')
|
println('recompilation command: $cmd')
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,9 +25,9 @@ fn testsuite_begin() {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn test_a_simple_vweb_app_can_be_compiled() {
|
fn test_a_simple_vweb_app_can_be_compiled() {
|
||||||
// did_server_compile := os.system('$vexe -g -o $serverexe vlib/vweb/tests/vweb_test_server.v')
|
// did_server_compile := os.system('${os.quoted_path(vexe)} -g -o ${os.quoted_path(serverexe)} vlib/vweb/tests/vweb_test_server.v')
|
||||||
// TODO: find out why it does not compile with -usecache and -g
|
// TODO: find out why it does not compile with -usecache and -g
|
||||||
did_server_compile := os.system('$vexe -o $serverexe vlib/vweb/tests/vweb_test_server.v')
|
did_server_compile := os.system('${os.quoted_path(vexe)} -o ${os.quoted_path(serverexe)} vlib/vweb/tests/vweb_test_server.v')
|
||||||
assert did_server_compile == 0
|
assert did_server_compile == 0
|
||||||
assert os.exists(serverexe)
|
assert os.exists(serverexe)
|
||||||
}
|
}
|
||||||
|
@ -38,9 +38,9 @@ fn test_a_simple_vweb_app_runs_in_the_background() {
|
||||||
suffix = ' > /dev/null &'
|
suffix = ' > /dev/null &'
|
||||||
}
|
}
|
||||||
if vweb_logfile != '' {
|
if vweb_logfile != '' {
|
||||||
suffix = ' 2>> $vweb_logfile >> $vweb_logfile &'
|
suffix = ' 2>> ${os.quoted_path(vweb_logfile)} >> ${os.quoted_path(vweb_logfile)} &'
|
||||||
}
|
}
|
||||||
server_exec_cmd := '$serverexe $sport $exit_after_time $suffix'
|
server_exec_cmd := '${os.quoted_path(serverexe)} $sport $exit_after_time $suffix'
|
||||||
$if debug_net_socket_client ? {
|
$if debug_net_socket_client ? {
|
||||||
eprintln('running:\n$server_exec_cmd')
|
eprintln('running:\n$server_exec_cmd')
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue