aboutsummaryrefslogtreecommitdiffstats
path: root/tool
diff options
context:
space:
mode:
authorYusuke Endoh <mame@ruby-lang.org>2023-11-15 17:52:46 +0900
committerYusuke Endoh <mame@ruby-lang.org>2023-11-15 19:27:10 +0900
commit5bf75c20a2098e626d0dd65708a35c46039c5310 (patch)
treebbe0796b786013df3725b44ec3409965f8f3eb94 /tool
parent960a031a06e4401589cfa29673e27b0bf2895f6d (diff)
downloadruby-5bf75c20a2098e626d0dd65708a35c46039c5310.tar.gz
Refactor the settings of test-all out
test/runner.rb and tool/lib/test/unit/parallel.rb must use the same settings. However, some settings were copied and pasted, while some were added only to test/runner.rb. This changeset creates tool/test/init.rb for all settings of test-unit, which is loaded not only by test/runner.rb but also tool/lib/test/unit/parallel.rb. Background: the GEM_HOME environment variable was removed in test/runner.rb, which prohibit `require "rake"` (note that rake is a bundled gem). However the parallel mode didn't refrect this setting, i.e., `require "rake"` was allowed. This leads to an inconsistency, which actually affected a test test defines s test class *only when* `require "rake"` is successful. (test/rubygems/test_gem_package_task.rb) https://github.com/ruby/ruby/actions/runs/6807729617/job/18511055636#step:8:1714 ``` /home/runner/work/ruby/ruby/src/tool/lib/test/unit.rb:729:in `const_get': uninitialized constant TestGemPackageTask (NameError) suites.map! {|r| ::Object.const_get(r[:testcase])} ^^^^^^^^^^ ```
Diffstat (limited to 'tool')
-rw-r--r--tool/lib/test/unit/parallel.rb10
-rw-r--r--tool/test/init.rb18
-rw-r--r--tool/test/runner.rb11
3 files changed, 21 insertions, 18 deletions
diff --git a/tool/lib/test/unit/parallel.rb b/tool/lib/test/unit/parallel.rb
index 407e3fa1a2..f2244ec20a 100644
--- a/tool/lib/test/unit/parallel.rb
+++ b/tool/lib/test/unit/parallel.rb
@@ -1,12 +1,6 @@
# frozen_string_literal: true
-$LOAD_PATH.unshift "#{__dir__}/../.."
-require_relative '../../test/unit'
-
-require_relative '../../profile_test_all' if ENV.key?('RUBY_TEST_ALL_PROFILE')
-require_relative '../../tracepointchecker'
-require_relative '../../zombie_hunter'
-require_relative '../../iseq_loader_checker'
-require_relative '../../gc_checker'
+
+require_relative "../../../test/init"
module Test
module Unit
diff --git a/tool/test/init.rb b/tool/test/init.rb
new file mode 100644
index 0000000000..3a1143d01d
--- /dev/null
+++ b/tool/test/init.rb
@@ -0,0 +1,18 @@
+# This file includes the settings for "make test-all".
+# Note that this file is loaded not only by test/runner.rb but also by tool/lib/test/unit/parallel.rb.
+
+ENV["GEM_SKIP"] = ENV["GEM_HOME"] = ENV["GEM_PATH"] = "".freeze
+ENV.delete("RUBY_CODESIGN")
+
+Warning[:experimental] = false
+
+$LOAD_PATH.unshift File.expand_path("../lib", __dir__)
+
+require 'test/unit'
+
+require "profile_test_all" if ENV.key?('RUBY_TEST_ALL_PROFILE')
+require "tracepointchecker"
+require "zombie_hunter"
+require "iseq_loader_checker"
+require "gc_checker"
+require_relative "../test-coverage.rb" if ENV.key?('COVERAGE')
diff --git a/tool/test/runner.rb b/tool/test/runner.rb
index 335fe65fd4..9001fc2d06 100644
--- a/tool/test/runner.rb
+++ b/tool/test/runner.rb
@@ -1,16 +1,7 @@
# frozen_string_literal: true
require 'rbconfig'
-$LOAD_PATH.unshift File.expand_path("../lib", __dir__)
-
-require 'test/unit'
-
-require "profile_test_all" if ENV.key?('RUBY_TEST_ALL_PROFILE')
-require "tracepointchecker"
-require "zombie_hunter"
-require "iseq_loader_checker"
-require "gc_checker"
-require_relative "../test-coverage.rb" if ENV.key?('COVERAGE')
+require_relative "init"
case $0
when __FILE__