busser-bats 0.2.0 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (48) hide show
  1. checksums.yaml +5 -5
  2. data/.github/dependabot.yml +8 -0
  3. data/.github/workflows/lint.yaml +9 -0
  4. data/.github/workflows/publish.yaml +35 -0
  5. data/.gitignore +1 -0
  6. data/.markdownlint-cli2.jsonc +7 -0
  7. data/.markdownlint.yaml +9 -0
  8. data/.rubocop.yml +11 -0
  9. data/.tool-versions +1 -0
  10. data/CHANGELOG.md +28 -0
  11. data/Gemfile +25 -1
  12. data/Guardfile +26 -0
  13. data/README.md +12 -8
  14. data/Rakefile +5 -14
  15. data/busser-bats.gemspec +17 -24
  16. data/config/cucumber.yml +1 -0
  17. data/config/features/plugin_install_command.feature +17 -0
  18. data/{features → config/features}/support/env.rb +8 -3
  19. data/config/features/test_command.feature +44 -0
  20. data/lib/busser/bats/version.rb +1 -5
  21. data/lib/busser/runner_plugin/bats.rb +3 -4
  22. data/renovate.json +8 -0
  23. data/vendor/bats/.travis.yml +5 -0
  24. data/vendor/bats/LICENSE +1 -1
  25. data/vendor/bats/README.md +34 -13
  26. data/vendor/bats/VERSION.txt +1 -1
  27. data/vendor/bats/bin/bats +1 -0
  28. data/vendor/bats/install.sh +3 -1
  29. data/vendor/bats/libexec/bats +4 -2
  30. data/vendor/bats/libexec/bats-exec-suite +3 -3
  31. data/vendor/bats/libexec/bats-exec-test +151 -12
  32. data/vendor/bats/libexec/bats-format-tap-stream +13 -6
  33. data/vendor/bats/libexec/bats-preprocess +6 -5
  34. data/vendor/bats/man/Makefile +10 -0
  35. data/vendor/bats/man/README.md +5 -0
  36. data/vendor/bats/man/bats.1 +101 -0
  37. data/vendor/bats/man/bats.1.ronn +109 -0
  38. data/vendor/bats/man/bats.7 +178 -0
  39. data/vendor/bats/man/bats.7.ronn +156 -0
  40. data/vendor/bats/package.json +9 -0
  41. metadata +29 -103
  42. data/.cane +0 -0
  43. data/.tailor +0 -4
  44. data/.travis.yml +0 -11
  45. data/features/plugin_install_command.feature +0 -14
  46. data/features/test_command.feature +0 -44
  47. data/vendor/bats/bin/bats +0 -140
  48. /data/{features → config/features}/plugin_list_command.feature +0 -0
