Skip to content

Commit 8b6f636

Browse files
committed
Update bats tests for command failure tree output
1 parent b7a8483 commit 8b6f636

3 files changed

Lines changed: 19 additions & 14 deletions

File tree

tests/command_cmd.bats

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,8 @@ setup() {
4343
# as there is no guarantee in which order cmds runs
4444
# we can not guarantee that all commands will run and complete.
4545
# But error message must be in the output.
46-
assert_output --partial "lets: cmd-as-map-error"
46+
assert_output --partial "lets: command failed:"
47+
assert_output --partial "└─ cmd-as-map-error <-- failed here"
4748
assert_output --partial "lets: exit status 2"
4849
}
4950

tests/command_options.bats

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -108,22 +108,26 @@ setup() {
108108
run lets test-options --kv-opt
109109

110110
assert_failure
111-
assert_line --index 1 "lets: failed to parse docopt options for cmd test-options: --kv-opt requires argument"
112-
assert_line --index 2 "Usage:"
113-
assert_line --index 3 " lets test-options [--kv-opt=<kv-opt>] [--bool-opt] [--attr=<attr>...] [<args>...]"
114-
assert_line --index 4 "Options:"
115-
assert_line --index 5 " <args>... Positional args in the end"
116-
assert_line --index 6 " --bool-opt, -b Boolean opt"
117-
assert_line --index 7 " --kv-opt=<kv-opt>, -K Key value opt"
118-
assert_line --index 8 " --attr=<attr>... Repeated kv args"
111+
assert_line --index 0 "lets: command failed:"
112+
assert_line --index 1 " └─ test-options <-- failed here"
113+
assert_line --index 2 "lets: failed to parse docopt options for cmd test-options: --kv-opt requires argument"
114+
assert_line --index 3 "Usage:"
115+
assert_line --index 4 " lets test-options [--kv-opt=<kv-opt>] [--bool-opt] [--attr=<attr>...] [<args>...]"
116+
assert_line --index 5 "Options:"
117+
assert_line --index 6 " <args>... Positional args in the end"
118+
assert_line --index 7 " --bool-opt, -b Boolean opt"
119+
assert_line --index 8 " --kv-opt=<kv-opt>, -K Key value opt"
120+
assert_line --index 9 " --attr=<attr>... Repeated kv args"
119121
}
120122

121123
@test "command_options: wrong usage" {
122124
run lets options-wrong-usage
123125

124126
assert_failure
125-
assert_line --index 1 "lets: failed to parse docopt options for cmd options-wrong-usage: unknown option or argument: options-wrong-usage"
126-
assert_line --index 2 "Usage: lets options-wrong-usage-xxx"
127+
assert_line --index 0 "lets: command failed:"
128+
assert_line --index 1 " └─ options-wrong-usage <-- failed here"
129+
assert_line --index 2 "lets: failed to parse docopt options for cmd options-wrong-usage: unknown option or argument: options-wrong-usage"
130+
assert_line --index 3 "Usage: lets options-wrong-usage-xxx"
127131
}
128132

129133
@test "command_options: should not break json argument" {

tests/default_env.bats

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ setup() {
6161
LETS_CONFIG_DIR=./a run lets print-workdir
6262

6363
assert_failure
64-
assert_line --index 0 --partial "lets: print-workdir"
65-
assert_line --index 0 --partial "failed here"
66-
assert_line --index 1 "lets: chdir ${TEST_DIR}/b: no such file or directory"
64+
assert_line --index 0 "lets: command failed:"
65+
assert_line --index 1 " └─ print-workdir <-- failed here"
66+
assert_line --index 2 "lets: chdir ${TEST_DIR}/b: no such file or directory"
6767
}

0 commit comments

Comments
 (0)