mirror of
				https://github.com/ruby/ruby.git
				synced 2022-11-09 12:17:21 -05:00 
			
		
		
		
	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.
This commit is contained in:
		
							parent
							
								
									523fec8a4b
								
							
						
					
					
						commit
						24712eeec3
					
				
					 4 changed files with 20 additions and 49 deletions
				
			
		
							
								
								
									
										10
									
								
								common.mk
									
										
									
									
									
								
							
							
						
						
									
										10
									
								
								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)" | ||||
|  |  | |||
|  | @ -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 | ||||
|  | @ -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 | ||||
|  |  | |||
|  | @ -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 | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Yusuke Endoh
						Yusuke Endoh