No flags found
Use flags to group coverage reports by test type, project and/or folders.
Then setup custom commit statuses and notifications for each flag.
e.g., #unittest #integration
#production #enterprise
#frontend #backend
410365f
... +2 ...
d635402
Use flags to group coverage reports by test type, project and/or folders.
Then setup custom commit statuses and notifications for each flag.
e.g., #unittest #integration
#production #enterprise
#frontend #backend
1 | + | # shellcheck shell=sh |
|
2 | + | ||
3 | + | # shellcheck disable=SC1083,SC2016 |
|
4 | + | parser_definition() { |
|
5 | + | : "${2?No variable prefix specified}" |
|
6 | + | : "${3?No message handler specified}" |
|
7 | + | ||
8 | + | extension "$@" |
|
9 | + | set -- "$1" "$2" "error_handler ${3:-echo}" |
|
10 | + | ||
11 | + | setup params export:true error:"$3" abbr:true help:usage width:36 leading:' ' -- \ |
|
12 | + | 'Usage: shellspec [options...] [files or directories...]' \ |
|
13 | + | '' \ |
|
14 | + | ' Using + instead of - for short options causes reverses the meaning' \ |
|
15 | + | '' |
|
16 | + | param SHELL -s --shell -- \ |
|
17 | + | 'Specify a path of shell [default: "auto" (the shell running shellspec)]' \ |
|
18 | + | ' ShellSpec ignores shebang and runs in the specified shell.' |
|
19 | + | ||
20 | + | param :'set_path PATH' --path var:PATH -- \ |
|
21 | + | 'Set PATH environment variable at startup' \ |
|
22 | + | " e.g. --path /bin:/usr/bin, --path \"\$(getconf PATH)\"" |
|
23 | + | ||
24 | + | flag SANDBOX --{no-}sandbox -- \ |
|
25 | + | 'Force the use of the mock instead of the actual command' \ |
|
26 | + | ' Make PATH empty (except "spec/support/bin" and mock dir) and readonly' \ |
|
27 | + | ' This is not a security feature and does not provide complete isolation' |
|
28 | + | ||
29 | + | param SANDBOX_PATH --sandbox-path var:PATH -- \ |
|
30 | + | 'Make PATH the sandbox path instead of empty (default: empty)' |
|
31 | + | ||
32 | + | multi REQUIRES ':' --require var:MODULE -- \ |
|
33 | + | 'Require a MODULE (shell script file)' |
|
34 | + | ||
35 | + | param :set_env -e --env validate:check_env_name var:'NAME[=VALUE]' -- \ |
|
36 | + | 'Set environment variable' |
|
37 | + | ||
38 | + | param ENV_FROM --env-from validate:check_env_file var:ENV-SCRIPT -- \ |
|
39 | + | 'Set environment variable from shell script file' |
|
40 | + | ||
41 | + | flag WARNING_AS_FAILURE -w +w --{no-}warning-as-failure init:@on -- \ |
|
42 | + | 'Treat warning as failure [default: enabled]' |
|
43 | + | ||
44 | + | option FAIL_FAST_COUNT --{no-}fail-fast on:1 validate:check_number \ |
|
45 | + | label:' --{no-}fail-fast[=COUNT]' -- \ |
|
46 | + | 'Abort the run after first (or COUNT) of failures [default: disabled]' |
|
47 | + | ||
48 | + | flag FAIL_NO_EXAMPLES --{no-}fail-no-examples -- \ |
|
49 | + | 'Fail if no examples found [default: disabled]' |
|
50 | + | ||
51 | + | flag FAIL_LOW_COVERAGE --{no-}fail-low-coverage -- \ |
|
52 | + | 'Fail on low coverage [default: disabled]' \ |
|
53 | + | ' The coverage threshold is specified by the coverage option' |
|
54 | + | ||
55 | + | param FAILURE_EXIT_CODE --failure-exit-code validate:check_number init:=101 var:CODE -- \ |
|
56 | + | 'Override the exit code used when there are failing specs [default: 101]' |
|
57 | + | ||
58 | + | param ERROR_EXIT_CODE --error-exit-code validate:check_number init:=102 var:CODE -- \ |
|
59 | + | 'Override the exit code used when there are fatal errors [default: 102]' |
|
60 | + | ||
61 | + | flag PROFILER -p +p --{no-}profile -- \ |
|
62 | + | 'Enable profiling and list the slowest examples [default: disabled]' \ |
|
63 | + | ' Profiler tries to use 100% ability of 1 CPU (1 core).' \ |
|
64 | + | ' Therefore, not recommended for single(-core) CPU.' |
|
65 | + | ||
66 | + | param PROFILER_LIMIT --profile-limit validate:check_number init:=10 var:N -- \ |
|
67 | + | 'List the top N slowest examples [default: 10]' |
|
68 | + | ||
69 | + | flag :boost --{no-}boost -- \ |
|
70 | + | 'Increase the CPU frequency to boost up testing speed [default: disabled]' \ |
|
71 | + | ' Equivalent of --profile --profile-limit 0' \ |
|
72 | + | " (Don't worry, this is not overclocking. This is joke option but works.)" |
|
73 | + | ||
74 | + | param LOGFILE --log-file init:='/dev/tty' -- \ |
|
75 | + | 'Log file for %logger directive and trace [default: /dev/tty]' |
|
76 | + | ||
77 | + | param TMPDIR --tmpdir init:"export $2_TMPDIR="'${TMPDIR:-${TMP:-/tmp}}' -- \ |
|
78 | + | 'Specify temporary directory [default: $TMPDIR, $TMP or /tmp]' |
|
79 | + | ||
80 | + | flag KEEP_TMPDIR --keep-tmpdir -- \ |
|
81 | + | 'Do not cleanup temporary directory [default: disabled]' |
|
82 | + | flag KEEP_TMPDIR --keep-tempdir validate:'deprecated "$1"' abbr: hidden:true |
|
83 | + | ||
84 | + | msg -- '' ' **** Execution ****' '' |
|
85 | + | ||
86 | + | flag QUICK -q +q --{no-}quick -- \ |
|
87 | + | 'Run not-passed examples if it exists, otherwise run all [default: disabled]' \ |
|
88 | + | ' not-passed examples: failure and temporary pending examples' \ |
|
89 | + | ' Quick mode is automatically enabled. To disable quick mode,' \ |
|
90 | + | ' delete .shellspec-quick.log on the project root directory.' |
|
91 | + | ||
92 | + | flag :only_failures -r --repair --only-failures -- \ |
|
93 | + | 'Run failure examples only (Depends on quick mode)' |
|
94 | + | ||
95 | + | flag :next_failure -n --next-failure -- \ |
|
96 | + | 'Run failure examples and abort on first failure (Depends on quick mode)' \ |
|
97 | + | ' Equivalent of --repair --fail-fast --random none' |
|
98 | + | ||
99 | + | param WORKERS -j --jobs validate:check_number init:=0 var:JOBS -- \ |
|
100 | + | 'Number of parallel jobs to run [default: 0 (disabled)]' |
|
101 | + | ||
102 | + | param :random --random validate:check_random init:='' var:"TYPE[:SEED]" -- \ |
|
103 | + | 'Run examples by the specified random type | <[none]> [specfiles] [examples]' \ |
|
104 | + | ' [none] run in the defined order [default]' \ |
|
105 | + | ' [specfiles] randomize the order of specfiles' \ |
|
106 | + | ' [examples] randomize the order of examples (slow)' |
|
107 | + | ||
108 | + | flag :xtrace -x --xtrace on:1 init:=0 -- \ |
|
109 | + | 'Run examples with trace output of evaluation enabled [default: disabled]' \ |
|
110 | + | ' Fall back to --xtrace-only if BASH_XTRACEFD not supported.' |
|
111 | + | ||
112 | + | flag :xtrace -X --xtrace-only on:2 -- \ |
|
113 | + | 'Run examples with trace output only enabled [default: disabled]' \ |
|
114 | + | ' The evaluation is executed, but the expectations are skipped.' |
|
115 | + | ||
116 | + | flag DRYRUN --dry-run -- \ |
|
117 | + | 'Print the formatter output without running any examples [default: disabled]' |
|
118 | + | ||
119 | + | msg -- '' ' **** Output ****' '' |
|
120 | + | ||
121 | + | flag BANNER --{no-}banner init:@on -- \ |
|
122 | + | "Show banner if exist 'spec/banner' [default: enabled]" |
|
123 | + | ||
124 | + | param FORMATTER -f --format validate:check_formatter init:='progress' -- \ |
|
125 | + | 'Choose a formatter for display | <[p]> [d] [t] [j] [f] [null] [debug]' \ |
|
126 | + | ' [p]rogress dots [default]' \ |
|
127 | + | ' [d]ocumentation group and example names' \ |
|
128 | + | ' [t]ap TAP format' \ |
|
129 | + | ' [j]unit JUnit XML (time attributre with --profile)' \ |
|
130 | + | ' [f]ailures file:line:message (suitable for editors integration)' \ |
|
131 | + | ' [null] do not display anything' \ |
|
132 | + | ' [debug] for developers' \ |
|
133 | + | ' custom formatter name' |
|
134 | + | ||
135 | + | multi GENERATORS ' ' -o --output validate:check_formatter var:FORMATTER -- \ |
|
136 | + | 'Choose a generator(s) to generate a report file(s) [default: none]' \ |
|
137 | + | ' You can use the same name as FORMATTER. (multiple options allowed)' |
|
138 | + | ||
139 | + | flag COLOR --{no-}color init:"detect_color_mode $2" -- \ |
|
140 | + | 'Enable or disable color [default: enabled if the output is a TTY]' \ |
|
141 | + | ' Disable if NO_COLOR environment variable set' |
|
142 | + | flag COLOR --{no-}colour --force-color --force-colour init:@none hidden abbr: |
|
143 | + | ||
144 | + | param SKIP_MESSAGE --skip-message pattern:'verbose | moderate | quiet' init:='verbose' var:VERBOSITY -- \ |
|
145 | + | 'Mute skip message | <[verbose]> [moderate] [quiet]' \ |
|
146 | + | ' [verbose] do not mute any messages [default]' \ |
|
147 | + | ' [moderate] mute repeated messages' \ |
|
148 | + | ' [quiet] mute repeated or non-temporary messages' |
|
149 | + | ||
150 | + | param PENDING_MESSAGE --pending-message pattern:'verbose | quiet' init:='verbose' var:VERBOSITY -- \ |
|
151 | + | 'Mute pending message | <[verbose]> [quiet]' \ |
|
152 | + | ' [verbose] do not mute any messages [default]' \ |
|
153 | + | ' [quiet] mute non-temporary messages' |
|
154 | + | ||
155 | + | flag :quiet --quiet -- \ |
|
156 | + | 'Equivalent of --skip-message quiet --pending-message quiet' |
|
157 | + | ||
158 | + | flag DEPRECATION_LOG --show-deprecations on:1 init:@on hidden |
|
159 | + | flag DEPRECATION_LOG --hide-deprecations on: init:@none \ |
|
160 | + | label:' --(show|hide)-deprecations' -- \ |
|
161 | + | 'Show or hide deprecations details [default: show]' |
|
162 | + | ||
163 | + | msg -- '' ' **** Ranges / Filters / Focus ****' '' |
|
164 | + | ||
165 | + | msg -- ' You can run selected examples by specified the line numbers or ids' \ |
|
166 | + | '' \ |
|
167 | + | ' shellspec path/to/a_spec.sh:10 # Run the groups or examples that includes lines 10' \ |
|
168 | + | ' shellspec path/to/a_spec.sh:@1-5 # Run the 5th groups/examples defined in the 1st group' \ |
|
169 | + | ' shellspec a_spec.sh:10:@1:20:@2 # You can mixing multiple line numbers and ids with join by ":"' \ |
|
170 | + | '' |
|
171 | + | ||
172 | + | flag FOCUS_FILTER -F --focus -- \ |
|
173 | + | 'Run focused groups / examples only' |
|
174 | + | ||
175 | + | param PATTERN -P --pattern init:='*_spec.sh' -- \ |
|
176 | + | 'Load files matching pattern [default: "*_spec.sh"]' |
|
177 | + | ||
178 | + | multi EXAMPLE_FILTER '|' -E --example var:PATTERN -- \ |
|
179 | + | 'Run examples whose names include PATTERN' |
|
180 | + | ||
181 | + | multi TAG_FILTER ',' -T --tag var:'TAG[:VALUE]' -- \ |
|
182 | + | 'Run examples with the specified TAG' |
|
183 | + | ||
184 | + | param DEFAULT_PATH -D --default-path init:='spec' var:PATH -- \ |
|
185 | + | 'Set the default path where looks for examples [default: "spec"]' |
|
186 | + | ||
187 | + | msg -- '' ' **** Coverage ****' '' |
|
188 | + | ||
189 | + | flag KCOV --{no-}kcov -- \ |
|
190 | + | 'Enable coverage using kcov [default: disabled]' |
|
191 | + | ||
192 | + | param KCOV_PATH --kcov-path init:="kcov" var:PATH -- \ |
|
193 | + | 'Specify kcov path [default: kcov]' |
|
194 | + | ||
195 | + | multi KCOV_OPTS ' ' --kcov-options var:OPTIONS -- \ |
|
196 | + | 'Additional Kcov options (coverage limits, coveralls id, etc)' \ |
|
197 | + | ' Default specified options: (can be overwritten)' \ |
|
198 | + | ' --include-path=.' \ |
|
199 | + | ' --include-pattern=.sh' \ |
|
200 | + | ' --exclude-pattern=/.shellspec,/spec/,/coverage/,/report/' \ |
|
201 | + | ' --path-strip-level=1' \ |
|
202 | + | ' To include files without extension, specify --include-pattern' \ |
|
203 | + | ' without ".sh" and filter with --include-*/--exclude-* options.' |
|
204 | + | ||
205 | + | flag COVERAGE_KSH_WORKAROUND --coverage-ksh-workaround hidden abbr: |
|
206 | + | ||
207 | + | msg -- '' ' **** Utility ****' '' |
|
208 | + | ||
209 | + | flag :mode --init on:init init:='runner' \ |
|
210 | + | label:' --init [TEMPLATE...]' -- \ |
|
211 | + | 'Initialize your project with ShellSpec | [git] [hg] [svn]' \ |
|
212 | + | ' Template: Create additional files.' \ |
|
213 | + | ' [git] .gitignore' \ |
|
214 | + | ' [hg] .hgignore' \ |
|
215 | + | ' [svn] .svnignore' |
|
216 | + | ||
217 | + | flag :mode --gen-bin on:gen-bin \ |
|
218 | + | label:' --gen-bin [@COMMAND...]' -- \ |
|
219 | + | 'Generate test support commands in spec/support/bin' \ |
|
220 | + | ' This is useful for run actual commands from mock/stub.' |
|
221 | + | ||
222 | + | flag :mode --count on:count -- \ |
|
223 | + | 'Count the number of specfiles and examples' |
|
224 | + | ||
225 | + | param :mode --list pattern:'specfiles | examples | examples:id | examples:lineno | debug' \ |
|
226 | + | var:LIST -- \ |
|
227 | + | 'List the specfiles/examples | [specfiles] [examples(:id|:lineno)]' \ |
|
228 | + | ' [specfiles] list the specfiles' \ |
|
229 | + | ' [examples] list the examples with id' \ |
|
230 | + | ' [examples:id] alias for examples' \ |
|
231 | + | ' [examples:lineno] list the examples with lineno' \ |
|
232 | + | ' [debug] for developer' \ |
|
233 | + | ' The order is randomized with --random but random TYPE is ignored.' |
|
234 | + | ||
235 | + | flag :mode --syntax-check on:syntax-check -- \ |
|
236 | + | 'Syntax check of the specfiles without running any examples' |
|
237 | + | ||
238 | + | flag :mode --translate on:translate -- \ |
|
239 | + | 'Output translated specfile' |
|
240 | + | ||
241 | + | flag :mode --task on:task \ |
|
242 | + | label:' --task [TASK]' -- \ |
|
243 | + | 'Run the TASK or Show the task list if TASK is not specified' |
|
244 | + | ||
245 | + | param DOCKER_IMAGE --docker var:DOCKER-IMAGE -- \ |
|
246 | + | 'Run tests in specified docker image (EXPERIMENTAL)' \ |
|
247 | + | ' This is an experimental feature and may be changed/removed in the future.' |
|
248 | + | ||
249 | + | disp VERSION -v --version -- 'Display the version' |
|
250 | + | disp ':help "$1"' -h --help -- '-h: short help, --help: long help' |
|
251 | + | } |
|
252 | + | ||
253 | + | extension() { |
|
254 | + | prefix=$2 |
|
255 | + | multi() { |
|
256 | + | name=${prefix}_$1 separator="$2" |
|
257 | + | shift 2 |
|
258 | + | param ":multiple $name '$separator'" "init:export $name=''" "$@" |
|
259 | + | } |
|
260 | + | prehook() { |
|
261 | + | helper=$1 name=$2 |
|
262 | + | shift 2 |
|
263 | + | case $helper in (flag | param | option | disp) |
|
264 | + | case $name in |
|
265 | + | :*) name="$name $prefix" ;; |
|
266 | + | *) name="${prefix}_${name}" ;; |
|
267 | + | esac |
|
268 | + | esac |
|
269 | + | invoke "$helper" "$name" "$@" |
|
270 | + | } |
|
271 | + | } |
5 | 5 | _width='30,12' _plus='' _leading=' ' |
|
6 | 6 | ||
7 | 7 | pad() { p=$2; while [ ${#p} -lt "$3" ]; do p="$p "; done; eval "$1=\$p"; } |
|
8 | - | kv() { eval "${1%%:*}=\${1#*:}"; } |
|
8 | + | kv() { eval "${2-}${1%%:*}=\${1#*:}"; } |
|
9 | 9 | sw() { pad sw "$sw${sw:+, }" "$1"; sw="$sw$2"; } |
|
10 | 10 | ||
11 | 11 | args() { |
15 | 15 | --*) sw $((${_plus:+4}+4)) "$i" ;; |
|
16 | 16 | -?) sw 0 "$i" ;; |
|
17 | 17 | +?) [ ! "$_plus" ] || sw 4 "$i" ;; |
|
18 | - | *) [ "$_type" = setup ] && kv "_$i"; kv "$i" |
|
18 | + | *) [ "$_type" = setup ] && kv "$i" _; kv "$i" |
|
19 | 19 | esac |
|
20 | 20 | done |
|
21 | 21 | [ "$hidden" ] && return 0 || len=${_width%,*} |
1 | 1 | # shellcheck shell=sh |
|
2 | 2 | ||
3 | - | # shellcheck source=lib/getoptions.sh |
|
4 | - | . "$SHELLSPEC_LIB/getoptions.sh" |
|
5 | - | # shellcheck source=lib/getoptions_help.sh |
|
6 | - | . "$SHELLSPEC_LIB/getoptions_help.sh" |
|
7 | - | # shellcheck source=lib/getoptions_abbr.sh |
|
8 | - | . "$SHELLSPEC_LIB/getoptions_abbr.sh" |
|
9 | - | ||
10 | - | # shellcheck disable=SC1083,SC2016 |
|
11 | - | parser_definition() { |
|
12 | - | extension "$@" |
|
13 | - | set -- "$1" "$2" "error_handler ${3:-echo}" |
|
14 | - | ||
15 | - | setup params export:true error:"$3" abbr:true help:usage width:36 leading:' ' -- \ |
|
16 | - | 'Usage: shellspec [options...] [files or directories...]' \ |
|
17 | - | '' \ |
|
18 | - | ' Using + instead of - for short options causes reverses the meaning' \ |
|
19 | - | '' |
|
20 | - | param SHELL -s --shell -- \ |
|
21 | - | 'Specify a path of shell [default: "auto" (the shell running shellspec)]' \ |
|
22 | - | ' ShellSpec ignores shebang and runs in the specified shell.' |
|
23 | - | ||
24 | - | param :'set_path PATH' --path var:PATH -- \ |
|
25 | - | 'Set PATH environment variable at startup' \ |
|
26 | - | " e.g. --path /bin:/usr/bin, --path \"\$(getconf PATH)\"" |
|
27 | - | ||
28 | - | flag SANDBOX --{no-}sandbox -- \ |
|
29 | - | 'Force the use of the mock instead of the actual command' \ |
|
30 | - | ' Make PATH empty (except "spec/support/bin" and mock dir) and readonly' \ |
|
31 | - | ' This is not a security feature and does not provide complete isolation' |
|
32 | - | ||
33 | - | param SANDBOX_PATH --sandbox-path var:PATH -- \ |
|
34 | - | 'Make PATH the sandbox path instead of empty (default: empty)' |
|
35 | - | ||
36 | - | multi REQUIRES ':' --require var:MODULE -- \ |
|
37 | - | 'Require a MODULE (shell script file)' |
|
38 | - | ||
39 | - | param :set_env -e --env validate:check_env_name var:'NAME[=VALUE]' -- \ |
|
40 | - | 'Set environment variable' |
|
41 | - | ||
42 | - | param ENV_FROM --env-from validate:check_env_file var:ENV-SCRIPT -- \ |
|
43 | - | 'Set environment variable from shell script file' |
|
44 | - | ||
45 | - | flag WARNING_AS_FAILURE -w +w --{no-}warning-as-failure init:@on -- \ |
|
46 | - | 'Treat warning as failure [default: enabled]' |
|
47 | - | ||
48 | - | option FAIL_FAST_COUNT --{no-}fail-fast on:1 validate:check_number \ |
|
49 | - | label:' --{no-}fail-fast[=COUNT]' -- \ |
|
50 | - | 'Abort the run after first (or COUNT) of failures [default: disabled]' |
|
51 | - | ||
52 | - | flag FAIL_NO_EXAMPLES --{no-}fail-no-examples -- \ |
|
53 | - | 'Fail if no examples found [default: disabled]' |
|
54 | - | ||
55 | - | flag FAIL_LOW_COVERAGE --{no-}fail-low-coverage -- \ |
|
56 | - | 'Fail on low coverage [default: disabled]' \ |
|
57 | - | ' The coverage threshold is specified by the coverage option' |
|
58 | - | ||
59 | - | param FAILURE_EXIT_CODE --failure-exit-code validate:check_number init:=101 var:CODE -- \ |
|
60 | - | 'Override the exit code used when there are failing specs [default: 101]' |
|
61 | - | ||
62 | - | param ERROR_EXIT_CODE --error-exit-code validate:check_number init:=102 var:CODE -- \ |
|
63 | - | 'Override the exit code used when there are fatal errors [default: 102]' |
|
64 | - | ||
65 | - | flag PROFILER -p +p --{no-}profile -- \ |
|
66 | - | 'Enable profiling and list the slowest examples [default: disabled]' \ |
|
67 | - | ' Profiler tries to use 100% ability of 1 CPU (1 core).' \ |
|
68 | - | ' Therefore, not recommended for single(-core) CPU.' |
|
69 | - | ||
70 | - | param PROFILER_LIMIT --profile-limit validate:check_number init:=10 var:N -- \ |
|
71 | - | 'List the top N slowest examples [default: 10]' |
|
72 | - | ||
73 | - | flag :boost --{no-}boost -- \ |
|
74 | - | 'Increase the CPU frequency to boost up testing speed [default: disabled]' \ |
|
75 | - | ' Equivalent of --profile --profile-limit 0' \ |
|
76 | - | " (Don't worry, this is not overclocking. This is joke option but works.)" |
|
77 | - | ||
78 | - | param LOGFILE --log-file init:='/dev/tty' -- \ |
|
79 | - | 'Log file for %logger directive and trace [default: /dev/tty]' |
|
80 | - | ||
81 | - | param TMPDIR --tmpdir init:="${TMPDIR:-${TMP:-/tmp}}" -- \ |
|
82 | - | 'Specify temporary directory [default: $TMPDIR, $TMP or /tmp]' |
|
83 | - | ||
84 | - | flag KEEP_TMPDIR --keep-tmpdir -- \ |
|
85 | - | 'Do not cleanup temporary directory [default: disabled]' |
|
86 | - | flag KEEP_TMPDIR --keep-tempdir validate:'deprecated $1' abbr: hidden:true |
|
87 | - | ||
88 | - | msg -- '' ' **** Execution ****' '' |
|
89 | - | ||
90 | - | flag QUICK -q +q --{no-}quick -- \ |
|
91 | - | 'Run not-passed examples if it exists, otherwise run all [default: disabled]' \ |
|
92 | - | ' not-passed examples: failure and temporary pending examples' \ |
|
93 | - | ' Quick mode is automatically enabled. To disable quick mode,' \ |
|
94 | - | ' delete .shellspec-quick.log on the project root directory.' |
|
95 | - | ||
96 | - | flag :only_failures -r --repair --only-failures -- \ |
|
97 | - | 'Run failure examples only (Depends on quick mode)' |
|
98 | - | ||
99 | - | flag :next_failure -n --next-failure -- \ |
|
100 | - | 'Run failure examples and abort on first failure (Depends on quick mode)' \ |
|
101 | - | ' Equivalent of --repair --fail-fast --random none' |
|
102 | - | ||
103 | - | param WORKERS -j --jobs validate:check_number init:=0 var:JOBS -- \ |
|
104 | - | 'Number of parallel jobs to run [default: 0 (disabled)]' |
|
105 | - | ||
106 | - | param :random --random validate:check_random init:='' var:"TYPE[:SEED]" -- \ |
|
107 | - | 'Run examples by the specified random type | <[none]> [specfiles] [examples]' \ |
|
108 | - | ' [none] run in the defined order [default]' \ |
|
109 | - | ' [specfiles] randomize the order of specfiles' \ |
|
110 | - | ' [examples] randomize the order of examples (slow)' |
|
111 | - | ||
112 | - | flag :xtrace -x --xtrace on:1 init:=0 -- \ |
|
113 | - | 'Run examples with trace output of evaluation enabled [default: disabled]' \ |
|
114 | - | ' Fall back to --xtrace-only if BASH_XTRACEFD not supported.' |
|
115 | - | ||
116 | - | flag :xtrace -X --xtrace-only on:2 -- \ |
|
117 | - | 'Run examples with trace output only enabled [default: disabled]' \ |
|
118 | - | ' The evaluation is executed, but the expectations are skipped.' |
|
119 | - | ||
120 | - | flag DRYRUN --dry-run -- \ |
|
121 | - | 'Print the formatter output without running any examples [default: disabled]' |
|
122 | - | ||
123 | - | msg -- '' ' **** Output ****' '' |
|
124 | - | ||
125 | - | flag BANNER --{no-}banner init:@on -- \ |
|
126 | - | "Show banner if exist 'spec/banner' [default: enabled]" |
|
127 | - | ||
128 | - | param FORMATTER -f --format validate:check_formatter init:='progress' -- \ |
|
129 | - | 'Choose a formatter for display | <[p]> [d] [t] [j] [f] [null] [debug]' \ |
|
130 | - | ' [p]rogress dots [default]' \ |
|
131 | - | ' [d]ocumentation group and example names' \ |
|
132 | - | ' [t]ap TAP format' \ |
|
133 | - | ' [j]unit JUnit XML (time attributre with --profile)' \ |
|
134 | - | ' [f]ailures file:line:message (suitable for editors integration)' \ |
|
135 | - | ' [null] do not display anything' \ |
|
136 | - | ' [debug] for developers' \ |
|
137 | - | ' custom formatter name' |
|
138 | - | ||
139 | - | multi GENERATORS ' ' -o --output validate:check_formatter var:FORMATTER -- \ |
|
140 | - | 'Choose a generator(s) to generate a report file(s) [default: none]' \ |
|
141 | - | ' You can use the same name as FORMATTER. (multiple options allowed)' |
|
142 | - | ||
143 | - | flag COLOR --{no-}color init:"detect_color_mode $2" -- \ |
|
144 | - | 'Enable or disable color [default: enabled if the output is a TTY]' \ |
|
145 | - | ' Disable if NO_COLOR environment variable set' |
|
146 | - | flag COLOR --{no-}colour --force-color --force-colour init:@none hidden abbr: |
|
147 | - | ||
148 | - | param SKIP_MESSAGE --skip-message pattern:'verbose | moderate | quiet' init:='verbose' var:VERBOSITY -- \ |
|
149 | - | 'Mute skip message | <[verbose]> [moderate] [quiet]' \ |
|
150 | - | ' [verbose] do not mute any messages [default]' \ |
|
151 | - | ' [moderate] mute repeated messages' \ |
|
152 | - | ' [quiet] mute repeated or non-temporary messages' |
|
153 | - | ||
154 | - | param PENDING_MESSAGE --pending-message pattern:'verbose | quiet' init:='verbose' var:VERBOSITY -- \ |
|
155 | - | 'Mute pending message | <[verbose]> [quiet]' \ |
|
156 | - | ' [verbose] do not mute any messages [default]' \ |
|
157 | - | ' [quiet] mute non-temporary messages' |
|
158 | - | ||
159 | - | flag :quiet --quiet -- \ |
|
160 | - | 'Equivalent of --skip-message quiet --pending-message quiet' |
|
161 | - | ||
162 | - | flag DEPRECATION_LOG --show-deprecations on:1 init:@on hidden |
|
163 | - | flag DEPRECATION_LOG --hide-deprecations on: init:@none \ |
|
164 | - | label:' --(show|hide)-deprecations' -- \ |
|
165 | - | 'Show or hide deprecations details [default: show]' |
|
166 | - | ||
167 | - | msg -- '' ' **** Ranges / Filters / Focus ****' '' |
|
168 | - | ||
169 | - | msg -- ' You can run selected examples by specified the line numbers or ids' \ |
|
170 | - | '' \ |
|
171 | - | ' shellspec path/to/a_spec.sh:10 # Run the groups or examples that includes lines 10' \ |
|
172 | - | ' shellspec path/to/a_spec.sh:@1-5 # Run the 5th groups/examples defined in the 1st group' \ |
|
173 | - | ' shellspec a_spec.sh:10:@1:20:@2 # You can mixing multiple line numbers and ids with join by ":"' \ |
|
174 | - | '' |
|
175 | - | ||
176 | - | flag FOCUS_FILTER -F --focus -- \ |
|
177 | - | 'Run focused groups / examples only' |
|
178 | - | ||
179 | - | param PATTERN -P --pattern init:='*_spec.sh' -- \ |
|
180 | - | 'Load files matching pattern [default: "*_spec.sh"]' |
|
181 | - | ||
182 | - | multi EXAMPLE_FILTER '|' -E --example var:PATTERN -- \ |
|
183 | - | 'Run examples whose names include PATTERN' |
|
184 | - | ||
185 | - | multi TAG_FILTER ',' -T --tag var:'TAG[:VALUE]' -- \ |
|
186 | - | 'Run examples with the specified TAG' |
|
187 | - | ||
188 | - | param DEFAULT_PATH -D --default-path init:='spec' var:PATH -- \ |
|
189 | - | 'Set the default path where looks for examples [default: "spec"]' |
|
190 | - | ||
191 | - | msg -- '' ' **** Coverage ****' '' |
|
192 | - | ||
193 | - | flag KCOV --{no-}kcov -- \ |
|
194 | - | 'Enable coverage using kcov [default: disabled]' |
|
195 | - | ||
196 | - | param KCOV_PATH --kcov-path init:="kcov" var:PATH -- \ |
|
197 | - | 'Specify kcov path [default: kcov]' |
|
198 | - | ||
199 | - | multi KCOV_OPTS ' ' --kcov-options var:OPTIONS -- \ |
|
200 | - | 'Additional Kcov options (coverage limits, coveralls id, etc)' \ |
|
201 | - | ' Default specified options: (can be overwritten)' \ |
|
202 | - | ' --include-path=.' \ |
|
203 | - | ' --include-pattern=.sh' \ |
|
204 | - | ' --exclude-pattern=/.shellspec,/spec/,/coverage/,/report/' \ |
|
205 | - | ' --path-strip-level=1' \ |
|
206 | - | ' To include files without extension, specify --include-pattern' \ |
|
207 | - | ' without ".sh" and filter with --include-*/--exclude-* options.' |
|
208 | - | ||
209 | - | flag COVERAGE_KSH_WORKAROUND --coverage-ksh-workaround hidden abbr: |
|
210 | - | ||
211 | - | msg -- '' ' **** Utility ****' '' |
|
212 | - | ||
213 | - | flag :mode --init on:init init:='runner' \ |
|
214 | - | label:' --init [TEMPLATE...]' -- \ |
|
215 | - | 'Initialize your project with ShellSpec | [git] [hg] [svn]' \ |
|
216 | - | ' Template: Create additional files.' \ |
|
217 | - | ' [git] .gitignore' \ |
|
218 | - | ' [hg] .hgignore' \ |
|
219 | - | ' [svn] .svnignore' |
|
220 | - | ||
221 | - | flag :mode --gen-bin on:gen-bin \ |
|
222 | - | label:' --gen-bin [@COMMAND...]' -- \ |
|
223 | - | 'Generate test support commands in spec/support/bin' \ |
|
224 | - | ' This is useful for run actual commands from mock/stub.' |
|
225 | - | ||
226 | - | flag :mode --count on:count -- \ |
|
227 | - | 'Count the number of specfiles and examples' |
|
228 | - | ||
229 | - | param :mode --list pattern:'specfiles | examples | examples:id | examples:lineno | debug' \ |
|
230 | - | var:LIST -- \ |
|
231 | - | 'List the specfiles/examples | [specfiles] [examples(:id|:lineno)]' \ |
|
232 | - | ' [specfiles] list the specfiles' \ |
|
233 | - | ' [examples] list the examples with id' \ |
|
234 | - | ' [examples:id] alias for examples' \ |
|
235 | - | ' [examples:lineno] list the examples with lineno' \ |
|
236 | - | ' [debug] for developer' \ |
|
237 | - | ' The order is randomized with --random but random TYPE is ignored.' |
|
238 | - | ||
239 | - | flag :mode --syntax-check on:syntax-check -- \ |
|
240 | - | 'Syntax check of the specfiles without running any examples' |
|
241 | - | ||
242 | - | flag :mode --translate on:translate -- \ |
|
243 | - | 'Output translated specfile' |
|
244 | - | ||
245 | - | flag :mode --task on:task \ |
|
246 | - | label:' --task [TASK]' -- \ |
|
247 | - | 'Run the TASK or Show the task list if TASK is not specified' |
|
248 | - | ||
249 | - | param DOCKER_IMAGE --docker var:DOCKER-IMAGE -- \ |
|
250 | - | 'Run tests in specified docker image (EXPERIMENTAL)' \ |
|
251 | - | ' This is an experimental feature and may be changed/removed in the future.' |
|
252 | - | ||
253 | - | disp VERSION -v --version -- 'Display the version' |
|
254 | - | disp ":help \$1" -h --help -- '-h: short help, --help: long help' |
|
255 | - | } |
|
256 | - | ||
257 | - | extension() { |
|
258 | - | prefix=$2 |
|
259 | - | multi() { |
|
260 | - | name=${prefix}_$1 separator="$2" |
|
261 | - | shift 2 |
|
262 | - | param ":multiple $name '$separator'" "init:export $name=''" "$@" |
|
263 | - | } |
|
264 | - | prehook() { |
|
265 | - | helper=$1 name=$2 |
|
266 | - | shift 2 |
|
267 | - | case $helper in (flag | param | option | disp) |
|
268 | - | case $name in |
|
269 | - | :*) name="$name $prefix" ;; |
|
270 | - | *) name="${prefix}_${name}" ;; |
|
271 | - | esac |
|
272 | - | esac |
|
273 | - | invoke "$helper" "$name" "$@" |
|
274 | - | } |
|
3 | + | optparser() { |
|
4 | + | # # shellcheck source=lib/getoptions.sh |
|
5 | + | # . "$SHELLSPEC_LIB/getoptions.sh" |
|
6 | + | # # shellcheck source=lib/getoptions_help.sh |
|
7 | + | # . "$SHELLSPEC_LIB/getoptions_help.sh" |
|
8 | + | # # shellcheck source=lib/getoptions_abbr.sh |
|
9 | + | # . "$SHELLSPEC_LIB/getoptions_abbr.sh" |
|
10 | + | # # shellcheck source=lib/libexec/parser_definition.sh |
|
11 | + | # . "$SHELLSPEC_LIB/libexec/parser_definition.sh" |
|
12 | + | # eval "$(getoptions parser_definition "$@")" |
|
13 | + | ||
14 | + | # shellcheck source=lib/libexec/parser_definition_generated.sh |
|
15 | + | . "$SHELLSPEC_LIB/libexec/parser_definition_generated.sh" |
|
275 | 16 | } |
|
276 | 17 | ||
277 | 18 | multiple() { |
19 | 19 | [ "${1#:}" = "$1" ] && c=3 || c=4 |
|
20 | 20 | eval "[ ! \${$c:+x} ] || $2 \"\$$c\"" |
|
21 | 21 | } |
|
22 | - | kv() { eval "${1%%:*}=\${1#*:}"; } |
|
22 | + | kv() { eval "${2-}${1%%:*}=\${1#*:}"; } |
|
23 | 23 | loop() { [ $# -gt 1 ] && [ "$2" != -- ]; } |
|
24 | 24 | ||
25 | 25 | invoke() { eval '"_$@"'; } |
53 | 53 | } |
|
54 | 54 | _setup() { |
|
55 | 55 | [ "${1#-}" ] && _rest=$1 |
|
56 | - | while loop "$@" && shift; do kv "_$1"; done |
|
56 | + | while loop "$@" && shift; do kv "$1" _; done |
|
57 | 57 | } |
|
58 | 58 | _flag() { args : "$@"; defvar "$@"; } |
|
59 | 59 | _param() { args '' "$@"; defvar "$@"; } |
Learn more Showing 1 files with coverage changes found.
lib/libexec/parser_definition.sh
Files | Coverage |
---|---|
lib | -0.03% 79.76% |
libexec | 20.97% |
install.sh | 53.10% |
shellspec | 0.00% |
Project Totals (99 files) | 66.24% |
d635402
ec60962
e49b15b
410365f