[前][次][番号順一覧][スレッド一覧]

ruby-changes:56611

From: Yusuke <ko1@a...>
Date: Sun, 21 Jul 2019 19:24:15 +0900 (JST)
Subject: [ruby-changes:56611] Yusuke Endoh: 24712eeec3 (master): tool/test/runner.rb: support --test-target-dir option

https://git.ruby-lang.org/ruby.git/commit/?id=24712eeec3

From 24712eeec39f5e9a11cfc2b940358403cda4f2b6 Mon Sep 17 00:00:00 2001
From: Yusuke Endoh <mame@r...>
Date: Sun, 21 Jul 2019 19:19:08 +0900
Subject: tool/test/runner.rb: support --test-target-dir option

tool/test/runner.rb had been copied from test/runner.rb.
test/runner.rb was for `make test-all`, and tool/test/runner.rb was for
`make test-testframework` and `make test-tool`.
But I want to avoid the code clones.

This change makes tool/test/runner.rb support --test-target-dir option
which allows tool/test/runner.rb to run `make test-all`.
Now we can remove test/runner.rb.

diff --git a/common.mk b/common.mk
index 63312b5..da81afa 100644
--- a/common.mk
+++ b/common.mk
@@ -754,12 +754,12 @@ yes-test-knownbug: prog PHONY https://github.com/ruby/ruby/blob/trunk/common.mk#L754
 
 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 https://github.com/ruby/ruby/blob/trunk/common.mk#L770
 # 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 https://github.com/ruby/ruby/blob/trunk/common.mk#L782
 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 db20849..0000000
--- a/test/runner.rb
+++ /dev/null
@@ -1,39 +0,0 @@ https://github.com/ruby/ruby/blob/trunk/common.mk#L0
-# 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 d237a9a..1034a99 100644
--- a/tool/lib/test/unit.rb
+++ b/tool/lib/test/unit.rb
@@ -856,9 +856,6 @@ module Test https://github.com/ruby/ruby/blob/trunk/tool/lib/test/unit.rb#L856
       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 64f6df1..db23ae2 100644
--- a/tool/test/runner.rb
+++ b/tool/test/runner.rb
@@ -1,9 +1,22 @@ https://github.com/ruby/ruby/blob/trunk/tool/test/runner.rb#L1
 # 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
-- 
cgit v0.10.2


--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]