From 62350e2eee304922b2a1fd0a5e70bad7f75d3a27 Mon Sep 17 00:00:00 2001 From: Lars Kanis Date: Fri, 8 Nov 2024 13:19:12 +0100 Subject: [PATCH 1/4] Update ci.yml to corresponding ruby version for specs --- .github/workflows/ci.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 07918f53..5a3c3055 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -14,22 +14,22 @@ jobs: - target_ruby: "3.3.6" arch: "x86-msvcrt" build_ruby: "3.1.6/x64" - run_mri_spec: v3_3_3 + run_mri_spec: v3_3_6 - target_ruby: "3.3.6" arch: "x64-ucrt" build_ruby: "3.1.6/x64" - run_mri_spec: v3_3_3 + run_mri_spec: v3_3_6 - target_ruby: "3.2.6" arch: "x86-msvcrt" build_ruby: "3.1.6/x64" - run_mri_spec: v3_2_4 + run_mri_spec: v3_2_6 - target_ruby: "3.2.6" arch: "x64-ucrt" build_ruby: "3.1.6/x64" - run_mri_spec: v3_2_4 + run_mri_spec: v3_2_6 - target_ruby: "3.1.6" arch: "x86-msvcrt" From 1753d1788a33ed1cc8f3da4aae79e4116bd672f2 Mon Sep 17 00:00:00 2001 From: Lars Kanis Date: Fri, 8 Nov 2024 13:05:40 +0100 Subject: [PATCH 2/4] Use a better detection of bundle install and add a test case Fixes #396 --- resources/files/operating_system.rb | 2 +- test/helper/testgem/Gemfile | 2 ++ test/test_gem_install.rb | 37 +++++++++++++++++++++++------ 3 files changed, 33 insertions(+), 8 deletions(-) create mode 100644 test/helper/testgem/Gemfile 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/helper/testgem/Gemfile b/test/helper/testgem/Gemfile new file mode 100644 index 00000000..8033850c --- /dev/null +++ b/test/helper/testgem/Gemfile @@ -0,0 +1,2 @@ +source "https://dummy-url.nonexit" +gem "testgem", "1.0.0" diff --git a/test/test_gem_install.rb b/test/test_gem_install.rb index 141a67df..2c9187b7 100644 --- a/test/test_gem_install.rb +++ b/test/test_gem_install.rb @@ -3,12 +3,12 @@ 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 + 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 +27,24 @@ def test_gem_install FileUtils.rm("test/helper/testgem/testgem-1.0.0.gem") end + def test_bundle_install + remove_pacman_packages_for_test + FileUtils.mkdir_p "test/helper/testgem/vendor/cache" + res = system <<-EOT.gsub("\n", "&") + cd test/helper/testgem + gem build testgem.gemspec + copy /b 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" + FileUtils.rm("test/helper/testgem/testgem-1.0.0.gem") + end + if RUBY_VERSION < "3.0" TESTUSER = "ritestuser" else @@ -64,6 +82,13 @@ def with_test_user(testname: nil) end end + private def remove_pacman_packages_for_test + RubyInstaller::Runtime.msys2_installation.with_msys_apps_enabled do + system("pacman -R --noconfirm %MINGW_PACKAGE_PREFIX%-libmowgli %MINGW_PACKAGE_PREFIX%-libguess ed") + end + end + + def test_user_gem_install unless ENV['USERNAME'] == TESTUSER RubyInstaller::Runtime.msys2_installation.with_msys_apps_enabled do @@ -74,9 +99,7 @@ def test_user_gem_install test_gem_install end unless ENV['USERNAME'] == TESTUSER - RubyInstaller::Runtime.msys2_installation.with_msys_apps_enabled do - system("pacman -R --noconfirm %MINGW_PACKAGE_PREFIX%-libmowgli %MINGW_PACKAGE_PREFIX%-libguess ed") - end + remove_pacman_packages_for_test end end From 300543570d7ac9dda3473e2e3584b8da98a45166 Mon Sep 17 00:00:00 2001 From: Lars Kanis Date: Fri, 8 Nov 2024 22:32:38 +0100 Subject: [PATCH 3/4] Run rubyinstaller tests on codepage 437 to trigger issues caused by character conversions to and from utf-8 --- .github/workflows/ci.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 5a3c3055..87df1392 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -201,7 +201,9 @@ jobs: - name: Run all tests against the new installed Ruby shell: cmd - run: ridk exec rake test + run: | + chcp 437 + ridk exec rake test - name: Run upload to github (only on tag builds) shell: cmd From f1773011af13c405937472ac50bd23990508f13a Mon Sep 17 00:00:00 2001 From: Lars Kanis Date: Fri, 8 Nov 2024 23:09:19 +0100 Subject: [PATCH 4/4] Do not update the uri.gem to 1.x Because uri-1.x breaks ruby/spec on ruby < 3.4 like so: 1) URI::Parser#parse raises errors on malformed URIs FAILED Expected URI::InvalidURIError but no exception was raised (# was returned) D:/a/rubyinstaller2/rubyinstaller2/ruby/spec/ruby/library/uri/shared/parse.rb:196:in `block (2 levels) in ' D:/a/rubyinstaller2/rubyinstaller2/ruby/spec/ruby/library/uri/parser/parse_spec.rb:5:in `' --- Gemfile | 1 + 1 file changed, 1 insertion(+) diff --git a/Gemfile b/Gemfile index ddaad233..b32edb95 100644 --- a/Gemfile +++ b/Gemfile @@ -5,3 +5,4 @@ gemspec gem "octokit" gem "win32-process" +gem "uri", "~> 0.13"