Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 13 additions & 8 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
86 changes: 86 additions & 0 deletions test/rubygems/mock_gem_ui.rb
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion test/rubygems/test_gem_commands_compare_command.rb
Original file line number Diff line number Diff line change
@@ -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
Expand Down