@@ -0,0 +1,178 @@
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)
@@ -0,0 +1,156 @@
1
+ bats(7) -- Bats test file format
2
+ ================================
3
+
4
+
5
+ DESCRIPTION
6
+ -----------
7
+
8
+ A Bats test file is a Bash script with special syntax for defining
9
+ test cases. Under the hood, each test case is just a function with a
10
+ description.
11
+
12
+ #!/usr/bin/env bats
13
+
14
+ @test "addition using bc" {
15
+ result="$(echo 2+2 | bc)"
16
+ [ "$result" -eq 4 ]
17
+ }
18
+
19
+ @test "addition using dc" {
20
+ result="$(echo 2 2+p | dc)"
21
+ [ "$result" -eq 4 ]
22
+ }
23
+
24
+
25
+ Each Bats test file is evaluated n+1 times, where _n_ is the number of
26
+ test cases in the file. The first run counts the number of test cases,
27
+ then iterates over the test cases and executes each one in its own
28
+ process.
29
+
30
+
31
+ THE RUN HELPER
32
+ --------------
33
+
34
+ Many Bats tests need to run a command and then make assertions about
35
+ its exit status and output. Bats includes a `run` helper that invokes
36
+ its arguments as a command, saves the exit status and output into
37
+ special global variables, and then returns with a `0` status code so
38
+ you can continue to make assertions in your test case.
39
+
40
+ For example, let's say you're testing that the `foo` command, when
41
+ passed a nonexistent filename, exits with a `1` status code and prints
42
+ an error message.
43
+
44
+ @test "invoking foo with a nonexistent file prints an error" {
45
+ run foo nonexistent_filename
46
+ [ "$status" -eq 1 ]
47
+ [ "$output" = "foo: no such file 'nonexistent_filename'" ]
48
+ }
49
+
50
+ The `$status` variable contains the status code of the command, and
51
+ the `$output` variable contains the combined contents of the command's
52
+ standard output and standard error streams.
53
+
54
+ A third special variable, the `$lines` array, is available for easily
55
+ accessing individual lines of output. For example, if you want to test
56
+ that invoking `foo` without any arguments prints usage information on
57
+ the first line:
58
+
59
+ @test "invoking foo without arguments prints usage" {
60
+ run foo
61
+ [ "$status" -eq 1 ]
62
+ [ "${lines[0]}" = "usage: foo <filename>" ]
63
+ }
64
+
65
+
66
+ THE LOAD COMMAND
67
+ ----------------
68
+
69
+ You may want to share common code across multiple test files. Bats
70
+ includes a convenient `load` command for sourcing a Bash source file
71
+ relative to the location of the current test file. For example, if you
72
+ have a Bats test in `test/foo.bats`, the command
73
+
74
+ load test_helper
75
+
76
+ will source the script `test/test_helper.bash` in your test file. This
77
+ can be useful for sharing functions to set up your environment or load
78
+ fixtures.
79
+
80
+
81
+ THE SKIP COMMAND
82
+ ----------------
83
+
84
+ Tests can be skipped by using the `skip` command at the point in a
85
+ test you wish to skip.
86
+
87
+ @test "A test I don't want to execute for now" {
88
+ skip
89
+ run foo
90
+ [ "$status" -eq 0 ]
91
+ }
92
+
93
+ Optionally, you may include a reason for skipping:
94
+
95
+ @test "A test I don't want to execute for now" {
96
+ skip "This command will return zero soon, but not now"
97
+ run foo
98
+ [ "$status" -eq 0 ]
99
+ }
100
+
101
+ Or you can skip conditionally:
102
+
103
+ @test "A test which should run" {
104
+ if [ foo != bar ]; then
105
+ skip "foo isn't bar"
106
+ fi
107
+
108
+ run foo
109
+ [ "$status" -eq 0 ]
110
+ }
111
+
112
+
113
+ SETUP AND TEARDOWN FUNCTIONS
114
+ ----------------------------
115
+
116
+ You can define special `setup` and `teardown` functions which run
117
+ before and after each test case, respectively. Use these to load
118
+ fixtures, set up your environment, and clean up when you're done.
119
+
120
+
121
+ CODE OUTSIDE OF TEST CASES
122
+ --------------------------
123
+
124
+ You can include code in your test file outside of `@test` functions.
125
+ For example, this may be useful if you want to check for dependencies
126
+ and fail immediately if they're not present. However, any output that
127
+ you print in code outside of `@test`, `setup` or `teardown` functions
128
+ must be redirected to `stderr` (`>&2`). Otherwise, the output may
129
+ cause Bats to fail by polluting the TAP stream on `stdout`.
130
+
131
+
132
+ SPECIAL VARIABLES
133
+ -----------------
134
+
135
+ There are several global variables you can use to introspect on Bats
136
+ tests:
137
+
138
+ * `$BATS_TEST_FILENAME` is the fully expanded path to the Bats test
139
+ file.
140
+ * `$BATS_TEST_DIRNAME` is the directory in which the Bats test file is
141
+ located.
142
+ * `$BATS_TEST_NAMES` is an array of function names for each test case.
143
+ * `$BATS_TEST_NAME` is the name of the function containing the current
144
+ test case.
145
+ * `$BATS_TEST_DESCRIPTION` is the description of the current test
146
+ case.
147
+ * `$BATS_TEST_NUMBER` is the (1-based) index of the current test case
148
+ in the test file.
149
+ * `$BATS_TMPDIR` is the location to a directory that may be used to
150
+ store temporary files.
151
+
152
+
153
+ SEE ALSO
154
+ --------
155
+
156
+ `bash`(1), `bats`(1)
@@ -0,0 +1,9 @@
1
+ {
2
+ "name": "bats",
3
+ "version": "0.3.1",
4
+ "description": "Bash Automated Testing System",
5
+ "global": "true",
6
+ "install": "./install.sh /usr/local",
7
+ "scripts": [ "libexec/bats", "libexec/bats-exec-suite", "libexec/bats-exec-test", "libexec/bats-format-tap-stream", "libexec/bats-preprocess", "bin/bats" ]
8
+ }
9
+
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: busser-bats
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Fletcher Nichol
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-03-23 00:00:00.000000000 Z
11
+ date: 2023-11-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: busser
@@ -24,90 +24,6 @@ dependencies:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0'
27
- - !ruby/object:Gem::Dependency
28
- name: bundler
29
- requirement: !ruby/object:Gem::Requirement
30
- requirements:
31
- - - "~>"
32
- - !ruby/object:Gem::Version
33
- version: '1.3'
34
- type: :development
35
- prerelease: false
36
- version_requirements: !ruby/object:Gem::Requirement
37
- requirements:
38
- - - "~>"
39
- - !ruby/object:Gem::Version
40
- version: '1.3'
41
- - !ruby/object:Gem::Dependency
42
- name: rake
43
- requirement: !ruby/object:Gem::Requirement
44
- requirements:
45
- - - ">="
46
- - !ruby/object:Gem::Version
47
- version: '0'
48
- type: :development
49
- prerelease: false
50
- version_requirements: !ruby/object:Gem::Requirement
51
- requirements:
52
- - - ">="
53
- - !ruby/object:Gem::Version
54
- version: '0'
55
- - !ruby/object:Gem::Dependency
56
- name: aruba
57
- requirement: !ruby/object:Gem::Requirement
58
- requirements:
59
- - - ">="
60
- - !ruby/object:Gem::Version
61
- version: '0'
62
- type: :development
63
- prerelease: false
64
- version_requirements: !ruby/object:Gem::Requirement
65
- requirements:
66
- - - ">="
67
- - !ruby/object:Gem::Version
68
- version: '0'
69
- - !ruby/object:Gem::Dependency
70
- name: cane
71
- requirement: !ruby/object:Gem::Requirement
72
- requirements:
73
- - - ">="
74
- - !ruby/object:Gem::Version
75
- version: '0'
76
- type: :development
77
- prerelease: false
78
- version_requirements: !ruby/object:Gem::Requirement
79
- requirements:
80
- - - ">="
81
- - !ruby/object:Gem::Version
82
- version: '0'
83
- - !ruby/object:Gem::Dependency
84
- name: tailor
85
- requirement: !ruby/object:Gem::Requirement
86
- requirements:
87
- - - ">="
88
- - !ruby/object:Gem::Version
89
- version: '0'
90
- type: :development
91
- prerelease: false
92
- version_requirements: !ruby/object:Gem::Requirement
93
- requirements:
94
- - - ">="
95
- - !ruby/object:Gem::Version
96
- version: '0'
97
- - !ruby/object:Gem::Dependency
98
- name: countloc
99
- requirement: !ruby/object:Gem::Requirement
100
- requirements:
101
- - - ">="
102
- - !ruby/object:Gem::Version
103
- version: '0'
104
- type: :development
105
- prerelease: false
106
- version_requirements: !ruby/object:Gem::Requirement
107
- requirements:
108
- - - ">="
109
- - !ruby/object:Gem::Version
110
- version: '0'
111
27
  description: A Busser runner plugin for Bats
