Skip to content
Draft
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
1 change: 1 addition & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ jobs:
os: [ ubuntu-latest, macos-latest, windows-latest ]
experimental: [false]
include:
- { ruby: jruby-head, os: ubuntu-latest, experimental: true }
- { ruby: truffleruby-head, os: ubuntu-latest, experimental: true }
runs-on: ${{ matrix.os }}
continue-on-error: ${{ matrix.experimental }}
Expand Down
6 changes: 6 additions & 0 deletions rakelib/string_prep_tables_generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,12 @@ def parse_rfc_text(rfc3454_text)
.to_h.compact
.transform_values {|t| t.first.size == 2 ? t.to_h : t }
tables["titles"] = titles

# See https://github.com/ruby/json/issues/870
if RUBY_ENGINE == "jruby"
tables["titles"].transform_values! { _1.dump.undump }
end

tables
end

Expand Down
54 changes: 29 additions & 25 deletions test/net/imap/test_data_lite.rb
Original file line number Diff line number Diff line change
Expand Up @@ -174,30 +174,32 @@ def initialize(value:, head: nil, tail: nil)
end
end

# anonymous class
list = klass[value: 1, tail: [2, 3, 4]]
seen = "#<data #{klass.inspect}:...>"
assert_equal(
"#<data value=1, head=nil," \
" tail=#<data value=2, head=#{seen}," \
" tail=#<data value=3, head=#{seen}," \
" tail=#<data value=4, head=#{seen}," \
" tail=nil>>>>",
list.inspect
)

# named class
Object.const_set(:DoubleLinkList, klass)
list = DoubleLinkList[value: 1, tail: [2, 3, 4]]
seen = "#<data DoubleLinkList:...>"
assert_equal(
"#<data DoubleLinkList value=1, head=nil," \
" tail=#<data DoubleLinkList value=2, head=#{seen}," \
" tail=#<data DoubleLinkList value=3, head=#{seen}," \
" tail=#<data DoubleLinkList value=4, head=#{seen}," \
" tail=nil>>>>",
list.inspect
)
pend_if_jruby do
# anonymous class
list = klass[value: 1, tail: [2, 3, 4]]
seen = "#<data #{klass.inspect}:...>"
assert_equal(
"#<data value=1, head=nil," \
" tail=#<data value=2, head=#{seen}," \
" tail=#<data value=3, head=#{seen}," \
" tail=#<data value=4, head=#{seen}," \
" tail=nil>>>>",
list.inspect
)

# named class
Object.const_set(:DoubleLinkList, klass)
list = DoubleLinkList[value: 1, tail: [2, 3, 4]]
seen = "#<data DoubleLinkList:...>"
assert_equal(
"#<data DoubleLinkList value=1, head=nil," \
" tail=#<data DoubleLinkList value=2, head=#{seen}," \
" tail=#<data DoubleLinkList value=3, head=#{seen}," \
" tail=#<data DoubleLinkList value=4, head=#{seen}," \
" tail=nil>>>>",
list.inspect
)
end
ensure
Object.instance_eval { remove_const(:DoubleLinkList) } rescue nil
end
Expand Down Expand Up @@ -362,7 +364,9 @@ class InheritsClassMethod < AbstractWithClassMethod.define(:foo)
end

def test_subclass_class_method
assert_equal :ok, InheritsClassMethod.inherited_class_method
pend_if_jruby do
assert_equal :ok, InheritsClassMethod.inherited_class_method
end
end

class AbstractWithOverride < Data
Expand Down
4 changes: 2 additions & 2 deletions test/net/imap/test_fetch_data.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,14 @@ def fetch_data_class
end

test "#seqno does not exist" do
data = Net::IMAP::UIDFetchData.new(22222)
data = pend_if_jruby { Net::IMAP::UIDFetchData.new(22222) } or next
assert_raise NoMethodError do
data.seqno
end
end

test "#uid replaces #seqno" do
data = Net::IMAP::UIDFetchData.new(22222)
data = pend_if_jruby { Net::IMAP::UIDFetchData.new(22222) } or next
assert_equal 22222, data.uid
end

Expand Down
8 changes: 8 additions & 0 deletions test/net/imap/test_imap.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ class IMAPTest < Net::IMAP::TestCase

if defined?(OpenSSL::SSL::SSLError)
def test_imaps_unknown_ca
omit_if_jruby "SSL tests don't work yet"
assert_raise(OpenSSL::SSL::SSLError) do
imaps_test do |port|
begin
Expand All @@ -27,6 +28,7 @@ def test_imaps_unknown_ca
end

def test_imaps_with_ca_file
omit_if_jruby "SSL tests don't work yet"
# Assert verified *after* the imaps_test and assert_nothing_raised blocks.
# Otherwise, failures can't logout and need to wait for the timeout.
verified, imap = :unknown, nil
Expand Down Expand Up @@ -54,6 +56,7 @@ def test_imaps_with_ca_file
end

def test_imaps_verify_none
omit_if_jruby "SSL tests don't work yet"
# Assert verified *after* the imaps_test and assert_nothing_raised blocks.
# Otherwise, failures can't logout and need to wait for the timeout.
verified, imap = :unknown, nil
Expand Down Expand Up @@ -81,6 +84,7 @@ def test_imaps_verify_none
end

