mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
os: implement Process.set_work_folder/0 to set the initial working folder of the new child process (#17946)
This commit is contained in:
@ -28,6 +28,8 @@ mut:
|
||||
target Target
|
||||
omode Target
|
||||
is_verbose bool
|
||||
show_wd bool
|
||||
show_env bool
|
||||
}
|
||||
|
||||
fn (mut ctx Context) println(s string) {
|
||||
@ -53,7 +55,7 @@ fn main() {
|
||||
args := os.args[1..]
|
||||
if '-h' in args || '--help' in args {
|
||||
println("Usage:
|
||||
test_os_process [-v] [-h] [-target stderr/stdout/both/alternate] [-exitcode 0] [-timeout_ms 200] [-period_ms 50]
|
||||
test_os_process [-v] [-h] [-target stderr/stdout/both/alternate] [-show_wd] [-show_env] [-exitcode 0] [-timeout_ms 200] [-period_ms 50]
|
||||
Prints lines periodically (-period_ms), to stdout/stderr (-target).
|
||||
After a while (-timeout_ms), exit with (-exitcode).
|
||||
This program is useful for platform independent testing
|
||||
@ -63,6 +65,8 @@ fn main() {
|
||||
return
|
||||
}
|
||||
ctx.is_verbose = '-v' in args
|
||||
ctx.show_wd = '-show_wd' in args
|
||||
ctx.show_env = '-show_env' in args
|
||||
ctx.target = s2target(cmdline.option(args, '-target', 'both'))
|
||||
ctx.exitcode = cmdline.option(args, '-exitcode', '0').int()
|
||||
ctx.timeout_ms = cmdline.option(args, '-timeout_ms', '200').int()
|
||||
@ -73,6 +77,15 @@ fn main() {
|
||||
if ctx.is_verbose {
|
||||
eprintln('> args: ${args} | context: ${ctx}')
|
||||
}
|
||||
if ctx.show_wd {
|
||||
ctx.println('WORK_DIR=${os.getwd()}')
|
||||
}
|
||||
if ctx.show_env {
|
||||
all := os.environ()
|
||||
for k, v in all {
|
||||
ctx.println('${k}=${v}')
|
||||
}
|
||||
}
|
||||
spawn do_timeout(&ctx)
|
||||
for i := 1; true; i++ {
|
||||
ctx.println('${i}')
|
||||
|
Reference in New Issue
Block a user