diff --git a/lib/tebako/deploy_helper.rb b/lib/tebako/deploy_helper.rb index 39b197fb..edd0ade2 100644 --- a/lib/tebako/deploy_helper.rb +++ b/lib/tebako/deploy_helper.rb @@ -25,6 +25,7 @@ # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE # POSSIBILITY OF SUCH DAMAGE. +# require "bundler" require "fileutils" require "find" @@ -92,7 +93,7 @@ def install_gem(name, ver = nil) params = [@gem_command, "install", name.to_s] params.push("-v", ver.to_s) if ver - ["--no-document", "--install-dir", @tgd].each do |param| + ["--no-document", "--install-dir", @tgd, "--bindir", @tbd].each do |param| params.push(param) end BuildHelpers.run_with_capture_v(params) @@ -146,6 +147,10 @@ def collect_and_deploy_gem(gemspec) copy_files(@pre_dir) Dir.chdir(@pre_dir) do + # spec = Bundler.load_gemspec(gemspec) + # puts spec.executables.first unless spec.executables.empty? + # puts spec.bindir + BuildHelpers.run_with_capture_v([@gem_command, "build", gemspec]) install_all_gems_or_fail end diff --git a/spec/deploy_helper_spec.rb b/spec/deploy_helper_spec.rb index 841efbf1..c2e6a46c 100644 --- a/spec/deploy_helper_spec.rb +++ b/spec/deploy_helper_spec.rb @@ -354,6 +354,7 @@ before do deploy_helper.instance_variable_set(:@tgd, "/path/to/tgd") + deploy_helper.instance_variable_set(:@tbd, "/path/to/tbd") deploy_helper.instance_variable_set(:@gem_command, gem_command) deploy_helper.instance_variable_set(:@bundler_command, bundler_command) allow(Open3).to receive(:capture2e).and_return(["", double("status", signaled?: false, exitstatus: 0)]) @@ -363,7 +364,7 @@ it "installs the gem with the specified version" do expect(Open3).to receive(:capture2e) .with(gem_command, "install", gem_name, "-v", gem_version, "--no-document", - "--install-dir", "/path/to/tgd") + "--install-dir", "/path/to/tgd", "--bindir", "/path/to/tbd") deploy_helper.install_gem(gem_name, gem_version) end end @@ -371,7 +372,8 @@ context "when gem version is not provided" do it "installs the gem without specifying the version" do expect(Open3).to receive(:capture2e) - .with(gem_command, "install", gem_name, "--no-document", "--install-dir", "/path/to/tgd") + .with(gem_command, "install", gem_name, "--no-document", + "--install-dir", "/path/to/tgd", "--bindir", "/path/to/tbd") deploy_helper.install_gem(gem_name) end end diff --git a/tests/scripts/functional-tests.sh b/tests/scripts/functional-tests.sh index c3a2948b..cea9daf1 100755 --- a/tests/scripts/functional-tests.sh +++ b/tests/scripts/functional-tests.sh @@ -250,6 +250,12 @@ test_tebako_press_04() { # 09. Ruby gem (xxx.gem, no gemspec, no gemfile) test_tebako_press_09() { echo "==> Ruby gem (xxx.gem, no gemspec, no gemfile)" + +# Use test-11 gemspec to build a test gem + pushd "${DIR_TESTS}/test-11" > /dev/null || fail "pushd ${DIR_TESTS}/test-11 failed" + gem build tebako-test.gemspec -o "${DIR_TESTS}/test-09/tebako-test-0.0.2.gem" + popd > /dev/null || fail "popd failed" + press_runner_"${MODE}" "${DIR_TESTS}/test-09" "tebako-test-run.rb" "test-09-package" package_runner_"${MODE}" "./test-09-package" "| a1 | b1 |" } @@ -263,6 +269,8 @@ test_tebako_press_10() { else rc=106 fi + +# Use gem built for test-09 press_runner_with_error_"${MODE}" "${DIR_TESTS}/test-09" \ "test-does-not-exist.rb" \ "test-10-package" \ diff --git a/tests/test-01/tebako-test-run.rb b/tests/test-01/tebako-test-run.rb index 01a7385b..c2b5051d 100755 --- a/tests/test-01/tebako-test-run.rb +++ b/tests/test-01/tebako-test-run.rb @@ -3,7 +3,7 @@ puts "Hello! This is test-01 talking from inside DwarFS" puts "Gem path: #{Gem.path}" -puts "Rubygems version: #{Gem::rubygems_version}" +puts "Rubygems version: #{Gem.rubygems_version}" if defined?(TebakoRuntime::VERSION) puts "Using tebako-runtime v#{TebakoRuntime::VERSION}" else diff --git a/tests/test-09/tebako-test-0.0.1.gem b/tests/test-09/tebako-test-0.0.1.gem deleted file mode 100644 index efce686c..00000000 Binary files a/tests/test-09/tebako-test-0.0.1.gem and /dev/null differ diff --git a/tests/test-09/tebako-test-0.0.2.gem b/tests/test-09/tebako-test-0.0.2.gem new file mode 100644 index 00000000..c4d25c52 Binary files /dev/null and b/tests/test-09/tebako-test-0.0.2.gem differ diff --git a/tests/test-11/bin/tebako-test-run.rb b/tests/test-11/exe/tebako-test-run.rb similarity index 71% rename from tests/test-11/bin/tebako-test-run.rb rename to tests/test-11/exe/tebako-test-run.rb index 6d61c934..5482a254 100755 --- a/tests/test-11/bin/tebako-test-run.rb +++ b/tests/test-11/exe/tebako-test-run.rb @@ -4,7 +4,5 @@ $LOAD_PATH.unshift File.expand_path("../lib", __dir__) require "tebako-test" -begin - instance = TebakoTest.new - instance.run! -end +instance = Test::TebakoTest.new +instance.run diff --git a/tests/test-11/lib/tebako-test.rb b/tests/test-11/lib/tebako-test.rb index 501f567a..31a03d52 100644 --- a/tests/test-11/lib/tebako-test.rb +++ b/tests/test-11/lib/tebako-test.rb @@ -1,20 +1,26 @@ # frozen_string_literal: true require "text-table" +require_relative "version" -# Tebako test class -class TebakoTest - def msg - table = Text::Table.new - table.head = %w[A B] - table.rows = [%w[a1 b1]] - table.rows << %w[a2 b2] - puts table - end +module Test + # Tebako test class + class TebakoTest + def msg + table = Text::Table.new + table.head = %w[A B] + table.rows = [%w[a1 b1]] + table.rows << %w[a2 b2] + table + end + + def run + puts <<~MSG + Running packaged tebako-test gem version #{VERSION}. + You shall see a nice text table below. - def run! - puts "Hello! This is test-11 talking from inside DwarFS" - puts "You will now see a nice table that will be drawn for you by text-table gem." - msg + #{msg} + MSG + end end end diff --git a/tests/test-11/lib/version.rb b/tests/test-11/lib/version.rb new file mode 100644 index 00000000..3e8b0a2c --- /dev/null +++ b/tests/test-11/lib/version.rb @@ -0,0 +1,5 @@ +# frozen_string_literal: true + +module Test + VERSION = "0.0.2" +end diff --git a/tests/test-11/tebako-test.gemspec b/tests/test-11/tebako-test.gemspec index 89b60f1f..4519b444 100644 --- a/tests/test-11/tebako-test.gemspec +++ b/tests/test-11/tebako-test.gemspec @@ -1,15 +1,16 @@ # frozen_string_literal: true +require_relative "lib/version" Gem::Specification.new do |s| s.name = "tebako-test" - s.version = "0.0.1" + s.version = Test::VERSION s.summary = "A simple gem for tebako testing" s.authors = ["Ribose"] s.email = ["open.source@ribose.com"] - s.files = ["bin/tebako-test-run.rb", "lib/tebako-test.rb"] + s.files = Dir.glob("lib/**/*") + Dir.glob("exe/**/*") s.homepage = "https://github.com/tamitebako" s.license = "Unlicense" - s.bindir = "bin" + s.bindir = "exe" s.required_ruby_version = Gem::Requirement.new(">= 2.7.0") s.add_dependency "text-table", "~> 1.2.4" s.executables << "tebako-test-run.rb" diff --git a/tests/test-20/tebako-test-run.rb b/tests/test-20/tebako-test-run.rb index 68ab6969..12cac792 100644 --- a/tests/test-20/tebako-test-run.rb +++ b/tests/test-20/tebako-test-run.rb @@ -1,6 +1,5 @@ # frozen_string_literal: true - puts "Hello! This is test-20 talking from inside DwarFS" require "net/http"