Skip to content

Commit

Permalink
Merge pull request #1211 from ruby/backport-single-process-stdlibtest
Browse files Browse the repository at this point in the history
Backport #1207 (ruby/single-process-stdlibtest) to 2.8
  • Loading branch information
soutaro authored Jan 18, 2023
2 parents 792d1b0 + b1fdf12 commit c822808
Show file tree
Hide file tree
Showing 9 changed files with 361 additions and 353 deletions.
10 changes: 9 additions & 1 deletion Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,15 @@ FileList["test/stdlib/**/*_test.rb"].each do |test|
task test => :compile do
sh "#{ruby} -Ilib #{bin}/test_runner.rb #{test}"
end
task stdlib_test: test
end

task :stdlib_test do
test_files = FileList["test/stdlib/**/*_test.rb"].reject do |path|
path =~ %r{Ractor}
end
sh "#{ruby} -Ilib #{bin}/test_runner.rb #{test_files.join(' ')}"
# TODO: Ractor tests need to be run in a separate process
sh "#{ruby} -Ilib #{bin}/test_runner.rb test/stdlib/Ractor_test.rb"
end

task :rubocop do
Expand Down
2 changes: 1 addition & 1 deletion test/stdlib/ERB_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,6 @@ class ERBDefMethodSingletonTest < Test::Unit::TestCase

def test_def_erb_method
assert_send_type "(String, String) -> untyped",
ERB::DefMethod, :def_erb_method, "render()", __FILE__
ERB::DefMethod, :def_erb_method, "render()", File.expand_path(__FILE__, "../..")
end
end
54 changes: 27 additions & 27 deletions test/stdlib/FileTest_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,175 +7,175 @@ class FileTestSingletonTest < Test::Unit::TestCase

def test_blockdev?
assert_send_type "(::String file_name) -> bool",
FileTest, :blockdev?, __FILE__
FileTest, :blockdev?, File.expand_path(__FILE__, "../..")
assert_send_type "(::IO file_name) -> bool",
FileTest, :blockdev?, io_open
end

def test_chardev?
assert_send_type "(::String file_name) -> bool",
FileTest, :chardev?, __FILE__
FileTest, :chardev?, File.expand_path(__FILE__, "../..")
assert_send_type "(::IO file_name) -> bool",
FileTest, :chardev?, io_open
end

def test_directory?
assert_send_type "(::String file_name) -> bool",
FileTest, :directory?, __FILE__
FileTest, :directory?, File.expand_path(__FILE__, "../..")
assert_send_type "(::IO file_name) -> bool",
FileTest, :directory?, io_open
end

def test_empty?
assert_send_type "(::String file_name) -> bool",
FileTest, :empty?, __FILE__
FileTest, :empty?, File.expand_path(__FILE__, "../..")
assert_send_type "(::IO file_name) -> bool",
FileTest, :empty?, io_open
end

def test_executable?
assert_send_type "(::String file_name) -> bool",
FileTest, :executable?, __FILE__
FileTest, :executable?, File.expand_path(__FILE__, "../..")
end

def test_executable_real?
assert_send_type "(::String file_name) -> bool",
FileTest, :executable_real?, __FILE__
FileTest, :executable_real?, File.expand_path(__FILE__, "../..")
end

def test_exist?
assert_send_type "(::String file_name) -> bool",
FileTest, :exist?, __FILE__
FileTest, :exist?, File.expand_path(__FILE__, "../..")
assert_send_type "(::IO file_name) -> bool",
FileTest, :exist?, io_open
end

def test_file?
assert_send_type "(::String file) -> bool",
FileTest, :file?, __FILE__
FileTest, :file?, File.expand_path(__FILE__, "../..")
assert_send_type "(::IO file) -> bool",
FileTest, :file?, io_open
end

def test_grpowned?
assert_send_type "(::String file_name) -> bool",
FileTest, :grpowned?, __FILE__
FileTest, :grpowned?, File.expand_path(__FILE__, "../..")
assert_send_type "(::IO file_name) -> bool",
FileTest, :grpowned?, io_open
end

def test_identical?
assert_send_type "(::String file_1, ::String file_2) -> bool",
FileTest, :identical?, __FILE__, __FILE__
FileTest, :identical?, File.expand_path(__FILE__, "../.."), File.expand_path(__FILE__, "../..")
assert_send_type "(::IO file_1, ::IO file_2) -> bool",
FileTest, :identical?, io_open, io_open
end

