mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
Split test files for test-framework that are test-unit and minitest to tool direcotry.
This commit is contained in:
parent
c3c0e3f5c9
commit
c68781e918
18 changed files with 7 additions and 6 deletions
71
tool/test/minitest/metametameta.rb
Normal file
71
tool/test/minitest/metametameta.rb
Normal file
|
|
@ -0,0 +1,71 @@
|
|||
# encoding: utf-8
|
||||
# frozen_string_literal: false
|
||||
|
||||
require 'tempfile'
|
||||
require 'stringio'
|
||||
require 'minitest/autorun'
|
||||
|
||||
class MiniTest::Unit::TestCase
|
||||
def clean s
|
||||
s.gsub(/^ {6}/, '')
|
||||
end
|
||||
end
|
||||
|
||||
class MetaMetaMetaTestCase < MiniTest::Unit::TestCase
|
||||
def assert_report expected, flags = %w[--seed 42]
|
||||
header = clean <<-EOM
|
||||
Run options: #{flags.map { |s| s =~ /\|/ ? s.inspect : s }.join " "}
|
||||
|
||||
# Running tests:
|
||||
|
||||
EOM
|
||||
|
||||
with_output do
|
||||
@tu.run flags
|
||||
end
|
||||
|
||||
output = @output.string.dup
|
||||
output.sub!(/Finished tests in .*/, "Finished tests in 0.00")
|
||||
output.sub!(/Loaded suite .*/, 'Loaded suite blah')
|
||||
|
||||
output.gsub!(/ = \d+.\d\d s = /, ' = 0.00 s = ')
|
||||
output.gsub!(/0x[A-Fa-f0-9]+/, '0xXXX')
|
||||
|
||||
if windows? then
|
||||
output.gsub!(/\[(?:[A-Za-z]:)?[^\]:]+:\d+\]/, '[FILE:LINE]')
|
||||
output.gsub!(/^(\s+)(?:[A-Za-z]:)?[^:]+:\d+:in/, '\1FILE:LINE:in')
|
||||
else
|
||||
output.gsub!(/\[[^\]:]+:\d+\]/, '[FILE:LINE]')
|
||||
output.gsub!(/^(\s+)[^:]+:\d+:in/, '\1FILE:LINE:in')
|
||||
end
|
||||
|
||||
assert_equal header + expected, output
|
||||
end
|
||||
|
||||
def setup
|
||||
super
|
||||
srand 42
|
||||
MiniTest::Unit::TestCase.reset
|
||||
@tu = MiniTest::Unit.new
|
||||
|
||||
MiniTest::Unit.runner = nil # protect the outer runner from the inner tests
|
||||
end
|
||||
|
||||
def teardown
|
||||
super
|
||||
end
|
||||
|
||||
def with_output
|
||||
synchronize do
|
||||
begin
|
||||
save = MiniTest::Unit.output
|
||||
@output = StringIO.new("")
|
||||
MiniTest::Unit.output = @output
|
||||
|
||||
yield
|
||||
ensure
|
||||
MiniTest::Unit.output = save
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
Loading…
Add table
Add a link
Reference in a new issue