SketchUp / testup-2

TestUp 2 for SketchUp - A GUI wrapper for running Minitest in SketchUp
MIT License
26 stars 37 forks source link

Error: #<Gem::Requirement::BadRequirementError: Illformed requirement [">=>= 0"]> on startup using -RubyStartupArgs setup #233

Closed Alex-Tsvetanov closed 5 months ago

Alex-Tsvetanov commented 5 months ago

The following line is causing Ruby Error on run_tests_without_gui: https://github.com/SketchUp/testup-2/blob/b5a28cd780977c2ccf8c13cc25025aa2e980fe48/src/testup/gem_helper.rb#L17

The fix would have to be applied for line 27 as well: https://github.com/SketchUp/testup-2/blob/b5a28cd780977c2ccf8c13cc25025aa2e980fe48/src/testup/gem_helper.rb#L27

The error is as follows:

Error: #<Gem::Requirement::BadRequirementError: Illformed requirement [">=>= 0"]>
/Applications/SketchUp 2023/SketchUp.app/Contents/Frameworks/Ruby.framework/Versions/2.7.1/lib/ruby/2.7.0/rubygems/requirement.rb:108:in `parse'
/Applications/SketchUp 2023/SketchUp.app/Contents/Frameworks/Ruby.framework/Versions/2.7.1/lib/ruby/2.7.0/rubygems/requirement.rb:140:in `block in initialize'
/Applications/SketchUp 2023/SketchUp.app/Contents/Frameworks/Ruby.framework/Versions/2.7.1/lib/ruby/2.7.0/rubygems/requirement.rb:140:in `map!'
/Applications/SketchUp 2023/SketchUp.app/Contents/Frameworks/Ruby.framework/Versions/2.7.1/lib/ruby/2.7.0/rubygems/requirement.rb:140:in `initialize'
/Applications/SketchUp 2023/SketchUp.app/Contents/Frameworks/Ruby.framework/Versions/2.7.1/lib/ruby/2.7.0/rubygems/requirement.rb:70:in `new'
/Applications/SketchUp 2023/SketchUp.app/Contents/Frameworks/Ruby.framework/Versions/2.7.1/lib/ruby/2.7.0/rubygems/requirement.rb:70:in `create'
/Applications/SketchUp 2023/SketchUp.app/Contents/Frameworks/Ruby.framework/Versions/2.7.1/lib/ruby/2.7.0/rubygems/dependency.rb:60:in `initialize'
/Applications/SketchUp 2023/SketchUp.app/Contents/Frameworks/Ruby.framework/Versions/2.7.1/lib/ruby/2.7.0/rubygems/core_ext/kernel_gem.rb:56:in `new'
/Applications/SketchUp 2023/SketchUp.app/Contents/Frameworks/Ruby.framework/Versions/2.7.1/lib/ruby/2.7.0/rubygems/core_ext/kernel_gem.rb:56:in `gem'
/Users/alextsvetanov/Library/Application Support/SketchUp 2023/SketchUp/Plugins/testup/gem_helper.rb:17:in `require'
<main>:in `<main>'
SketchUp:in `eval'

This is caused because the default value of the keyword argument version is Gem::Requirement.default which is #<Gem::Requirement:0x00000002bf5d7688 @requirements=[[">=", #<Gem::Version "0">]]>. Therefore when the ">=" is added manually on lines 17 and 27 it becomes ">=>= 0" which causes the error.

This is reproducible with the latest release (2.5.1 using the .rbz file) on both Sketchup 2023 and Sketchup 2024 using Ruby 2.7 and Ruby 3.2 respectively.

