|
| 1 | +-------------------------------------------------------------------------------- |
| 2 | +-- 0002-shell-read.lua: tests for shell piping |
| 3 | +-------------------------------------------------------------------------------- |
| 4 | + |
| 5 | +local make_suite = ... |
| 6 | + |
| 7 | +-------------------------------------------------------------------------------- |
| 8 | + |
| 9 | +local shell_read, |
| 10 | + exports |
| 11 | + = import 'lua-aplicado/shell.lua' |
| 12 | + { |
| 13 | + 'shell_read' |
| 14 | + } |
| 15 | + |
| 16 | +local ensure, |
| 17 | + ensure_equals, |
| 18 | + ensure_strequals, |
| 19 | + ensure_error, |
| 20 | + ensure_fails_with_substring |
| 21 | + = import 'lua-nucleo/ensure.lua' |
| 22 | + { |
| 23 | + 'ensure', |
| 24 | + 'ensure_equals', |
| 25 | + 'ensure_strequals', |
| 26 | + 'ensure_error', |
| 27 | + 'ensure_fails_with_substring' |
| 28 | + } |
| 29 | + |
| 30 | +local test = make_suite("shell", exports) |
| 31 | + |
| 32 | +test:test_for "shell_read" (function() |
| 33 | + ensure_strequals( |
| 34 | + "plain read", |
| 35 | + shell_read("/bin/echo", "foobar"), |
| 36 | + "foobar\n" |
| 37 | + ) |
| 38 | + ensure_equals("empty read", shell_read("/bin/true"), "") |
| 39 | + ensure_fails_with_substring( |
| 40 | + "false read", |
| 41 | + (function() |
| 42 | + shell_read("/bin/false") |
| 43 | + end), |
| 44 | + "command `/bin/false' stopped with rc==1" |
| 45 | + ) |
| 46 | +end) |
| 47 | + |
| 48 | +test:UNTESTED "shell_format_command_no_subst" |
| 49 | +test:UNTESTED "shell_escape_many" |
| 50 | +test:UNTESTED "shell_escape_no_subst" |
| 51 | +test:UNTESTED "shell_exec_no_subst" |
| 52 | +test:UNTESTED "shell_escape" |
| 53 | +test:UNTESTED "shell_format_command" |
| 54 | +test:UNTESTED "shell_exec" |
| 55 | +test:UNTESTED "shell_read_no_subst" |
| 56 | +test:UNTESTED "shell_escape_many_no_subst" |
| 57 | + |
| 58 | +test:run() |
0 commit comments