112
28
  email:
113
29
  - fnichol@nichol.ca
@@ -115,23 +31,31 @@ executables: []
115
31
  extensions: []
116
32
  extra_rdoc_files: []
117
33
  files:
118
- - ".cane"
34
+ - ".github/dependabot.yml"
35
+ - ".github/workflows/lint.yaml"
36
+ - ".github/workflows/publish.yaml"
119
37
  - ".gitignore"
120
- - ".tailor"
121
- - ".travis.yml"
38
+ - ".markdownlint-cli2.jsonc"
39
+ - ".markdownlint.yaml"
40
+ - ".rubocop.yml"
41
+ - ".tool-versions"
122
42
  - CHANGELOG.md
123
43
  - Gemfile
44
+ - Guardfile
124
45
  - LICENSE
125
46
  - README.md
126
47
  - Rakefile
127
48
  - busser-bats.gemspec
128
- - features/plugin_install_command.feature
129
- - features/plugin_list_command.feature
130
- - features/support/env.rb
131
- - features/test_command.feature
49
+ - config/cucumber.yml
50
+ - config/features/plugin_install_command.feature
51
+ - config/features/plugin_list_command.feature
52
+ - config/features/support/env.rb
53
+ - config/features/test_command.feature
132
54
  - lib/busser/bats/version.rb
