Don't use benchmark for test_activate_via_require_respects_loaded_files
benchmark.rb may extract as bundled gems in the future release
This commit is contained in:
parent
a68208235e
commit
a780633d2a
Notes:
git
2024-08-29 08:38:03 +00:00
@ -223,7 +223,7 @@ class TestGemRequire < Gem::TestCase
|
|||||||
|
|
||||||
def test_activate_via_require_respects_loaded_files
|
def test_activate_via_require_respects_loaded_files
|
||||||
pend "Not sure what's going on. If another spec creates a 'a' gem before
|
pend "Not sure what's going on. If another spec creates a 'a' gem before
|
||||||
this test, somehow require will load the benchmark in b, and ignore that the
|
this test, somehow require will load the erb in b, and ignore that the
|
||||||
stdlib one is already in $LOADED_FEATURES?. Reproducible by running the
|
stdlib one is already in $LOADED_FEATURES?. Reproducible by running the
|
||||||
spaceship_specific_file test before this one" if Gem.java_platform?
|
spaceship_specific_file test before this one" if Gem.java_platform?
|
||||||
|
|
||||||
@ -240,11 +240,11 @@ class TestGemRequire < Gem::TestCase
|
|||||||
load_path_changed = true
|
load_path_changed = true
|
||||||
end
|
end
|
||||||
|
|
||||||
require "benchmark" # the stdlib
|
require "erb" # the stdlib
|
||||||
|
|
||||||
a1 = util_spec "a", "1", { "b" => ">= 1" }, "lib/test_gem_require_a.rb"
|
a1 = util_spec "a", "1", { "b" => ">= 1" }, "lib/test_gem_require_a.rb"
|
||||||
b1 = util_spec "b", "1", nil, "lib/benchmark.rb"
|
b1 = util_spec "b", "1", nil, "lib/erb.rb"
|
||||||
b2 = util_spec "b", "2", nil, "lib/benchmark.rb"
|
b2 = util_spec "b", "2", nil, "lib/erb.rb"
|
||||||
|
|
||||||
install_specs b1, b2, a1
|
install_specs b1, b2, a1
|
||||||
|
|
||||||
@ -257,12 +257,12 @@ class TestGemRequire < Gem::TestCase
|
|||||||
|
|
||||||
assert_equal unresolved_names, ["b (>= 1)"]
|
assert_equal unresolved_names, ["b (>= 1)"]
|
||||||
|
|
||||||
# The require('benchmark') below will activate b-2. However, its
|
# The require('erb') below will activate b-2. However, its
|
||||||
# lib/benchmark.rb won't ever be loaded. The reason is MRI sees that even
|
# lib/erb.rb won't ever be loaded. The reason is MRI sees that even
|
||||||
# though b-2 is earlier in $LOAD_PATH it already loaded a benchmark.rb file
|
# though b-2 is earlier in $LOAD_PATH it already loaded a erb.rb file
|
||||||
# and that still exists in $LOAD_PATH (further down),
|
# and that still exists in $LOAD_PATH (further down),
|
||||||
# and as a result #gem_original_require returns false.
|
# and as a result #gem_original_require returns false.
|
||||||
refute require("benchmark"), "the benchmark stdlib should be recognized as already loaded"
|
refute require("erb"), "the erb stdlib should be recognized as already loaded"
|
||||||
|
|
||||||
assert_includes $LOAD_PATH, b2.full_require_paths[0]
|
assert_includes $LOAD_PATH, b2.full_require_paths[0]
|
||||||
assert_includes $LOAD_PATH, rubylibdir
|
assert_includes $LOAD_PATH, rubylibdir
|
||||||
@ -273,7 +273,7 @@ class TestGemRequire < Gem::TestCase
|
|||||||
assert_operator $LOAD_PATH.index(b2.full_require_paths[0]), :<, $LOAD_PATH.index(rubylibdir), message
|
assert_operator $LOAD_PATH.index(b2.full_require_paths[0]), :<, $LOAD_PATH.index(rubylibdir), message
|
||||||
|
|
||||||
# We detected that we should activate b-2, so we did so, but
|
# We detected that we should activate b-2, so we did so, but
|
||||||
# then #gem_original_require decided "I've already got some benchmark.rb" loaded.
|
# then #gem_original_require decided "I've already got some erb.rb" loaded.
|
||||||
# This case is fine because our lazy loading provided exactly
|
# This case is fine because our lazy loading provided exactly
|
||||||
# the same behavior as eager loading would have.
|
# the same behavior as eager loading would have.
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user