Skip to content
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
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,6 @@
/pkg/
/spec/reports/
/tmp/
Gemfile.lock
*.bundle
*.so
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ gemspec

gem "rake"
gem "rake-compiler"
gem "test-unit"
8 changes: 8 additions & 0 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,17 @@ require "rake/testtask"

Rake::TestTask.new(:test) do |t|
t.libs << "test/lib"
t.ruby_opts << "-rhelper"
t.test_files = FileList["test/**/test_*.rb"]
end

task :sync_tool do
require 'fileutils'
FileUtils.cp "../ruby/tool/lib/test/unit/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

require 'rake/extensiontask'
Rake::ExtensionTask.new("pathname")

Expand Down
41 changes: 38 additions & 3 deletions test/lib/core_assertions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ def syntax_check(code, fname, line)

def assert_no_memory_leak(args, prepare, code, message=nil, limit: 2.0, rss: false, **opt)
# TODO: consider choosing some appropriate limit for MJIT and stop skipping this once it does not randomly fail
pend 'assert_no_memory_leak may consider MJIT memory usage as leak' if defined?(RubyVM::MJIT) && RubyVM::MJIT.enabled?
pend 'assert_no_memory_leak may consider MJIT memory usage as leak' if defined?(RubyVM::JIT) && RubyVM::JIT.enabled?

require_relative '../../memory_status'
raise MiniTest::Skip, "unsupported platform" unless defined?(Memory::Status)
Expand Down Expand Up @@ -264,7 +264,7 @@ def separated_runner(out = nil)
at_exit {
out.puts [Marshal.dump($!)].pack('m'), "assertions=\#{self._assertions}"
}
Test::Unit::Runner.class_variable_set(:@@stop_auto_run, true)
Test::Unit::Runner.class_variable_set(:@@stop_auto_run, true) if defined?(Test::Unit::Runner)
end

def assert_separately(args, file = nil, line = nil, src, ignore_stderr: nil, **opt)
Expand All @@ -276,7 +276,7 @@ def assert_separately(args, file = nil, line = nil, src, ignore_stderr: nil, **o
capture_stdout = true
unless /mswin|mingw/ =~ RUBY_PLATFORM
capture_stdout = false
opt[:out] = MiniTest::Unit.output
opt[:out] = MiniTest::Unit.output if defined?(MiniTest::Unit)
res_p, res_c = IO.pipe
opt[res_c.fileno] = res_c.fileno
end
Expand Down Expand Up @@ -330,6 +330,27 @@ def assert_separately(args, file = nil, line = nil, src, ignore_stderr: nil, **o
raise marshal_error if marshal_error
end

# Run Ractor-related test without influencing the main test suite
def assert_ractor(src, args: [], require: nil, require_relative: nil, file: nil, line: nil, ignore_stderr: nil, **opt)
return unless defined?(Ractor)

require = "require #{require.inspect}" if require
if require_relative
dir = File.dirname(caller_locations[0,1][0].absolute_path)
full_path = File.expand_path(require_relative, dir)
require = "#{require}; require #{full_path.inspect}"
end

assert_separately(args, file, line, <<~RUBY, ignore_stderr: ignore_stderr, **opt)
#{require}
previous_verbose = $VERBOSE
$VERBOSE = nil
Ractor.new {} # trigger initial warning
$VERBOSE = previous_verbose
#{src}
RUBY
end

# :call-seq:
# assert_throw( tag, failure_message = nil, &block )
#
Expand Down Expand Up @@ -587,6 +608,20 @@ def assert_warn(*args)
assert_warning(*args) {$VERBOSE = false; yield}
end

def assert_deprecated_warning(mesg = /deprecated/)
assert_warning(mesg) do
Warning[:deprecated] = true
yield
end
end

def assert_deprecated_warn(mesg = /deprecated/)
assert_warn(mesg) do
Warning[:deprecated] = true
yield
end
end

class << (AssertFile = Struct.new(:failure_message).new)
include CoreAssertions
def assert_file_predicate(predicate, *args)
Expand Down
203 changes: 0 additions & 203 deletions test/lib/leakchecker.rb

This file was deleted.

14 changes: 0 additions & 14 deletions test/lib/minitest/autorun.rb

This file was deleted.

Loading