Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use test-unit gem instead of deep copy test-suite from ruby repo #244

Merged
merged 10 commits into from
Aug 30, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
source "https://rubygems.org"

git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }

gemspec

group :development do
gem "bundler"
is_unix = RUBY_PLATFORM =~ /(aix|darwin|linux|(net|free|open)bsd|cygwin|solaris|irix|hpux)/i
is_truffleruby = RUBY_DESCRIPTION =~ /truffleruby/
gem 'vterm', '>= 0.0.5' if is_unix && ENV['WITH_VTERM']
gem 'yamatanooroti', '>= 0.0.6'
gem "rake"
gem "stackprof" if is_unix && !is_truffleruby
gem "test-unit"
end
11 changes: 10 additions & 1 deletion Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,23 @@ require "rake/testtask"
Rake::TestTask.new(:test) do |t|
t.libs << "test" << "test/lib"
t.libs << "lib"
t.ruby_opts << "-rhelper"
t.test_files = FileList["test/irb/test_*.rb"]
end

Rake::TestTask.new(:test_yamatanooroti) do |t|
t.libs << 'test'
t.libs << 'test' << "test/lib"
t.libs << 'lib'
#t.loader = :direct
t.ruby_opts << "-rhelper"
t.pattern = 'test/irb/yamatanooroti/test_*.rb'
end

task :sync_tool do
require 'fileutils'
FileUtils.cp "../ruby/tool/lib/core_assertions.rb", "./test/lib"
FileUtils.cp "../ruby/tool/lib/envutil.rb", "./test/lib"
FileUtils.cp "../ruby/tool/lib/find_executable.rb", "./test/lib"
end

task :default => :test
2 changes: 1 addition & 1 deletion test/irb/test_color.rb
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ def test_colorize_code

def test_colorize_code_complete_true
unless complete_option_supported?
skip '`complete: true` is the same as `complete: false` in Ruby 2.6-'
pend '`complete: true` is the same as `complete: false` in Ruby 2.6-'
end

# `complete: true` behaviors. Warn end-of-file.
Expand Down
2 changes: 1 addition & 1 deletion test/irb/test_color_printer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def teardown