def test_imaps_post_connection_check
omit_if_jruby "SSL tests don't work yet"
assert_raise(OpenSSL::SSL::SSLError) do
imaps_test do |port|
# server_addr is different from the hostname in the certificate,
Expand All @@ -95,6 +99,7 @@ def test_imaps_post_connection_check

if defined?(OpenSSL::SSL)
def test_starttls_unknown_ca
omit_if_jruby "SSL tests don't work yet"
omit "This test is not working with Windows" if RUBY_PLATFORM =~ /mswin|mingw/

imap = nil
Expand All @@ -115,6 +120,7 @@ def test_starttls_unknown_ca
end

def test_starttls
omit_if_jruby "SSL tests don't work yet"
initial_verified, initial_ctx, initial_params = :unknown, :unknown, :unknown
imap = nil
starttls_test do |port|
Expand All @@ -139,6 +145,7 @@ def test_starttls
end

def test_starttls_stripping
omit_if_jruby "SSL tests don't work yet"
imap = nil
starttls_stripping_test do |port|
imap = Net::IMAP.new("localhost", :port => port)
Expand Down Expand Up @@ -497,6 +504,7 @@ def test_connection_closed_during_idle
end

def test_connection_closed_without_greeting
omit_if_jruby "???"
server = create_tcp_server
port = server.addr[1]
h = {
Expand Down
3 changes: 3 additions & 0 deletions test/net/imap/test_imap_capabilities.rb
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ class IMAPCapabilitiesTest < Net::IMAP::TestCase

if defined?(OpenSSL::SSL::SSLError)
test "#capabilities caches greeting capabilities (implicit TLS)" do
omit_if_jruby
with_fake_server(preauth: false, implicit_tls: true) do |server, imap|
assert imap.capabilities_cached?
assert_equal %w[IMAP4REV1 AUTH=PLAIN], imap.capabilities
Expand All @@ -136,6 +137,7 @@ class IMAPCapabilitiesTest < Net::IMAP::TestCase

test "#capabilities cache is cleared after #starttls" do
with_fake_server(preauth: false, cleartext_auth: false) do |server, imap|
omit_if_jruby
assert imap.capabilities_cached?
assert imap.capable? :IMAP4rev1
refute imap.auth_capable? "plain"
Expand Down Expand Up @@ -189,6 +191,7 @@ class IMAPCapabilitiesTest < Net::IMAP::TestCase

# TODO: should we warn about this?
test "#capabilities cache IGNORES tagged OK response to STARTTLS" do
omit_if_jruby
with_fake_server(preauth: false) do |server, imap|
server.on "STARTTLS" do |cmd|
cmd.done_ok code: "[CAPABILITY IMAP4rev1 AUTH=PLAIN fnord]"
Expand Down
4 changes: 4 additions & 0 deletions test/net/imap/test_imap_deprecated_client_options.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ class InitializeTests < IMAPDeprecatedClientOptionsTest
end

test "Convert deprecated usessl (= true) and certs, with warning" do
omit_if_jruby "SSL tests don't work yet"
run_fake_server_in_thread(implicit_tls: true) do |server|
certs = server.config.tls[:ca_file]
assert_deprecated_warning(/Call Net::IMAP\.new with keyword/i) do
Expand All @@ -58,6 +59,7 @@ class InitializeTests < IMAPDeprecatedClientOptionsTest
end

test "Convert deprecated usessl (= true) and verify (= false), with warning" do
omit_if_jruby "SSL tests don't work yet"
run_fake_server_in_thread(implicit_tls: true) do |server|
assert_deprecated_warning(/Call Net::IMAP\.new with keyword/i) do
with_client("localhost", server.port, true, nil, false) do |client|
Expand Down Expand Up @@ -89,6 +91,7 @@ class InitializeTests < IMAPDeprecatedClientOptionsTest

class StartTLSTests < IMAPDeprecatedClientOptionsTest
test "Convert obsolete options hash to keywords" do
omit_if_jruby "SSL tests don't work yet"
with_fake_server(preauth: false) do |server, imap|
imap.starttls(ca_file: server.config.tls[:ca_file], min_version: :TLS1_2)
assert_equal(
Expand All @@ -101,6 +104,7 @@ class StartTLSTests < IMAPDeprecatedClientOptionsTest
end

test "Convert deprecated certs, verify with warning" do
omit_if_jruby "SSL tests don't work yet"
with_fake_server(preauth: false) do |server, imap|
assert_deprecated_warning(/Call Net::IMAP#starttls with keyword/i) do
imap.starttls(server.config.tls[:ca_file], false)
Expand Down
10 changes: 6 additions & 4 deletions test/net/imap/test_vanished_data.rb
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,13 @@ class VanishedDataTest < Net::IMAP::TestCase
end

test ".[], mixing args raises ArgumentError" do
assert_raise ArgumentError do
VanishedData[1, true, uids: "1", earlier: true]
pend_if_jruby do
assert_raise ArgumentError do
VanishedData[1, true, uids: "1", earlier: true]
end
assert_raise ArgumentError do VanishedData["1234", earlier: true] end
assert_raise ArgumentError do VanishedData[nil, true, uids: "1"] end
end
assert_raise ArgumentError do VanishedData["1234", earlier: true] end
assert_raise ArgumentError do VanishedData[nil, true, uids: "1"] end
end

test ".[], missing args raises ArgumentError" do
Expand Down
Loading