From a07e7dc0764cb8cbc99d7394db9e759ad6c3c13f Mon Sep 17 00:00:00 2001 From: Lars Kanis Date: Fri, 8 Nov 2024 13:05:40 +0100 Subject: [PATCH] Use a better detection of bundle install and add a test case Fixes #396 --- resources/files/operating_system.rb | 2 +- test/test_gem_install.rb | 26 ++++++++++++++++++++++---- 2 files changed, 23 insertions(+), 5 deletions(-) diff --git a/resources/files/operating_system.rb b/resources/files/operating_system.rb index d75f0d8a..bcf58301 100644 --- a/resources/files/operating_system.rb +++ b/resources/files/operating_system.rb @@ -38,7 +38,7 @@ def operating_system_defaults RubyInstaller::Runtime.enable_msys_apps(for_gem_install: true) unless gem_installer.spec.extensions.empty? - if !gem_installer.options || !gem_installer.options[:ignore_dependencies] || gem_installer.options[:bundler_expected_checksum] + if !gem_installer.options || !gem_installer.options[:ignore_dependencies] || gem_installer.class.to_s.include?("Bundler") [['msys2_dependencies' , :install_packages ], ['msys2_mingw_dependencies', :install_mingw_packages]].each do |metakey, func| diff --git a/test/test_gem_install.rb b/test/test_gem_install.rb index 141a67df..44ae3861 100644 --- a/test/test_gem_install.rb +++ b/test/test_gem_install.rb @@ -3,12 +3,13 @@ class TestGemInstall < Minitest::Test # Remove installed packages per: - # pacman -R mingw-w64-ucrt-x86_64-libmowgli mingw-w64-ucrt-x86_64-libguess ed + # pacman -R %MINGW_PACKAGE_PREFIX%-libmowgli %MINGW_PACKAGE_PREFIX%-libguess ed def test_gem_install res = system <<-EOT.gsub("\n", "&") -cd test/helper/testgem -gem build testgem.gemspec -gem install testgem-1.0.0.gem --verbose + pacman -R --noconfirm %MINGW_PACKAGE_PREFIX%-libmowgli %MINGW_PACKAGE_PREFIX%-libguess ed 2>error.out + cd test/helper/testgem + gem build testgem.gemspec + gem install testgem-1.0.0.gem --verbose EOT assert res, "shell commands should succeed" @@ -27,6 +28,23 @@ def test_gem_install FileUtils.rm("test/helper/testgem/testgem-1.0.0.gem") end + def test_bundle_install + FileUtils.mkdir_p "test/helper/testgem/vendor/cache" + res = system <<-EOT.gsub("\n", "&") + pacman -R --noconfirm %MINGW_PACKAGE_PREFIX%-libmowgli %MINGW_PACKAGE_PREFIX%-libguess ed 2>error.out + cd test/helper/testgem + gem build testgem.gemspec + cp testgem-1.0.0.gem vendor/cache/ + bundle install --local + EOT + assert res, "shell commands should succeed" + + out = IO.popen("bundle exec ruby -rtestgem -e \"puts Libguess.determine_encoding('abc', 'Greek')\"", chdir: "test/helper/testgem", &:read) + assert_match(/UTF-8/, out.scrub, "call the ruby API of the testgem") + + assert system("gem uninstall testgem --executables --force"), "uninstall testgem" + end + if RUBY_VERSION < "3.0" TESTUSER = "ritestuser" else