diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b06344e..be384bf 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -22,17 +22,22 @@ jobs: strategy: fail-fast: false matrix: - os: [ubuntu-20.04] - ruby: ['3.0', '3.1'] + os: [ubuntu-24.04] + ruby: + - '3.0' + - '3.1' + - '3.2' + - '3.3' + - '3.4' include: - - { os: ubuntu-20.04 , ruby: ruby-head } - - { os: ubuntu-20.04 , ruby: jruby, allow-failure: true } - - { os: ubuntu-20.04 , ruby: jruby-head } - - { os: ubuntu-20.04 , ruby: truffleruby } - - { os: ubuntu-20.04 , ruby: truffleruby-head, allow-failure: true } + - { os: ubuntu-24.04 , ruby: ruby-head } + - { os: ubuntu-24.04 , ruby: jruby, allow-failure: true } + - { os: ubuntu-24.04 , ruby: jruby-head } + - { os: ubuntu-24.04 , ruby: truffleruby } + - { os: ubuntu-24.04 , ruby: truffleruby-head, allow-failure: true } runs-on: ${{ matrix.os }} steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - uses: ruby/setup-ruby@v1 continue-on-error: ${{ matrix.allow-failure || false }} id: bundle diff --git a/test/rubygems/mock_gem_ui.rb b/test/rubygems/mock_gem_ui.rb new file mode 100644 index 0000000..218d4b6 --- /dev/null +++ b/test/rubygems/mock_gem_ui.rb @@ -0,0 +1,86 @@ +# frozen_string_literal: true + +require "rubygems/user_interaction" + +## +# This Gem::StreamUI subclass records input and output to StringIO for +# retrieval during tests. + +class Gem::MockGemUi < Gem::StreamUI + ## + # Raised when you haven't provided enough input to your MockGemUi + + class InputEOFError < RuntimeError + def initialize(question) + super "Out of input for MockGemUi on #{question.inspect}" + end + end + + class TermError < SystemExit + attr_reader :exit_code + + def initialize(exit_code) + super + @exit_code = exit_code + end + end + + class SystemExitException < RuntimeError; end + + module TTY + attr_accessor :tty + + def tty? + @tty = true unless defined?(@tty) + @tty + end + + def noecho + yield self + end + end + + def initialize(input = "") + require "stringio" + ins = StringIO.new input + outs = StringIO.new + errs = StringIO.new + + ins.extend TTY + outs.extend TTY + errs.extend TTY + + super ins, outs, errs, true + + @terminated = false + end + + def ask(question) + raise InputEOFError, question if @ins.eof? + + super + end + + def input + @ins.string + end + + def output + @outs.string + end + + def error + @errs.string + end + + def terminated? + @terminated + end + + def terminate_interaction(status=0) + @terminated = true + + raise TermError, status if status != 0 + raise SystemExitException + end +end diff --git a/test/rubygems/test_gem_commands_compare_command.rb b/test/rubygems/test_gem_commands_compare_command.rb index b9b099b..04782dd 100644 --- a/test/rubygems/test_gem_commands_compare_command.rb +++ b/test/rubygems/test_gem_commands_compare_command.rb @@ -1,6 +1,6 @@ require_relative '../test_helper' +require_relative 'mock_gem_ui' require 'rubygems/user_interaction' -require 'rubygems/mock_gem_ui' require 'rubygems/commands/compare_command' class TestGemCommandsCompareCommand < Minitest::Test