test-queue-patched 0.4.3
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.
- checksums.yaml +7 -0
- data/.gitignore +1 -0
- data/.travis.yml +18 -0
- data/Gemfile +5 -0
- data/Gemfile-cucumber1-3 +4 -0
- data/Gemfile-cucumber1-3.lock +33 -0
- data/Gemfile-cucumber2-4 +4 -0
- data/Gemfile-cucumber2-4.lock +37 -0
- data/Gemfile-minitest4 +3 -0
- data/Gemfile-minitest4.lock +19 -0
- data/Gemfile-minitest5 +3 -0
- data/Gemfile-minitest5.lock +19 -0
- data/Gemfile-rspec2-1 +3 -0
- data/Gemfile-rspec2-1.lock +27 -0
- data/Gemfile-rspec3-0 +3 -0
- data/Gemfile-rspec3-0.lock +31 -0
- data/Gemfile-rspec3-1 +3 -0
- data/Gemfile-rspec3-1.lock +31 -0
- data/Gemfile-rspec3-2 +3 -0
- data/Gemfile-rspec3-2.lock +32 -0
- data/Gemfile-testunit +3 -0
- data/Gemfile-testunit.lock +21 -0
- data/Gemfile.lock +41 -0
- data/README.md +126 -0
- data/bin/cucumber-queue +4 -0
- data/bin/minitest-queue +4 -0
- data/bin/rspec-queue +4 -0
- data/bin/testunit-queue +4 -0
- data/lib/test-queue.rb +1 -0
- data/lib/test_queue/iterator.rb +107 -0
- data/lib/test_queue/runner/cucumber.rb +115 -0
- data/lib/test_queue/runner/minitest.rb +21 -0
- data/lib/test_queue/runner/minitest4.rb +88 -0
- data/lib/test_queue/runner/minitest5.rb +87 -0
- data/lib/test_queue/runner/puppet_lint.rb +31 -0
- data/lib/test_queue/runner/rspec.rb +79 -0
- data/lib/test_queue/runner/rspec2.rb +44 -0
- data/lib/test_queue/runner/rspec3.rb +54 -0
- data/lib/test_queue/runner/sample.rb +74 -0
- data/lib/test_queue/runner/testunit.rb +74 -0
- data/lib/test_queue/runner.rb +632 -0
- data/lib/test_queue/stats.rb +95 -0
- data/lib/test_queue/test_framework.rb +29 -0
- data/lib/test_queue.rb +8 -0
- data/script/bootstrap +12 -0
- data/script/cibuild +19 -0
- data/script/spec +7 -0
- data/spec/stats_spec.rb +76 -0
- data/test/cucumber.bats +57 -0
- data/test/minitest4.bats +34 -0
- data/test/minitest5.bats +194 -0
- data/test/rspec.bats +46 -0
- data/test/samples/features/bad.feature +5 -0
- data/test/samples/features/sample.feature +25 -0
- data/test/samples/features/sample2.feature +29 -0
- data/test/samples/features/step_definitions/common.rb +19 -0
- data/test/samples/sample_minispec.rb +37 -0
- data/test/samples/sample_minitest4.rb +25 -0
- data/test/samples/sample_minitest5.rb +33 -0
- data/test/samples/sample_rspec_helper.rb +1 -0
- data/test/samples/sample_shared_examples_for_spec.rb +5 -0
- data/test/samples/sample_spec.rb +25 -0
- data/test/samples/sample_split_spec.rb +17 -0
- data/test/samples/sample_testunit.rb +25 -0
- data/test/samples/sample_use_shared_example1_spec.rb +8 -0
- data/test/samples/sample_use_shared_example2_spec.rb +8 -0
- data/test/sleepy_runner.rb +14 -0
- data/test/testlib.bash +89 -0
- data/test/testunit.bats +20 -0
- data/test-queue-patched.gemspec +21 -0
- metadata +117 -0
@@ -0,0 +1,29 @@
|
|
1
|
+
module TestQueue
|
2
|
+
# This class provides an abstraction over the various test frameworks we
|
3
|
+
# support. The framework-specific subclasses are defined in the various
|
4
|
+
# test_queue/runner/* files.
|
5
|
+
class TestFramework
|
6
|
+
# Return all file paths to load test suites from.
|
7
|
+
#
|
8
|
+
# An example implementation might just return files passed on the command
|
9
|
+
# line, or defer to the underlying test framework to determine which files
|
10
|
+
# to load.
|
11
|
+
#
|
12
|
+
# Returns an Enumerable of String file paths.
|
13
|
+
def all_suite_files
|
14
|
+
raise NotImplementedError
|
15
|
+
end
|
16
|
+
|
17
|
+
# Load all suites from the specified file path.
|
18
|
+
#
|
19
|
+
# path - String file path to load suites from
|
20
|
+
#
|
21
|
+
# Returns an Enumerable of tuples containing:
|
22
|
+
# suite_name - String that uniquely identifies this suite
|
23
|
+
# suite - Framework-specific object that can be used to actually
|
24
|
+
# run the suite
|
25
|
+
def suites_from_file(path)
|
26
|
+
raise NotImplementedError
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
data/lib/test_queue.rb
ADDED
data/script/bootstrap
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
#!/bin/sh
|
2
|
+
|
3
|
+
set -ex
|
4
|
+
|
5
|
+
cd "$(dirname "$0")/.."
|
6
|
+
ROOT=$(pwd)
|
7
|
+
|
8
|
+
rm -rf tmp
|
9
|
+
mkdir tmp
|
10
|
+
mkdir -p vendor/bats
|
11
|
+
curl --silent --location --show-error https://github.com/sstephenson/bats/archive/v0.4.0.tar.gz | tar -xz -C tmp
|
12
|
+
tmp/bats-0.4.0/install.sh "$ROOT/vendor/bats"
|
data/script/cibuild
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
#!/bin/sh
|
2
|
+
|
3
|
+
set -ex
|
4
|
+
|
5
|
+
if [ "$SUITE" = "ruby" ]; then
|
6
|
+
exec script/spec
|
7
|
+
fi
|
8
|
+
|
9
|
+
export TEST_QUEUE_WORKERS=2 TEST_QUEUE_VERBOSE=1
|
10
|
+
|
11
|
+
if [ -f "Gemfile-$SUITE" ]; then
|
12
|
+
export BUNDLE_GEMFILE="Gemfile-$SUITE"
|
13
|
+
else
|
14
|
+
export BUNDLE_GEMFILE=Gemfile
|
15
|
+
fi
|
16
|
+
|
17
|
+
bundle install
|
18
|
+
|
19
|
+
vendor/bats/bin/bats test
|
data/script/spec
ADDED
data/spec/stats_spec.rb
ADDED
@@ -0,0 +1,76 @@
|
|
1
|
+
require "fileutils"
|
2
|
+
require "tempfile"
|
3
|
+
require "test_queue/stats"
|
4
|
+
|
5
|
+
RSpec.describe TestQueue::Stats do
|
6
|
+
before do
|
7
|
+
Tempfile.open("test_queue_stats") do |f|
|
8
|
+
@path = f.path
|
9
|
+
f.close!
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
after do
|
14
|
+
FileUtils.rm_f(@path)
|
15
|
+
end
|
16
|
+
|
17
|
+
describe "#initialize" do
|
18
|
+
it "ignores empty stats files" do
|
19
|
+
File.write(@path, "")
|
20
|
+
stats = TestQueue::Stats.new(@path)
|
21
|
+
expect(stats.all_suites).to be_empty
|
22
|
+
end
|
23
|
+
|
24
|
+
it "ignores invalid data in the stats files" do
|
25
|
+
File.write(@path, "this is not marshal data")
|
26
|
+
stats = TestQueue::Stats.new(@path)
|
27
|
+
expect(stats.all_suites).to be_empty
|
28
|
+
end
|
29
|
+
|
30
|
+
it "ignores badly-typed data in the stats file" do
|
31
|
+
File.write(@path, Marshal.dump(["heyyy"]))
|
32
|
+
stats = TestQueue::Stats.new(@path)
|
33
|
+
expect(stats.all_suites).to be_empty
|
34
|
+
end
|
35
|
+
|
36
|
+
it "ignores stats files with a wrong version number" do
|
37
|
+
File.write(@path, Marshal.dump({ :version => 1e8, :suites => "boom" }))
|
38
|
+
stats = TestQueue::Stats.new(@path)
|
39
|
+
expect(stats.all_suites).to be_empty
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
it "can save and load data" do
|
44
|
+
stats = TestQueue::Stats.new(@path)
|
45
|
+
time = truncated_now
|
46
|
+
suites = [
|
47
|
+
TestQueue::Stats::Suite.new("Suite1", "foo.rb", 0.3, time),
|
48
|
+
TestQueue::Stats::Suite.new("Suite2", "bar.rb", 0.5, time + 5),
|
49
|
+
]
|
50
|
+
stats.record_suites(suites)
|
51
|
+
stats.save
|
52
|
+
|
53
|
+
stats = TestQueue::Stats.new(@path)
|
54
|
+
expect(stats.all_suites.sort_by(&:name)).to eq(suites)
|
55
|
+
end
|
56
|
+
|
57
|
+
it "prunes suites not seen in the last 8 days" do
|
58
|
+
stats = TestQueue::Stats.new(@path)
|
59
|
+
time = truncated_now
|
60
|
+
suites = [
|
61
|
+
TestQueue::Stats::Suite.new("Suite1", "foo.rb", 0.3, time),
|
62
|
+
TestQueue::Stats::Suite.new("Suite2", "bar.rb", 0.5, time - (8 * 24 * 60 * 60) - 2),
|
63
|
+
TestQueue::Stats::Suite.new("Suite3", "baz.rb", 0.6, time - (7 * 24 * 60 * 60)),
|
64
|
+
]
|
65
|
+
stats.record_suites(suites)
|
66
|
+
stats.save
|
67
|
+
|
68
|
+
stats = TestQueue::Stats.new(@path)
|
69
|
+
expect(stats.all_suites.map(&:name).sort).to eq(%w[Suite1 Suite3])
|
70
|
+
end
|
71
|
+
|
72
|
+
# Returns Time.now rounded down to the nearest second.
|
73
|
+
def truncated_now
|
74
|
+
Time.at(Time.now.to_i)
|
75
|
+
end
|
76
|
+
end
|
data/test/cucumber.bats
ADDED
@@ -0,0 +1,57 @@
|
|
1
|
+
load "testlib"
|
2
|
+
|
3
|
+
SCRATCH=tmp/cucumber-tests
|
4
|
+
|
5
|
+
setup() {
|
6
|
+
require_gem "cucumber" ">= 1.0"
|
7
|
+
rm -rf $SCRATCH
|
8
|
+
mkdir -p $SCRATCH
|
9
|
+
}
|
10
|
+
|
11
|
+
teardown() {
|
12
|
+
rm -rf $SCRATCH
|
13
|
+
}
|
14
|
+
|
15
|
+
@test "cucumber-queue succeeds when all features pass" {
|
16
|
+
run bundle exec cucumber-queue test/samples/features --require test/samples/features/step_definitions
|
17
|
+
assert_status 0
|
18
|
+
assert_output_contains "Starting test-queue master"
|
19
|
+
}
|
20
|
+
|
21
|
+
@test "cucumber-queue fails when a feature fails" {
|
22
|
+
export FAIL=1
|
23
|
+
run bundle exec cucumber-queue test/samples/features --require test/samples/features/step_definitions
|
24
|
+
assert_status 2
|
25
|
+
assert_output_contains "Starting test-queue master"
|
26
|
+
assert_output_contains "cucumber test/samples/features/bad.feature:2 # Scenario: failure"
|
27
|
+
assert_output_contains "cucumber test/samples/features/sample2.feature:26 # Scenario: failure"
|
28
|
+
}
|
29
|
+
|
30
|
+
@test "cucumber-queue fails when given a missing feature" {
|
31
|
+
run bundle exec cucumber-queue test/samples/does_not_exist.feature --require test/samples/features/step_definitions
|
32
|
+
assert_status 1
|
33
|
+
assert_output_contains "Aborting: Discovering suites failed."
|
34
|
+
}
|
35
|
+
|
36
|
+
@test "cucumber-queue fails when given a malformed feature" {
|
37
|
+
[ -f README.md ]
|
38
|
+
run bundle exec cucumber-queue README.md --require test/samples/features/step_definitions
|
39
|
+
|
40
|
+
# Cucumber 1 and 2 fail in different ways.
|
41
|
+
refute_status 0
|
42
|
+
assert_output_matches 'Aborting: Discovering suites failed\.|README\.md: Parser errors:'
|
43
|
+
}
|
44
|
+
|
45
|
+
@test "cucumber-queue handles test file being deleted" {
|
46
|
+
cp test/samples/features/*.feature $SCRATCH
|
47
|
+
|
48
|
+
run bundle exec cucumber-queue $SCRATCH --require test/samples/features/step_definitions
|
49
|
+
assert_status 0
|
50
|
+
assert_output_matches "Feature: Foobar$"
|
51
|
+
|
52
|
+
rm $SCRATCH/sample.feature
|
53
|
+
|
54
|
+
run bundle exec cucumber-queue $SCRATCH --require test/samples/features/step_definitions
|
55
|
+
assert_status 0
|
56
|
+
refute_output_matches "Feature: Foobar$"
|
57
|
+
}
|
data/test/minitest4.bats
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
load "testlib"
|
2
|
+
|
3
|
+
setup() {
|
4
|
+
require_gem "minitest" ">= 4.0"
|
5
|
+
}
|
6
|
+
|
7
|
+
@test "minitest-queue succeeds when all tests pass" {
|
8
|
+
run bundle exec minitest-queue ./test/samples/*_minitest4.rb
|
9
|
+
assert_status 0
|
10
|
+
assert_output_contains "Starting test-queue master"
|
11
|
+
}
|
12
|
+
|
13
|
+
@test "minitest-queue fails when a test fails" {
|
14
|
+
export FAIL=1
|
15
|
+
run bundle exec minitest-queue ./test/samples/*_minitest4.rb
|
16
|
+
assert_status 1
|
17
|
+
assert_output_contains "Starting test-queue master"
|
18
|
+
assert_output_contains "1) Failure:"
|
19
|
+
assert_output_contains "MiniTestFailure#test_fail"
|
20
|
+
}
|
21
|
+
|
22
|
+
@test "minitest-queue succeeds when all specs pass" {
|
23
|
+
run bundle exec minitest-queue ./test/samples/*_minispec.rb
|
24
|
+
assert_status 0
|
25
|
+
assert_output_contains "Starting test-queue master"
|
26
|
+
}
|
27
|
+
|
28
|
+
@test "minitest-queue fails when a spec fails" {
|
29
|
+
export FAIL=1
|
30
|
+
run bundle exec minitest-queue ./test/samples/*_minispec.rb
|
31
|
+
assert_status 1
|
32
|
+
assert_output_contains "1) Failure:"
|
33
|
+
assert_output_contains "Meme::when asked about blending possibilities#test_0002_fails"
|
34
|
+
}
|
data/test/minitest5.bats
ADDED
@@ -0,0 +1,194 @@
|
|
1
|
+
load "testlib"
|
2
|
+
|
3
|
+
SCRATCH=tmp/minitest5-tests
|
4
|
+
|
5
|
+
setup() {
|
6
|
+
require_gem "minitest" ">= 5.0"
|
7
|
+
rm -rf $SCRATCH
|
8
|
+
mkdir -p $SCRATCH
|
9
|
+
}
|
10
|
+
|
11
|
+
teardown() {
|
12
|
+
rm -rf $SCRATCH
|
13
|
+
}
|
14
|
+
|
15
|
+
@test "minitest-queue (minitest5) succeeds when all tests pass" {
|
16
|
+
run bundle exec minitest-queue ./test/samples/*_minitest5.rb
|
17
|
+
assert_status 0
|
18
|
+
assert_output_contains "Starting test-queue master"
|
19
|
+
}
|
20
|
+
|
21
|
+
@test "minitest-queue (minitest5) fails when a test fails" {
|
22
|
+
export FAIL=1
|
23
|
+
run bundle exec minitest-queue ./test/samples/*_minitest5.rb
|
24
|
+
assert_status 1
|
25
|
+
assert_output_contains "Starting test-queue master"
|
26
|
+
assert_output_contains "1) Failure:"
|
27
|
+
assert_output_contains "MiniTestFailure#test_fail"
|
28
|
+
}
|
29
|
+
|
30
|
+
@test "TEST_QUEUE_FORCE whitelists certain tests" {
|
31
|
+
export TEST_QUEUE_WORKERS=1 TEST_QUEUE_FORCE="MiniTestSleep21,MiniTestSleep8"
|
32
|
+
run bundle exec minitest-queue ./test/samples/*_minitest5.rb
|
33
|
+
assert_status 0
|
34
|
+
assert_output_contains "Starting test-queue master"
|
35
|
+
assert_output_contains "MiniTestSleep21"
|
36
|
+
assert_output_contains "MiniTestSleep8"
|
37
|
+
refute_output_contains "MiniTestSleep9"
|
38
|
+
}
|
39
|
+
|
40
|
+
assert_test_queue_force_ordering() {
|
41
|
+
run bundle exec minitest-queue "$@"
|
42
|
+
assert_status 0
|
43
|
+
assert_output_contains "Starting test-queue master"
|
44
|
+
|
45
|
+
# Turn the list of suites that were run into a comma-separated list. Input
|
46
|
+
# looks like:
|
47
|
+
# SuiteName: . <0.001>
|
48
|
+
actual_tests=$(echo "$output" | \
|
49
|
+
egrep '^ .*: \.+ <' | \
|
50
|
+
sed -E -e 's/^ (.*): \.+.*/\1/' | \
|
51
|
+
tr '\n' ',' | \
|
52
|
+
sed -e 's/,$//')
|
53
|
+
assert_equal "$TEST_QUEUE_FORCE" "$actual_tests"
|
54
|
+
}
|
55
|
+
|
56
|
+
@test "TEST_QUEUE_FORCE ensures test ordering" {
|
57
|
+
export TEST_QUEUE_WORKERS=1 TEST_QUEUE_FORCE="Meme::when asked about cheeseburgers,MiniTestEqual"
|
58
|
+
|
59
|
+
# Without stats file
|
60
|
+
rm -f .test_queue_stats
|
61
|
+
assert_test_queue_force_ordering ./test/samples/sample_minitest5.rb ./test/samples/sample_minispec.rb
|
62
|
+
rm -f .test_queue_stats
|
63
|
+
assert_test_queue_force_ordering ./test/samples/sample_minispec.rb ./test/samples/sample_minitest5.rb
|
64
|
+
|
65
|
+
# With stats file
|
66
|
+
assert_test_queue_force_ordering ./test/samples/sample_minitest5.rb ./test/samples/sample_minispec.rb
|
67
|
+
assert_test_queue_force_ordering ./test/samples/sample_minispec.rb ./test/samples/sample_minitest5.rb
|
68
|
+
}
|
69
|
+
|
70
|
+
@test "minitest-queue fails if TEST_QUEUE_FORCE specifies nonexistent tests" {
|
71
|
+
export TEST_QUEUE_WORKERS=1 TEST_QUEUE_FORCE="MiniTestSleep21,DoesNotExist"
|
72
|
+
run bundle exec minitest-queue ./test/samples/*_minitest5.rb
|
73
|
+
assert_status 1
|
74
|
+
assert_output_contains "Failed to discover DoesNotExist specified in TEST_QUEUE_FORCE"
|
75
|
+
}
|
76
|
+
|
77
|
+
@test "multi-master central master succeeds when all tests pass" {
|
78
|
+
export TEST_QUEUE_RELAY_TOKEN=$(date | cksum | cut -d' ' -f1)
|
79
|
+
export SLEEP_AS_RELAY=1
|
80
|
+
TEST_QUEUE_RELAY=0.0.0.0:12345 bundle exec ruby ./test/sleepy_runner.rb ./test/samples/sample_minitest5.rb || true &
|
81
|
+
sleep 0.1
|
82
|
+
TEST_QUEUE_SOCKET=0.0.0.0:12345 run bundle exec ruby ./test/sleepy_runner.rb ./test/samples/sample_minitest5.rb
|
83
|
+
wait
|
84
|
+
|
85
|
+
assert_status 0
|
86
|
+
assert_output_contains "Starting test-queue master"
|
87
|
+
}
|
88
|
+
|
89
|
+
@test "multi-master remote master succeeds when all tests pass" {
|
90
|
+
export TEST_QUEUE_RELAY_TOKEN=$(date | cksum | cut -d' ' -f1)
|
91
|
+
export SLEEP_AS_MASTER=1
|
92
|
+
TEST_QUEUE_SOCKET=0.0.0.0:12345 bundle exec ruby ./test/sleepy_runner.rb ./test/samples/sample_minitest5.rb || true &
|
93
|
+
sleep 0.1
|
94
|
+
TEST_QUEUE_RELAY=0.0.0.0:12345 run bundle exec ruby ./test/sleepy_runner.rb ./test/samples/sample_minitest5.rb
|
95
|
+
wait
|
96
|
+
|
97
|
+
assert_status 0
|
98
|
+
assert_output_contains "Starting test-queue master"
|
99
|
+
}
|
100
|
+
|
101
|
+
@test "multi-master central master fails when a test fails" {
|
102
|
+
export FAIL=1
|
103
|
+
export SLEEP_AS_RELAY=1
|
104
|
+
export TEST_QUEUE_RELAY_TOKEN=$(date | cksum | cut -d' ' -f1)
|
105
|
+
TEST_QUEUE_RELAY=0.0.0.0:12345 bundle exec ruby ./test/sleepy_runner.rb ./test/samples/sample_minitest5.rb || true &
|
106
|
+
sleep 0.1
|
107
|
+
TEST_QUEUE_SOCKET=0.0.0.0:12345 run bundle exec ruby ./test/sleepy_runner.rb ./test/samples/sample_minitest5.rb
|
108
|
+
wait
|
109
|
+
|
110
|
+
assert_status 1
|
111
|
+
assert_output_contains "Starting test-queue master"
|
112
|
+
assert_output_contains "1) Failure:"
|
113
|
+
assert_output_contains "MiniTestFailure#test_fail"
|
114
|
+
}
|
115
|
+
|
116
|
+
@test "multi-master remote master fails when a test fails" {
|
117
|
+
export FAIL=1
|
118
|
+
export SLEEP_AS_MASTER=1
|
119
|
+
export TEST_QUEUE_RELAY_TOKEN=$(date | cksum | cut -d' ' -f1)
|
120
|
+
TEST_QUEUE_SOCKET=0.0.0.0:12345 bundle exec ruby ./test/sleepy_runner.rb ./test/samples/sample_minitest5.rb || true &
|
121
|
+
sleep 0.1
|
122
|
+
TEST_QUEUE_RELAY=0.0.0.0:12345 run bundle exec ruby ./test/sleepy_runner.rb ./test/samples/sample_minitest5.rb
|
123
|
+
wait
|
124
|
+
|
125
|
+
assert_status 1
|
126
|
+
assert_output_contains "Starting test-queue master"
|
127
|
+
assert_output_contains "1) Failure:"
|
128
|
+
assert_output_contains "MiniTestFailure#test_fail"
|
129
|
+
}
|
130
|
+
|
131
|
+
@test "multi-master central master prints out remote master messages" {
|
132
|
+
export TEST_QUEUE_RELAY_TOKEN=$(date | cksum | cut -d' ' -f1)
|
133
|
+
TEST_QUEUE_RELAY=0.0.0.0:12345 TEST_QUEUE_REMOTE_MASTER_MESSAGE="hello from remote master" bundle exec minitest-queue ./test/samples/sample_minitest5.rb &
|
134
|
+
TEST_QUEUE_SOCKET=0.0.0.0:12345 run bundle exec minitest-queue ./test/samples/sample_minitest5.rb
|
135
|
+
wait
|
136
|
+
|
137
|
+
assert_status 0
|
138
|
+
assert_output_contains "hello from remote master"
|
139
|
+
}
|
140
|
+
|
141
|
+
@test "recovers from child processes dying in an unorderly way" {
|
142
|
+
export KILL=1
|
143
|
+
run bundle exec minitest-queue ./test/samples/sample_minitest5.rb
|
144
|
+
assert_status 1
|
145
|
+
assert_output_contains "SIGKILL (signal 9)"
|
146
|
+
}
|
147
|
+
|
148
|
+
@test "minitest-queue fails when TEST_QUEUE_WORKERS is <= 0" {
|
149
|
+
export TEST_QUEUE_WORKERS=0
|
150
|
+
run bundle exec minitest-queue ./test/samples/sample_minitest5.rb
|
151
|
+
assert_status 1
|
152
|
+
assert_output_contains "Worker count (0) must be greater than 0"
|
153
|
+
}
|
154
|
+
|
155
|
+
@test "minitest-queue fails when given a missing test file" {
|
156
|
+
run bundle exec minitest-queue ./test/samples/does_not_exist.rb
|
157
|
+
assert_status 1
|
158
|
+
assert_output_contains "Aborting: Discovering suites failed"
|
159
|
+
}
|
160
|
+
|
161
|
+
@test "minitest-queue fails when given a malformed test file" {
|
162
|
+
[ -f README.md ]
|
163
|
+
run bundle exec minitest-queue README.md
|
164
|
+
assert_status 1
|
165
|
+
assert_output_contains "Aborting: Discovering suites failed"
|
166
|
+
}
|
167
|
+
|
168
|
+
@test "minitest-queue handles test file being deleted" {
|
169
|
+
cp test/samples/sample_mini{test5,spec}.rb $SCRATCH
|
170
|
+
|
171
|
+
run bundle exec minitest-queue $SCRATCH/*
|
172
|
+
assert_status 0
|
173
|
+
assert_output_contains "Meme::when asked about blending possibilities"
|
174
|
+
|
175
|
+
rm $SCRATCH/sample_minispec.rb
|
176
|
+
|
177
|
+
run bundle exec minitest-queue $SCRATCH/*
|
178
|
+
assert_status 0
|
179
|
+
refute_output_contains "Meme::when asked about blending possibilities"
|
180
|
+
}
|
181
|
+
|
182
|
+
@test "minitest-queue handles suites changing inside a file" {
|
183
|
+
cp test/samples/sample_minispec.rb $SCRATCH
|
184
|
+
|
185
|
+
run bundle exec minitest-queue $SCRATCH/sample_minispec.rb
|
186
|
+
assert_status 0
|
187
|
+
assert_output_contains "Meme::when asked about blending possibilities"
|
188
|
+
|
189
|
+
sed -i'' -e 's/Meme/Meme2/g' $SCRATCH/sample_minispec.rb
|
190
|
+
|
191
|
+
run bundle exec minitest-queue $SCRATCH/sample_minispec.rb
|
192
|
+
assert_status 0
|
193
|
+
assert_output_contains "Meme2::when asked about blending possibilities"
|
194
|
+
}
|
data/test/rspec.bats
ADDED
@@ -0,0 +1,46 @@
|
|
1
|
+
load "testlib"
|
2
|
+
|
3
|
+
setup() {
|
4
|
+
require_gem "rspec" ">= 2.0"
|
5
|
+
}
|
6
|
+
|
7
|
+
@test "rspec-queue succeeds when all specs pass" {
|
8
|
+
run bundle exec rspec-queue ./test/samples/sample_spec.rb
|
9
|
+
assert_status 0
|
10
|
+
assert_output_contains "Starting test-queue master"
|
11
|
+
}
|
12
|
+
|
13
|
+
@test "rspec-queue fails when a spec fails" {
|
14
|
+
export FAIL=1
|
15
|
+
run bundle exec rspec-queue ./test/samples/sample_spec.rb
|
16
|
+
assert_status 1
|
17
|
+
assert_output_contains "1) RSpecFailure fails"
|
18
|
+
assert_output_contains "Failure/Error: expect(:foo).to eq :bar"
|
19
|
+
}
|
20
|
+
|
21
|
+
@test "TEST_QUEUE_SPLIT_GROUPS splits splittable groups" {
|
22
|
+
export TEST_QUEUE_SPLIT_GROUPS=true
|
23
|
+
run bundle exec rspec-queue ./test/samples/sample_split_spec.rb
|
24
|
+
assert_status 0
|
25
|
+
|
26
|
+
assert_output_matches '\[ 1\] +1 example, 0 failures'
|
27
|
+
assert_output_matches '\[ 2\] +1 example, 0 failures'
|
28
|
+
}
|
29
|
+
|
30
|
+
@test "TEST_QUEUE_SPLIT_GROUPS does not split unsplittable groups" {
|
31
|
+
export TEST_QUEUE_SPLIT_GROUPS=true
|
32
|
+
export NOSPLIT=1
|
33
|
+
run bundle exec rspec-queue ./test/samples/sample_split_spec.rb
|
34
|
+
assert_status 0
|
35
|
+
|
36
|
+
assert_output_contains "2 examples, 0 failures"
|
37
|
+
assert_output_contains "0 examples, 0 failures"
|
38
|
+
}
|
39
|
+
|
40
|
+
@test "rspec-queue supports shared example groups" {
|
41
|
+
run bundle exec rspec-queue ./test/samples/sample_use_shared_example1_spec.rb \
|
42
|
+
./test/samples/sample_use_shared_example2_spec.rb
|
43
|
+
assert_status 0
|
44
|
+
|
45
|
+
}
|
46
|
+
|
@@ -0,0 +1,25 @@
|
|
1
|
+
Feature: Foobar
|
2
|
+
Scenario: Bar
|
3
|
+
Given a
|
4
|
+
When b
|
5
|
+
Then c
|
6
|
+
Scenario: Baz
|
7
|
+
Given a
|
8
|
+
When b
|
9
|
+
Then c
|
10
|
+
Scenario: Bam
|
11
|
+
Given a
|
12
|
+
When b
|
13
|
+
Then c
|
14
|
+
Scenario: Car
|
15
|
+
Given a
|
16
|
+
When b
|
17
|
+
Then c
|
18
|
+
Scenario: Caz
|
19
|
+
Given a
|
20
|
+
When b
|
21
|
+
Then c
|
22
|
+
Scenario: Cam
|
23
|
+
Given a
|
24
|
+
When b
|
25
|
+
Then c
|
@@ -0,0 +1,29 @@
|
|
1
|
+
Feature: Foobar2
|
2
|
+
Scenario: Bar
|
3
|
+
Given a
|
4
|
+
When b
|
5
|
+
Then c
|
6
|
+
Scenario: Baz
|
7
|
+
Given a
|
8
|
+
When b
|
9
|
+
Then c
|
10
|
+
Scenario: Bam
|
11
|
+
Given a
|
12
|
+
When b
|
13
|
+
Then c
|
14
|
+
Scenario: Car
|
15
|
+
Given a
|
16
|
+
When b
|
17
|
+
Then c
|
18
|
+
Scenario: Caz
|
19
|
+
Given a
|
20
|
+
When b
|
21
|
+
Then c
|
22
|
+
Scenario: Cam
|
23
|
+
Given a
|
24
|
+
When b
|
25
|
+
Then c
|
26
|
+
Scenario: failure
|
27
|
+
Given a
|
28
|
+
When bad
|
29
|
+
Then c
|
@@ -0,0 +1,37 @@
|
|
1
|
+
require 'minitest/spec'
|
2
|
+
|
3
|
+
class Meme
|
4
|
+
def i_can_has_cheezburger?
|
5
|
+
"OHAI!"
|
6
|
+
end
|
7
|
+
|
8
|
+
def will_it_blend?
|
9
|
+
"YES!"
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
describe Meme do
|
14
|
+
before do
|
15
|
+
@meme = Meme.new
|
16
|
+
end
|
17
|
+
|
18
|
+
describe "when asked about cheeseburgers" do
|
19
|
+
it "must respond positively" do
|
20
|
+
sleep 0.1
|
21
|
+
@meme.i_can_has_cheezburger?.must_equal "OHAI!"
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
describe "when asked about blending possibilities" do
|
26
|
+
it "won't say no" do
|
27
|
+
sleep 0.1
|
28
|
+
@meme.will_it_blend?.wont_match /^no/i
|
29
|
+
end
|
30
|
+
|
31
|
+
if ENV["FAIL"]
|
32
|
+
it "fails" do
|
33
|
+
@meme.will_it_blend?.must_equal "NO!"
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
require 'minitest/unit'
|
2
|
+
|
3
|
+
class MiniTestEqual < MiniTest::Unit::TestCase
|
4
|
+
def test_equal
|
5
|
+
assert_equal 1, 1
|
6
|
+
end
|
7
|
+
end
|
8
|
+
|
9
|
+
30.times do |i|
|
10
|
+
Object.const_set("MiniTestSleep#{i}", Class.new(MiniTest::Unit::TestCase) do
|
11
|
+
define_method('test_sleep') do
|
12
|
+
start = Time.now
|
13
|
+
sleep(0.25)
|
14
|
+
assert_in_delta Time.now-start, 0.25, 0.02
|
15
|
+
end
|
16
|
+
end)
|
17
|
+
end
|
18
|
+
|
19
|
+
if ENV["FAIL"]
|
20
|
+
class MiniTestFailure < MiniTest::Unit::TestCase
|
21
|
+
def test_fail
|
22
|
+
assert_equal 0, 1
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
require 'minitest/autorun'
|
2
|
+
|
3
|
+
class MiniTestEqual < MiniTest::Test
|
4
|
+
def test_equal
|
5
|
+
assert_equal 1, 1
|
6
|
+
end
|
7
|
+
end
|
8
|
+
|
9
|
+
30.times do |i|
|
10
|
+
Object.const_set("MiniTestSleep#{i}", Class.new(MiniTest::Test) do
|
11
|
+
define_method('test_sleep') do
|
12
|
+
start = Time.now
|
13
|
+
sleep(0.25)
|
14
|
+
assert_in_delta Time.now-start, 0.25, 0.02
|
15
|
+
end
|
16
|
+
end)
|
17
|
+
end
|
18
|
+
|
19
|
+
if ENV["FAIL"]
|
20
|
+
class MiniTestFailure < MiniTest::Test
|
21
|
+
def test_fail
|
22
|
+
assert_equal 0, 1
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
if ENV["KILL"]
|
28
|
+
class MiniTestKilledFailure < MiniTest::Test
|
29
|
+
def test_kill
|
30
|
+
Process.kill(9, $$)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
require_relative 'sample_shared_examples_for_spec'
|