-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
15 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,18 @@ | ||
# load files from install, not src | ||
diff --git a/test/ruby/test_require_lib.rb b/test/ruby/test_require_lib.rb | ||
index 95fa3f29e1..3530014740 100644 | ||
index a88279727e..92f67f453d 100644 | ||
--- a/test/ruby/test_require_lib.rb | ||
+++ b/test/ruby/test_require_lib.rb | ||
@@ -1,14 +1,25 @@ | ||
# frozen_string_literal: false | ||
@@ -1,8 +1,11 @@ | ||
# frozen_string_literal: true | ||
require 'test/unit' | ||
+require 'rbconfig' | ||
|
||
class TestRequireLib < Test::Unit::TestCase | ||
TEST_RATIO = ENV["TEST_REQUIRE_THREAD_RATIO"]&.tap {|s|break s.to_f} || 0.05 # testing all files needs too long time... | ||
|
||
- Dir.glob(File.expand_path('../../lib/**/*.rb', __dir__)).each do |lib| | ||
- libdir = __dir__ + '/../../lib' | ||
+ | ||
+ temp = RbConfig::CONFIG['rubylibdir'] | ||
+ files = if Dir.exist? temp | ||
+ re_lib = '' | ||
+ Dir.glob('**/*.rb', base: temp) | ||
+ else | ||
+ re_lib = '/lib/' | ||
+ Dir.glob(File.expand_path('../../lib/**/*.rb', __dir__)) | ||
+ end | ||
+ | ||
+ files.each do |lib| | ||
# skip some problems | ||
- next if %r!/lib/(?:bundler|rubygems)\b! =~ lib | ||
- next if %r!/lib/(?:debug|mkmf)\.rb\z! =~ lib | ||
- next if %r!/lib/irb/ext/tracer\.rb\z! =~ lib | ||
+ next if %r!#{re_lib}(?:bundler|rubygems)\b! =~ lib | ||
+ next if %r!#{re_lib}(?:debug|mkmf)\.rb\z! =~ lib | ||
+ next if %r!#{re_lib}irb/ext/tracer\.rb\z! =~ lib | ||
+ | ||
# skip many files that almost use no threads | ||
next if TEST_RATIO < rand(0.0..1.0) | ||
define_method "test_thread_size:#{lib}" do | ||
+ libdir = Dir.exist?(temp) ? temp : (__dir__ + '/../../lib') | ||
|
||
# .rb files at lib | ||
scripts = Dir.glob('*.rb', base: libdir).map {|f| f.chomp('.rb')} |