-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- end-to-end tests - scheduling tests Part of #1
- Loading branch information
Showing
30 changed files
with
422 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
*.gem | ||
dump.rdb | ||
Gemfile.lock |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
require "rake/testtask" | ||
|
||
Rake::TestTask.new do |t| | ||
t.libs << "test" | ||
t.test_files = FileList['test/test*.rb'] | ||
t.verbose = true | ||
end | ||
|
||
task default: :test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Sample RSpec suites, used as fixtures in the tests. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
RSpec.describe do | ||
it "I should not be executed!" do | ||
expect(1).to eq 2 | ||
end | ||
end |
13 changes: 13 additions & 0 deletions
13
test/sample_suites/different_spec_path/mytests/qwe_spec.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
RSpec.describe do | ||
context "foo" do | ||
describe "abc" do | ||
it { expect(false).to be false } | ||
end | ||
end | ||
|
||
context "bar" do | ||
describe "dfg" do | ||
it { expect(true).to be true } | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
RSpec.describe do | ||
it { expect(false).to be false } | ||
it { expect(1).to be 2 } | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
RSpec.describe do | ||
it { expect(true).to be true } | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
RSpec.describe do | ||
it do | ||
$tries ||= 0 | ||
$tries += 1 | ||
|
||
expect($tries).to eq 3 | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
RSpec.describe do | ||
it { expect(true).to be true } | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
RSpec.describe IDONTEXISTZ do | ||
it { expect(true).to be true } | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
RSpec.describe do | ||
it { expect(true).to be true } | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
RSpec.describe do | ||
it do | ||
expect(true).to be true | ||
end | ||
|
||
it do | ||
expect(true).to be true | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
RSpec.describe "slow spec file (will be split)" do | ||
it do | ||
sleep 0.1 | ||
expect(true).to be true | ||
end | ||
|
||
context "foo" do | ||
it do | ||
sleep 0.2 | ||
expect(true).to be true | ||
end | ||
end | ||
end |
5 changes: 5 additions & 0 deletions
5
test/sample_suites/scheduling_untimed/spec/bar/untimed_spec.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
RSpec.describe do | ||
it do | ||
expect(true).to be true | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
RSpec.describe do | ||
it do | ||
sleep 0.15 | ||
expect(true).to be true | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
RSpec.describe do | ||
it do | ||
expect(true).to be true | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
RSpec.describe do | ||
it do | ||
sleep 0.1 | ||
expect(true).to be true | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
RSpec.describe do | ||
it do | ||
sleep 0.05 | ||
expect(true).to be true | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
RSpec.describe do | ||
it { expect(true).to be true } | ||
it { expect(true).to be true } | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
RSpec.describe do | ||
it do | ||
sleep 0.6 | ||
expect(true).to be true | ||
end | ||
|
||
context "foo" do | ||
it do | ||
sleep 0.6 | ||
expect(true).to be true | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
RSpec.describe do | ||
it do | ||
sleep 0.1 | ||
expect(true).to be true | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
RSpec.describe do | ||
it do | ||
sleep 0.2 | ||
expect(true).to be true | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
RSpec.describe do | ||
it do | ||
sleep 0.3 | ||
expect(true).to be true | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
RSpec.describe do | ||
it do | ||
expect(true).to be true | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
RSpec.describe do | ||
it do | ||
sleep 0.4 | ||
expect(true).to be true | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
require "test_helpers" | ||
|
||
class TestEndToEnd < RSpecQTest | ||
def test_suite_with_legit_failures | ||
queue = exec_build("failing_suite") | ||
|
||
refute queue.build_successful? | ||
|
||
assert_processed_jobs [ | ||
"./spec/foo_spec.rb", | ||
"./spec/bar_spec.rb", | ||
"./spec/bar_spec.rb[1:2]", | ||
], queue | ||
|
||
assert_equal 3+RSpecQ::MAX_REQUEUES, queue.example_count | ||
|
||
assert_equal({ "./spec/bar_spec.rb[1:2]" => "3" }, queue.requeued_jobs) | ||
end | ||
|
||
def test_passing_suite | ||
queue = exec_build("passing_suite") | ||
|
||
assert queue.build_successful? | ||
assert_build_not_flakey(queue) | ||
assert_equal 1, queue.example_count | ||
assert_equal ["./spec/foo_spec.rb"], queue.processed_jobs | ||
end | ||
|
||
def test_flakey_suite | ||
queue = exec_build("flakey_suite") | ||
|
||
assert queue.build_successful? | ||
assert_processed_jobs [ | ||
"./spec/foo_spec.rb", | ||
"./spec/foo_spec.rb[1:1]", | ||
], queue | ||
|
||
assert_equal({ "./spec/foo_spec.rb[1:1]" => "2" }, queue.requeued_jobs) | ||
end | ||
|
||
def test_scheduling_by_file_and_custom_spec_path | ||
queue = exec_build("different_spec_path", "mytests/qwe_spec.rb") | ||
|
||
assert queue.build_successful? | ||
assert_build_not_flakey(queue) | ||
assert_equal 2, queue.example_count | ||
assert_processed_jobs ["./mytests/qwe_spec.rb"], queue | ||
end | ||
|
||
def test_non_example_error | ||
queue = exec_build("non_example_error") | ||
|
||
refute queue.build_successful? | ||
assert_build_not_flakey(queue) | ||
assert_equal 1, queue.example_count | ||
assert_processed_jobs ["./spec/foo_spec.rb", "./spec/bar_spec.rb"], queue | ||
assert_equal ["./spec/foo_spec.rb"], queue.non_example_errors.keys | ||
end | ||
|
||
def test_timings_update | ||
queue = exec_build("timings", "--update-timings") | ||
|
||
assert queue.build_successful? | ||
|
||
assert_equal [ | ||
"./spec/very_fast_spec.rb", | ||
"./spec/fast_spec.rb", | ||
"./spec/medium_spec.rb", | ||
"./spec/slow_spec.rb", | ||
"./spec/very_slow_spec.rb", | ||
], queue.timings.sort_by { |k,v| v }.map(&:first) | ||
end | ||
|
||
def test_timings_no_update | ||
queue = exec_build("timings") | ||
|
||
assert queue.build_successful? | ||
assert_empty queue.timings | ||
end | ||
|
||
def test_spec_file_splitting | ||
queue = exec_build( "spec_file_splitting", "--update-timings") | ||
assert queue.build_successful? | ||
refute_empty queue.timings | ||
|
||
queue = exec_build( "spec_file_splitting", "--file-split-threshold 1") | ||
|
||
assert queue.build_successful? | ||
refute_empty queue.timings | ||
assert_processed_jobs([ | ||
"./spec/slow_spec.rb[1:2:1]", | ||
"./spec/slow_spec.rb[1:1]", | ||
"./spec/fast_spec.rb", | ||
], queue) | ||
end | ||
end |
Oops, something went wrong.