2016-02-01 07:43:26 -05:00
|
|
|
# frozen_string_literal: true
|
2021-06-01 23:32:47 -04:00
|
|
|
require_relative "helper"
|
2012-11-29 01:52:18 -05:00
|
|
|
require "rubygems"
|
|
|
|
|
|
|
|
class TestGemRequire < Gem::TestCase
|
2014-09-13 23:30:02 -04:00
|
|
|
class Latch
|
2018-11-21 05:20:47 -05:00
|
|
|
def initialize(count = 1)
|
2014-09-13 23:30:02 -04:00
|
|
|
@count = count
|
|
|
|
@lock = Monitor.new
|
|
|
|
@cv = @lock.new_cond
|
|
|
|
end
|
|
|
|
|
|
|
|
def release
|
|
|
|
@lock.synchronize do
|
|
|
|
@count -= 1 if @count > 0
|
|
|
|
@cv.broadcast if @count.zero?
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def await
|
|
|
|
@lock.synchronize do
|
|
|
|
@cv.wait_while { @count > 0 }
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2013-03-05 18:11:43 -05:00
|
|
|
|
2012-11-29 01:52:18 -05:00
|
|
|
def assert_require(path)
|
|
|
|
assert require(path), "'#{path}' was already required"
|
|
|
|
end
|
|
|
|
|
2019-04-25 09:58:45 -04:00
|
|
|
def refute_require(path)
|
|
|
|
refute require(path), "'#{path}' was not yet required"
|
|
|
|
end
|
|
|
|
|
2020-05-21 09:20:57 -04:00
|
|
|
def test_respect_loaded_features_caching_like_standard_require
|
|
|
|
dir = Dir.mktmpdir("test_require", @tempdir)
|
|
|
|
|
|
|
|
lp1 = File.join dir, "foo1"
|
|
|
|
foo1 = File.join lp1, "foo.rb"
|
|
|
|
|
|
|
|
FileUtils.mkdir_p lp1
|
2020-06-10 13:46:05 -04:00
|
|
|
File.open(foo1, "w") {|f| f.write "class Object; HELLO = 'foo1' end" }
|
2020-05-21 09:20:57 -04:00
|
|
|
|
|
|
|
lp = $LOAD_PATH.dup
|
|
|
|
|
|
|
|
$LOAD_PATH.unshift lp1
|
|
|
|
assert_require "foo"
|
|
|
|
assert_equal "foo1", ::Object::HELLO
|
|
|
|
|
|
|
|
lp2 = File.join dir, "foo2"
|
|
|
|
foo2 = File.join lp2, "foo.rb"
|
|
|
|
|
|
|
|
FileUtils.mkdir_p lp2
|
2020-06-10 13:46:05 -04:00
|
|
|
File.open(foo2, "w") {|f| f.write "class Object; HELLO = 'foo2' end" }
|
2020-05-21 09:20:57 -04:00
|
|
|
|
|
|
|
$LOAD_PATH.unshift lp2
|
|
|
|
refute_require "foo"
|
|
|
|
assert_equal "foo1", ::Object::HELLO
|
|
|
|
ensure
|
|
|
|
$LOAD_PATH.replace lp
|
|
|
|
Object.send :remove_const, :HELLO if Object.const_defined? :HELLO
|
|
|
|
end
|
|
|
|
|
2015-07-01 17:50:14 -04:00
|
|
|
# Providing -I on the commandline should always beat gems
|
|
|
|
def test_dash_i_beats_gems
|
2022-05-20 04:15:15 -04:00
|
|
|
a1 = util_spec "a", "1", { "b" => "= 1" }, "lib/test_gem_require_a.rb"
|
|
|
|
b1 = util_spec "b", "1", { "c" => "> 0" }, "lib/b/c.rb"
|
2018-05-30 09:01:35 -04:00
|
|
|
c1 = util_spec "c", "1", nil, "lib/c/c.rb"
|
|
|
|
c2 = util_spec "c", "2", nil, "lib/c/c.rb"
|
2015-07-01 17:50:14 -04:00
|
|
|
|
|
|
|
install_specs c1, c2, b1, a1
|
|
|
|
|
2016-01-26 23:11:53 -05:00
|
|
|
dir = Dir.mktmpdir("test_require", @tempdir)
|
2015-07-01 17:50:14 -04:00
|
|
|
dash_i_arg = File.join dir, "lib"
|
|
|
|
|
|
|
|
c_rb = File.join dash_i_arg, "b", "c.rb"
|
|
|
|
|
|
|
|
FileUtils.mkdir_p File.dirname c_rb
|
2020-06-10 13:46:05 -04:00
|
|
|
File.open(c_rb, "w") {|f| f.write "class Object; HELLO = 'world' end" }
|
2015-07-01 17:50:14 -04:00
|
|
|
|
|
|
|
# Pretend to provide a commandline argument that overrides a file in gem b
|
|
|
|
$LOAD_PATH.unshift dash_i_arg
|
|
|
|
|
|
|
|
assert_require "test_gem_require_a"
|
|
|
|
assert_require "b/c" # this should be required from -I
|
|
|
|
assert_equal "world", ::Object::HELLO
|
2020-03-24 14:51:43 -04:00
|
|
|
assert_equal %w[a-1 b-1], loaded_spec_names
|
2015-07-01 17:50:14 -04:00
|
|
|
ensure
|
|
|
|
Object.send :remove_const, :HELLO if Object.const_defined? :HELLO
|
|
|
|
end
|
|
|
|
|
2017-12-27 09:50:49 -05:00
|
|
|
def create_sync_thread
|
|
|
|
Thread.new do
|
2018-02-05 21:58:35 -05:00
|
|
|
begin
|
|
|
|
yield
|
|
|
|
ensure
|
|
|
|
FILE_ENTERED_LATCH.release
|
|
|
|
FILE_EXIT_LATCH.await
|
|
|
|
end
|
2017-12-27 09:50:49 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2019-08-16 19:54:05 -04:00
|
|
|
# Providing -I on the commandline should always beat gems
|
|
|
|
def test_dash_i_beats_default_gems
|
2022-05-20 04:15:15 -04:00
|
|
|
a1 = new_default_spec "a", "1", { "b" => "= 1" }, "test_gem_require_a.rb"
|
|
|
|
b1 = new_default_spec "b", "1", { "c" => "> 0" }, "b/c.rb"
|
2019-08-16 19:54:05 -04:00
|
|
|
c1 = new_default_spec "c", "1", nil, "c/c.rb"
|
|
|
|
c2 = new_default_spec "c", "2", nil, "c/c.rb"
|
|
|
|
|
2020-12-08 02:33:39 -05:00
|
|
|
install_default_gems c1, c2, b1, a1
|
2019-08-16 19:54:05 -04:00
|
|
|
|
|
|
|
dir = Dir.mktmpdir("test_require", @tempdir)
|
|
|
|
dash_i_arg = File.join dir, "lib"
|
|
|
|
|
|
|
|
c_rb = File.join dash_i_arg, "c", "c.rb"
|
|
|
|
|
|
|
|
FileUtils.mkdir_p File.dirname c_rb
|
2020-06-10 13:46:05 -04:00
|
|
|
File.open(c_rb, "w") {|f| f.write "class Object; HELLO = 'world' end" }
|
2019-08-16 19:54:05 -04:00
|
|
|
|
|
|
|
assert_require "test_gem_require_a"
|
|
|
|
|
|
|
|
# Pretend to provide a commandline argument that overrides a file in gem b
|
|
|
|
$LOAD_PATH.unshift dash_i_arg
|
|
|
|
|
|
|
|
assert_require "b/c"
|
|
|
|
assert_require "c/c" # this should be required from -I
|
|
|
|
assert_equal "world", ::Object::HELLO
|
2020-03-24 14:51:43 -04:00
|
|
|
assert_equal %w[a-1 b-1], loaded_spec_names
|
2019-08-16 19:54:05 -04:00
|
|
|
ensure
|
|
|
|
Object.send :remove_const, :HELLO if Object.const_defined? :HELLO
|
|
|
|
end
|
|
|
|
|
2020-03-24 02:39:24 -04:00
|
|
|
def test_dash_i_respects_default_library_extension_priority
|
2021-05-10 23:27:07 -04:00
|
|
|
pend "extensions don't quite work on jruby" if Gem.java_platform?
|
|
|
|
pend "not installed yet" unless RbConfig::TOPDIR
|
2020-03-24 02:39:24 -04:00
|
|
|
|
|
|
|
dash_i_ext_arg = util_install_extension_file("a")
|
|
|
|
dash_i_lib_arg = util_install_ruby_file("a")
|
|
|
|
|
2020-02-17 08:02:17 -05:00
|
|
|
$LOAD_PATH.unshift dash_i_lib_arg
|
|
|
|
$LOAD_PATH.unshift dash_i_ext_arg
|
|
|
|
assert_require "a"
|
|
|
|
assert_match(/a\.rb$/, $LOADED_FEATURES.last)
|
2020-03-24 02:39:24 -04:00
|
|
|
end
|
|
|
|
|
2014-09-13 23:30:02 -04:00
|
|
|
def test_concurrent_require
|
|
|
|
Object.const_set :FILE_ENTERED_LATCH, Latch.new(2)
|
|
|
|
Object.const_set :FILE_EXIT_LATCH, Latch.new(1)
|
|
|
|
|
2019-12-10 04:31:01 -05:00
|
|
|
a1 = util_spec "a#{$$}", "1", nil, "lib/a#{$$}.rb"
|
|
|
|
b1 = util_spec "b#{$$}", "1", nil, "lib/b#{$$}.rb"
|
2014-09-13 23:30:02 -04:00
|
|
|
|
|
|
|
install_specs a1, b1
|
|
|
|
|
2022-05-20 04:15:15 -04:00
|
|
|
t1 = create_sync_thread { assert_require "a#{$$}" }
|
|
|
|
t2 = create_sync_thread { assert_require "b#{$$}" }
|
2014-09-13 23:30:02 -04:00
|
|
|
|
|
|
|
# wait until both files are waiting on the exit latch
|
|
|
|
FILE_ENTERED_LATCH.await
|
|
|
|
|
|
|
|
# now let them finish
|
|
|
|
FILE_EXIT_LATCH.release
|
|
|
|
|
|
|
|
assert t1.join, "thread 1 should exit"
|
|
|
|
assert t2.join, "thread 2 should exit"
|
|
|
|
ensure
|
2018-02-05 21:58:35 -05:00
|
|
|
Object.send :remove_const, :FILE_ENTERED_LATCH if Object.const_defined? :FILE_ENTERED_LATCH
|
|
|
|
Object.send :remove_const, :FILE_EXIT_LATCH if Object.const_defined? :FILE_EXIT_LATCH
|
2014-09-13 23:30:02 -04:00
|
|
|
end
|
|
|
|
|
2012-11-29 01:52:18 -05:00
|
|
|
def test_require_is_not_lazy_with_exact_req
|
2022-05-20 04:15:15 -04:00
|
|
|
a1 = util_spec "a", "1", { "b" => "= 1" }, "lib/test_gem_require_a.rb"
|
2018-05-30 09:01:35 -04:00
|
|
|
b1 = util_spec "b", "1", nil, "lib/b/c.rb"
|
|
|
|
b2 = util_spec "b", "2", nil, "lib/b/c.rb"
|
2012-11-29 01:52:18 -05:00
|
|
|
|
2015-07-01 17:50:14 -04:00
|
|
|
install_specs b1, b2, a1
|
2012-11-29 01:52:18 -05:00
|
|
|
|
2015-07-01 17:50:14 -04:00
|
|
|
assert_require "test_gem_require_a"
|
2020-03-24 14:51:43 -04:00
|
|
|
assert_equal %w[a-1 b-1], loaded_spec_names
|
2015-07-01 17:50:14 -04:00
|
|
|
assert_equal unresolved_names, []
|
2012-11-29 01:52:18 -05:00
|
|
|
|
2015-07-01 17:50:14 -04:00
|
|
|
assert_require "b/c"
|
2020-03-24 14:51:43 -04:00
|
|
|
assert_equal %w[a-1 b-1], loaded_spec_names
|
2012-11-29 01:52:18 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
def test_require_is_lazy_with_inexact_req
|
2022-05-20 04:15:15 -04:00
|
|
|
a1 = util_spec "a", "1", { "b" => ">= 1" }, "lib/test_gem_require_a.rb"
|
2018-05-30 09:01:35 -04:00
|
|
|
b1 = util_spec "b", "1", nil, "lib/b/c.rb"
|
|
|
|
b2 = util_spec "b", "2", nil, "lib/b/c.rb"
|
2012-11-29 01:52:18 -05:00
|
|
|
|
2015-07-01 17:50:14 -04:00
|
|
|
install_specs b1, b2, a1
|
2012-11-29 01:52:18 -05:00
|
|
|
|
2015-07-01 17:50:14 -04:00
|
|
|
assert_require "test_gem_require_a"
|
2020-03-24 14:51:43 -04:00
|
|
|
assert_equal %w[a-1], loaded_spec_names
|
2015-07-01 17:50:14 -04:00
|
|
|
assert_equal unresolved_names, ["b (>= 1)"]
|
2012-11-29 01:52:18 -05:00
|
|
|
|
2015-07-01 17:50:14 -04:00
|
|
|
assert_require "b/c"
|
2020-03-24 14:51:43 -04:00
|
|
|
assert_equal %w[a-1 b-2], loaded_spec_names
|
2012-11-29 01:52:18 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
def test_require_is_not_lazy_with_one_possible
|
2022-05-20 04:15:15 -04:00
|
|
|
a1 = util_spec "a", "1", { "b" => ">= 1" }, "lib/test_gem_require_a.rb"
|
2018-05-30 09:01:35 -04:00
|
|
|
b1 = util_spec "b", "1", nil, "lib/b/c.rb"
|
2012-11-29 01:52:18 -05:00
|
|
|
|
2015-07-01 17:50:14 -04:00
|
|
|
install_specs b1, a1
|
2012-11-29 01:52:18 -05:00
|
|
|
|
2015-07-01 17:50:14 -04:00
|
|
|
assert_require "test_gem_require_a"
|
2020-03-24 14:51:43 -04:00
|
|
|
assert_equal %w[a-1 b-1], loaded_spec_names
|
2015-07-01 17:50:14 -04:00
|
|
|
assert_equal unresolved_names, []
|
2012-11-29 01:52:18 -05:00
|
|
|
|
2015-07-01 17:50:14 -04:00
|
|
|
assert_require "b/c"
|
2020-03-24 14:51:43 -04:00
|
|
|
assert_equal %w[a-1 b-1], loaded_spec_names
|
2012-11-29 01:52:18 -05:00
|
|
|
end
|
|
|
|
|
2013-10-15 20:14:16 -04:00
|
|
|
def test_require_can_use_a_pathname_object
|
2018-05-30 09:01:35 -04:00
|
|
|
a1 = util_spec "a", "1", nil, "lib/test_gem_require_a.rb"
|
2013-10-15 20:14:16 -04:00
|
|
|
|
|
|
|
install_specs a1
|
|
|
|
|
2015-07-01 17:50:14 -04:00
|
|
|
assert_require Pathname.new "test_gem_require_a"
|
2020-03-24 14:51:43 -04:00
|
|
|
assert_equal %w[a-1], loaded_spec_names
|
2015-07-01 17:50:14 -04:00
|
|
|
assert_equal unresolved_names, []
|
2013-10-15 20:14:16 -04:00
|
|
|
end
|
|
|
|
|
2012-11-29 01:52:18 -05:00
|
|
|
def test_activate_via_require_respects_loaded_files
|
2021-05-10 23:27:07 -04:00
|
|
|
pend "Not sure what's going on. If another spec creates a 'a' gem before
|
2019-06-01 05:45:11 -04:00
|
|
|
this test, somehow require will load the benchmark in b, and ignore that the
|
|
|
|
stdlib one is already in $LOADED_FEATURES?. Reproducible by running the
|
|
|
|
spaceship_specific_file test before this one" if java_platform?
|
2019-08-16 08:30:32 -04:00
|
|
|
|
2021-05-10 23:27:07 -04:00
|
|
|
pend "not installed yet" unless RbConfig::TOPDIR
|
2020-06-04 21:20:38 -04:00
|
|
|
|
2022-04-01 07:36:59 -04:00
|
|
|
lib_dir = File.expand_path("../lib", __dir__)
|
2020-06-04 21:20:06 -04:00
|
|
|
rubylibdir = File.realdirpath(RbConfig::CONFIG["rubylibdir"])
|
|
|
|
if rubylibdir == lib_dir
|
2020-04-22 15:20:06 -04:00
|
|
|
# testing in the ruby repository where RubyGems' lib/ == stdlib lib/
|
|
|
|
# In that case we want to move the stdlib lib/ to still be after b-2 in $LOAD_PATH
|
|
|
|
lp = $LOAD_PATH.dup
|
2019-08-16 08:30:32 -04:00
|
|
|
$LOAD_PATH.delete lib_dir
|
|
|
|
$LOAD_PATH.push lib_dir
|
2020-04-22 15:20:06 -04:00
|
|
|
load_path_changed = true
|
2019-08-16 08:30:32 -04:00
|
|
|
end
|
|
|
|
|
2020-04-22 15:23:14 -04:00
|
|
|
require "benchmark" # the stdlib
|
|
|
|
|
2022-05-20 04:15:15 -04:00
|
|
|
a1 = util_spec "a", "1", { "b" => ">= 1" }, "lib/test_gem_require_a.rb"
|
2018-05-30 09:01:35 -04:00
|
|
|
b1 = util_spec "b", "1", nil, "lib/benchmark.rb"
|
|
|
|
b2 = util_spec "b", "2", nil, "lib/benchmark.rb"
|
2012-11-29 01:52:18 -05:00
|
|
|
|
2015-07-01 17:50:14 -04:00
|
|
|
install_specs b1, b2, a1
|
2012-11-29 01:52:18 -05:00
|
|
|
|
2020-04-22 15:23:14 -04:00
|
|
|
# Activates a-1, but not b-1 and b-2
|
2019-04-03 09:06:29 -04:00
|
|
|
assert_require "test_gem_require_a"
|
2020-04-22 15:20:06 -04:00
|
|
|
assert_equal %w[a-1], loaded_spec_names
|
2020-04-22 15:23:14 -04:00
|
|
|
assert $LOAD_PATH.include? a1.load_paths[0]
|
|
|
|
refute $LOAD_PATH.include? b1.load_paths[0]
|
|
|
|
refute $LOAD_PATH.include? b2.load_paths[0]
|
|
|
|
|
2015-07-01 17:50:14 -04:00
|
|
|
assert_equal unresolved_names, ["b (>= 1)"]
|
2012-11-29 01:52:18 -05:00
|
|
|
|
2020-04-22 15:23:14 -04:00
|
|
|
# The require('benchmark') below will activate b-2. However, its
|
|
|
|
# lib/benchmark.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
|
|
|
|
# and that still exists in $LOAD_PATH (further down),
|
|
|
|
# and as a result #gem_original_require returns false.
|
|
|
|
refute require("benchmark"), "the benchmark stdlib should be recognized as already loaded"
|
2020-04-22 15:20:06 -04:00
|
|
|
|
2020-06-04 21:20:06 -04:00
|
|
|
assert_includes $LOAD_PATH, b2.load_paths[0]
|
|
|
|
assert_includes $LOAD_PATH, rubylibdir
|
|
|
|
message = proc {
|
|
|
|
"this test relies on the b-2 gem lib/ to be before stdlib to make sense\n" +
|
2022-08-08 22:16:07 -04:00
|
|
|
$LOAD_PATH.pretty_inspect
|
2020-06-04 21:20:06 -04:00
|
|
|
}
|
|
|
|
assert_operator $LOAD_PATH.index(b2.load_paths[0]), :<, $LOAD_PATH.index(rubylibdir), message
|
2012-11-29 01:52:18 -05:00
|
|
|
|
2015-07-01 17:50:14 -04:00
|
|
|
# We detected that we should activate b-2, so we did so, but
|
2020-04-22 15:23:14 -04:00
|
|
|
# then #gem_original_require decided "I've already got some benchmark.rb" loaded.
|
|
|
|
# This case is fine because our lazy loading provided exactly
|
2015-07-01 17:50:14 -04:00
|
|
|
# the same behavior as eager loading would have.
|
2012-11-29 01:52:18 -05:00
|
|
|
|
2020-03-24 14:51:43 -04:00
|
|
|
assert_equal %w[a-1 b-2], loaded_spec_names
|
2019-08-16 08:30:32 -04:00
|
|
|
ensure
|
2020-04-22 15:20:06 -04:00
|
|
|
$LOAD_PATH.replace lp if load_path_changed
|
2012-11-29 01:52:18 -05:00
|
|
|
end
|
|
|
|
|
2020-03-25 10:55:16 -04:00
|
|
|
def test_activate_via_require_respects_loaded_default_from_default_gems
|
|
|
|
a1 = new_default_spec "a", "1", nil, "a.rb"
|
|
|
|
|
|
|
|
# simulate requiring a default gem before rubygems is loaded
|
|
|
|
Kernel.send(:gem_original_require, "a")
|
|
|
|
|
|
|
|
# simulate registering default specs on loading rubygems
|
|
|
|
install_default_gems a1
|
|
|
|
|
|
|
|
a2 = util_spec "a", "2", nil, "lib/a.rb"
|
|
|
|
|
|
|
|
install_specs a2
|
|
|
|
|
|
|
|
refute_require "a"
|
|
|
|
|
|
|
|
assert_equal %w[a-1], loaded_spec_names
|
|
|
|
end
|
|
|
|
|
2012-11-29 01:52:18 -05:00
|
|
|
def test_already_activated_direct_conflict
|
2018-05-30 09:01:35 -04:00
|
|
|
a1 = util_spec "a", "1", { "b" => "> 0" }
|
|
|
|
b1 = util_spec "b", "1", { "c" => ">= 1" }, "lib/ib.rb"
|
|
|
|
b2 = util_spec "b", "2", { "c" => ">= 2" }, "lib/ib.rb"
|
|
|
|
c1 = util_spec "c", "1", nil, "lib/d.rb"
|
|
|
|
c2 = util_spec("c", "2", nil, "lib/d.rb")
|
2012-11-29 01:52:18 -05:00
|
|
|
|
2015-07-01 17:50:14 -04:00
|
|
|
install_specs c1, c2, b1, b2, a1
|
2012-11-29 01:52:18 -05:00
|
|
|
|
2015-07-01 17:50:14 -04:00
|
|
|
a1.activate
|
|
|
|
c1.activate
|
2020-03-24 14:51:43 -04:00
|
|
|
assert_equal %w[a-1 c-1], loaded_spec_names
|
2015-07-01 17:50:14 -04:00
|
|
|
assert_equal ["b (> 0)"], unresolved_names
|
2012-11-29 01:52:18 -05:00
|
|
|
|
2015-07-01 17:50:14 -04:00
|
|
|
assert require("ib")
|
2012-11-29 01:52:18 -05:00
|
|
|
|
2020-03-24 14:51:43 -04:00
|
|
|
assert_equal %w[a-1 b-1 c-1], loaded_spec_names
|
2015-07-01 17:50:14 -04:00
|
|
|
assert_equal [], unresolved_names
|
2012-11-29 01:52:18 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
def test_multiple_gems_with_the_same_path
|
2018-05-30 09:01:35 -04:00
|
|
|
a1 = util_spec "a", "1", { "b" => "> 0", "x" => "> 0" }
|
|
|
|
b1 = util_spec "b", "1", { "c" => ">= 1" }, "lib/ib.rb"
|
|
|
|
b2 = util_spec "b", "2", { "c" => ">= 2" }, "lib/ib.rb"
|
|
|
|
x1 = util_spec "x", "1", nil, "lib/ib.rb"
|
|
|
|
x2 = util_spec "x", "2", nil, "lib/ib.rb"
|
|
|
|
c1 = util_spec "c", "1", nil, "lib/d.rb"
|
|
|
|
c2 = util_spec("c", "2", nil, "lib/d.rb")
|
2015-07-01 17:50:14 -04:00
|
|
|
|
|
|
|
install_specs c1, c2, x1, x2, b1, b2, a1
|
|
|
|
|
|
|
|
a1.activate
|
|
|
|
c1.activate
|
2020-03-24 14:51:43 -04:00
|
|
|
assert_equal %w[a-1 c-1], loaded_spec_names
|
2015-07-01 17:50:14 -04:00
|
|
|
assert_equal ["b (> 0)", "x (> 0)"], unresolved_names
|
|
|
|
|
2021-05-10 23:25:46 -04:00
|
|
|
e = assert_raise(Gem::LoadError) do
|
2015-07-01 17:50:14 -04:00
|
|
|
require("ib")
|
2012-11-29 01:52:18 -05:00
|
|
|
end
|
2015-07-01 17:50:14 -04:00
|
|
|
|
|
|
|
assert_equal "ib found in multiple gems: b, x", e.message
|
2012-11-29 01:52:18 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
def test_unable_to_find_good_unresolved_version
|
2018-05-30 09:01:35 -04:00
|
|
|
a1 = util_spec "a", "1", { "b" => "> 0" }
|
|
|
|
b1 = util_spec "b", "1", { "c" => ">= 2" }, "lib/ib.rb"
|
|
|
|
b2 = util_spec "b", "2", { "c" => ">= 3" }, "lib/ib.rb"
|
2012-11-29 01:52:18 -05:00
|
|
|
|
2018-05-30 09:01:35 -04:00
|
|
|
c1 = util_spec "c", "1", nil, "lib/d.rb"
|
|
|
|
c2 = util_spec "c", "2", nil, "lib/d.rb"
|
|
|
|
c3 = util_spec "c", "3", nil, "lib/d.rb"
|
2012-11-29 01:52:18 -05:00
|
|
|
|
2015-07-01 17:50:14 -04:00
|
|
|
install_specs c1, c2, c3, b1, b2, a1
|
2012-11-29 01:52:18 -05:00
|
|
|
|
2015-07-01 17:50:14 -04:00
|
|
|
a1.activate
|
|
|
|
c1.activate
|
2020-03-24 14:51:43 -04:00
|
|
|
assert_equal %w[a-1 c-1], loaded_spec_names
|
2015-07-01 17:50:14 -04:00
|
|
|
assert_equal ["b (> 0)"], unresolved_names
|
2012-11-29 01:52:18 -05:00
|
|
|
|
2021-05-10 23:25:46 -04:00
|
|
|
e = assert_raise(Gem::LoadError) do
|
2015-07-01 17:50:14 -04:00
|
|
|
require("ib")
|
2012-11-29 01:52:18 -05:00
|
|
|
end
|
2015-07-01 17:50:14 -04:00
|
|
|
|
|
|
|
assert_equal "unable to find a version of 'b' to activate", e.message
|
2012-11-29 01:52:18 -05:00
|
|
|
end
|
|
|
|
|
2015-10-29 20:54:12 -04:00
|
|
|
def test_require_works_after_cleanup
|
|
|
|
a1 = new_default_spec "a", "1.0", nil, "a/b.rb"
|
|
|
|
b1 = new_default_spec "b", "1.0", nil, "b/c.rb"
|
|
|
|
b2 = new_default_spec "b", "2.0", nil, "b/d.rb"
|
|
|
|
|
|
|
|
install_default_gems a1
|
|
|
|
install_default_gems b1
|
|
|
|
install_default_gems b2
|
|
|
|
|
|
|
|
# Load default ruby gems fresh as if we've just started a ruby script.
|
|
|
|
Gem::Specification.reset
|
|
|
|
require "rubygems"
|
|
|
|
Gem::Specification.stubs
|
|
|
|
|
|
|
|
# Remove an old default gem version directly from disk as if someone ran
|
|
|
|
# gem cleanup.
|
2020-12-08 02:33:39 -05:00
|
|
|
FileUtils.rm_rf(File.join @gemhome, "#{b1.full_name}")
|
|
|
|
FileUtils.rm_rf(File.join @gemhome, "specifications", "default", "#{b1.full_name}.gemspec")
|
2015-10-29 20:54:12 -04:00
|
|
|
|
|
|
|
# Require gems that have not been removed.
|
|
|
|
assert_require "a/b"
|
2020-03-24 14:51:43 -04:00
|
|
|
assert_equal %w[a-1.0], loaded_spec_names
|
2015-10-29 20:54:12 -04:00
|
|
|
assert_require "b/d"
|
2020-03-24 14:51:43 -04:00
|
|
|
assert_equal %w[a-1.0 b-2.0], loaded_spec_names
|
2015-10-29 20:54:12 -04:00
|
|
|
end
|
|
|
|
|
2015-11-19 01:16:19 -05:00
|
|
|
def test_require_doesnt_traverse_development_dependencies
|
2019-12-10 04:31:01 -05:00
|
|
|
a = util_spec("a#{$$}", "1", nil, "lib/a#{$$}.rb")
|
2018-05-30 09:01:35 -04:00
|
|
|
z = util_spec("z", "1", "w" => "> 0")
|
2020-06-10 13:46:05 -04:00
|
|
|
w1 = util_spec("w", "1") {|s| s.add_development_dependency "non-existent" }
|
|
|
|
w2 = util_spec("w", "2") {|s| s.add_development_dependency "non-existent" }
|
2015-11-19 01:16:19 -05:00
|
|
|
|
|
|
|
install_specs a, w1, w2, z
|
|
|
|
|
|
|
|
assert gem("z")
|
2020-03-24 14:51:43 -04:00
|
|
|
assert_equal %w[z-1], loaded_spec_names
|
2015-11-19 01:16:19 -05:00
|
|
|
assert_equal ["w (> 0)"], unresolved_names
|
|
|
|
|
2019-12-10 04:31:01 -05:00
|
|
|
assert require("a#{$$}")
|
2015-11-19 01:16:19 -05:00
|
|
|
end
|
|
|
|
|
2012-11-29 01:52:18 -05:00
|
|
|
def test_default_gem_only
|
2015-07-01 17:50:14 -04:00
|
|
|
default_gem_spec = new_default_spec("default", "2.0.0.0",
|
|
|
|
nil, "default/gem.rb")
|
2020-12-08 02:33:39 -05:00
|
|
|
install_default_gems(default_gem_spec)
|
2015-07-01 17:50:14 -04:00
|
|
|
assert_require "default/gem"
|
2020-03-24 14:51:43 -04:00
|
|
|
assert_equal %w[default-2.0.0.0], loaded_spec_names
|
2012-11-29 01:52:18 -05:00
|
|
|
end
|
|
|
|
|
2019-04-25 09:58:45 -04:00
|
|
|
def test_default_gem_require_activates_just_once
|
|
|
|
default_gem_spec = new_default_spec("default", "2.0.0.0",
|
|
|
|
nil, "default/gem.rb")
|
2020-12-08 02:33:39 -05:00
|
|
|
install_default_gems(default_gem_spec)
|
2019-04-25 09:58:45 -04:00
|
|
|
|
|
|
|
assert_require "default/gem"
|
|
|
|
|
|
|
|
times_called = 0
|
|
|
|
|
|
|
|
Kernel.stub(:gem, ->(name, requirement) { times_called += 1 }) do
|
|
|
|
refute_require "default/gem"
|
|
|
|
end
|
|
|
|
|
|
|
|
assert_equal 0, times_called
|
|
|
|
end
|
|
|
|
|
2020-05-19 08:00:00 -04:00
|
|
|
def test_second_gem_require_does_not_resolve_path_manually_before_going_through_standard_require
|
|
|
|
a1 = util_spec "a", "1", nil, "lib/test_gem_require_a.rb"
|
|
|
|
install_gem a1
|
|
|
|
|
|
|
|
assert_require "test_gem_require_a"
|
|
|
|
|
|
|
|
stub(:gem_original_require, ->(path) { assert_equal "test_gem_require_a", path }) do
|
|
|
|
require "test_gem_require_a"
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2017-09-11 05:44:29 -04:00
|
|
|
def test_realworld_default_gem
|
2022-06-23 05:22:36 -04:00
|
|
|
omit "this test can't work under ruby-core setup" if ruby_repo?
|
2017-09-11 05:44:29 -04:00
|
|
|
|
|
|
|
cmd = <<-RUBY
|
|
|
|
$stderr = $stdout
|
|
|
|
require "json"
|
2019-12-13 06:19:08 -05:00
|
|
|
puts Gem.loaded_specs["json"]
|
2017-09-11 05:44:29 -04:00
|
|
|
RUBY
|
2020-04-08 15:14:27 -04:00
|
|
|
output = Gem::Util.popen(*ruby_with_rubygems_in_load_path, "-e", cmd).strip
|
2020-05-09 06:40:57 -04:00
|
|
|
assert $?.success?
|
2019-12-13 06:19:08 -05:00
|
|
|
refute_empty output
|
2017-09-11 05:44:29 -04:00
|
|
|
end
|
|
|
|
|
2020-05-09 06:40:57 -04:00
|
|
|
def test_realworld_upgraded_default_gem
|
2022-06-23 05:22:36 -04:00
|
|
|
omit "this test can't work under ruby-core setup" if ruby_repo?
|
2020-05-09 06:40:57 -04:00
|
|
|
|
|
|
|
newer_json = util_spec("json", "999.99.9", nil, ["lib/json.rb"])
|
|
|
|
install_gem newer_json
|
|
|
|
|
2020-05-09 07:10:17 -04:00
|
|
|
path = "#{@tempdir}/test_realworld_upgraded_default_gem.rb"
|
|
|
|
code = <<-RUBY
|
2020-05-09 06:40:57 -04:00
|
|
|
$stderr = $stdout
|
|
|
|
require "json"
|
|
|
|
puts Gem.loaded_specs["json"].version
|
|
|
|
puts $LOADED_FEATURES
|
|
|
|
RUBY
|
2020-05-09 07:10:17 -04:00
|
|
|
File.write(path, code)
|
|
|
|
|
|
|
|
output = Gem::Util.popen({ "GEM_HOME" => @gemhome }, *ruby_with_rubygems_in_load_path, path).strip
|
2020-05-09 06:40:57 -04:00
|
|
|
assert $?.success?
|
|
|
|
refute_empty output
|
|
|
|
assert_equal "999.99.9", output.lines[0].chomp
|
|
|
|
# Make sure only files from the newer json gem are loaded, and no files from the default json gem
|
|
|
|
assert_equal ["#{@gemhome}/gems/json-999.99.9/lib/json.rb"], output.lines.grep(%r{/gems/json-}).map(&:chomp)
|
|
|
|
end
|
|
|
|
|
2012-11-29 01:52:18 -05:00
|
|
|
def test_default_gem_and_normal_gem
|
2015-07-01 17:50:14 -04:00
|
|
|
default_gem_spec = new_default_spec("default", "2.0.0.0",
|
|
|
|
nil, "default/gem.rb")
|
2020-12-08 02:33:39 -05:00
|
|
|
install_default_gems(default_gem_spec)
|
2018-05-30 09:01:35 -04:00
|
|
|
normal_gem_spec = util_spec("default", "3.0", nil,
|
2015-07-01 17:50:14 -04:00
|
|
|
"lib/default/gem.rb")
|
|
|
|
install_specs(normal_gem_spec)
|
|
|
|
assert_require "default/gem"
|
2020-03-24 14:51:43 -04:00
|
|
|
assert_equal %w[default-3.0], loaded_spec_names
|
2012-11-29 01:52:18 -05:00
|
|
|
end
|
|
|
|
|
2020-05-25 20:34:56 -04:00
|
|
|
def test_normal_gems_with_overridden_load_error_message
|
|
|
|
normal_gem_spec = util_spec("normal", "3.0", nil, "lib/normal/gem.rb")
|
|
|
|
|
|
|
|
install_specs(normal_gem_spec)
|
|
|
|
|
|
|
|
File.write("require_with_overridden_load_error_message.rb", <<-RUBY)
|
|
|
|
LoadError.class_eval do
|
|
|
|
def message
|
|
|
|
"Overridden message"
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
require 'normal/gem'
|
|
|
|
RUBY
|
|
|
|
|
|
|
|
require "open3"
|
|
|
|
|
|
|
|
output, exit_status = Open3.capture2e(
|
|
|
|
{ "GEM_HOME" => Gem.paths.home },
|
|
|
|
*ruby_with_rubygems_in_load_path,
|
|
|
|
"-r",
|
|
|
|
"./require_with_overridden_load_error_message.rb"
|
|
|
|
)
|
|
|
|
|
|
|
|
assert exit_status.success?, "Require failed due to #{output}"
|
|
|
|
end
|
|
|
|
|
2019-04-26 07:26:21 -04:00
|
|
|
def test_default_gem_prerelease
|
|
|
|
default_gem_spec = new_default_spec("default", "2.0.0",
|
|
|
|
nil, "default/gem.rb")
|
2020-12-08 02:33:39 -05:00
|
|
|
install_default_gems(default_gem_spec)
|
2019-04-26 07:26:21 -04:00
|
|
|
|
|
|
|
normal_gem_higher_prerelease_spec = util_spec("default", "3.0.0.rc2", nil,
|
|
|
|
"lib/default/gem.rb")
|
2020-12-08 02:33:39 -05:00
|
|
|
install_default_gems(normal_gem_higher_prerelease_spec)
|
2019-04-26 07:26:21 -04:00
|
|
|
|
|
|
|
assert_require "default/gem"
|
2020-03-24 14:51:43 -04:00
|
|
|
assert_equal %w[default-3.0.0.rc2], loaded_spec_names
|
2019-04-26 07:26:21 -04:00
|
|
|
end
|
|
|
|
|
2012-11-29 01:52:18 -05:00
|
|
|
def loaded_spec_names
|
|
|
|
Gem.loaded_specs.values.map(&:full_name).sort
|
|
|
|
end
|
|
|
|
|
|
|
|
def unresolved_names
|
|
|
|
Gem::Specification.unresolved_deps.values.map(&:to_s).sort
|
|
|
|
end
|
2016-03-27 22:26:39 -04:00
|
|
|
|
|
|
|
def test_try_activate_error_unlocks_require_monitor
|
|
|
|
silence_warnings do
|
|
|
|
class << ::Gem
|
|
|
|
alias old_try_activate try_activate
|
|
|
|
def try_activate(*); raise "raised from try_activate"; end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
require "does_not_exist_for_try_activate_test"
|
|
|
|
rescue RuntimeError => e
|
|
|
|
assert_match(/raised from try_activate/, e.message)
|
|
|
|
assert Kernel::RUBYGEMS_ACTIVATION_MONITOR.try_enter, "require monitor was not unlocked when try_activate raised"
|
|
|
|
ensure
|
|
|
|
silence_warnings do
|
|
|
|
class << ::Gem
|
|
|
|
alias try_activate old_try_activate
|
|
|
|
end
|
|
|
|
end
|
|
|
|
Kernel::RUBYGEMS_ACTIVATION_MONITOR.exit
|
|
|
|
end
|
|
|
|
|
2017-01-23 21:38:57 -05:00
|
|
|
def test_require_when_gem_defined
|
|
|
|
default_gem_spec = new_default_spec("default", "2.0.0.0",
|
|
|
|
nil, "default/gem.rb")
|
2020-12-08 02:33:39 -05:00
|
|
|
install_default_gems(default_gem_spec)
|
2017-01-23 21:38:57 -05:00
|
|
|
c = Class.new do
|
|
|
|
def self.gem(*args)
|
|
|
|
raise "received #gem with #{args.inspect}"
|
|
|
|
end
|
|
|
|
end
|
|
|
|
assert c.send(:require, "default/gem")
|
2020-03-24 14:51:43 -04:00
|
|
|
assert_equal %w[default-2.0.0.0], loaded_spec_names
|
2017-01-23 21:38:57 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
def test_require_default_when_gem_defined
|
2019-12-10 04:31:01 -05:00
|
|
|
a = util_spec("a#{$$}", "1", nil, "lib/a#{$$}.rb")
|
2017-01-23 21:38:57 -05:00
|
|
|
install_specs a
|
|
|
|
c = Class.new do
|
|
|
|
def self.gem(*args)
|
|
|
|
raise "received #gem with #{args.inspect}"
|
|
|
|
end
|
|
|
|
end
|
2019-12-10 04:31:01 -05:00
|
|
|
assert c.send(:require, "a#{$$}")
|
2020-03-24 14:51:43 -04:00
|
|
|
assert_equal %W[a#{$$}-1], loaded_spec_names
|
2017-01-23 21:38:57 -05:00
|
|
|
end
|
|
|
|
|
2017-10-07 21:32:18 -04:00
|
|
|
def test_require_bundler
|
2018-05-30 09:01:35 -04:00
|
|
|
b1 = util_spec("bundler", "1", nil, "lib/bundler/setup.rb")
|
|
|
|
b2a = util_spec("bundler", "2.a", nil, "lib/bundler/setup.rb")
|
2017-10-07 21:32:18 -04:00
|
|
|
install_specs b1, b2a
|
|
|
|
|
|
|
|
require "rubygems/bundler_version_finder"
|
|
|
|
$:.clear
|
|
|
|
assert_require "bundler/setup"
|
|
|
|
assert_equal %w[bundler-2.a], loaded_spec_names
|
|
|
|
assert_empty unresolved_names
|
|
|
|
end
|
|
|
|
|
2019-12-13 06:19:08 -05:00
|
|
|
# uplevel is 2.5+ only
|
|
|
|
if RUBY_VERSION >= "2.5"
|
|
|
|
["", "Kernel."].each do |prefix|
|
|
|
|
define_method "test_no_kernel_require_in_#{prefix.tr(".", "_")}warn_with_uplevel" do
|
|
|
|
Dir.mktmpdir("warn_test") do |dir|
|
|
|
|
File.write(dir + "/sub.rb", "#{prefix}warn 'uplevel', 'test', uplevel: 1\n")
|
|
|
|
File.write(dir + "/main.rb", "require 'sub'\n")
|
|
|
|
_, err = capture_subprocess_io do
|
2020-04-22 14:13:30 -04:00
|
|
|
system(*ruby_with_rubygems_in_load_path, "-w", "--disable=gems", "-C", dir, "-I", dir, "main.rb")
|
2019-12-13 06:19:08 -05:00
|
|
|
end
|
|
|
|
assert_match(/main\.rb:1: warning: uplevel\ntest\n$/, err)
|
|
|
|
_, err = capture_subprocess_io do
|
2020-04-22 14:13:30 -04:00
|
|
|
system(*ruby_with_rubygems_in_load_path, "-w", "--enable=gems", "-C", dir, "-I", dir, "main.rb")
|
2019-12-13 06:19:08 -05:00
|
|
|
end
|
|
|
|
assert_match(/main\.rb:1: warning: uplevel\ntest\n$/, err)
|
2018-09-24 10:26:00 -04:00
|
|
|
end
|
|
|
|
end
|
2019-09-12 03:44:22 -04:00
|
|
|
|
2019-12-13 06:19:08 -05:00
|
|
|
define_method "test_no_other_behavioral_changes_with_#{prefix.tr(".", "_")}warn" do
|
|
|
|
Dir.mktmpdir("warn_test") do |dir|
|
2020-03-24 02:39:24 -04:00
|
|
|
File.write(dir + "/main.rb", "#{prefix}warn({x:1}, {y:2}, [])\n")
|
2019-12-13 06:19:08 -05:00
|
|
|
_, err = capture_subprocess_io do
|
2020-04-08 15:14:27 -04:00
|
|
|
system(*ruby_with_rubygems_in_load_path, "-w", "--disable=gems", "-C", dir, "main.rb")
|
2019-12-13 06:19:08 -05:00
|
|
|
end
|
2020-03-24 02:39:24 -04:00
|
|
|
assert_match(/{:x=>1}\n{:y=>2}\n$/, err)
|
2019-12-13 06:19:08 -05:00
|
|
|
_, err = capture_subprocess_io do
|
2020-04-08 15:14:27 -04:00
|
|
|
system(*ruby_with_rubygems_in_load_path, "-w", "--enable=gems", "-C", dir, "main.rb")
|
2019-12-13 06:19:08 -05:00
|
|
|
end
|
2020-03-24 02:39:24 -04:00
|
|
|
assert_match(/{:x=>1}\n{:y=>2}\n$/, err)
|
2019-09-12 03:44:22 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2020-12-08 02:33:39 -05:00
|
|
|
|
|
|
|
def test_no_crash_when_overriding_warn_with_warning_module
|
|
|
|
Dir.mktmpdir("warn_test") do |dir|
|
|
|
|
File.write(dir + "/main.rb", "module Warning; def warn(str); super; end; end; warn 'Foo Bar'")
|
|
|
|
_, err = capture_subprocess_io do
|
|
|
|
system(*ruby_with_rubygems_in_load_path, "-w", "--disable=gems", "-C", dir, "main.rb")
|
|
|
|
end
|
|
|
|
assert_match(/Foo Bar\n$/, err)
|
|
|
|
_, err = capture_subprocess_io do
|
|
|
|
system(*ruby_with_rubygems_in_load_path, "-w", "--enable=gems", "-C", dir, "main.rb")
|
|
|
|
end
|
|
|
|
assert_match(/Foo Bar\n$/, err)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def test_expected_backtrace_location_when_inheriting_from_basic_object_and_including_kernel
|
|
|
|
Dir.mktmpdir("warn_test") do |dir|
|
|
|
|
File.write(dir + "/main.rb", "\nrequire 'sub'\n")
|
|
|
|
File.write(dir + "/sub.rb", <<-'RUBY')
|
|
|
|
require 'rubygems'
|
|
|
|
class C < BasicObject
|
|
|
|
include ::Kernel
|
|
|
|
def deprecated
|
|
|
|
warn "This is a deprecated method", uplevel: 2
|
|
|
|
end
|
|
|
|
end
|
|
|
|
C.new.deprecated
|
|
|
|
RUBY
|
|
|
|
|
|
|
|
_, err = capture_subprocess_io do
|
|
|
|
system(*ruby_with_rubygems_in_load_path, "-w", "--disable=gems", "-C", dir, "-I", dir, "main.rb")
|
|
|
|
end
|
|
|
|
assert_match(/main\.rb:2: warning: This is a deprecated method$/, err)
|
|
|
|
_, err = capture_subprocess_io do
|
|
|
|
system(*ruby_with_rubygems_in_load_path, "-w", "--enable=gems", "-C", dir, "-I", dir, "main.rb")
|
|
|
|
end
|
|
|
|
assert_match(/main\.rb:2: warning: This is a deprecated method$/, err)
|
|
|
|
end
|
|
|
|
end
|
2018-09-24 10:26:00 -04:00
|
|
|
end
|
|
|
|
|
2020-02-04 11:25:56 -05:00
|
|
|
private
|
|
|
|
|
2020-03-24 02:39:24 -04:00
|
|
|
def util_install_extension_file(name)
|
|
|
|
spec = quick_gem name
|
|
|
|
util_build_gem spec
|
|
|
|
|
|
|
|
spec.extensions << "extconf.rb"
|
|
|
|
write_file File.join(@tempdir, "extconf.rb") do |io|
|
|
|
|
io.write <<-RUBY
|
|
|
|
require "mkmf"
|
|
|
|
CONFIG['LDSHARED'] = '$(TOUCH) $@ ||'
|
|
|
|
create_makefile("#{name}")
|
|
|
|
RUBY
|
|
|
|
end
|
|
|
|
|
|
|
|
write_file File.join(@tempdir, "#{name}.c") do |io|
|
|
|
|
io.write <<-C
|
|
|
|
void Init_#{name}() { }
|
|
|
|
C
|
|
|
|
end
|
|
|
|
|
|
|
|
write_file File.join(@tempdir, "depend")
|
|
|
|
|
|
|
|
spec.files += ["extconf.rb", "depend", "#{name}.c"]
|
|
|
|
|
|
|
|
so = File.join(spec.gem_dir, "#{name}.#{RbConfig::CONFIG["DLEXT"]}")
|
2020-05-25 08:05:45 -04:00
|
|
|
assert_path_not_exist so
|
2020-03-24 02:39:24 -04:00
|
|
|
|
|
|
|
path = Gem::Package.build spec
|
|
|
|
installer = Gem::Installer.at path
|
|
|
|
installer.install
|
2020-05-25 08:05:45 -04:00
|
|
|
assert_path_exist so
|
2020-03-24 02:39:24 -04:00
|
|
|
|
|
|
|
spec.gem_dir
|
|
|
|
end
|
|
|
|
|
|
|
|
def util_install_ruby_file(name)
|
|
|
|
dir_lib = Dir.mktmpdir("test_require_lib", @tempdir)
|
|
|
|
dash_i_lib_arg = File.join dir_lib
|
|
|
|
|
|
|
|
a_rb = File.join dash_i_lib_arg, "#{name}.rb"
|
|
|
|
|
|
|
|
FileUtils.mkdir_p File.dirname a_rb
|
2020-06-10 13:46:05 -04:00
|
|
|
File.open(a_rb, "w") {|f| f.write "# #{name}.rb" }
|
2020-03-24 02:39:24 -04:00
|
|
|
|
|
|
|
dash_i_lib_arg
|
|
|
|
end
|
2012-11-29 01:52:18 -05:00
|
|
|
end
|