mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
os: add os.quoted_path/1, use it consistently for running V itself
This commit is contained in:
@@ -745,3 +745,12 @@ pub fn execute_or_exit(cmd string) Result {
|
||||
}
|
||||
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 {
|
||||
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()
|
||||
// println('exit_code: $result.exit_code')
|
||||
// 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
|
||||
os.cp(os.getenv('WINE_TEST_OS_PROCESS_EXE'), test_os_process) ?
|
||||
} 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)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user