133
55
  - lib/busser/runner_plugin/bats.rb
56
+ - renovate.json
134
57
  - vendor/bats/.gitattributes
58
+ - vendor/bats/.travis.yml
135
59
  - vendor/bats/LICENSE
136
60
  - vendor/bats/README.md
137
61
  - vendor/bats/VERSION.txt
@@ -142,11 +66,18 @@ files:
142
66
  - vendor/bats/libexec/bats-exec-test
143
67
  - vendor/bats/libexec/bats-format-tap-stream
144
68
  - vendor/bats/libexec/bats-preprocess
69
+ - vendor/bats/man/Makefile
70
+ - vendor/bats/man/README.md
71
+ - vendor/bats/man/bats.1
72
+ - vendor/bats/man/bats.1.ronn
73
+ - vendor/bats/man/bats.7
74
+ - vendor/bats/man/bats.7.ronn
75
+ - vendor/bats/package.json
145
76
  homepage: https://github.com/test-kitchen/busser-bats
146
77
  licenses:
147
78
  - Apache 2.0
148
79
  metadata: {}
149
- post_install_message:
80
+ post_install_message:
150
81
  rdoc_options: []
151
82
  require_paths:
152
83
  - lib
@@ -161,13 +92,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
161
92
  - !ruby/object:Gem::Version
162
93
  version: '0'
163
94
  requirements: []
164
- rubyforge_project:
165
- rubygems_version: 2.2.2
166
- signing_key:
95
+ rubygems_version: 3.4.10
96
+ signing_key:
167
97
  specification_version: 4
168
98
  summary: A Busser runner plugin for Bats
169
- test_files:
170
- - features/plugin_install_command.feature
171
- - features/plugin_list_command.feature
172
- - features/support/env.rb
173
- - features/test_command.feature
99
+ test_files: []
data/.cane DELETED
File without changes
data/.tailor DELETED
@@ -1,4 +0,0 @@
1
- Tailor.config do |config|
2
- config.formatters "text"
3
- config.file_set 'lib/**/*.rb'
4
- end
data/.travis.yml DELETED
@@ -1,11 +0,0 @@
1
- language: ruby
2
-
3
- rvm:
4
- - 2.0.0
5
- - 1.9.3
6
- - 1.9.2
7
- - ruby-head
8
-
9
- matrix:
10
- allow_failures:
11
- - rvm: ruby-head
@@ -1,14 +0,0 @@
1
- Feature: Plugin install command
2
- In order to use this plugin
3
- As a user of Busser
4
- I want to run the postinstall for this plugin
5
-
6
- Background:
7
- Given a test BUSSER_ROOT directory named "busser-bats-install"
8
-
9
- Scenario: Running the postinstall generator
10
- When I run `busser plugin install busser-bats --force-postinstall`
11
- Then the vendor directory named "bats" should exist
12
- And the vendor file "bats/bin/bats" should contain "BATS_PREFIX="
13
- And the output should contain "Installed Bats"
14
- And the exit status should be 0
@@ -1,44 +0,0 @@
1
- Feature: Test command
2
- In order to run tests written with bats
3
- As a user of Busser
4
- I want my tests to run when the bats runner plugin is installed
5
-
6
- Background:
7
- Given a test BUSSER_ROOT directory named "busser-bats-test"
8
- When I successfully run `busser plugin install busser-bats --force-postinstall`
9
- Given a suite directory named "bats"
10
-
11
- Scenario: A passing test suite
12
- Given a file in suite "bats" named "default.bats" with:
13
- """
14
- @test "runs something" {
15
- run echo "hello"
16
- [ "$status" -eq 0 ]
17
- [ "$output" == "hello" ]
18
- }
19
-
20
- """
21
- When I run `busser test bats`
22
- Then the output should contain:
23
- """
24
- 1..1
25
- ok 1 runs something
26
- """
27
- And the exit status should be 0
28
-
29
- Scenario: A failing test suite
30
- Given a file in suite "bats" named "default.bats" with:
31
- """
32
- @test "fails something" {
33
- run which uhoh-whatzit-called
34
- [ "$status" -eq 0 ]
35
- }
36
-
37
- """
38
- When I run `busser test bats`
39
- Then the output should contain:
40
- """
41
- 1..1
42
- not ok 1 fails something
43
- """
44
- And the exit status should not be 0