blackstart 0.5.0 → 0.8.0
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.
- data/LICENSE +202 -0
- data/{README.txt → README} +27 -12
- data/lib/blackstart.rb +26 -25
- data/sig/blackstart.rbs +18 -0
- data/test/blackstart_test.rb +38 -17
- metadata +8 -24
- data/LICENSE.txt +0 -19
- data/blackstart.gemspec +0 -11
data/LICENSE
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright [yyyy] [name of copyright owner]
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
data/{README.txt → README}
RENAMED
|
@@ -2,8 +2,9 @@ Blackstart
|
|
|
2
2
|
|
|
3
3
|
Blackstart is a small, subdued library for automated testing in Ruby. It
|
|
4
4
|
doesn't depend on anything beyond the Ruby platform and doesn't modify the
|
|
5
|
-
environment beyond its conventional namespace.
|
|
6
|
-
|
|
5
|
+
environment beyond its conventional namespace. The program that tests it is
|
|
6
|
+
written in primitive Ruby, with no other testing library, so it can be verified
|
|
7
|
+
straightforwardly.
|
|
7
8
|
|
|
8
9
|
The blackstart is a small, subdued bird that eats bugs. A black start is when
|
|
9
10
|
an inactive power plant restarts by means of an independent power source rather
|
|
@@ -14,13 +15,13 @@ Here's an example of a test program that uses Blackstart:
|
|
|
14
15
|
require "blackstart"
|
|
15
16
|
|
|
16
17
|
exit Blackstart.run [
|
|
17
|
-
|
|
18
|
+
lambda {
|
|
18
19
|
unless "Hello, World!" == ["He", "", "o, Wor", "d!"].join("l")
|
|
19
20
|
raise "join did not work as expected"
|
|
20
21
|
end
|
|
21
22
|
},
|
|
22
23
|
|
|
23
|
-
|
|
24
|
+
lambda {
|
|
24
25
|
unless "sample" == "simple".gsub(/i/, "a")
|
|
25
26
|
raise "gsub did not work as expected"
|
|
26
27
|
end
|
|
@@ -44,11 +45,15 @@ Blackstart.run interprets it as a failed test.
|
|
|
44
45
|
After each test failure, Blackstart.run sends a puts message with failure
|
|
45
46
|
information to its second parameter, which is $stdout by default. The failure
|
|
46
47
|
information includes a description of the test (the test object converted to a
|
|
47
|
-
string) and a description of the error raised (its class,
|
|
48
|
-
backtrace).
|
|
48
|
+
string) and a description of the error raised (its class, string
|
|
49
|
+
representation, and backtrace).
|
|
49
50
|
|
|
50
|
-
|
|
51
|
-
|
|
51
|
+
If a test raises a non-StandardError exception, Blackstart.run interprets it as
|
|
52
|
+
a system-level event or fundamental problem: it immediately raises the
|
|
53
|
+
exception and doesn't run any more tests.
|
|
54
|
+
|
|
55
|
+
The library provides little beyond this, but it supports more sophisticated
|
|
56
|
+
uses. Some examples follow.
|
|
52
57
|
|
|
53
58
|
|
|
54
59
|
- Exiting with the appropriate status
|
|
@@ -104,8 +109,8 @@ Blackstart::Scratchpad#instance_exec. For example:
|
|
|
104
109
|
end
|
|
105
110
|
end
|
|
106
111
|
|
|
107
|
-
Use this
|
|
108
|
-
to self.
|
|
112
|
+
Use this technique with care because the test proc could send instance_exec
|
|
113
|
+
messages to self.
|
|
109
114
|
|
|
110
115
|
|
|
111
116
|
- Building a test collection in stages
|
|
@@ -118,7 +123,7 @@ can be done straightforwardly:
|
|
|
118
123
|
TESTS = []
|
|
119
124
|
|
|
120
125
|
TESTS.concat [
|
|
121
|
-
|
|
126
|
+
lambda {
|
|
122
127
|
unless "Hello, World!" == ["He", "", "o, Wor", "d!"].join("l")
|
|
123
128
|
raise "join did not work as expected"
|
|
124
129
|
end
|
|
@@ -126,7 +131,7 @@ can be done straightforwardly:
|
|
|
126
131
|
]
|
|
127
132
|
|
|
128
133
|
TESTS.concat [
|
|
129
|
-
|
|
134
|
+
lambda {
|
|
130
135
|
unless "sample" == "simple".gsub(/i/, "a")
|
|
131
136
|
raise "gsub did not work as expected"
|
|
132
137
|
end
|
|
@@ -174,3 +179,13 @@ stream is $stdout, so the default behavior is to print unadorned failure
|
|
|
174
179
|
information to standard output. But you can specify any object as the output
|
|
175
180
|
stream -- even if it's not really a stream -- allowing you to handle failure
|
|
176
181
|
information however you want.
|
|
182
|
+
|
|
183
|
+
|
|
184
|
+
- Running multiple tests at the same time
|
|
185
|
+
|
|
186
|
+
Although Blackstart.run is written in a sequential style, it can run multiple
|
|
187
|
+
tests at the same time. Blackstart.run sends an each message with a block to
|
|
188
|
+
your test collection, expecting the block to be executed once for each test;
|
|
189
|
+
your test collection can execute the block in multiple threads concurrently.
|
|
190
|
+
For your program to work well in this mode, your tests and the output stream
|
|
191
|
+
must work correctly when used from multiple threads.
|
data/lib/blackstart.rb
CHANGED
|
@@ -11,18 +11,18 @@ module Blackstart
|
|
|
11
11
|
# raises an error -- meaning an exception whose class is StandardError or a
|
|
12
12
|
# descendant of StandardError -- this method attempts to make and return a
|
|
13
13
|
# string describing that error; the description consists of the error's
|
|
14
|
-
# class,
|
|
15
|
-
# making an error description, this method raises that
|
|
16
|
-
# yielding to the block raises a non-error exception, this
|
|
17
|
-
# exception. If yielding to the block does not raise an
|
|
18
|
-
# method returns nil.
|
|
14
|
+
# class, string representation, and backtrace (if any). If an exception is
|
|
15
|
+
# raised while making an error description, this method raises that
|
|
16
|
+
# exception. If yielding to the block raises a non-error exception, this
|
|
17
|
+
# method raises that exception. If yielding to the block does not raise an
|
|
18
|
+
# exception, this method returns nil.
|
|
19
19
|
|
|
20
20
|
def self.vet
|
|
21
21
|
yield
|
|
22
22
|
nil
|
|
23
|
-
rescue ::StandardError
|
|
23
|
+
rescue ::StandardError => e
|
|
24
24
|
# Like IO#puts, separate lines with a line feed character rather than $\.
|
|
25
|
-
["#{
|
|
25
|
+
["#{e.class}: #{e}"].concat(e.backtrace || []).join "\n"
|
|
26
26
|
end
|
|
27
27
|
|
|
28
28
|
##
|
|
@@ -40,36 +40,37 @@ module Blackstart
|
|
|
40
40
|
# test object in the sequence with that test object as the first argument.
|
|
41
41
|
# Each test involves creating a new scratchpad -- an instance of
|
|
42
42
|
# Blackstart::Scratchpad -- and sending an instance_exec message to it with
|
|
43
|
-
# the test object as
|
|
44
|
-
#
|
|
45
|
-
#
|
|
46
|
-
# when the test (which includes any initial conversion to a proc) raises
|
|
47
|
-
# error: an exception whose class is StandardError or a descendant of
|
|
43
|
+
# the test object as the block, which converts the test object to a proc via
|
|
44
|
+
# to_proc if it's not already a proc. The resulting proc is called with no
|
|
45
|
+
# arguments and no block; the self object is set to the scratchpad. A failure
|
|
46
|
+
# is when the test (which includes any initial conversion to a proc) raises
|
|
47
|
+
# an error: an exception whose class is StandardError or a descendant of
|
|
48
48
|
# StandardError. After a failure, this method sends a puts message to the
|
|
49
|
-
# output stream, ostream, with these arguments (positional, in
|
|
50
|
-
# string "FAILED TEST:"; the test object converted to a string via
|
|
51
|
-
# string "...ERROR:"; a string combining the class,
|
|
52
|
-
# the error; and an empty string. If a test
|
|
53
|
-
# this method immediately raises that
|
|
54
|
-
# tests and handled any failures, this
|
|
55
|
-
# failures, true otherwise. This method
|
|
56
|
-
# raised outside of a test.
|
|
49
|
+
# output stream, ostream, with no block and these arguments (positional, in
|
|
50
|
+
# order): a string "FAILED TEST:"; the test object converted to a string via
|
|
51
|
+
# to_s; a string "...ERROR:"; a string combining the class, string
|
|
52
|
+
# representation, and backtrace of the error; and an empty string. If a test
|
|
53
|
+
# raises a non-error exception, this method immediately raises that
|
|
54
|
+
# exception. After it has run all the tests and handled any failures, this
|
|
55
|
+
# method returns false if there were failures, true otherwise. This method
|
|
56
|
+
# immediately raises any exception raised outside of a test.
|
|
57
57
|
#
|
|
58
58
|
# By default, ostream is $stdout.
|
|
59
59
|
|
|
60
60
|
def self.run source, ostream = $stdout
|
|
61
|
-
|
|
61
|
+
no_failures = true
|
|
62
62
|
source.each do |tst|
|
|
63
63
|
# Create the scratchpad outside the vet block so that this method will
|
|
64
64
|
# raise any exception that results instead of potentially treating it as
|
|
65
65
|
# a test failure.
|
|
66
|
-
scratchpad = Scratchpad.new
|
|
66
|
+
scratchpad = ::Blackstart::Scratchpad.new
|
|
67
67
|
if err_desc = vet { scratchpad.instance_exec(&tst) }
|
|
68
|
-
|
|
69
|
-
ostream.puts "FAILED TEST:", tst.to_s, "...ERROR:", err_desc
|
|
68
|
+
no_failures = false
|
|
69
|
+
ostream.puts "FAILED TEST:", tst.to_s, "...ERROR:", err_desc, ""
|
|
70
70
|
end
|
|
71
|
+
nil
|
|
71
72
|
end
|
|
72
|
-
|
|
73
|
+
no_failures
|
|
73
74
|
end
|
|
74
75
|
|
|
75
76
|
end
|
data/sig/blackstart.rbs
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
module Blackstart
|
|
2
|
+
def self.vet: () ?{ () -> void } -> ::String?
|
|
3
|
+
|
|
4
|
+
class Scratchpad
|
|
5
|
+
end
|
|
6
|
+
|
|
7
|
+
type test_proc = ^() [self: Scratchpad] -> void
|
|
8
|
+
interface _ConvertsToTestProc
|
|
9
|
+
def to_proc: () -> test_proc
|
|
10
|
+
end
|
|
11
|
+
type test = (test_proc | _ConvertsToTestProc) & ::_ToS
|
|
12
|
+
|
|
13
|
+
interface _OutputStream
|
|
14
|
+
def puts: (::String, ::String, ::String, ::String, ::String) -> void
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def self.run: (::_Each[test], ?_OutputStream) -> bool
|
|
18
|
+
end
|
data/test/blackstart_test.rb
CHANGED
|
@@ -1,6 +1,22 @@
|
|
|
1
1
|
# Sections that create local variables are in class definitions so that later
|
|
2
2
|
# sections cannot accidentally reference those local variables.
|
|
3
3
|
|
|
4
|
+
# Kernel#fail is an alias of Kernel#raise, so they do the same thing. However,
|
|
5
|
+
# they are used differently in this file: Kernel#fail is used only for
|
|
6
|
+
# assertions and Kernel#raise is used otherwise. Assertions always pass a
|
|
7
|
+
# string argument so that a new RuntimeError is raised. Kernel#fail with no
|
|
8
|
+
# arguments re-raises the current exception ($!) or, if there is none, raises a
|
|
9
|
+
# new RuntimeError. This would be fine (that is, it would raise a new
|
|
10
|
+
# RuntimeError) sometimes, but not always (not in a rescue clause, for
|
|
11
|
+
# example). Always using Kernel#fail with a string argument makes assertions
|
|
12
|
+
# consistent and avoids this subtle error.
|
|
13
|
+
|
|
14
|
+
# Constant references in blocks are fully qualified because this program must
|
|
15
|
+
# run correctly on a wide range of Ruby versions, including those in the 1.9.1
|
|
16
|
+
# and 1.9.2 branches. Ruby 1.9.1 and 1.9.2 used constant-lookup rules in
|
|
17
|
+
# certain situations that differed from those of earlier and later branches of
|
|
18
|
+
# Ruby.
|
|
19
|
+
|
|
4
20
|
require "blackstart"
|
|
5
21
|
|
|
6
22
|
# Blackstart should be a module.
|
|
@@ -71,7 +87,7 @@ class ::Object
|
|
|
71
87
|
e1 = StandardError.new
|
|
72
88
|
e2_class = Class.new StandardError
|
|
73
89
|
e1.instance_variable_set :@next_exception_class, e2_class
|
|
74
|
-
def e1.
|
|
90
|
+
def e1.to_s
|
|
75
91
|
::Kernel.raise @next_exception_class
|
|
76
92
|
end
|
|
77
93
|
begin
|
|
@@ -95,7 +111,7 @@ class ::Object
|
|
|
95
111
|
end
|
|
96
112
|
|
|
97
113
|
# If yielding to the block does not raise an exception, Blackstart.vet should
|
|
98
|
-
# return nil. The object returned shouldn't matter.
|
|
114
|
+
# return nil. The object returned by the block shouldn't matter.
|
|
99
115
|
fail "" unless nil.equal? Blackstart.vet { nil }
|
|
100
116
|
fail "" unless nil.equal? Blackstart.vet { true }
|
|
101
117
|
|
|
@@ -106,6 +122,9 @@ fail "" unless nil.equal? Blackstart.vet { true }
|
|
|
106
122
|
# class.
|
|
107
123
|
fail "" unless Blackstart::Scratchpad.equal? Blackstart::Scratchpad.new.class
|
|
108
124
|
|
|
125
|
+
# Blackstart::Scratchpad should not be frozen.
|
|
126
|
+
fail "" if Blackstart::Scratchpad.frozen?
|
|
127
|
+
|
|
109
128
|
# A new scratchpad should have no instance variables.
|
|
110
129
|
fail "" unless 0 == Blackstart::Scratchpad.new.instance_variables.length
|
|
111
130
|
|
|
@@ -141,7 +160,7 @@ class ::Object
|
|
|
141
160
|
# When there are tests but none raise exceptions, Blackstart.run should not
|
|
142
161
|
# notify the output stream of any failures. The objects returned by the
|
|
143
162
|
# test procs shouldn't affect Blackstart.run's behavior.
|
|
144
|
-
source = [
|
|
163
|
+
source = [lambda {}, lambda { 42 }]
|
|
145
164
|
fail "" unless true.equal? Blackstart.run(source, invalid_ostream)
|
|
146
165
|
fail "" unless true.equal? Blackstart.run(source, spy_stdout)
|
|
147
166
|
fail "" unless true.equal? Blackstart.run(source)
|
|
@@ -158,17 +177,19 @@ class ::Object
|
|
|
158
177
|
def e_class.to_s
|
|
159
178
|
"FakeError".freeze
|
|
160
179
|
end
|
|
161
|
-
fail_prc1 =
|
|
180
|
+
fail_prc1 = lambda { ::Kernel.raise e_class, "fake message 1".freeze }
|
|
162
181
|
def fail_prc1.to_s
|
|
163
182
|
"to_s 1".freeze
|
|
164
183
|
end
|
|
165
184
|
fail_prc1.freeze
|
|
166
|
-
pass_prc =
|
|
185
|
+
pass_prc = lambda {}.freeze
|
|
167
186
|
fail_prc2 = Object.new # Not a Proc instance, but converts to one.
|
|
168
187
|
fail_prc2.instance_variable_set :@_test_e_class, e_class
|
|
169
188
|
def fail_prc2.to_proc
|
|
170
189
|
e_class = @_test_e_class
|
|
171
|
-
::
|
|
190
|
+
::Kernel.lambda do
|
|
191
|
+
::Kernel.raise e_class, "fake message 2".freeze
|
|
192
|
+
end.freeze
|
|
172
193
|
end
|
|
173
194
|
def fail_prc2.to_s
|
|
174
195
|
"to_s 2".freeze
|
|
@@ -281,7 +302,7 @@ class ::Object
|
|
|
281
302
|
# tests. (In general, the only exceptions Blackstart.run should rescue are
|
|
282
303
|
# StandardError exceptions raised by tests.)
|
|
283
304
|
second_test_run = false
|
|
284
|
-
source = [
|
|
305
|
+
source = [lambda { ::Kernel.raise "" }, lambda { second_test_run = true }]
|
|
285
306
|
begin
|
|
286
307
|
Blackstart.run source, invalid_ostream
|
|
287
308
|
rescue NoMethodError
|
|
@@ -297,8 +318,8 @@ class ::Object
|
|
|
297
318
|
# raised by tests.)
|
|
298
319
|
second_test_run = false
|
|
299
320
|
non_standard_error = Class.new Exception
|
|
300
|
-
source = [
|
|
301
|
-
|
|
321
|
+
source = [lambda { ::Kernel.raise non_standard_error },
|
|
322
|
+
lambda { second_test_run = true }]
|
|
302
323
|
begin
|
|
303
324
|
Blackstart.run source, spy_stdout
|
|
304
325
|
rescue non_standard_error
|
|
@@ -329,11 +350,11 @@ class ::Object
|
|
|
329
350
|
# tests. (In general, the only exceptions Blackstart.run should rescue are
|
|
330
351
|
# StandardError exceptions raised by tests.)
|
|
331
352
|
second_test_run = false
|
|
332
|
-
no_desc =
|
|
353
|
+
no_desc = lambda { ::Kernel.raise "" }
|
|
333
354
|
def no_desc.to_s
|
|
334
355
|
::Kernel.raise ::NoMethodError
|
|
335
356
|
end
|
|
336
|
-
source = [no_desc,
|
|
357
|
+
source = [no_desc, lambda { second_test_run = true }]
|
|
337
358
|
begin
|
|
338
359
|
Blackstart.run source, spy_stdout
|
|
339
360
|
rescue NoMethodError
|
|
@@ -350,7 +371,7 @@ end
|
|
|
350
371
|
# Blackstart.run should run tests in order.
|
|
351
372
|
class ::Object
|
|
352
373
|
data = []
|
|
353
|
-
Blackstart.run [
|
|
374
|
+
Blackstart.run [lambda { data << 1 }, lambda { data << 2 }], nil
|
|
354
375
|
fail "" unless [1, 2] == data
|
|
355
376
|
end
|
|
356
377
|
|
|
@@ -371,7 +392,7 @@ class ::Object
|
|
|
371
392
|
source = Object.new
|
|
372
393
|
def source.each
|
|
373
394
|
ran = false
|
|
374
|
-
yield
|
|
395
|
+
yield lambda { ran = true }
|
|
375
396
|
@ran = ran
|
|
376
397
|
self
|
|
377
398
|
end
|
|
@@ -380,7 +401,7 @@ class ::Object
|
|
|
380
401
|
|
|
381
402
|
source = Object.new
|
|
382
403
|
def source.each
|
|
383
|
-
yield
|
|
404
|
+
yield lambda {}
|
|
384
405
|
nil
|
|
385
406
|
end
|
|
386
407
|
fail "" unless true.equal? Blackstart.run(source, nil)
|
|
@@ -402,7 +423,7 @@ end
|
|
|
402
423
|
# instance of Blackstart::Scratchpad.
|
|
403
424
|
class ::Object
|
|
404
425
|
sp1 = sp2 = nil
|
|
405
|
-
Blackstart.run [
|
|
426
|
+
Blackstart.run [lambda { sp1 = self }, lambda { sp2 = self }], nil
|
|
406
427
|
fail "" unless Blackstart::Scratchpad.equal? sp1.class
|
|
407
428
|
fail "" unless Blackstart::Scratchpad.equal? sp2.class
|
|
408
429
|
fail "" if sp1.equal? sp2
|
|
@@ -411,7 +432,7 @@ end
|
|
|
411
432
|
# When Blackstart.run runs a test, the scratchpad should not be frozen.
|
|
412
433
|
class ::Object
|
|
413
434
|
frozen = true
|
|
414
|
-
Blackstart.run [
|
|
435
|
+
Blackstart.run [lambda { frozen = frozen? }], nil
|
|
415
436
|
fail "" if frozen
|
|
416
437
|
end
|
|
417
438
|
|
|
@@ -449,7 +470,7 @@ class Blackstart::Scratchpad
|
|
|
449
470
|
end
|
|
450
471
|
class ::Object
|
|
451
472
|
result = nil
|
|
452
|
-
Blackstart.run [
|
|
473
|
+
Blackstart.run [lambda { result = [@ivar, foo()] }], nil
|
|
453
474
|
fail "" unless [1, 2] == result
|
|
454
475
|
end
|
|
455
476
|
|
metadata
CHANGED
|
@@ -1,13 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: blackstart
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
|
|
5
|
-
prerelease:
|
|
6
|
-
segments:
|
|
7
|
-
- 0
|
|
8
|
-
- 5
|
|
9
|
-
- 0
|
|
10
|
-
version: 0.5.0
|
|
4
|
+
version: 0.8.0
|
|
11
5
|
platform: ruby
|
|
12
6
|
authors:
|
|
13
7
|
- Aaron Beckerman
|
|
@@ -15,7 +9,7 @@ autorequire:
|
|
|
15
9
|
bindir: bin
|
|
16
10
|
cert_chain: []
|
|
17
11
|
|
|
18
|
-
date:
|
|
12
|
+
date: 2026-06-04 00:00:00 -07:00
|
|
19
13
|
default_executable:
|
|
20
14
|
dependencies: []
|
|
21
15
|
|
|
@@ -28,39 +22,29 @@ extensions: []
|
|
|
28
22
|
extra_rdoc_files: []
|
|
29
23
|
|
|
30
24
|
files:
|
|
31
|
-
- LICENSE
|
|
32
|
-
- README
|
|
33
|
-
- blackstart.gemspec
|
|
25
|
+
- LICENSE
|
|
26
|
+
- README
|
|
34
27
|
- lib/blackstart.rb
|
|
28
|
+
- sig/blackstart.rbs
|
|
35
29
|
- test/blackstart_test.rb
|
|
36
30
|
has_rdoc: true
|
|
37
31
|
homepage:
|
|
38
32
|
licenses:
|
|
39
|
-
-
|
|
33
|
+
- Apache-2.0
|
|
40
34
|
post_install_message:
|
|
41
35
|
rdoc_options: []
|
|
42
36
|
|
|
43
37
|
require_paths:
|
|
44
38
|
- lib
|
|
45
39
|
required_ruby_version: !ruby/object:Gem::Requirement
|
|
46
|
-
none: false
|
|
47
40
|
requirements:
|
|
48
41
|
- - ">="
|
|
49
42
|
- !ruby/object:Gem::Version
|
|
50
|
-
hash: 57
|
|
51
|
-
segments:
|
|
52
|
-
- 1
|
|
53
|
-
- 8
|
|
54
|
-
- 7
|
|
55
43
|
version: 1.8.7
|
|
56
44
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
57
|
-
none: false
|
|
58
45
|
requirements:
|
|
59
46
|
- - ">="
|
|
60
47
|
- !ruby/object:Gem::Version
|
|
61
|
-
hash: 3
|
|
62
|
-
segments:
|
|
63
|
-
- 0
|
|
64
48
|
version: "0"
|
|
65
49
|
requirements: []
|
|
66
50
|
|
|
@@ -69,5 +53,5 @@ rubygems_version: 1.6.2
|
|
|
69
53
|
signing_key:
|
|
70
54
|
specification_version: 3
|
|
71
55
|
summary: A small, subdued library for automated testing.
|
|
72
|
-
test_files:
|
|
73
|
-
|
|
56
|
+
test_files: []
|
|
57
|
+
|
data/LICENSE.txt
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
Copyright (c) 2024 Aaron Beckerman
|
|
2
|
-
|
|
3
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
|
4
|
-
this software and associated documentation files (the "Software"), to deal in
|
|
5
|
-
the Software without restriction, including without limitation the rights to
|
|
6
|
-
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
|
7
|
-
of the Software, and to permit persons to whom the Software is furnished to do
|
|
8
|
-
so, subject to the following conditions:
|
|
9
|
-
|
|
10
|
-
The above copyright notice and this permission notice shall be included in all
|
|
11
|
-
copies or substantial portions of the Software.
|
|
12
|
-
|
|
13
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
14
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
15
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
16
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
17
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
18
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
19
|
-
SOFTWARE.
|
data/blackstart.gemspec
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
Gem::Specification.new do |s|
|
|
2
|
-
s.name = "blackstart"
|
|
3
|
-
s.version = "0.5.0"
|
|
4
|
-
s.authors = ["Aaron Beckerman"]
|
|
5
|
-
s.summary = "A small, subdued library for automated testing."
|
|
6
|
-
s.licenses = ["MIT"]
|
|
7
|
-
s.required_ruby_version = ">= 1.8.7"
|
|
8
|
-
s.files = ["LICENSE.txt", "README.txt", "blackstart.gemspec",
|
|
9
|
-
"lib/blackstart.rb", "test/blackstart_test.rb"]
|
|
10
|
-
s.test_files = ["test/blackstart_test.rb"]
|
|
11
|
-
end
|