Skip to content
Merged
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
5 changes: 4 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ jobs:
ruby: ${{ fromJson(needs.ruby-versions.outputs.versions) }}
os: [ ubuntu-latest, macos-latest, windows-latest ]
experimental: [false]
include:
- { ruby: truffleruby-head, os: ubuntu-latest, experimental: true }
runs-on: ${{ matrix.os }}
continue-on-error: ${{ matrix.experimental }}
timeout-minutes: 15
Expand All @@ -36,7 +38,8 @@ jobs:
timeout-minutes: 5 # _should_ finish in under a minute

- uses: joshmfrankel/simplecov-check-action@main
if: matrix.os == 'ubuntu-latest' && github.event_name != 'pull_request'
if: ${{ matrix.os == 'ubuntu-latest' && github.event_name != 'pull_request' &&
!startsWith(matrix.ruby, 'truffleruby') && !startsWith(matrix.ruby, 'jruby') }}
with:
check_job_name: "SimpleCov - ${{ matrix.ruby }}"
minimum_suite_coverage: 90
Expand Down
6 changes: 3 additions & 3 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ gem "benchmark-driver", require: false
gem "vernier", require: false, platform: :mri

group :test do
gem "simplecov", require: false
gem "simplecov-html", require: false
gem "simplecov-json", require: false
gem "simplecov", require: false, platforms: %i[mri windows]
gem "simplecov-html", require: false, platforms: %i[mri windows]
gem "simplecov-json", require: false, platforms: %i[mri windows]
end
44 changes: 43 additions & 1 deletion test/lib/helper.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
unless ENV["SIMPLECOV_DISABLE"] in /\A(1|y(es)?|t(rue)?)\z/i
if !(ENV["SIMPLECOV_DISABLE"] in /\A(1|y(es)?|t(rue)?)\z/i) &&
RUBY_ENGINE == "ruby" # C Ruby only

require "simplecov"

# Cannot use ".simplecov" file: simplecov-json triggers a circular require.
Expand Down Expand Up @@ -71,6 +73,46 @@ def assert_pattern
end
end

def pend_if(condition, *args, &block)
if condition
pend(*args, &block)
else
block.call if block
end
end

def pend_unless(condition, *args, &block)
if condition
block.call if block
else
pend(*args, &block)
end
end

def omit_unless_cruby(msg = "test omitted for non-CRuby", &block)
omit_unless(RUBY_ENGINE == "ruby", msg, &block)
end

def omit_if_truffleruby(msg = "test omitted on TruffleRuby", &block)
omit_if(RUBY_ENGINE == "truffleruby", msg, &block)
end

def omit_if_jruby(msg = "test omitted on JRuby", &block)
omit_if(RUBY_ENGINE == "jruby", msg, &block)
end

def pend_unless_cruby(msg = "test is pending for non-CRuby", &block)
pend_unless(RUBY_ENGINE == "ruby", msg, &block)
end

def pend_if_truffleruby(msg = "test is pending on TruffleRuby", &block)
pend_if(RUBY_ENGINE == "truffleruby", msg, &block)
end

def pend_if_jruby(msg = "test is pending on JRuby", &block)
pend_if(RUBY_ENGINE == "jruby", msg, &block)
end

end

require_relative "profiling_helper"
28 changes: 16 additions & 12 deletions test/net/imap/test_connection_state.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,21 +25,25 @@ class ConnectionStateTest < Net::IMAP::TestCase
end

test "#deconstruct" do
assert_equal [:not_authenticated], NotAuthenticated[].deconstruct
assert_equal [:authenticated], Authenticated[] .deconstruct
assert_equal [:selected], Selected[] .deconstruct
assert_equal [:logout], Logout[] .deconstruct
pend_if_truffleruby "TruffleRuby bug overriding ::Data methods" do
assert_equal [:not_authenticated], NotAuthenticated[].deconstruct
assert_equal [:authenticated], Authenticated[] .deconstruct
assert_equal [:selected], Selected[] .deconstruct
assert_equal [:logout], Logout[] .deconstruct
end
end

test "#deconstruct_keys" do
assert_equal({symbol: :not_authenticated}, NotAuthenticated[].deconstruct_keys([:symbol]))
assert_equal({symbol: :authenticated}, Authenticated[] .deconstruct_keys([:symbol]))
assert_equal({symbol: :selected}, Selected[] .deconstruct_keys([:symbol]))
assert_equal({symbol: :logout}, Logout[] .deconstruct_keys([:symbol]))
assert_equal({name: "not_authenticated"}, NotAuthenticated[].deconstruct_keys([:name]))
assert_equal({name: "authenticated"}, Authenticated[] .deconstruct_keys([:name]))
assert_equal({name: "selected"}, Selected[] .deconstruct_keys([:name]))
assert_equal({name: "logout"}, Logout[] .deconstruct_keys([:name]))
pend_if_truffleruby "TruffleRuby bug overriding ::Data methods" do
assert_equal({symbol: :not_authenticated}, NotAuthenticated[].deconstruct_keys([:symbol]))
assert_equal({symbol: :authenticated}, Authenticated[] .deconstruct_keys([:symbol]))
assert_equal({symbol: :selected}, Selected[] .deconstruct_keys([:symbol]))
assert_equal({symbol: :logout}, Logout[] .deconstruct_keys([:symbol]))
assert_equal({name: "not_authenticated"}, NotAuthenticated[].deconstruct_keys([:name]))
assert_equal({name: "authenticated"}, Authenticated[] .deconstruct_keys([:name]))
assert_equal({name: "selected"}, Selected[] .deconstruct_keys([:name]))
assert_equal({name: "logout"}, Logout[] .deconstruct_keys([:name]))
end
end

test "#not_authenticated?" do
Expand Down
4 changes: 3 additions & 1 deletion test/net/imap/test_data_lite.rb
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,9 @@ class InheritsOverride < AbstractWithOverride.define(:foo)

def test_subclass_override_deconstruct
data = InheritsOverride[:foo]
assert_equal %i[ok foo], data.deconstruct
pend_if_truffleruby do
assert_equal %i[ok foo], data.deconstruct
end
end

end
Expand Down