-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy path_replica
More file actions
143 lines (131 loc) · 3.9 KB
/
_replica
File metadata and controls
143 lines (131 loc) · 3.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
#compdef replica
typeset -A opt_args
_arguments -C \
'1:command:->cmds' \
'*:: :->args' \
&& ret=0
local commands common
commands=(
'run:run test suite'
'info:get information about test suites'
'new:create a test suite'
'set:set replica default config'
'help:get some help'
'version:show replica version'
)
tests=(
{-n,--only}'[list tests to run]:tests:_testnames'
{-N,--exclude}'[tests to ignore]:tests:_testnames'
)
suites=(
+ '(suites)'
{-s,--suites,--only-suites}'[suites to run]:suites:_suitenames'
{-S,--exclude-suites}'[suites to exclude]:suites:_suitesnames'
)
tags=(
+ '(tags)'
{-t,--tags}'[tags to run]:tags:_tagnames'
{-T,--exclude-tags}'[tags to exclude]:tags:_tagnames'
)
common=(
$tests
{-l,--last-fails}'[select only failing tests]'
'--replica-dir[replica store directory]:replica_dir:_path_files -/'
'--golden-dir[golden values directory]:golden_dir:_path_files -/'
$suites
$tags
+ '(show_diff)'
'--no-diff[dont show diff on errors]'
{-d,--diff}'[define a diff command]'
+ '(symbols)'
'--ascii[disable emojis in reports]'
'--utf8[enable emojis in reports]'
+ '(termcolor)'
{--no-color,--no-colour}'[disable coloured ouput]'
{-color,--colour}'[enable coloured ouput]'
+ '(verbosity)'
{-v,--verbose}'[similar to log info]'
'--log[log level]:log_level:(none debug info warning critical)'
)
_testnames() {
if command -v jq
then
_values -s , 'flags' `jq -Scrs ".[] | keys | .[]" *.json`
fi
}
_tagnames() {
if (command -v jq > /dev/null)
then
_values -s , 'flags' `jq -crs ".[] | .[] | .tags | .[]" *.json | sort -u`
fi
}
_suitenames() {
if (command -v jq > /dev/null)
then
_values -s , 'flags' `jq -crs ".[] | .[] | .suite" *.json | sort -u`
fi
}
case "$state" in
cmds)
_describe -V -t commands 'command' commands \
&& ret=0
;;
args)
case $line[1] in
info)
_arguments \
{-e,--expectations}'[show expectations for each test]' \
$common \
'(-)*:tests files:_path_files -g "*.json' \
&& ret=0
;;
run)
_arguments \
{--threads,-x}'[Number of threads to run the tests]' \
{--punitive,-p}'[Stop on first error]' \
{--interactive,-i}'[Generate golden value if different/missing]' \
{--hide-success,--fail-only}'[Only show failing tests]' \
$common \
+ '(timing)' \
{--timing,--duration,-d}'[display execution time of each tests]' \
{--no-timing,--no-duration,-D}'[hide execution time of each tests]' \
'(-)*:tests files:_path_files -g "*.json" -/' \
&& ret=0
;;
new)
_arguments \
'--format[type of the file to be created]:file format:(json dhall)' \
+ '(use_sample)' \
{-s,--includeSample}'[sample test included]:sample' \
{-S,--noSample}'[no sample test included]:no sample' \
&& ret=0
;;
set)
_arguments \
+ '(scope)' \
{-l,--local}'[Set local config value]:key=value pair:->kv' \
{-g,--global}'[Set global config value]:key=value pair:->kv' \
&& ret=0
;;
kv)
_values 'replica configuration' \
'replicaDir:replica file location:_path_files -/' \
'goldenDir:golden values location:_path_files -/' \
'colour:coloured output:(true false)' \
'ascii:use only ascii in reports:(false true)' \
'diff:tool used to print diff' \
'log:specify a log level:(none critical warning info debug)' \
'testFile:name of the file to test:_files' \
&& ret=0
;;
help)
_arguments -C ':topic:->topic'
case "$state" in
(topic)
_describe -V -t topic 'topic' commands && ret=0
esac
;;
esac
;;
esac
return 1