1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

os: make process_test.v more portable (prepare for windows)

This commit is contained in:
Delyan Angelov
2021-02-22 09:42:00 +02:00
parent c37daba41d
commit 5d653a37b6
2 changed files with 43 additions and 13 deletions

View File

@ -53,19 +53,20 @@ 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 1000] [-period_ms 100]
test_os_process [-v] [-h] [-target stderr/stdout/both/alternate] [-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
of child process/standart input/output control.
It is used in V's `os` module tests.
")
return
}
ctx.is_verbose = '-v' 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', '1000').int()
ctx.period_ms = cmdline.option(args, '-period_ms', '100').int()
ctx.timeout_ms = cmdline.option(args, '-timeout_ms', '200').int()
ctx.period_ms = cmdline.option(args, '-period_ms', '50').int()
if ctx.target == .alternate {
ctx.omode = .stdout
}