From d019ac81861e2fac3ab06812fff7ffa6895894b3 Mon Sep 17 00:00:00 2001 From: Andrew Konchin Date: Fri, 15 Nov 2024 12:49:53 +0200 Subject: [PATCH 1/2] Skip tests failing on TruffleRuby --- test/date/test_date_conv.rb | 13 ++++++++----- test/date/test_date_parse.rb | 11 +++++++---- 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/test/date/test_date_conv.rb b/test/date/test_date_conv.rb index ed478b4..772fbee 100644 --- a/test/date/test_date_conv.rb +++ b/test/date/test_date_conv.rb @@ -89,11 +89,14 @@ def test_to_time__from_datetime [t.year, t.mon, t.mday, t.hour, t.min, t.sec, t.nsec]) end - if Time.allocate.respond_to?(:subsec) - d = DateTime.new(2004, 9, 19, 1, 2, 3, 0) + 456789123456789123.to_r/86400000000000000000000 - t = d.to_time.utc - assert_equal([2004, 9, 19, 1, 2, 3, Rational(456789123456789123,1000000000000000000)], - [t.year, t.mon, t.mday, t.hour, t.min, t.sec, t.subsec]) + # TruffleRuby does not support more than nanoseconds + unless RUBY_ENGINE == 'truffleruby' + if Time.allocate.respond_to?(:subsec) + d = DateTime.new(2004, 9, 19, 1, 2, 3, 0) + 456789123456789123.to_r/86400000000000000000000 + t = d.to_time.utc + assert_equal([2004, 9, 19, 1, 2, 3, Rational(456789123456789123,1000000000000000000)], + [t.year, t.mon, t.mday, t.hour, t.min, t.sec, t.subsec]) + end end end diff --git a/test/date/test_date_parse.rb b/test/date/test_date_parse.rb index 16362e3..cc29771 100644 --- a/test/date/test_date_parse.rb +++ b/test/date/test_date_parse.rb @@ -589,10 +589,13 @@ def test__parse_odd_offset end def test__parse_too_long_year - str = "Jan 1" + "0" * 100_000 - h = EnvUtil.timeout(3) {Date._parse(str, limit: 100_010)} - assert_equal(100_000, Math.log10(h[:year])) - assert_equal(1, h[:mon]) + # Math.log10 does not support so big numbers like 10^100_000 on TruffleRuby + unless RUBY_ENGINE == 'truffleruby' + str = "Jan 1" + "0" * 100_000 + h = EnvUtil.timeout(3) {Date._parse(str, limit: 100_010)} + assert_equal(100_000, Math.log10(h[:year])) + assert_equal(1, h[:mon]) + end str = "Jan - 1" + "0" * 100_000 h = EnvUtil.timeout(3) {Date._parse(str, limit: 100_010)} From f6578ba80ed37af6c374723f8143354c123a0cf9 Mon Sep 17 00:00:00 2001 From: Andrew Konchin Date: Thu, 9 Jan 2025 19:48:59 +0200 Subject: [PATCH 2/2] Add TruffleRuby in CI --- .github/workflows/test.yml | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 107aa5b..dfb4de6 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -10,7 +10,7 @@ jobs: ruby-versions: uses: ruby/actions/.github/workflows/ruby_versions.yml@master with: - engine: cruby + engine: cruby-truffleruby min_version: 2.6 build: @@ -24,6 +24,14 @@ jobs: exclude: - ruby: head os: windows-latest + - ruby: truffleruby # need truffleruby 24.2+ + os: ubuntu-latest + - ruby: truffleruby # need truffleruby 24.2+ + os: macos-latest + - ruby: truffleruby + os: windows-latest + - ruby: truffleruby-head + os: windows-latest include: - ruby: mingw os: windows-latest