def test_owned?
assert_send_type "(::String file_name) -> bool",
FileTest, :owned?, __FILE__
FileTest, :owned?, File.expand_path(__FILE__, "../..")
assert_send_type "(::IO file_name) -> bool",
FileTest, :owned?, io_open
end

def test_pipe?
assert_send_type "(::String file_name) -> bool",
FileTest, :pipe?, __FILE__
FileTest, :pipe?, File.expand_path(__FILE__, "../..")
assert_send_type "(::IO file_name) -> bool",
FileTest, :pipe?, io_open
end

def test_readable?
assert_send_type "(::String file_name) -> bool",
FileTest, :readable?, __FILE__
FileTest, :readable?, File.expand_path(__FILE__, "../..")
end

def test_readable_real?
assert_send_type "(::String file_name) -> bool",
FileTest, :readable_real?, __FILE__
FileTest, :readable_real?, File.expand_path(__FILE__, "../..")
end

def test_setgid?
assert_send_type "(::String file_name) -> bool",
FileTest, :setgid?, __FILE__
FileTest, :setgid?, File.expand_path(__FILE__, "../..")
assert_send_type "(::IO file_name) -> bool",
FileTest, :setgid?, io_open
end

def test_setuid?
assert_send_type "(::String file_name) -> bool",
FileTest, :setuid?, __FILE__
FileTest, :setuid?, File.expand_path(__FILE__, "../..")
assert_send_type "(::IO file_name) -> bool",
FileTest, :setuid?, io_open
end

def test_size
assert_send_type "(::String file_name) -> ::Integer",
FileTest, :size, __FILE__
FileTest, :size, File.expand_path(__FILE__, "../..")
assert_send_type "(::IO file_name) -> ::Integer",
FileTest, :size, io_open
end

def test_size?
assert_send_type "(::String file_name) -> ::Integer?",
FileTest, :size?, __FILE__
FileTest, :size?, File.expand_path(__FILE__, "../..")
assert_send_type "(::IO file_name) -> ::Integer?",
FileTest, :size?, io_open
end

def test_socket?
assert_send_type "(::String file_name) -> bool",
FileTest, :socket?, __FILE__
FileTest, :socket?, File.expand_path(__FILE__, "../..")
assert_send_type "(::IO file_name) -> bool",
FileTest, :socket?, io_open
end

def test_sticky?
assert_send_type "(::String file_name) -> bool",
FileTest, :sticky?, __FILE__
FileTest, :sticky?, File.expand_path(__FILE__, "../..")
assert_send_type "(::IO file_name) -> bool",
FileTest, :sticky?, io_open
end

def test_symlink?
assert_send_type "(::String file_name) -> bool",
FileTest, :symlink?, __FILE__
FileTest, :symlink?, File.expand_path(__FILE__, "../..")
end

def test_world_readable?
assert_send_type "(::String file_name) -> ::Integer?",
FileTest, :world_readable?, __FILE__
FileTest, :world_readable?, File.expand_path(__FILE__, "../..")
assert_send_type "(::IO file_name) -> ::Integer?",
FileTest, :world_readable?, io_open
end

def test_world_writable?
assert_send_type "(::String file_name) -> ::Integer?",
FileTest, :world_writable?, __FILE__
FileTest, :world_writable?, File.expand_path(__FILE__, "../..")
assert_send_type "(::IO file_name) -> ::Integer?",
FileTest, :world_writable?, io_open
end

def test_writable?
assert_send_type "(::String file_name) -> bool",
FileTest, :writable?, __FILE__
FileTest, :writable?, File.expand_path(__FILE__, "../..")
end

def test_writable_real?
assert_send_type "(::String file_name) -> bool",
FileTest, :writable_real?, __FILE__
FileTest, :writable_real?, File.expand_path(__FILE__, "../..")
end

def test_zero?
assert_send_type "(::String file_name) -> bool",
FileTest, :zero?, __FILE__
FileTest, :zero?, File.expand_path(__FILE__, "../..")
assert_send_type "(::IO file_name) -> bool",
FileTest, :zero?, io_open
end

private

def io_open
IO.open(IO.sysopen(__FILE__))
IO.open(IO.sysopen(File.expand_path(__FILE__, "../..")))
end
end
Loading

0 comments on commit c822808

Please sign in to comment.