Added test-tool target for the test suite of tool/test files.

This commit is contained in:
Hiroshi SHIBATA 2019-07-15 11:16:05 +09:00
Родитель 41c5f9a166
Коммит ac6d137157
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: F9CF13417264FAC2
2 изменённых файлов: 46 добавлений и 1 удалений

Просмотреть файл

@ -187,6 +187,7 @@ INSTALL_DATA_MODE = 0644
TESTSDIR = $(srcdir)/test
TOOL_TESTSDIR = $(srcdir)/tool/test
TEST_EXCLUDES = --excludes-dir=$(TESTSDIR)/excludes --name=!/memory_leak/
EXCLUDE_TESTFRAMEWORK = --exclude=/testunit/ --exclude=/minitest/
TESTWORKDIR = testwork
TESTOPTS = $(RUBY_TESTOPTS)
@ -753,9 +754,14 @@ yes-test-knownbug: prog PHONY
test-testframework: $(TEST_RUNNABLE)-test-testframework
yes-test-testframework: prog PHONY
$(gnumake_recursive)$(Q)$(exec) $(RUNRUBY) "$(srcdir)/test/runner.rb" --ruby="$(RUNRUBY)" --basedir=$(TOOL_TESTSDIR) $(TESTOPTS) testunit minitest
$(gnumake_recursive)$(Q)$(exec) $(RUNRUBY) "$(TOOL_TESTSDIR)/runner.rb" --ruby="$(RUNRUBY)" --basedir=$(TOOL_TESTSDIR) $(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)
no-test-tool: PHONY
test-sample: test-basic # backward compatibility for mswin-build
test-short: btest-ruby test-knownbug test-basic
test: test-short

39
tool/test/runner.rb Normal file
Просмотреть файл

@ -0,0 +1,39 @@
# frozen_string_literal: false
require 'rbconfig'
src_testdir = File.dirname(File.realpath(__FILE__))
$LOAD_PATH << src_testdir
tool_dir = File.join src_testdir, ".."
$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