@@ -728,27 +728,18 @@ def test_run_in_parallel_with_processes
728
728
end
729
729
RUBY
730
730
731
- output = run_test_command ( file_name )
731
+ output = run_test_command ( file_name , allow_failure : false )
732
732
733
- assert_match ( /Finished in.*2 runs, 2 assertions/m , output )
733
+ assert_match ( /Finished in.*2 runs, 2 assertions, 0 failures, 0 errors, 0 skips /m , output )
734
734
assert_match %r{Running \d + tests in parallel using \d + processes} , output
735
735
assert_no_match "create_table(:users)" , output
736
736
end
737
737
738
738
def test_parallelization_is_disabled_when_number_of_tests_is_below_threshold
739
739
exercise_parallelization_regardless_of_machine_core_count ( with : :processes , threshold : 100 )
740
740
741
- file_name = create_parallel_processes_test_file
742
-
743
- app_file "db/schema.rb" , <<-RUBY
744
- ActiveRecord::Schema.define(version: 1) do
745
- create_table :users do |t|
746
- t.string :name
747
- end
748
- end
749
- RUBY
750
-
751
- output = run_test_command ( file_name )
741
+ file_name = create_parallel_blank_test_file
742
+ output = run_test_command ( file_name , allow_failure : false )
752
743
753
744
assert_match %r{Running \d + tests in a single process} , output
754
745
assert_no_match %r{Running \d + tests in parallel using \d + processes} , output
@@ -760,18 +751,25 @@ def test_parallel_is_enabled_when_PARALLEL_WORKERS_is_set
760
751
761
752
exercise_parallelization_regardless_of_machine_core_count ( with : :processes , threshold : 100 )
762
753
763
- file_name = app_file "test/unit/parallel_test.rb" , <<-RUBY
764
- require "test_helper"
754
+ file_name = create_parallel_blank_test_file
755
+ output = run_test_command ( file_name , allow_failure : false )
765
756
766
- class ParallelTest < ActiveSupport::TestCase
767
- def test_verify_test_order
768
- end
769
- end
770
- RUBY
757
+ assert_match %r{Running \d + tests in parallel using 5 processes} , output
758
+ ensure
759
+ ENV [ "PARALLEL_WORKERS" ] = @old
760
+ end
771
761
772
- output = run_test_command ( file_name )
762
+ def test_parallel_is_disabled_when_PARALLEL_WORKERS_is_set_to_1
763
+ @old = ENV [ "PARALLEL_WORKERS" ]
764
+ ENV [ "PARALLEL_WORKERS" ] = "1"
773
765
774
- assert_match %r{Running \d + tests in parallel using \d + processes} , output
766
+ exercise_parallelization_regardless_of_machine_core_count ( with : :processes , threshold : 100 )
767
+
768
+ file_name = create_parallel_blank_test_file
769
+ output = run_test_command ( file_name , allow_failure : false )
770
+
771
+ assert_no_match %r{Running \d + tests in a single process} , output
772
+ assert_no_match %r{Running \d + tests in parallel using \d + processes} , output
775
773
ensure
776
774
ENV [ "PARALLEL_WORKERS" ] = @old
777
775
end
@@ -807,9 +805,9 @@ def test_run_in_parallel_with_threads
807
805
end
808
806
RUBY
809
807
810
- output = run_test_command ( file_name )
808
+ output = run_test_command ( file_name , allow_failure : false )
811
809
812
- assert_match ( /Finished in.*2 runs, 2 assertions/m , output )
810
+ assert_match ( /Finished in.*2 runs, 2 assertions, 0 failures, 0 errors, 0 skips /m , output )
813
811
assert_no_match "create_table(:users)" , output
814
812
end
815
813
@@ -1226,6 +1224,16 @@ def test_truth
1226
1224
RUBY
1227
1225
end
1228
1226
1227
+ def create_parallel_blank_test_file
1228
+ app_file "test/unit/parallel_test.rb" , <<-RUBY
1229
+ require "test_helper"
1230
+ class ParallelTest < ActiveSupport::TestCase
1231
+ def test_verify_test_order
1232
+ end
1233
+ end
1234
+ RUBY
1235
+ end
1236
+
1229
1237
def create_parallel_processes_test_file
1230
1238
app_file "test/models/parallel_test.rb" , <<-RUBY
1231
1239
require "test_helper"
0 commit comments