diff --git a/common.mk b/common.mk index 63312b5fb1..da81afa418 100644 --- a/common.mk +++ b/common.mk @@ -754,12 +754,12 @@ yes-test-knownbug: prog PHONY test-testframework: $(TEST_RUNNABLE)-test-testframework yes-test-testframework: prog PHONY - $(gnumake_recursive)$(Q)$(exec) $(RUNRUBY) "$(TOOL_TESTSDIR)/runner.rb" --ruby="$(RUNRUBY)" --basedir=$(TOOL_TESTSDIR) $(TESTOPTS) testunit minitest + $(gnumake_recursive)$(Q)$(exec) $(RUNRUBY) "$(TOOL_TESTSDIR)/runner.rb" --test-target-dir="$(TOOL_TESTSDIR)" -- --ruby="$(RUNRUBY)" $(TESTOPTS) testunit minitest no-test-testframework: PHONY test-tool: $(TEST_RUNNABLE)-test-tool yes-test-tool: prog PHONY - $(gnumake_recursive)$(Q)$(exec) $(RUNRUBY) "$(TOOL_TESTSDIR)/runner.rb" --ruby="$(RUNRUBY)" --basedir=$(TOOL_TESTSDIR) $(TESTOPTS) $(EXCLUDE_TESTFRAMEWORK) + $(gnumake_recursive)$(Q)$(exec) $(RUNRUBY) "$(TOOL_TESTSDIR)/runner.rb" --test-target-dir="$(TOOL_TESTSDIR)" -- --ruby="$(RUNRUBY)" $(TESTOPTS) $(EXCLUDE_TESTFRAMEWORK) no-test-tool: PHONY test-sample: test-basic # backward compatibility for mswin-build @@ -770,10 +770,10 @@ test: test-short # for example, make test-all TESTOPTS="-j2 -v -n test-name -- test-file-name" test-all: $(TEST_RUNNABLE)-test-all yes-test-all: programs PHONY - $(gnumake_recursive)$(Q)$(exec) $(RUNRUBY) "$(srcdir)/test/runner.rb" --ruby="$(RUNRUBY)" $(TEST_EXCLUDES) $(TESTOPTS) $(TESTS) + $(gnumake_recursive)$(Q)$(exec) $(RUNRUBY) "$(TOOL_TESTSDIR)/runner.rb" --test-target-dir="$(TESTSDIR)" -- --ruby="$(RUNRUBY)" $(TEST_EXCLUDES) $(TESTOPTS) $(TESTS) TESTS_BUILD = mkmf no-test-all: PHONY - $(gnumake_recursive)$(MINIRUBY) -I"$(srcdir)/lib" "$(srcdir)/test/runner.rb" $(TESTOPTS) $(TESTS_BUILD) + $(gnumake_recursive)$(MINIRUBY) -I"$(srcdir)/lib" "$(TOOL_TESTSDIR)/runner.rb" --test-target-dir="$(TESTSDIR)" -- $(TESTOPTS) $(TESTS_BUILD) test-almost: test-all yes-test-almost: yes-test-all @@ -782,7 +782,7 @@ no-test-almost: no-test-all test-ruby: $(TEST_RUNNABLE)-test-ruby no-test-ruby: PHONY yes-test-ruby: prog encs PHONY - $(gnumake_recursive)$(RUNRUBY) "$(srcdir)/test/runner.rb" $(TEST_EXCLUDES) $(TESTOPTS) -- ruby -ext- + $(gnumake_recursive)$(RUNRUBY) "$(TOOL_TESTSDIR)/runner.rb" --test-target-dir="$(TESTSDIR)" -- $(TEST_EXCLUDES) $(TESTOPTS) -- ruby -ext- extconf: $(PREP) $(Q) $(MAKEDIRS) "$(EXTCONFDIR)" diff --git a/test/runner.rb b/test/runner.rb deleted file mode 100644 index db2084949e..0000000000 --- a/test/runner.rb +++ /dev/null @@ -1,39 +0,0 @@ -# frozen_string_literal: false -require 'rbconfig' - -src_testdir = File.dirname(File.realpath(__FILE__)) -$LOAD_PATH << src_testdir -tool_dir = File.join src_testdir, "..", "tool" -$LOAD_PATH.unshift "#{tool_dir}/lib" - -# Get bundled gems on load path -Dir.glob("#{src_testdir}/../gems/*/*.gemspec") - .reject {|f| f =~ /minitest|test-unit|power_assert/ } - .map {|f| $LOAD_PATH.unshift File.join(File.dirname(f), "lib") } - -require 'test/unit' - -module Gem -end -class Gem::TestCase < MiniTest::Unit::TestCase - @@project_dir = File.dirname($LOAD_PATH.last) -end - -ENV["GEM_SKIP"] = ENV["GEM_HOME"] = ENV["GEM_PATH"] = "".freeze - -require_relative "#{tool_dir}/lib/profile_test_all" if ENV.has_key?('RUBY_TEST_ALL_PROFILE') -require_relative "#{tool_dir}/lib/tracepointchecker" -require_relative "#{tool_dir}/lib/zombie_hunter" -require_relative "#{tool_dir}/lib/iseq_loader_checker" - -if ENV['COVERAGE'] - require_relative "#{tool_dir}/test-coverage.rb" -end - -begin - exit Test::Unit::AutoRunner.run(true, src_testdir) -rescue NoMemoryError - system("cat /proc/meminfo") if File.exist?("/proc/meminfo") - system("ps x -opid,args,%cpu,%mem,nlwp,rss,vsz,wchan,stat,start,time,etime,blocked,caught,ignored,pending,f") if File.exist?("/bin/ps") - raise -end diff --git a/tool/lib/test/unit.rb b/tool/lib/test/unit.rb index d237a9a0e9..1034a993b0 100644 --- a/tool/lib/test/unit.rb +++ b/tool/lib/test/unit.rb @@ -856,9 +856,6 @@ module Test def setup_options(parser, options) super parser.separator "globbing options:" - parser.on '-b', '--basedir=DIR', 'Base directory of test suites.' do |dir| - options[:base_directory] = dir - end parser.on '-x', '--exclude REGEXP', 'Exclude test files on pattern.' do |pattern| (options[:reject] ||= []) << pattern end diff --git a/tool/test/runner.rb b/tool/test/runner.rb index 64f6df167e..db23ae2d33 100644 --- a/tool/test/runner.rb +++ b/tool/test/runner.rb @@ -1,9 +1,22 @@ # frozen_string_literal: false require 'rbconfig' -src_testdir = File.dirname(File.realpath(__FILE__)) +tool_dir = File.dirname(File.dirname(File.realpath(__FILE__))) +src_testdir = nil + +while opt = ARGV.shift + break if opt == "--" + case opt + when /\A--test-target-dir=(.*?)\z/ + src_testdir = File.realpath($1) + else + raise "unknown runner option: #{ opt }" + end +end + +raise "#$0: specify --test-target-dir" if !src_testdir + $LOAD_PATH << src_testdir -tool_dir = File.join src_testdir, ".." $LOAD_PATH.unshift "#{tool_dir}/lib" # Get bundled gems on load path