init
This commit is contained in:
27
shell_test.v
Normal file
27
shell_test.v
Normal file
@@ -0,0 +1,27 @@
|
||||
import shell
|
||||
|
||||
// TODO: pass all tests from https://github.com/python/cpython/blob/main/Lib/test/test_shlex.py
|
||||
|
||||
fn test_quote() {
|
||||
assert shell.quote("janna d'arc") == '\'janna d\'"\'"\'arc\''
|
||||
}
|
||||
|
||||
fn test_join() {
|
||||
assert shell.join(['sh', '-c', 'hostname -f']) == "sh -c 'hostname -f'"
|
||||
}
|
||||
|
||||
fn test_split() {
|
||||
assert shell.split("sh -c 'hostname -f'") == ['sh', '-c', 'hostname -f']
|
||||
assert shell.split('sh -c hostname') == ['sh', '-c', 'hostname']
|
||||
assert shell.split('hostname -f # some comment') == ['hostname', '-f', '#', 'some', 'comment']
|
||||
assert shell.split('hostname -f # some comment', comments: true) == ['hostname', '-f']
|
||||
assert shell.split('grep -rn "#"') == ['grep', '-rn', '#']
|
||||
assert shell.split('grep -rn "#"', comments: true) == ['grep', '-rn', '#']
|
||||
|
||||
// FIXME: both assertions fails
|
||||
// s := 'grep -rn hello # search hello
|
||||
// awk --help
|
||||
// '.trim_indent()
|
||||
// assert shell.split(s) == ['grep', '-rn', 'hello', '#', 'search', 'hello', 'awk', '--help']
|
||||
// assert shell.split(s, comments: true) == ['grep', '-rn', 'hello', 'awk', '--help']
|
||||
}
|
Reference in New Issue
Block a user