Skip to content

Commit 31e1837

Browse files
committed
add v run args test
1 parent abdce45 commit 31e1837

2 files changed

Lines changed: 21 additions & 0 deletions

File tree

cmd/tools/test_os_args.v

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
println(arguments()#[1..])

vlib/os/process_args_test.v

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import os
2+
3+
const vexe = os.getenv('VEXE')
4+
const vroot = os.dir(vexe)
5+
6+
fn test_v_run_simple() {
7+
echo_os_args := os.join_path(vroot, 'cmd/tools/test_os_args.v')
8+
res123 := os.execute('${os.quoted_path(vexe)} run ${os.quoted_path(echo_os_args)} 1 2 3')
9+
println(res123)
10+
assert res123.exit_code == 0
11+
assert res123.output.starts_with("['1', '2', '3']")
12+
}
13+
14+
fn test_v_run_quoted_args_with_spaces() {
15+
echo_os_args := os.join_path(vroot, 'cmd/tools/test_os_args.v')
16+
res := os.execute('${os.quoted_path(vexe)} run ${os.quoted_path(echo_os_args)} 1 "Learn V" 3')
17+
println(res)
18+
assert res.exit_code == 0
19+
assert res.output.starts_with("['1', 'Learn V', '3']")
20+
}

0 commit comments

Comments
 (0)