|
| 1 | +#compdef bashunit |
| 2 | +# zsh completion for bashunit |
| 3 | +# |
| 4 | +# Install: copy this file as _bashunit into a directory in your $fpath, e.g. |
| 5 | +# cp completions/_bashunit /usr/local/share/zsh/site-functions/_bashunit |
| 6 | +# then restart zsh (or reinitialize completions with compinit). |
| 7 | +# |
| 8 | +# Kept in sync with src/main.sh by tests/unit/completions_test.sh (anti-drift). |
| 9 | + |
| 10 | +_bashunit() { |
| 11 | + local curcontext="$curcontext" ret=1 |
| 12 | + |
| 13 | + # `bashunit assert <fn>` completes the public assertion names. |
| 14 | + if (( CURRENT == 3 )) && [ "${words[2]}" = "assert" ]; then |
| 15 | + local -a assert_fns |
| 16 | + assert_fns=( |
| 17 | + assert_array_contains assert_array_length assert_array_not_contains |
| 18 | + assert_arrays_equal assert_command_not_found assert_contains |
| 19 | + assert_contains_ignore_case assert_date_after assert_date_before |
| 20 | + assert_date_equals assert_date_within_delta assert_date_within_range |
| 21 | + assert_directory_exists assert_directory_not_exists assert_duration |
| 22 | + assert_duration_greater_than assert_duration_less_than assert_empty |
| 23 | + assert_equals assert_exec assert_exit_code assert_false |
| 24 | + assert_file_contains assert_file_exists assert_file_not_contains |
| 25 | + assert_file_not_exists assert_file_permissions assert_files_equals |
| 26 | + assert_files_not_equals assert_general_error assert_greater_or_equal_than |
| 27 | + assert_greater_than assert_is_directory assert_is_directory_empty |
| 28 | + assert_is_directory_not_empty assert_is_directory_not_readable |
| 29 | + assert_is_directory_not_writable assert_is_directory_readable |
| 30 | + assert_is_directory_writable assert_is_file assert_is_file_empty |
| 31 | + assert_json_contains assert_json_equals assert_json_key_exists |
| 32 | + assert_less_or_equal_than assert_less_than assert_line_count |
| 33 | + assert_match_snapshot assert_match_snapshot_ignore_colors assert_matches |
| 34 | + assert_not_contains assert_not_empty assert_not_equals assert_not_matches |
| 35 | + assert_not_same assert_same assert_string_ends_with |
| 36 | + assert_string_matches_format assert_string_not_ends_with |
| 37 | + assert_string_not_matches_format assert_string_not_starts_with |
| 38 | + assert_string_starts_with assert_successful_code assert_true |
| 39 | + assert_unsuccessful_code assert_within_delta |
| 40 | + ) |
| 41 | + compadd -a assert_fns |
| 42 | + return 0 |
| 43 | + fi |
| 44 | + |
| 45 | + if (( CURRENT == 2 )); then |
| 46 | + local -a subcommands |
| 47 | + subcommands=( |
| 48 | + 'test:Run tests (default command)' |
| 49 | + 'bench:Run benchmarks' |
| 50 | + 'doc:Display assertion documentation' |
| 51 | + 'init:Initialize a new test directory' |
| 52 | + 'learn:Start interactive tutorial' |
| 53 | + 'upgrade:Upgrade bashunit to latest version' |
| 54 | + 'assert:Run standalone assertion' |
| 55 | + 'watch:Watch files and rerun tests on change' |
| 56 | + ) |
| 57 | + _describe 'bashunit command' subcommands && ret=0 |
| 58 | + fi |
| 59 | + |
| 60 | + _arguments \ |
| 61 | + '(-a --assert)'{-a,--assert}'[Run a standalone assert function]:function:' \ |
| 62 | + '(-e --env --boot)'{-e,--env,--boot}'[Load a custom env/bootstrap file]:file:_files' \ |
| 63 | + '(-f --filter)'{-f,--filter}'[Only run tests matching the name]:name:' \ |
| 64 | + '--tag[Only run tests with matching @tag]:tag:' \ |
| 65 | + '--exclude-tag[Skip tests with matching @tag]:tag:' \ |
| 66 | + '--log-junit[Write JUnit XML report]:file:_files' \ |
| 67 | + '--report-junit[Write JUnit XML report]:file:_files' \ |
| 68 | + '--log-gha[Write GitHub Actions workflow-commands log]:file:_files' \ |
| 69 | + '(-j --jobs)'{-j,--jobs}'[Max N parallel jobs, or auto]:jobs:(auto)' \ |
| 70 | + '(-p --parallel)'{-p,--parallel}'[Run tests in parallel]' \ |
| 71 | + '--no-parallel[Run tests sequentially]' \ |
| 72 | + '(-r --report-html)'{-r,--report-html}'[Write HTML report]:file:_files' \ |
| 73 | + '--report-tap[Write TAP version 13 report]:file:_files' \ |
| 74 | + '--report-json[Write machine-readable JSON report]:file:_files' \ |
| 75 | + '(-s --simple)'{-s,--simple}'[Simple output with dots]' \ |
| 76 | + '--detailed[Detailed output, the default]' \ |
| 77 | + '--output[Output format]:format:(tap)' \ |
| 78 | + '(-R --run-all)'{-R,--run-all}'[Run all assertions without stopping on first failure]' \ |
| 79 | + '(-S --stop-on-failure)'{-S,--stop-on-failure}'[Stop on first failure]' \ |
| 80 | + '--test-timeout[Fail a test running longer than N seconds]:seconds:' \ |
| 81 | + '--retry[Rerun a failed test up to N extra times]:count:' \ |
| 82 | + '--random-order[Randomize test execution order]' \ |
| 83 | + '--seed[Seed for random order]:seed:' \ |
| 84 | + '--shard[Run shard i of n]:shard:' \ |
| 85 | + '--rerun-failed[Replay only the tests that failed on the last run]' \ |
| 86 | + '(-vvv --verbose)'{-vvv,--verbose}'[Show execution details]' \ |
| 87 | + '--debug[Enable shell debug mode]::file:_files' \ |
| 88 | + '--no-output[Suppress all output]' \ |
| 89 | + '--failures-only[Only show failures]' \ |
| 90 | + '--fail-on-risky[Treat tests without assertions as failures]' \ |
| 91 | + '--profile[Report the slowest tests]' \ |
| 92 | + '--no-progress[Suppress real-time progress]' \ |
| 93 | + '--show-output[Show test output on failure]' \ |
| 94 | + '--no-output-on-failure[Hide test output on failure]' \ |
| 95 | + '--show-skipped[Show skipped tests summary]' \ |
| 96 | + '--show-incomplete[Show incomplete tests summary]' \ |
| 97 | + '--strict[Enable strict shell mode]' \ |
| 98 | + '--skip-env-file[Skip .env loading]' \ |
| 99 | + '(-l --login)'{-l,--login}'[Run tests in login shell context]' \ |
| 100 | + '(-w --watch)'{-w,--watch}'[Watch for changes and rerun tests]' \ |
| 101 | + '--no-color[Disable colored output]' \ |
| 102 | + '--coverage[Enable code coverage tracking]' \ |
| 103 | + '--coverage-paths[Paths to track]:paths:_files' \ |
| 104 | + '--coverage-exclude[Coverage exclusion patterns]:pattern:' \ |
| 105 | + '--coverage-report[LCOV output path]:file:_files' \ |
| 106 | + '--coverage-report-html[Generate HTML coverage report]::dir:_files' \ |
| 107 | + '--coverage-min[Minimum coverage threshold]:percent:' \ |
| 108 | + '--no-coverage-report[Console coverage output only]' \ |
| 109 | + '(-h --help)'{-h,--help}'[Show help message]' \ |
| 110 | + '*:path:_files' && ret=0 |
| 111 | + |
| 112 | + return ret |
| 113 | +} |
| 114 | + |
| 115 | +_bashunit "$@" |
0 commit comments