gabr 2.0.13 → 2.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,174 +0,0 @@
1
- #!/usr/bin/env bash
2
- set -e
3
-
4
- header_pattern='[0-9]+\.\.[0-9]+'
5
- IFS= read -r header
6
-
7
- if [[ "$header" =~ $header_pattern ]]; then
8
- count="${header:3}"
9
- index=0
10
- failures=0
11
- skipped=0
12
- name=
13
- count_column_width=$(( ${#count} * 2 + 2 ))
14
- else
15
- # If the first line isn't a TAP plan, print it and pass the rest through
16
- printf '%s\n' "$header"
17
- exec cat
18
- fi
19
-
20
- update_screen_width() {
21
- screen_width="$(tput cols)"
22
- count_column_left=$(( $screen_width - $count_column_width ))
23
- }
24
-
25
- trap update_screen_width WINCH
26
- update_screen_width
27
-
28
- begin() {
29
- go_to_column 0
30
- buffer_with_truncation $(( $count_column_left - 1 )) ' %s' "$name"
31
- clear_to_end_of_line
32
- go_to_column $count_column_left
33
- buffer "%${#count}s/${count}" "$index"
34
- go_to_column 1
35
- }
36
-
37
- pass() {
38
- go_to_column 0
39
- buffer ' ✓ %s' "$name"
40
- advance
41
- }
42
-
43
- skip() {
44
- local reason="$1"
45
- if [[ -n "$reason" ]]; then
46
- reason=": $reason"
47
- fi
48
- go_to_column 0
49
- buffer ' - %s (skipped%s)' "$name" "$reason"
50
- advance
51
- }
52
-
53
- fail() {
54
- go_to_column 0
55
- set_color 1 bold
56
- buffer ' ✗ %s' "$name"
57
- advance
58
- }
59
-
60
- log() {
61
- set_color 1
62
- buffer ' %s\n' "$1"
63
- clear_color
64
- }
65
-
66
- summary() {
67
- buffer '\n%d test' "$count"
68
- if [[ "$count" -ne 1 ]]; then
69
- buffer 's'
70
- fi
71
-
72
- buffer ', %d failure' "$failures"
73
- if [[ "$failures" -ne 1 ]]; then
74
- buffer 's'
75
- fi
76
-
77
- if [[ "$skipped" -gt 0 ]]; then
78
- buffer ', %d skipped' "$skipped"
79
- fi
80
-
81
- buffer '\n'
82
- }
83
-
84
- buffer_with_truncation() {
85
- local width="$1"
86
- shift
87
- local string
88
-
89
- printf -v 'string' -- "$@"
90
-
91
- if [[ "${#string}" -gt "$width" ]]; then
92
- buffer '%s...' "${string:0:$(( $width - 4 ))}"
93
- else
94
- buffer '%s' "$string"
95
- fi
96
- }
97
-
98
- go_to_column() {
99
- local column="$1"
100
- buffer '\x1B[%dG' $(( $column + 1 ))
101
- }
102
-
103
- clear_to_end_of_line() {
104
- buffer '\x1B[K'
105
- }
106
-
107
- advance() {
108
- clear_to_end_of_line
109
- buffer '\n'
110
- clear_color
111
- }
112
-
113
- set_color() {
114
- local color="$1"
115
- local weight=22
116
-
117
- if [[ "$2" == 'bold' ]]; then
118
- weight=1
119
- fi
120
- buffer '\x1B[%d;%dm' "$(( 30 + $color ))" "$weight"
121
- }
122
-
123
- clear_color() {
124
- buffer '\x1B[0m'
125
- }
126
-
127
- _buffer=
128
-
129
- buffer() {
130
- local content
131
- printf -v content -- "$@"
132
- _buffer+="$content"
133
- }
134
-
135
- flush() {
136
- printf '%s' "$_buffer"
137
- _buffer=
138
- }
139
-
140
- finish() {
141
- flush
142
- printf '\n'
143
- }
144
-
145
- trap finish EXIT
146
-
147
- while IFS= read -r line; do
148
- case "$line" in
149
- 'begin '* )
150
- ((++index))
151
- name="${line#* $index }"
152
- begin
153
- flush
154
- ;;
155
- 'ok '* )
156
- skip_expr="ok $index (.*) # skip ?(([[:print:]]*))?"
157
- if [[ "$line" =~ $skip_expr ]]; then
158
- ((++skipped))
159
- skip "${BASH_REMATCH[2]}"
160
- else
161
- pass
162
- fi
163
- ;;
164
- 'not ok '* )
165
- ((++failures))
166
- fail
167
- ;;
168
- '# '* )
169
- log "${line:2}"
170
- ;;
171
- esac
172
- done
173
-
174
- summary
@@ -1,58 +0,0 @@
1
- #!/usr/bin/env bash
2
- set -e
3
-
4
- bats_encode_test_name() {
5
- local name="$1"
6
- local result='test_'
7
- local hex_code
8
-
9
- if [[ ! "$name" =~ [^[:alnum:]\ _-] ]]; then
10
- name="${name//_/-5f}"
11
- name="${name//-/-2d}"
12
- name="${name// /_}"
13
- result+="$name"
14
- else
15
- local length="${#name}"
16
- local char i
17
-
18
- for ((i=0; i<length; i++)); do
19
- char="${name:$i:1}"
20
- if [[ "$char" == ' ' ]]; then
21
- result+='_'
22
- elif [[ "$char" =~ [[:alnum:]] ]]; then
23
- result+="$char"
24
- else
25
- printf -v 'hex_code' -- '-%02x' \'"$char"
26
- result+="$hex_code"
27
- fi
28
- done
29
- fi
30
-
31
- printf -v "$2" '%s' "$result"
32
- }
33
-
34
- test_file="$1"
35
- tests=()
36
-
37
- {
38
- while IFS= read -r line; do
39
- line="${line//$'\r'}"
40
- if [[ "$line" =~ $BATS_TEST_PATTERN ]]; then
41
- name="${BASH_REMATCH[1]#[\'\"]}"
42
- name="${name%[\'\"]}"
43
- body="${BASH_REMATCH[2]}"
44
- bats_encode_test_name "$name" 'encoded_name'
45
- printf '%s() { bats_test_begin "%s"; %s\n' "$encoded_name" "$name" "$body" || :
46
-
47
- if [[ -z "$BATS_TEST_FILTER" || "$name" =~ $BATS_TEST_FILTER ]]; then
48
- tests+=("$encoded_name")
49
- fi
50
- else
51
- printf '%s\n' "$line"
52
- fi
53
- done
54
- } <<< "$(< "$test_file")"$'\n'
55
-
56
- for test_name in "${tests[@]}"; do
57
- printf 'bats_test_function %s\n' "$test_name"
58
- done
@@ -1,10 +0,0 @@
1
- RONN := ronn
2
- PAGES := bats.1 bats.7
3
-
4
- all: $(PAGES)
5
-
6
- bats.1: bats.1.ronn
7
- $(RONN) -r $<
8
-
9
- bats.7: bats.7.ronn
10
- $(RONN) -r $<
@@ -1,5 +0,0 @@
1
- Bats man pages are generated with [Ronn](http://rtomayko.github.io/ronn/).
2
-
3
- After making changes to `bats.1.ronn` or `bats.7.ronn`, run `make` in
4
- this directory to generate `bats.1` and `bats.7`. **Do not edit the
5
- `bats.1` or `bats.7` files directly.**
@@ -1,115 +0,0 @@
1
- .\" generated with Ronn/v0.7.3
2
- .\" http://github.com/rtomayko/ronn/tree/0.7.3
3
- .
4
- .TH "BATS" "1" "July 2018" "" ""
5
- .
6
- .SH "NAME"
7
- \fBbats\fR \- Bash Automated Testing System
8
- .
9
- .SH "SYNOPSIS"
10
- bats [\-cr] [\-f \fIregex\fR] [\-p | \-t] \fItest\fR\.\.\.
11
- .
12
- .br
13
- bats [\-h | \-v]
14
- .
15
- .P
16
- \fItest\fR is the path to a Bats test file, or the path to a directory containing Bats test files (ending with "\.bats")\.
17
- .
18
- .SH "DESCRIPTION"
19
- Bats is a TAP\-compliant testing framework for Bash\. It provides a simple way to verify that the UNIX programs you write behave as expected\.
20
- .
21
- .P
22
- A Bats test file is a Bash script with special syntax for defining test cases\. Under the hood, each test case is just a function with a description\.
23
- .
24
- .P
25
- Test cases consist of standard shell commands\. Bats makes use of Bash\'s \fBerrexit\fR (\fBset \-e\fR) option when running test cases\. If every command in the test case exits with a \fB0\fR status code (success), the test passes\. In this way, each line is an assertion of truth\.
26
- .
27
- .P
28
- See \fBbats\fR(7) for more information on writing Bats tests\.
29
- .
30
- .SH "RUNNING TESTS"
31
- To run your tests, invoke the \fBbats\fR interpreter with a path to a test file\. The file\'s test cases are run sequentially and in isolation\. If all the test cases pass, \fBbats\fR exits with a \fB0\fR status code\. If there are any failures, \fBbats\fR exits with a \fB1\fR status code\.
32
- .
33
- .P
34
- You can invoke the \fBbats\fR interpreter with multiple test file arguments, or with a path to a directory containing multiple \fB\.bats\fR files\. Bats will run each test file individually and aggregate the results\. If any test case fails, \fBbats\fR exits with a \fB1\fR status code\.
35
- .
36
- .SH "OPTIONS"
37
- .
38
- .TP
39
- \fB\-c\fR, \fB\-\-count\fR
40
- Count the number of test cases without running any tests
41
- .
42
- .TP
43
- \fB\-f\fR, \fB\-\-filter\fR
44
- Filter test cases by names matching the regular expression
45
- .
46
- .TP
47
- \fB\-h\fR, \fB\-\-help\fR
48
- Display help message
49
- .
50
- .TP
51
- \fB\-p\fR, \fB\-\-pretty\fR
52
- Show results in pretty format (default for terminals)
53
- .
54
- .TP
55
- \fB\-r\fR, \fB\-\-recursive\fR
56
- Include tests in subdirectories
57
- .
58
- .TP
59
- \fB\-t\fR, \fB\-\-tap\fR
60
- Show results in TAP format
61
- .
62
- .TP
63
- \fB\-v\fR, \fB\-\-version\fR
64
- Display the version number
65
- .
66
- .SH "OUTPUT"
67
- When you run Bats from a terminal, you\'ll see output as each test is performed, with a check\-mark next to the test\'s name if it passes or an "X" if it fails\.
68
- .
69
- .IP "" 4
70
- .
71
- .nf
72
-
73
- $ bats addition\.bats
74
- ✓ addition using bc
75
- ✓ addition using dc
76
-
77
- 2 tests, 0 failures
78
- .
79
- .fi
80
- .
81
- .IP "" 0
82
- .
83
- .P
84
- If Bats is not connected to a terminal\-\-in other words, if you run it from a continuous integration system or redirect its output to a file\-\-the results are displayed in human\-readable, machine\-parsable TAP format\. You can force TAP output from a terminal by invoking Bats with the \fB\-\-tap\fR option\.
85
- .
86
- .IP "" 4
87
- .
88
- .nf
89
-
90
- $ bats \-\-tap addition\.bats
91
- 1\.\.2
92
- ok 1 addition using bc
93
- ok 2 addition using dc
94
- .
95
- .fi
96
- .
97
- .IP "" 0
98
- .
99
- .SH "EXIT STATUS"
100
- The \fBbats\fR interpreter exits with a value of \fB0\fR if all test cases pass, or \fB1\fR if one or more test cases fail\.
101
- .
102
- .SH "SEE ALSO"
103
- Bats wiki: \fIhttps://github\.com/bats\-core/bats\-core/wiki/\fR
104
- .
105
- .P
106
- \fBbash\fR(1), \fBbats\fR(7)
107
- .
108
- .SH "COPYRIGHT"
109
- (c) 2017\-2018 bats\-core organization
110
- .
111
- .br
112
- (c) 2011\-2016 Sam Stephenson
113
- .
114
- .P
115
- Bats is released under the terms of an MIT\-style license\.
@@ -1,115 +0,0 @@
1
- bats(1) -- Bash Automated Testing System
2
- ========================================
3
-
4
-
5
- SYNOPSIS
6
- --------
7
-
8
- bats [-cr] [-f <regex>] [-p | -t] <test>...<br/>
9
- bats [-h | -v]
10
-
11
- <test> is the path to a Bats test file, or the path to a directory containing
12
- Bats test files (ending with ".bats").
13
-
14
-
15
- DESCRIPTION
16
- -----------
17
-
18
- Bats is a TAP-compliant testing framework for Bash. It provides a simple
19
- way to verify that the UNIX programs you write behave as expected.
20
-
21
- A Bats test file is a Bash script with special syntax for defining
22
- test cases. Under the hood, each test case is just a function with a
23
- description.
24
-
25
- Test cases consist of standard shell commands. Bats makes use of
26
- Bash's `errexit` (`set -e`) option when running test cases. If every
27
- command in the test case exits with a `0` status code (success), the
28
- test passes. In this way, each line is an assertion of truth.
29
-
30
- See `bats`(7) for more information on writing Bats tests.
31
-
32
-
33
- RUNNING TESTS
34
- -------------
35
-
36
- To run your tests, invoke the `bats` interpreter with a path to a test
37
- file. The file's test cases are run sequentially and in isolation. If
38
- all the test cases pass, `bats` exits with a `0` status code. If there
39
- are any failures, `bats` exits with a `1` status code.
40
-
41
- You can invoke the `bats` interpreter with multiple test file arguments,
42
- or with a path to a directory containing multiple `.bats` files. Bats
43
- will run each test file individually and aggregate the results. If any
44
- test case fails, `bats` exits with a `1` status code.
45
-
46
-
47
- OPTIONS
48
- -------
49
-
50
- * `-c`, `--count`:
51
- Count the number of test cases without running any tests
52
- * `-f`, `--filter`:
53
- Filter test cases by names matching the regular expression
54
- * `-h`, `--help`:
55
- Display help message
56
- * `-p`, `--pretty`:
57
- Show results in pretty format (default for terminals)
58
- * `-r`, `--recursive`:
59
- Include tests in subdirectories
60
- * `-t`, `--tap`:
61
- Show results in TAP format
62
- * `-v`, `--version`:
63
- Display the version number
64
-
65
-
66
- OUTPUT
67
- ------
68
-
69
- When you run Bats from a terminal, you'll see output as each test is
70
- performed, with a check-mark next to the test's name if it passes or
71
- an "X" if it fails.
72
-
73
- $ bats addition.bats
74
- ✓ addition using bc
75
- ✓ addition using dc
76
-
77
- 2 tests, 0 failures
78
-
79
- If Bats is not connected to a terminal--in other words, if you run it
80
- from a continuous integration system or redirect its output to a
81
- file--the results are displayed in human-readable, machine-parsable
82
- TAP format. You can force TAP output from a terminal by invoking Bats
83
- with the `--tap` option.
84
-
85
- $ bats --tap addition.bats
86
- 1..2
87
- ok 1 addition using bc
88
- ok 2 addition using dc
89
-
90
-
91
- EXIT STATUS
92
- -----------
93
-
94
- The `bats` interpreter exits with a value of `0` if all test cases pass,
95
- or `1` if one or more test cases fail.
96
-
97
-
98
- SEE ALSO
99
- --------
100
-
101
- Bats wiki: _https://github.com/bats\-core/bats\-core/wiki/_
102
-
103
- `bash`(1), `bats`(7)
104
-
105
-
106
- COPYRIGHT
107
- ---------
108
-
109
- (c) 2017-2018 bats-core organization<br/>
110
- (c) 2011-2016 Sam Stephenson
111
-
112
- Bats is released under the terms of an MIT-style license.
113
-
114
-
115
-
@@ -1,178 +0,0 @@
1
- .\" generated with Ronn/v0.7.3
2
- .\" http://github.com/rtomayko/ronn/tree/0.7.3
3
- .
4
- .TH "BATS" "7" "November 2013" "" ""
5
- .
6
- .SH "NAME"
7
- \fBbats\fR \- Bats test file format
8
- .
9
- .SH "DESCRIPTION"
10
- A Bats test file is a Bash script with special syntax for defining test cases\. Under the hood, each test case is just a function with a description\.
11
- .
12
- .IP "" 4
13
- .
14
- .nf
15
-
16
- #!/usr/bin/env bats
17
-
18
- @test "addition using bc" {
19
- result="$(echo 2+2 | bc)"
20
- [ "$result" \-eq 4 ]
21
- }
22
-
23
- @test "addition using dc" {
24
- result="$(echo 2 2+p | dc)"
25
- [ "$result" \-eq 4 ]
26
- }
27
- .
28
- .fi
29
- .
30
- .IP "" 0
31
- .
32
- .P
33
- Each Bats test file is evaluated n+1 times, where \fIn\fR is the number of test cases in the file\. The first run counts the number of test cases, then iterates over the test cases and executes each one in its own process\.
34
- .
35
- .SH "THE RUN HELPER"
36
- Many Bats tests need to run a command and then make assertions about its exit status and output\. Bats includes a \fBrun\fR helper that invokes its arguments as a command, saves the exit status and output into special global variables, and then returns with a \fB0\fR status code so you can continue to make assertions in your test case\.
37
- .
38
- .P
39
- For example, let\'s say you\'re testing that the \fBfoo\fR command, when passed a nonexistent filename, exits with a \fB1\fR status code and prints an error message\.
40
- .
41
- .IP "" 4
42
- .
43
- .nf
44
-
45
- @test "invoking foo with a nonexistent file prints an error" {
46
- run foo nonexistent_filename
47
- [ "$status" \-eq 1 ]
48
- [ "$output" = "foo: no such file \'nonexistent_filename\'" ]
49
- }
50
- .
51
- .fi
52
- .
53
- .IP "" 0
54
- .
55
- .P
56
- The \fB$status\fR variable contains the status code of the command, and the \fB$output\fR variable contains the combined contents of the command\'s standard output and standard error streams\.
57
- .
58
- .P
59
- A third special variable, the \fB$lines\fR array, is available for easily accessing individual lines of output\. For example, if you want to test that invoking \fBfoo\fR without any arguments prints usage information on the first line:
60
- .
61
- .IP "" 4
62
- .
63
- .nf
64
-
65
- @test "invoking foo without arguments prints usage" {
66
- run foo
67
- [ "$status" \-eq 1 ]
68
- [ "${lines[0]}" = "usage: foo <filename>" ]
69
- }
70
- .
71
- .fi
72
- .
73
- .IP "" 0
74
- .
75
- .SH "THE LOAD COMMAND"
76
- You may want to share common code across multiple test files\. Bats includes a convenient \fBload\fR command for sourcing a Bash source file relative to the location of the current test file\. For example, if you have a Bats test in \fBtest/foo\.bats\fR, the command
77
- .
78
- .IP "" 4
79
- .
80
- .nf
81
-
82
- load test_helper
83
- .
84
- .fi
85
- .
86
- .IP "" 0
87
- .
88
- .P
89
- will source the script \fBtest/test_helper\.bash\fR in your test file\. This can be useful for sharing functions to set up your environment or load fixtures\.
90
- .
91
- .SH "THE SKIP COMMAND"
92
- Tests can be skipped by using the \fBskip\fR command at the point in a test you wish to skip\.
93
- .
94
- .IP "" 4
95
- .
96
- .nf
97
-
98
- @test "A test I don\'t want to execute for now" {
99
- skip
100
- run foo
101
- [ "$status" \-eq 0 ]
102
- }
103
- .
104
- .fi
105
- .
106
- .IP "" 0
107
- .
108
- .P
109
- Optionally, you may include a reason for skipping:
110
- .
111
- .IP "" 4
112
- .
113
- .nf
114
-
115
- @test "A test I don\'t want to execute for now" {
116
- skip "This command will return zero soon, but not now"
117
- run foo
118
- [ "$status" \-eq 0 ]
119
- }
120
- .
121
- .fi
122
- .
123
- .IP "" 0
124
- .
125
- .P
126
- Or you can skip conditionally:
127
- .
128
- .IP "" 4
129
- .
130
- .nf
131
-
132
- @test "A test which should run" {
133
- if [ foo != bar ]; then
134
- skip "foo isn\'t bar"
135
- fi
136
-
137
- run foo
138
- [ "$status" \-eq 0 ]
139
- }
140
- .
141
- .fi
142
- .
143
- .IP "" 0
144
- .
145
- .SH "SETUP AND TEARDOWN FUNCTIONS"
146
- You can define special \fBsetup\fR and \fBteardown\fR functions which run before and after each test case, respectively\. Use these to load fixtures, set up your environment, and clean up when you\'re done\.
147
- .
148
- .SH "CODE OUTSIDE OF TEST CASES"
149
- You can include code in your test file outside of \fB@test\fR functions\. For example, this may be useful if you want to check for dependencies and fail immediately if they\'re not present\. However, any output that you print in code outside of \fB@test\fR, \fBsetup\fR or \fBteardown\fR functions must be redirected to \fBstderr\fR (\fB>&2\fR)\. Otherwise, the output may cause Bats to fail by polluting the TAP stream on \fBstdout\fR\.
150
- .
151
- .SH "SPECIAL VARIABLES"
152
- There are several global variables you can use to introspect on Bats tests:
153
- .
154
- .IP "\(bu" 4
155
- \fB$BATS_TEST_FILENAME\fR is the fully expanded path to the Bats test file\.
156
- .
157
- .IP "\(bu" 4
158
- \fB$BATS_TEST_DIRNAME\fR is the directory in which the Bats test file is located\.
159
- .
160
- .IP "\(bu" 4
161
- \fB$BATS_TEST_NAMES\fR is an array of function names for each test case\.
162
- .
163
- .IP "\(bu" 4
164
- \fB$BATS_TEST_NAME\fR is the name of the function containing the current test case\.
165
- .
166
- .IP "\(bu" 4
167
- \fB$BATS_TEST_DESCRIPTION\fR is the description of the current test case\.
168
- .
169
- .IP "\(bu" 4
170
- \fB$BATS_TEST_NUMBER\fR is the (1\-based) index of the current test case in the test file\.
171
- .
172
- .IP "\(bu" 4
173
- \fB$BATS_TMPDIR\fR is the location to a directory that may be used to store temporary files\.
174
- .
175
- .IP "" 0
176
- .
177
- .SH "SEE ALSO"
178
- \fBbash\fR(1), \fBbats\fR(1)