def test_color_printer
unless ripper_lexer_scan_supported?
skip 'Ripper::Lexer#scan is supported in Ruby 2.7+'
pend 'Ripper::Lexer#scan is supported in Ruby 2.7+'
end
{
1 => "#{BLUE}#{BOLD}1#{CLEAR}\n",
Expand Down
2 changes: 1 addition & 1 deletion test/irb/test_completion.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def test_nonstring_module_name
status = assert_in_out_err(cmds, "", //, [], bug5938)
assert(status.success?, bug5938)
rescue LoadError
skip "cannot load irb/completion"
pend "cannot load irb/completion"
end
end

Expand Down
58 changes: 31 additions & 27 deletions test/irb/test_context.rb
Original file line number Diff line number Diff line change
Expand Up @@ -79,22 +79,22 @@ def test_evaluate_with_exception
end

def test_evaluate_with_encoding_error_without_lineno
skip if RUBY_ENGINE == 'truffleruby'
pend if RUBY_ENGINE == 'truffleruby'
assert_raise_with_message(EncodingError, /invalid symbol/) {
@context.evaluate(%q[{"\xAE": 1}], 1)
# The backtrace of this invalid encoding hash doesn't contain lineno.
}
end

def test_evaluate_with_onigmo_warning
skip if RUBY_ENGINE == 'truffleruby'
pend if RUBY_ENGINE == 'truffleruby'
assert_warning("(irb):1: warning: character class has duplicated range: /[aa]/\n") do
@context.evaluate('/[aa]/', 1)
end
end

def test_eval_input
skip if RUBY_ENGINE == 'truffleruby'
pend if RUBY_ENGINE == 'truffleruby'
verbose, $VERBOSE = $VERBOSE, nil
input = TestInputMethod.new([
"raise 'Foo'\n",
Expand All @@ -117,7 +117,7 @@ def test_eval_input
end

def test_eval_input_raise2x
skip if RUBY_ENGINE == 'truffleruby'
pend if RUBY_ENGINE == 'truffleruby'
input = TestInputMethod.new([
"raise 'Foo'\n",
"raise 'Bar'\n",
Expand Down Expand Up @@ -221,7 +221,7 @@ def test_echo_on_assignment
# The default
irb.context.echo = true
irb.context.echo_on_assignment = false
out, err = capture_io do
out, err = capture_output do
irb.eval_input
end
assert_empty err
Expand All @@ -231,7 +231,7 @@ def test_echo_on_assignment
input.reset
irb.context.echo = true
irb.context.echo_on_assignment = true
out, err = capture_io do
out, err = capture_output do
irb.eval_input
end
assert_empty err
Expand All @@ -241,7 +241,7 @@ def test_echo_on_assignment
input.reset
irb.context.echo = false
irb.context.echo_on_assignment = false
out, err = capture_io do
out, err = capture_output do
irb.eval_input
end
assert_empty err
Expand All @@ -251,7 +251,7 @@ def test_echo_on_assignment
input.reset
irb.context.echo = false
irb.context.echo_on_assignment = true
out, err = capture_io do
out, err = capture_output do
irb.eval_input
end
assert_empty err
Expand All @@ -269,7 +269,7 @@ def test_omit_on_assignment

irb.context.echo = true
irb.context.echo_on_assignment = false
out, err = capture_io do
out, err = capture_output do
irb.eval_input
end
assert_empty err
Expand All @@ -278,7 +278,7 @@ def test_omit_on_assignment
input.reset
irb.context.echo = true
irb.context.echo_on_assignment = :truncate
out, err = capture_io do
out, err = capture_output do
irb.eval_input
end
assert_empty err
Expand All @@ -287,7 +287,7 @@ def test_omit_on_assignment
input.reset
irb.context.echo = true
irb.context.echo_on_assignment = true
out, err = capture_io do
out, err = capture_output do
irb.eval_input
end
assert_empty err
Expand All @@ -296,7 +296,7 @@ def test_omit_on_assignment
input.reset
irb.context.echo = false
irb.context.echo_on_assignment = false
out, err = capture_io do
out, err = capture_output do
irb.eval_input
end
assert_empty err
Expand All @@ -305,7 +305,7 @@ def test_omit_on_assignment
input.reset
irb.context.echo = false
irb.context.echo_on_assignment = :truncate
out, err = capture_io do
out, err = capture_output do
irb.eval_input
end
assert_empty err
Expand All @@ -314,7 +314,7 @@ def test_omit_on_assignment
input.reset
irb.context.echo = false
irb.context.echo_on_assignment = true
out, err = capture_io do
out, err = capture_output do
irb.eval_input
end
assert_empty err
Expand All @@ -333,7 +333,7 @@ def test_omit_multiline_on_assignment

irb.context.echo = true
irb.context.echo_on_assignment = false
out, err = capture_io do
out, err = capture_output do
irb.eval_input
end
assert_empty err
Expand All @@ -343,7 +343,7 @@ def test_omit_multiline_on_assignment
input.reset
irb.context.echo = true
irb.context.echo_on_assignment = :truncate
out, err = capture_io do
out, err = capture_output do
irb.eval_input
end
assert_empty err
Expand All @@ -353,7 +353,7 @@ def test_omit_multiline_on_assignment
input.reset
irb.context.echo = true
irb.context.echo_on_assignment = true
out, err = capture_io do
out, err = capture_output do
irb.eval_input
end
assert_empty err
Expand All @@ -363,7 +363,7 @@ def test_omit_multiline_on_assignment
input.reset
irb.context.echo = false
irb.context.echo_on_assignment = false
out, err = capture_io do
out, err = capture_output do
irb.eval_input
end
assert_empty err
Expand All @@ -373,7 +373,7 @@ def test_omit_multiline_on_assignment
input.reset
irb.context.echo = false
irb.context.echo_on_assignment = :truncate
out, err = capture_io do
out, err = capture_output do
irb.eval_input
end
assert_empty err
Expand All @@ -383,7 +383,7 @@ def test_omit_multiline_on_assignment
input.reset
irb.context.echo = false
irb.context.echo_on_assignment = true
out, err = capture_io do
out, err = capture_output do
irb.eval_input
end
assert_empty err
Expand Down Expand Up @@ -430,7 +430,7 @@ def main.inspect

# The default
irb.context.newline_before_multiline_output = true
out, err = capture_io do
out, err = capture_output do
irb.eval_input
end
assert_empty err
Expand All @@ -440,7 +440,7 @@ def main.inspect
# No newline before multiline output
input.reset
irb.context.newline_before_multiline_output = false
out, err = capture_io do
out, err = capture_output do
irb.eval_input
end
assert_empty err
Expand All @@ -449,7 +449,7 @@ def main.inspect
end

def test_eval_input_with_exception
skip if RUBY_ENGINE == 'truffleruby'
pend if RUBY_ENGINE == 'truffleruby'
verbose, $VERBOSE = $VERBOSE, nil
input = TestInputMethod.new([
"def hoge() fuga; end; def fuga() raise; end; hoge\n",
Expand All @@ -462,6 +462,7 @@ def test_eval_input_with_exception
if '2.5.0' <= RUBY_VERSION && RUBY_VERSION < '3.0.0' && STDOUT.tty?
expected = [
:*, /Traceback \(most recent call last\):\n/,
:*, /\t... 8 levels...\n/,
:*, /\t 2: from \(irb\):1:in `<main>'\n/,
:*, /\t 1: from \(irb\):1:in `hoge'\n/,
:*, /\(irb\):1:in `fuga': unhandled exception\n/,
Expand All @@ -471,6 +472,7 @@ def test_eval_input_with_exception
:*, /\(irb\):1:in `fuga': unhandled exception\n/,
:*, /\tfrom \(irb\):1:in `hoge'\n/,
:*, /\tfrom \(irb\):1:in `<main>'\n/,
:*, /\t... 8 levels...\n/,
]
end
assert_pattern_list(expected, out)
Expand All @@ -479,7 +481,7 @@ def test_eval_input_with_exception
end

def test_eval_input_with_invalid_byte_sequence_exception
skip if RUBY_ENGINE == 'truffleruby'
pend if RUBY_ENGINE == 'truffleruby'
verbose, $VERBOSE = $VERBOSE, nil
input = TestInputMethod.new([
%Q{def hoge() fuga; end; def fuga() raise "A\\xF3B"; end; hoge\n},
Expand All @@ -492,6 +494,7 @@ def test_eval_input_with_invalid_byte_sequence_exception
if '2.5.0' <= RUBY_VERSION && RUBY_VERSION < '3.0.0' && STDOUT.tty?
expected = [
:*, /Traceback \(most recent call last\):\n/,
:*, /\t... 8 levels...\n/,
:*, /\t 2: from \(irb\):1:in `<main>'\n/,
:*, /\t 1: from \(irb\):1:in `hoge'\n/,
:*, /\(irb\):1:in `fuga': A\\xF3B \(RuntimeError\)\n/,
Expand All @@ -501,6 +504,7 @@ def test_eval_input_with_invalid_byte_sequence_exception
:*, /\(irb\):1:in `fuga': A\\xF3B \(RuntimeError\)\n/,
:*, /\tfrom \(irb\):1:in `hoge'\n/,
:*, /\tfrom \(irb\):1:in `<main>'\n/,
:*, /\t... 8 levels...\n/,
]
end
assert_pattern_list(expected, out)
Expand All @@ -509,7 +513,7 @@ def test_eval_input_with_invalid_byte_sequence_exception
end

def test_eval_input_with_long_exception
skip if RUBY_ENGINE == 'truffleruby'
pend if RUBY_ENGINE == 'truffleruby'
verbose, $VERBOSE = $VERBOSE, nil
nesting = 20
generated_code = ''
Expand All @@ -528,7 +532,7 @@ def test_eval_input_with_long_exception
if '2.5.0' <= RUBY_VERSION && RUBY_VERSION < '3.0.0' && STDOUT.tty?
expected = [
:*, /Traceback \(most recent call last\):\n/,
:*, /\t... 5 levels...\n/,
:*, /\t... 27 levels...\n/,
:*, /\t16: from \(irb\):1:in `a4'\n/,
:*, /\t15: from \(irb\):1:in `a5'\n/,
:*, /\t14: from \(irb\):1:in `a6'\n/,
Expand Down Expand Up @@ -566,7 +570,7 @@ def test_eval_input_with_long_exception
:*, /\tfrom \(irb\):1:in `a6'\n/,
:*, /\tfrom \(irb\):1:in `a5'\n/,
:*, /\tfrom \(irb\):1:in `a4'\n/,
:*, /\t... 5 levels...\n/,
:*, /\t... 27 levels...\n/,
]
end
assert_pattern_list(expected, out)
Expand Down
6 changes: 3 additions & 3 deletions test/irb/test_raise_no_backtrace_exception.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
module TestIRB
class TestRaiseNoBacktraceException < Test::Unit::TestCase
def test_raise_exception
skip if RUBY_ENGINE == 'truffleruby'
pend if RUBY_ENGINE == 'truffleruby'
bundle_exec = ENV.key?('BUNDLE_GEMFILE') ? ['-rbundler/setup'] : []
assert_in_out_err(bundle_exec + %w[-rirb -W0 -e IRB.start(__FILE__) -- -f --], <<-IRB, /Exception: foo/, [])
e = Exception.new("foo")
Expand All @@ -15,15 +15,15 @@ def e.backtrace; nil; end
end

def test_raise_exception_with_invalid_byte_sequence
skip if RUBY_ENGINE == 'truffleruby' || /mswin|mingw/ =~ RUBY_PLATFORM
pend if RUBY_ENGINE == 'truffleruby' || /mswin|mingw/ =~ RUBY_PLATFORM
bundle_exec = ENV.key?('BUNDLE_GEMFILE') ? ['-rbundler/setup'] : []
assert_in_out_err(bundle_exec + %w[-rirb -W0 -e IRB.start(__FILE__) -- -f --], <<~IRB, /A\\xF3B \(StandardError\)/, [])
raise StandardError, "A\\xf3B"
IRB
end

def test_raise_exception_with_different_encoding_containing_invalid_byte_sequence
skip if RUBY_ENGINE == 'truffleruby'
pend if RUBY_ENGINE == 'truffleruby'
backup_home = ENV["HOME"]
Dir.mktmpdir("test_irb_raise_no_backtrace_exception_#{$$}") do |tmpdir|
ENV["HOME"] = tmpdir
Expand Down
Loading