Found while running the testup-2 using -RubyStartupArgs setup from the ReadMe. Apparently run_tests_without_gui is being called and it reaches line 17 where it all goes down. Confirmed the source by doing TestUp::GemHelper.require('minitest-reporters-json_reporter', 'minitest/reporters/json_reporter') (as written here https://github.com/SketchUp/testup-2/blob/b5a28cd780977c2ccf8c13cc25025aa2e980fe48/src/testup/json_ci_reporter.rb#L13 required here https://github.com/SketchUp/testup-2/blob/b5a28cd780977c2ccf8c13cc25025aa2e980fe48/src/testup/api.rb#L49)

Alex-Tsvetanov commented 5 months ago

Original Ruby console logs on startup:

Error: #<Gem::Requirement::BadRequirementError: Illformed requirement [">=>= 0"]>
/Applications/SketchUp 2024/SketchUp.app/Contents/Frameworks/Ruby.framework/Versions/3.2.2/lib/ruby/3.2.0/rubygems/requirement.rb:106:in `parse'
/Applications/SketchUp 2024/SketchUp.app/Contents/Frameworks/Ruby.framework/Versions/3.2.2/lib/ruby/3.2.0/rubygems/requirement.rb:138:in `block in initialize'
/Applications/SketchUp 2024/SketchUp.app/Contents/Frameworks/Ruby.framework/Versions/3.2.2/lib/ruby/3.2.0/rubygems/requirement.rb:138:in `map!'
/Applications/SketchUp 2024/SketchUp.app/Contents/Frameworks/Ruby.framework/Versions/3.2.2/lib/ruby/3.2.0/rubygems/requirement.rb:138:in `initialize'
/Applications/SketchUp 2024/SketchUp.app/Contents/Frameworks/Ruby.framework/Versions/3.2.2/lib/ruby/3.2.0/rubygems/requirement.rb:68:in `new'
/Applications/SketchUp 2024/SketchUp.app/Contents/Frameworks/Ruby.framework/Versions/3.2.2/lib/ruby/3.2.0/rubygems/requirement.rb:68:in `create'
/Applications/SketchUp 2024/SketchUp.app/Contents/Frameworks/Ruby.framework/Versions/3.2.2/lib/ruby/3.2.0/rubygems/dependency.rb:56:in `initialize'
/Applications/SketchUp 2024/SketchUp.app/Contents/Frameworks/Ruby.framework/Versions/3.2.2/lib/ruby/3.2.0/rubygems/core_ext/kernel_gem.rb:51:in `new'
/Applications/SketchUp 2024/SketchUp.app/Contents/Frameworks/Ruby.framework/Versions/3.2.2/lib/ruby/3.2.0/rubygems/core_ext/kernel_gem.rb:51:in `gem'
/Users/alextsvetanov/Library/Application Support/SketchUp 2024/SketchUp/Plugins/testup/gem_helper.rb:17:in `require'
/Users/alextsvetanov/Library/Application Support/SketchUp 2024/SketchUp/Plugins/testup/json_ci_reporter.rb:13:in `<module:TestUp>'
/Users/alextsvetanov/Library/Application Support/SketchUp 2024/SketchUp/Plugins/testup/json_ci_reporter.rb:11:in `<top (required)>'
<internal:/Applications/SketchUp 2024/SketchUp.app/Contents/Frameworks/Ruby.framework/Versions/3.2.2/lib/ruby/3.2.0/rubygems/core_ext/kernel_require.rb>:85:in `require'
<internal:/Applications/SketchUp 2024/SketchUp.app/Contents/Frameworks/Ruby.framework/Versions/3.2.2/lib/ruby/3.2.0/rubygems/core_ext/kernel_require.rb>:85:in `require'
/Users/alextsvetanov/Library/Application Support/SketchUp 2024/SketchUp/Plugins/testup/api.rb:49:in `run_suite_without_gui'

Dev setup:

file(GENERATE OUTPUT Run_Tests.rb CONTENT "require 'testup'
TestUp::API.run_suite_without_gui('${CMAKE_CURRENT_BINARY_DIR}')")

add_custom_target(Tests ALL)
add_dependencies(Tests ${tests})
set_target_properties(Tests PROPERTIES 
    VS_DEBUGGER_COMMAND "C:/Program Files/SketchUp/SketchUp ${SKETCHUP_VERSION}/SketchUp.exe"
    VS_DEBUGGER_COMMAND_ARGUMENTS "-RubyStartup \"${CMAKE_CURRENT_BINARY_DIR}/Run_Tests.rb\""
    XCODE_SCHEME_EXECUTABLE "/Applications/SketchUp ${SKETCHUP_VERSION}/SketchUp.app"
    XCODE_SCHEME_ARGUMENTS  "-RubyStartup '${CMAKE_CURRENT_BINARY_DIR}/Run_Tests.rb'"
)
thomthom commented 5 months ago

This should be fixed by this hotfix: https://github.com/SketchUp/testup-2/pull/234

thomthom commented 5 months ago

Released 2.5.2 that should fix this. https://github.com/SketchUp/testup-2/releases