@@ -571,7 +571,7 @@ def test_run_in_parallel_with_processes
571571 assert_no_match "create_table(:users)" , output
572572 end
573573
574- def test_avoid_parallelizing_when_number_of_tests_is_below_threshold
574+ def test_parallelization_is_disabled_when_number_of_tests_is_below_threshold
575575 exercise_parallelization_regardless_of_machine_core_count ( with : :processes , threshold : 100 )
576576
577577 file_name = create_parallel_processes_test_file
@@ -590,72 +590,24 @@ def test_avoid_parallelizing_when_number_of_tests_is_below_threshold
590590 assert_no_match %r{Running \d + tests in parallel using \d + processes} , output
591591 end
592592
593- def test_parallel_is_disabled_when_single_file_is_run
594- exercise_parallelization_regardless_of_machine_core_count ( with : :processes , force : false )
595-
596- file_name = app_file "test/unit/parallel_test.rb" , <<-RUBY
597- require "test_helper"
598-
599- class ParallelTest < ActiveSupport::TestCase
600- def test_verify_test_order
601- puts "Test parallelization disabled: \# {ActiveSupport.test_parallelization_disabled}"
602- end
603- end
604- RUBY
605-
606- output = run_test_command ( file_name )
607-
608- assert_match "Test parallelization disabled: true" , output
609- end
610-
611- def test_parallel_is_enabled_when_multiple_files_are_run
612- exercise_parallelization_regardless_of_machine_core_count ( with : :processes , force : false )
613-
614- file_1 = app_file "test/unit/parallel_test_first.rb" , <<-RUBY
615- require "test_helper"
616-
617- class ParallelTestFirst < ActiveSupport::TestCase
618- def test_verify_test_order
619- puts "Test parallelization disabled (file 1): \# {ActiveSupport.test_parallelization_disabled}"
620- end
621- end
622- RUBY
623-
624- file_2 = app_file "test/unit/parallel_test_second.rb" , <<-RUBY
625- require "test_helper"
626-
627- class ParallelTestSecond < ActiveSupport::TestCase
628- def test_verify_test_order
629- puts "Test parallelization disabled (file 2): \# {ActiveSupport.test_parallelization_disabled}"
630- end
631- end
632- RUBY
633-
634- output = run_test_command ( [ file_1 , file_2 ] . join ( " " ) )
635-
636- assert_match "Test parallelization disabled (file 1): false" , output
637- assert_match "Test parallelization disabled (file 2): false" , output
638- end
639-
640593 def test_parallel_is_enabled_when_PARALLEL_WORKERS_is_set
641594 @old = ENV [ "PARALLEL_WORKERS" ]
642595 ENV [ "PARALLEL_WORKERS" ] = "5"
643596
644- exercise_parallelization_regardless_of_machine_core_count ( with : :processes , force : false )
597+ exercise_parallelization_regardless_of_machine_core_count ( with : :processes , threshold : 100 )
645598
646599 file_name = app_file "test/unit/parallel_test.rb" , <<-RUBY
647600 require "test_helper"
648601
649602 class ParallelTest < ActiveSupport::TestCase
650603 def test_verify_test_order
651- puts "Test parallelization disabled: \# {ActiveSupport.test_parallelization_disabled}"
652604 end
653605 end
654606 RUBY
655607
656608 output = run_test_command ( file_name )
657609
658- assert_match "Test parallelization disabled: false" , output
610+ assert_match %r{Running \d + tests in parallel using \d + processes} , output
659611 ensure
660612 ENV [ "PARALLEL_WORKERS" ] = @old
661613 end
@@ -1160,18 +1112,13 @@ class ParallelTest < ActiveSupport::TestCase
11601112 RUBY
11611113 end
11621114
1163- def exercise_parallelization_regardless_of_machine_core_count ( with :, force : true , threshold : 0 )
1164- file_content = ERB . new ( <<-ERB , trim_mode : "-" ) . result_with_hash ( with : with . to_s , force : force )
1115+ def exercise_parallelization_regardless_of_machine_core_count ( with :, threshold : 0 )
1116+ file_content = ERB . new ( <<-ERB , trim_mode : "-" ) . result_with_hash ( with : with . to_s )
11651117 ENV["RAILS_ENV"] ||= "test"
11661118 require_relative "../config/environment"
11671119 require "rails/test_help"
11681120
11691121 class ActiveSupport::TestCase
1170- <%- if force -%>
1171- # Force parallelization, even with single files
1172- ActiveSupport.test_parallelization_disabled = false
1173- <%- end -%>
1174-
11751122 # Run tests in parallel with specified workers
11761123 parallelize(workers: 2, with: :<%= with %> , threshold: #{ threshold } )
11771124
0 commit comments