New upstream snapshot.
Debian Janitor
1 year, 6 months ago
0 | // https://aka.ms/devcontainer.json | |
1 | { | |
2 | "name": "clitest dev", | |
3 | // | |
4 | // https://github.com/aureliojargas/devcontainer | |
5 | "image": "ghcr.io/aureliojargas/devcontainer", | |
6 | // | |
7 | // https://aka.ms/vscode-remote/containers/non-root | |
8 | "remoteUser": "vscode", | |
9 | // | |
10 | // https://github.com/devcontainers/features/tree/main/src | |
11 | "features": { | |
12 | "github-cli": "latest", | |
13 | // Makefile commands are run inside the clitest-dev Docker container | |
14 | "docker-in-docker": "latest" | |
15 | } | |
16 | } |
0 | language: bash | |
1 | ||
2 | script: | |
3 | - make docker-build | |
4 | - make versions | |
5 | - make lint | |
6 | - make test | |
7 | ||
8 | notifications: | |
9 | email: false |
0 | # Developer workflow: run locally the same commands Travis will run in | |
1 | # the CI. See the .travis.yml file for the list of commands. | |
0 | # Developer workflow: run locally the same commands the CI will run. | |
1 | # See the .github/workflows/check.yml file for the list of commands. | |
2 | 2 | # |
3 | 3 | # By default, the linting and testing targets are run inside the |
4 | 4 | # clitest-dev Docker container. To run them directly on the host, |
8 | 8 | # make test-bash docker_run= # test using host's bash |
9 | 9 | |
10 | 10 | docker_image = clitest-dev |
11 | docker_run = docker run --rm -it -v $$PWD:/mnt $(docker_image) | |
11 | docker_run = docker run --rm -t -v $$PWD:/mnt $(docker_image) | |
12 | 12 | test_cmd = ./clitest --first --progress none test.md |
13 | 13 | |
14 | 14 | default: |
463 | 463 | - ksh |
464 | 464 | - sh (busybox) |
465 | 465 | - zsh |
466 | ||
467 | > Fish shell is not supported (it's not POSIX), but you | |
468 | > can use [doctest.fish][27] instead. | |
466 | 469 | |
467 | 470 | Portability issues are considered serious bugs, please |
468 | 471 | [report them][14]! |
516 | 519 | [24]: https://github.com/funcoeszz/funcoeszz/tree/master/testador |
517 | 520 | [25]: https://linux.die.net/man/1/checkbashisms |
518 | 521 | [26]: https://www.shellcheck.net/ |
522 | [27]: https://github.com/aureliojargas/doctest.fish |
26 | 26 | |
27 | 27 | tt_my_name="$(basename "$0")" |
28 | 28 | tt_my_url='https://github.com/aureliojargas/clitest' |
29 | tt_my_version='0.4.0' | |
29 | tt_my_version='dev' | |
30 | 30 | |
31 | 31 | # Customization (if needed, edit here or use the command line options) |
32 | 32 | tt_prefix='' |
89 | 89 | tt_skip_range= |
90 | 90 | tt_skip_range_data= |
91 | 91 | tt_failed_range= |
92 | tt_temp_dir= | |
92 | 93 | tt_test_file= |
93 | 94 | tt_input_line= |
94 | 95 | tt_line_number=0 |
112 | 113 | ### Utilities |
113 | 114 | |
114 | 115 | tt_clean_up() { |
115 | rm -rf "$tt_temp_dir" | |
116 | test -n "$tt_temp_dir" && rm -rf "$tt_temp_dir" | |
116 | 117 | } |
117 | 118 | tt_message() { |
118 | 119 | test "$tt_output_mode" = 'quiet' && return 0 |
130 | 131 | tt_error() { |
131 | 132 | test $tt_missing_nl -eq 1 && echo |
132 | 133 | printf '%s\n' "$tt_my_name: Error: $1" >&2 |
133 | tt_clean_up | |
134 | 134 | exit 2 |
135 | 135 | } |
136 | 136 | tt_debug() { # $1=id, $2=contents |
137 | 137 | test $tt_debug -ne 1 && return 0 |
138 | 138 | if test INPUT_LINE = "$1"; then |
139 | # Original input line is all blue | |
140 | printf "${tt_color_blue}[%10s: %s]${tt_color_off}\n" "$1" "$2" | |
139 | # Original input line is all cyan and preceded by separator line | |
140 | printf -- "${tt_color_cyan}%s${tt_color_off}\n" "$(tt_separator_line)" | |
141 | printf -- "${tt_color_cyan}-- %10s[%s]${tt_color_off}\n" "$1" "$2" | |
141 | 142 | else |
142 | # Highlight tabs and inline prefix | |
143 | printf "${tt_color_blue}[%10s:${tt_color_off} %s${tt_color_blue}]${tt_color_off}\n" "$1" "$2" | | |
144 | sed "/LINE_CMD:/ s/$tt_inline_prefix/${tt_color_red}&${tt_color_off}/g" | | |
143 | # Highlight tabs and the (last) inline prefix | |
144 | printf -- "${tt_color_cyan}-- %10s[${tt_color_off}%s${tt_color_cyan}]${tt_color_off}\n" "$1" "$2" | | |
145 | sed "/LINE_CMD/ s/\(.*\)\($tt_inline_prefix\)/\1${tt_color_red}\2${tt_color_off}/" | | |
145 | 146 | sed "s/$tt_tab/${tt_color_green}<tab>${tt_color_off}/g" |
146 | 147 | fi |
147 | 148 | } |
297 | 298 | ;; |
298 | 299 | esac |
299 | 300 | |
300 | #tt_debug EVAL "$tt_test_command" | |
301 | tt_debug EVAL "$tt_test_command" | |
301 | 302 | |
302 | 303 | # Execute the test command, saving output (STDOUT and STDERR) |
303 | eval "$tt_test_command" > "$tt_test_output_file" 2>&1 | |
304 | eval "$tt_test_command" > "$tt_test_output_file" 2>&1 < /dev/null | |
304 | 305 | tt_test_exit_code=$? |
305 | 306 | |
306 | #tt_debug OUTPUT "$(cat "$tt_test_output_file")" | |
307 | tt_debug OUTPUT "$(cat "$tt_test_output_file")" | |
307 | 308 | |
308 | 309 | # The command output matches the expected output? |
309 | 310 | case $tt_test_mode in |
417 | 418 | |
418 | 419 | # Should I abort now? |
419 | 420 | if test $tt_stop_on_first_fail -eq 1; then |
420 | tt_clean_up | |
421 | 421 | exit 1 |
422 | 422 | fi |
423 | 423 | |
441 | 441 | # Note: read -r to preserve the backslashes |
442 | 442 | while IFS='' read -r tt_input_line || test -n "$tt_input_line"; do |
443 | 443 | tt_line_number=$((tt_line_number + 1)) |
444 | #tt_debug INPUT_LINE "$tt_input_line" | |
444 | tt_debug INPUT_LINE "$tt_input_line" | |
445 | 445 | |
446 | 446 | case "$tt_input_line" in |
447 | 447 | |
448 | 448 | "$tt_prefix$tt_prompt" | "$tt_prefix${tt_prompt% }" | "$tt_prefix$tt_prompt ") |
449 | 449 | # Prompt alone: closes previous command line (if any) |
450 | 450 | |
451 | #tt_debug 'LINE_$' "$tt_input_line" | |
451 | tt_debug 'LINE_$' "$tt_input_line" | |
452 | 452 | |
453 | 453 | # Run pending tests |
454 | 454 | test -n "$tt_test_command" && tt_run_test |
457 | 457 | "$tt_prefix$tt_prompt"*) |
458 | 458 | # This line is a command line to be tested |
459 | 459 | |
460 | #tt_debug LINE_CMD "$tt_input_line" | |
460 | tt_debug LINE_CMD "$tt_input_line" | |
461 | 461 | |
462 | 462 | # Run pending tests |
463 | 463 | test -n "$tt_test_command" && tt_run_test |
474 | 474 | tt_test_command="${tt_test_command%"$tt_inline_prefix"*}" |
475 | 475 | tt_test_inline="${tt_input_line##*"$tt_inline_prefix"}" |
476 | 476 | |
477 | #tt_debug NEW_CMD "$tt_test_command" | |
478 | #tt_debug OK_INLINE "$tt_test_inline" | |
477 | tt_debug NEW_CMD "$tt_test_command" | |
478 | tt_debug OK_INLINE "$tt_test_inline" | |
479 | 479 | |
480 | 480 | # Maybe the OK text has options? |
481 | 481 | case "$tt_test_inline" in |
516 | 516 | ;; |
517 | 517 | esac |
518 | 518 | |
519 | #tt_debug OK_TEXT "$tt_test_inline" | |
519 | tt_debug OK_TEXT "$tt_test_inline" | |
520 | 520 | |
521 | 521 | # There must be a number in --lines and --exit |
522 | 522 | if test "$tt_test_mode" = 'lines' || test "$tt_test_mode" = 'exit'; then |
538 | 538 | # It's a normal command line, output begins in next line |
539 | 539 | tt_test_mode='output' |
540 | 540 | |
541 | #tt_debug NEW_CMD "$tt_test_command" | |
541 | tt_debug NEW_CMD "$tt_test_command" | |
542 | 542 | fi |
543 | 543 | ;; |
544 | 544 | |
545 | 545 | *) |
546 | 546 | # Test output, blank line or comment |
547 | 547 | |
548 | #tt_debug 'LINE_*' "$tt_input_line" | |
548 | tt_debug 'LINE_MISC' "$tt_input_line" | |
549 | 549 | |
550 | 550 | # Ignore this line if there's no pending test |
551 | 551 | test -n "$tt_test_command" || continue |
552 | 552 | |
553 | 553 | # Required prefix is missing: we just left a command block |
554 | 554 | if test -n "$tt_prefix" && test "${tt_input_line#"$tt_prefix"}" = "$tt_input_line"; then |
555 | #tt_debug BLOCK_OUT "$tt_input_line" | |
555 | tt_debug BLOCK_OUT "$tt_input_line" | |
556 | 556 | |
557 | 557 | # Run the pending test and we're done in this line |
558 | 558 | tt_run_test |
562 | 562 | # This line is a test output, save it (without prefix) |
563 | 563 | tt_test_ok_text="$tt_test_ok_text${tt_input_line#"$tt_prefix"}$tt_nl" |
564 | 564 | |
565 | #tt_debug OK_TEXT "${tt_input_line#"$tt_prefix"}" | |
565 | tt_debug OK_TEXT "${tt_input_line#"$tt_prefix"}" | |
566 | 566 | ;; |
567 | 567 | esac |
568 | 568 | done < "$tt_temp_file" |
569 | 569 | |
570 | #tt_debug LOOP_OUT "\$tt_test_command=$tt_test_command" | |
570 | tt_debug LOOP_OUT "\$tt_test_command=$tt_test_command" | |
571 | 571 | |
572 | 572 | # Run pending tests |
573 | 573 | test -n "$tt_test_command" && tt_run_test |
588 | 588 | |
589 | 589 | ### Init process |
590 | 590 | |
591 | # Temporary files (using files because <(...) is not portable) | |
592 | tt_temp_dir= | |
593 | tt_make_temp_dir # sets global $tt_temp_dir | |
594 | tt_temp_file="$tt_temp_dir/temp.txt" | |
595 | tt_stdin_file="$tt_temp_dir/stdin.txt" | |
596 | tt_test_ok_file="$tt_temp_dir/ok.txt" | |
597 | tt_test_output_file="$tt_temp_dir/output.txt" | |
598 | ||
599 | 591 | # Handle command line options |
600 | 592 | while test "${1#-}" != "$1"; do |
601 | 593 | case "$1" in |
635 | 627 | tt_post_command="$1" |
636 | 628 | shift |
637 | 629 | ;; |
638 | --debug) | |
639 | shift | |
640 | tt_debug=1 | |
641 | ;; | |
642 | 630 | -P | --progress) |
643 | 631 | shift |
644 | 632 | tt_progress="$1" |
677 | 665 | -V | --version) |
678 | 666 | printf '%s %s\n' "$tt_my_name" "$tt_my_version" |
679 | 667 | exit 0 |
668 | ;; | |
669 | --debug) | |
670 | # Undocumented dev-only option | |
671 | shift | |
672 | tt_debug=1 | |
680 | 673 | ;; |
681 | 674 | --) |
682 | 675 | # No more options to process |
770 | 763 | if test $tt_use_colors -eq 1; then |
771 | 764 | tt_color_red=$( printf '\033[31m') # fail |
772 | 765 | tt_color_green=$(printf '\033[32m') # ok |
773 | tt_color_blue=$( printf '\033[34m') # debug | |
774 | #tt_color_cyan=$( printf '\033[36m') # not used | |
766 | tt_color_cyan=$( printf '\033[36m') # debug | |
775 | 767 | tt_color_off=$( printf '\033[m') |
776 | 768 | fi |
777 | 769 | |
795 | 787 | fi |
796 | 788 | |
797 | 789 | ### Real execution begins here |
790 | ||
791 | trap tt_clean_up EXIT | |
792 | ||
793 | # Temporary files (using files because <(...) is not portable) | |
794 | tt_make_temp_dir # sets global $tt_temp_dir | |
795 | tt_temp_file="$tt_temp_dir/temp.txt" | |
796 | tt_stdin_file="$tt_temp_dir/stdin.txt" | |
797 | tt_test_ok_file="$tt_temp_dir/ok.txt" | |
798 | tt_test_output_file="$tt_temp_dir/output.txt" | |
798 | 799 | |
799 | 800 | # Some preparing command to run before all the tests? |
800 | 801 | if test -n "$tt_pre_command"; then |
869 | 870 | test $tt_missing_nl -eq 1 && tt_missing_nl=0 && tt_message |
870 | 871 | done |
871 | 872 | |
872 | tt_clean_up | |
873 | ||
874 | 873 | # Some clean up command to run after all the tests? |
875 | 874 | if test -n "$tt_post_command"; then |
876 | 875 | eval "$tt_post_command" || |
912 | 911 | if test $tt_nr_files -gt 1 && test "$tt_output_mode" != 'quiet'; then |
913 | 912 | echo |
914 | 913 | printf ' %5s %5s %5s\n' ok fail skip |
915 | printf %s "$tt_files_stats" | while read -r ok fail skip; do | |
914 | printf %s "$tt_files_stats" | while IFS=' ' read -r ok fail skip; do | |
916 | 915 | printf ' %5s %5s %5s %s\n' "$ok" "$fail" "$skip" "$1" |
917 | 916 | shift |
918 | 917 | done | sed 's/ 0/ -/g' # hide zeros |
0 | clitest (0.4.0+git20221025.1.3d6ebeb-1) UNRELEASED; urgency=low | |
1 | ||
2 | * New upstream snapshot. | |
3 | ||
4 | -- Debian Janitor <janitor@jelmer.uk> Sun, 30 Oct 2022 18:07:17 -0000 | |
5 | ||
0 | 6 | clitest (0.4.0-1) unstable; urgency=medium |
1 | 7 | |
2 | 8 | * New upstream version 0.4.0 |
8 | 8 | |
9 | 9 | $ echo 'ok' > /tmp/foo.txt |
10 | 10 | $ echo 'ok' #=> --file /tmp/foo.txt |
11 | $ rm /tmp/foo.txt | |
12 | $ | |
11 | 13 | |
12 | 14 | # Syntax: Must be exactly one space before and after --file |
13 | 15 |
0 | # If multiple markers, only the last one is identified as such | |
1 | # There are 4 ' #=> ' marker-like occurrences in this test. | |
2 | ||
3 | $ echo "a #=> b #=> c" #=> --lines 99 #=> --lines 1 |
0 | # Test file to be run with --debug | |
1 | ||
2 | $ echo "tab+space " #=> tab+space | |
3 | $ | |
4 | # A comment line between command blocks | |
5 | $ echo "unclosed block" | |
6 | unclosed block |
0 | # | |
1 | # This was a bug found on early versions of clitest in which tests shared | |
2 | # STDIN with clitest and with each other, causing unexpected results when | |
3 | # a test read from STDIN. This was reported on issue #42 on Github. | |
4 | # | |
5 | # Testing for a regression. | |
6 | # | |
7 | ||
8 | $ echo testing stdin isolation ; read stdin_isolation | |
9 | testing stdin isolation | |
10 | $ echo Failed\? Regression to stdin isolation added. ; unset stdin_isolation | |
11 | Failed? Regression to stdin isolation added. |
119 | 119 | |
120 | 120 | ``` |
121 | 121 | $ ./clitest --version |
122 | clitest 0.4.0 | |
122 | clitest dev | |
123 | 123 | $ ./clitest -V |
124 | clitest 0.4.0 | |
124 | clitest dev | |
125 | 125 | $ |
126 | 126 | ``` |
127 | 127 | |
193 | 193 | $ |
194 | 194 | ``` |
195 | 195 | |
196 | ## Option --quiet has no effect in --debug (disabled) | |
197 | ||
198 | ``` | |
199 | # $ ./clitest --quiet --debug test/ok-2.sh | |
200 | # [INPUT_LINE: $ echo ok] | |
201 | # [ LINE_CMD: $ echo ok] | |
202 | # [ NEW_CMD: echo ok] | |
203 | # [INPUT_LINE: ok] | |
204 | # [ LINE_*: ok] | |
205 | # [ OK_TEXT: ok] | |
206 | # [INPUT_LINE: $ echo ok #=> ok] | |
207 | # [ LINE_CMD: $ echo ok #=> ok] | |
208 | # [ EVAL: echo ok] | |
209 | # [ OUTPUT: ok] | |
210 | # [ NEW_CMD: echo ok ] | |
211 | # [ OK_INLINE: ok] | |
212 | # [ OK_TEXT: ok] | |
213 | # [ EVAL: echo ok ] | |
214 | # [ OUTPUT: ok] | |
215 | # [ LOOP_OUT: $test_command=] | |
216 | # $ | |
196 | ## Option --quiet has no effect in --debug | |
197 | ||
198 | ``` | |
199 | $ ./clitest --debug --quiet test/ok-1.sh | grep -o INPUT_LINE | |
200 | INPUT_LINE | |
201 | INPUT_LINE | |
202 | $ | |
203 | ``` | |
204 | ||
205 | ## Option --debug | |
206 | ||
207 | Tricky test file with: empty line, inline marker, tab, $, comment line, normal command, unclosed block. | |
208 | ||
209 | ``` | |
210 | $ ./clitest --debug test/option-debug.sh | |
211 | -------------------------------------------------------------------------------- | |
212 | -- INPUT_LINE[# Test file to be run with --debug] | |
213 | -- LINE_MISC[# Test file to be run with --debug] | |
214 | -------------------------------------------------------------------------------- | |
215 | -- INPUT_LINE[] | |
216 | -- LINE_MISC[] | |
217 | -------------------------------------------------------------------------------- | |
218 | -- INPUT_LINE[$ echo "tab+space " #=> tab+space ] | |
219 | -- LINE_CMD[$ echo "tab+space<tab> "<tab> #=> tab+space<tab> ] | |
220 | -- NEW_CMD[echo "tab+space<tab> "<tab> ] | |
221 | -- OK_INLINE[tab+space<tab> ] | |
222 | -- OK_TEXT[tab+space<tab> ] | |
223 | #1 echo "tab+space " | |
224 | -- EVAL[echo "tab+space<tab> "<tab> ] | |
225 | -- OUTPUT[tab+space<tab> ] | |
226 | -------------------------------------------------------------------------------- | |
227 | -- INPUT_LINE[$] | |
228 | -- LINE_$[$] | |
229 | -------------------------------------------------------------------------------- | |
230 | -- INPUT_LINE[# A comment line between command blocks] | |
231 | -- LINE_MISC[# A comment line between command blocks] | |
232 | -------------------------------------------------------------------------------- | |
233 | -- INPUT_LINE[$ echo "unclosed block"] | |
234 | -- LINE_CMD[$ echo "unclosed block"] | |
235 | -- NEW_CMD[echo "unclosed block"] | |
236 | -------------------------------------------------------------------------------- | |
237 | -- INPUT_LINE[unclosed block] | |
238 | -- LINE_MISC[unclosed block] | |
239 | -- OK_TEXT[unclosed block] | |
240 | -- LOOP_OUT[$tt_test_command=echo "unclosed block"] | |
241 | #2 echo "unclosed block" | |
242 | -- EVAL[echo "unclosed block"] | |
243 | -- OUTPUT[unclosed block] | |
244 | OK: 2 of 2 tests passed | |
245 | $ | |
246 | ``` | |
247 | ||
248 | ## Option --debug with colors | |
249 | ||
250 | - Separator line is cyan | |
251 | - `INPUT_LINE[...]` is cyan, others are normal color inside `[]` | |
252 | - `<tab>` must be green | |
253 | - `#=>` inline marker must be red | |
254 | ||
255 | This test forces `--color always` because normally the tests inside this file are not colored (output is not a terminal). Note that the escape character (`\033`) is removed to have only printable ASCII characters in the output. | |
256 | ||
257 | ``` | |
258 | $ ./clitest --debug --color always test/option-debug-color.sh | head -n 3 | tr -d '\033' | |
259 | [36m--------------------------------------------------------------------------------[m | |
260 | [36m-- INPUT_LINE[$ echo "tab " #=> tab ][m | |
261 | [36m-- LINE_CMD[[m$ echo "tab[32m<tab>[m" [31m#=> [mtab[32m<tab>[m[36m][m | |
262 | $ | |
263 | ``` | |
264 | ||
265 | In case of multiple `#=>`, only the last one should be red: | |
266 | ||
267 | ``` | |
268 | $ ./clitest --debug --color always test/inline-multiple-marker.sh | command grep LINE_CMD | tr -d '\033' | |
269 | [36m-- LINE_CMD[[m$ echo "a #=> b #=> c" #=> --lines 99 [31m#=> [m--lines 1[36m][m | |
270 | $ | |
217 | 271 | ``` |
218 | 272 | |
219 | 273 | ## Option --color |
229 | 283 | |
230 | 284 | Color ON |
231 | 285 | |
232 | ``` | |
233 | $ ./clitest --color always test/ok-1.sh | |
234 | #1 echo ok | |
235 | [32mOK:[m 1 of 1 test passed | |
236 | $ ./clitest --color yes test/ok-1.sh | |
237 | #1 echo ok | |
238 | [32mOK:[m 1 of 1 test passed | |
286 | > Note that the escape character (`\033`) is removed to have only printable ASCII characters in the output. | |
287 | ||
288 | ``` | |
289 | $ ./clitest --color always test/ok-1.sh | tr -d '\033' | |
290 | #1 echo ok | |
291 | [32mOK:[m 1 of 1 test passed | |
292 | $ ./clitest --color yes test/ok-1.sh | tr -d '\033' | |
293 | #1 echo ok | |
294 | [32mOK:[m 1 of 1 test passed | |
239 | 295 | $ |
240 | 296 | ``` |
241 | 297 | |
265 | 321 | |
266 | 322 | The real default `--color auto` cannot be tested here. |
267 | 323 | Test it by hand at the command line. |
268 | ||
269 | ``` | |
270 | ## $ ./clitest test/ok-1.sh | |
271 | ## [32mOK![m The single test has passed. | |
272 | ## $ ./clitest --color auto test/ok-1.sh | |
273 | ## [32mOK![m The single test has passed. | |
274 | ## $ | |
275 | ``` | |
276 | 324 | |
277 | 325 | ## Option --list |
278 | 326 | |
345 | 393 | |
346 | 394 | Normal results (using colors) and exit code |
347 | 395 | |
348 | ``` | |
349 | $ ./clitest --list-run --color yes test/no-nl-command.sh; echo $? | |
350 | [32m#1 printf 'ok\n'[m | |
351 | [31m#2 printf 'fail'[m | |
352 | [31m#3 printf 'ok\nok\nfail'[m | |
353 | [32m#4 printf 'ok\n' [m | |
354 | [31m#5 printf 'fail' [m | |
355 | [32m#6 printf 'ok'; echo [m | |
356 | [32m#7 printf 'ok' [m | |
396 | > Note that the escape character (`\033`) is removed to have only printable ASCII characters in the output. | |
397 | ||
398 | ``` | |
399 | $ ./clitest --list-run --color always test/no-nl-command.sh > /tmp/foo.txt; echo $? | |
357 | 400 | 1 |
401 | $ cat /tmp/foo.txt | tr -d '\033' | |
402 | [32m#1 printf 'ok\n'[m | |
403 | [31m#2 printf 'fail'[m | |
404 | [31m#3 printf 'ok\nok\nfail'[m | |
405 | [32m#4 printf 'ok\n' [m | |
406 | [31m#5 printf 'fail' [m | |
407 | [32m#6 printf 'ok'; echo [m | |
408 | [32m#7 printf 'ok' [m | |
409 | $ rm /tmp/foo.txt | |
358 | 410 | $ |
359 | 411 | ``` |
360 | 412 | |
1071 | 1123 | OK: 19 of 19 tests passed |
1072 | 1124 | $ |
1073 | 1125 | ``` |
1126 | ||
1127 | In case of multiple `#=>`, consider only the last one: | |
1128 | ||
1129 | ``` | |
1130 | $ ./clitest test/inline-multiple-marker.sh | |
1131 | #1 echo "a #=> b #=> c" #=> --lines 99 | |
1132 | OK: 1 of 1 test passed | |
1133 | $ | |
1074 | 1134 | |
1075 | 1135 | ## Inline match modes |
1076 | 1136 | |
1243 | 1303 | #1 OK printf '$ echo ok\nok\n' |
1244 | 1304 | #2 OK echo 'ok' > /tmp/foo.txt |
1245 | 1305 | #3 OK echo 'ok' |
1246 | #4 FAIL echo 'fail' | |
1306 | #4 OK rm /tmp/foo.txt | |
1247 | 1307 | #5 FAIL echo 'fail' |
1248 | #6 OK echo '--file' | |
1249 | #7 OK echo '--filer' | |
1250 | #8 OK echo '--file is cool' | |
1308 | #6 FAIL echo 'fail' | |
1309 | #7 OK echo '--file' | |
1310 | #8 OK echo '--filer' | |
1311 | #9 OK echo '--file is cool' | |
1251 | 1312 | $ |
1252 | 1313 | ``` |
1253 | 1314 | |
2190 | 2251 | $ |
2191 | 2252 | ``` |
2192 | 2253 | |
2254 | STDIN Isolation | |
2255 | ||
2256 | ``` | |
2257 | $ ./clitest --quiet test/stdin-isolation.sh ; echo $? | |
2258 | 0 | |
2259 | $ | |
2260 | ``` | |
2261 | ||
2262 | Temporary files and directories must be removed after execution | |
2263 | ||
2264 | ``` | |
2265 | $ TMPDIR__TEST=$(mktemp -d) | |
2266 | $ TMPDIR="$TMPDIR__TEST" ./clitest --help >/dev/null 2>&1 | |
2267 | $ find "$TMPDIR__TEST" -mindepth 1 | |
2268 | $ echo '$ true' | TMPDIR="$TMPDIR__TEST" ./clitest --debug - >/dev/null 2>&1 | |
2269 | $ find "$TMPDIR__TEST" -mindepth 1 | |
2270 | $ unset TMPDIR__TEST | |
2271 | $ | |
2272 | ``` | |
2193 | 2273 | Multiple commands in one line |
2194 | 2274 | |
2195 | 2275 | ``` |
2327 | 2407 | |
2328 | 2408 | ## And now, the colored output tests |
2329 | 2409 | |
2330 | ``` | |
2331 | $ ./clitest --color yes --first test/fail-2.sh | |
2332 | #1 echo ok | |
2333 | [31m--------------------------------------------------------------------------------[m | |
2334 | [31m[FAILED #1, line 1] echo ok[m | |
2410 | > Note that the escape character (`\033`) is removed to have only printable ASCII characters in the output. | |
2411 | ||
2412 | ``` | |
2413 | $ ./clitest --color yes --first test/fail-2.sh | tr -d '\033' | |
2414 | #1 echo ok | |
2415 | [31m--------------------------------------------------------------------------------[m | |
2416 | [31m[FAILED #1, line 1] echo ok[m | |
2335 | 2417 | @@ -1 +1 @@ |
2336 | 2418 | -fail |
2337 | 2419 | +ok |
2338 | [31m--------------------------------------------------------------------------------[m | |
2339 | $ | |
2340 | ``` | |
2420 | [31m--------------------------------------------------------------------------------[m | |
2421 | $ | |
2422 | ``` |