From d25af1f44e8920e15c5cab7808757e28fa9f6492 Mon Sep 17 00:00:00 2001 From: S-H-GAMELINKS Date: Sun, 3 Oct 2021 17:16:58 +0900 Subject: [PATCH 01/12] Add flo_ndigits function --- numeric.c | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/numeric.c b/numeric.c index 3b481b3869134b..4a4a128bb5b038 100644 --- a/numeric.c +++ b/numeric.c @@ -1876,13 +1876,19 @@ rb_float_floor(VALUE num, int ndigits) * (0.3 / 0.1).floor #=> 2 (!) */ -static VALUE -flo_floor(int argc, VALUE *argv, VALUE num) +static int +flo_ndigits(int argc, VALUE *argv) { - int ndigits = 0; if (rb_check_arity(argc, 0, 1)) { - ndigits = NUM2INT(argv[0]); + return NUM2INT(argv[0]); } + return 0; +} + +static VALUE +flo_floor(int argc, VALUE *argv, VALUE num) +{ + int ndigits = flo_ndigits(argc, argv); return rb_float_floor(num, ndigits); } @@ -1928,11 +1934,7 @@ flo_floor(int argc, VALUE *argv, VALUE num) static VALUE flo_ceil(int argc, VALUE *argv, VALUE num) { - int ndigits = 0; - - if (rb_check_arity(argc, 0, 1)) { - ndigits = NUM2INT(argv[0]); - } + int ndigits = flo_ndigits(argc, argv); return rb_float_ceil(num, ndigits); } From 9cd9eca3793ecf47f0e5971efaf99b514b72be94 Mon Sep 17 00:00:00 2001 From: S-H-GAMELINKS Date: Sun, 26 Sep 2021 21:50:38 +0900 Subject: [PATCH 02/12] Refactor rb_proc_call function --- proc.c | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/proc.c b/proc.c index bf04f4c26d30ec..e09aeca223b6cf 100644 --- a/proc.c +++ b/proc.c @@ -990,15 +990,7 @@ rb_proc_call_kw(VALUE self, VALUE args, int kw_splat) VALUE rb_proc_call(VALUE self, VALUE args) { - VALUE vret; - rb_proc_t *proc; - GetProcPtr(self, proc); - vret = rb_vm_invoke_proc(GET_EC(), proc, - check_argc(RARRAY_LEN(args)), RARRAY_CONST_PTR(args), - RB_NO_KEYWORDS, VM_BLOCK_HANDLER_NONE); - RB_GC_GUARD(self); - RB_GC_GUARD(args); - return vret; + return rb_proc_call_kw(self, args, RB_NO_KEYWORDS); } static VALUE From 72797acf6e16911a4a0345d23685070a0f993732 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Sun, 10 Oct 2021 10:03:21 +0900 Subject: [PATCH 03/12] Set `TEST_ALL` options first to show in the summary page --- .travis.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index c84cb1a6d7ff8a..9732123e4d7400 100644 --- a/.travis.yml +++ b/.travis.yml @@ -26,6 +26,10 @@ cache: env: global: + # The tests skipped in `make test-all`. + - TEST_ALL_SKIPPED_TESTS= + # The tests executed separately by `make test-all`. + - TEST_ALL_SEPARATED_TESTS= # Reset timestamps early - _=$(touch NEWS && find . -type f -exec touch -r NEWS {} +) - CONFIGURE_TTY=no @@ -38,12 +42,8 @@ env: - SETARCH= - RUBY_PREFIX=/tmp/ruby-prefix - GEMS_FOR_TEST='timezone tzinfo' - # The tests skipped in `make test-all`. - - TEST_ALL_SKIPPED_TESTS= # Run the separated tests with allowing failures. - RUN_SEPARATED_TESTS=true - # The tests executed separately by `make test-all`. - - TEST_ALL_SEPARATED_TESTS= # https://github.com/travis-ci/travis-build/blob/e411371dda21430a60f61b8f3f57943d2fe4d344/lib/travis/build/bash/travis_apt_get_options.bash#L7 - travis_apt_get_options='--allow-downgrades --allow-remove-essential --allow-change-held-packages' - travis_apt_get_options="-yq --no-install-suggests --no-install-recommends $travis_apt_get_options" From 3817d1823c9a0f729a8a796afa46314b9385a1d8 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Sun, 10 Oct 2021 10:14:31 +0900 Subject: [PATCH 04/12] Remove `RUN_SEPARATED_TESTS` which seems unnecessary --- .travis.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index 9732123e4d7400..bee7959953862b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -42,8 +42,6 @@ env: - SETARCH= - RUBY_PREFIX=/tmp/ruby-prefix - GEMS_FOR_TEST='timezone tzinfo' - # Run the separated tests with allowing failures. - - RUN_SEPARATED_TESTS=true # https://github.com/travis-ci/travis-build/blob/e411371dda21430a60f61b8f3f57943d2fe4d344/lib/travis/build/bash/travis_apt_get_options.bash#L7 - travis_apt_get_options='--allow-downgrades --allow-remove-essential --allow-change-held-packages' - travis_apt_get_options="-yq --no-install-suggests --no-install-recommends $travis_apt_get_options" @@ -199,7 +197,7 @@ script: # Run the failing tests separately returning ok status to check if it works, # visualize them. - | - if [ "${RUN_SEPARATED_TESTS}" = true -a -n "${TEST_ALL_OPTS_SEPARATED}" ]; then + if [ -n "${TEST_ALL_OPTS_SEPARATED}" ]; then $SETARCH make -s test-all -o exts TESTOPTS="$JOBS -v --tty=no ${TEST_ALL_OPTS_SEPARATED}" RUBYOPT="-w" || : fi - $SETARCH make -s test-spec MSPECOPT=-ff # not using `-j` because sometimes `mspec -j` silently dies From f6048e592c520e20ba498ba4d553f07f02213a61 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Sun, 10 Oct 2021 10:15:21 +0900 Subject: [PATCH 05/12] Run the failing readline test on arm32-linux separately --- .travis.yml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index bee7959953862b..72becb1973e453 100644 --- a/.travis.yml +++ b/.travis.yml @@ -95,6 +95,9 @@ env: compiler: arm-linux-gnueabihf-gcc env: - SETARCH='setarch linux32 --verbose --32bit' + # The "TestReadline#test_interrupt_in_other_thread" started failing on arm32 + # from https://www.travis-ci.com/github/ruby/ruby/jobs/529005145 + - TEST_ALL_SKIPPED_TESTS=test_interrupt_in_other_thread before_install: - sudo dpkg --add-architecture armhf - tool/travis_retry.sh sudo bash -c "rm -rf '${TRAVIS_ROOT}/var/lib/apt/lists/'* && exec apt-get update -yq" @@ -121,9 +124,7 @@ matrix: - <<: *ppc64le-linux - <<: *s390x-linux allow_failures: - # The "TestReadline#test_interrupt_in_other_thread" started failing on arm32 - # from https://www.travis-ci.com/github/ruby/ruby/jobs/529005145 - - name: arm32-linux + # - name: arm32-linux # - name: arm64-linux # We see "Some worker was crashed." in about 40% of recent ppc64le-linux jobs # e.g. https://app.travis-ci.com/github/ruby/ruby/jobs/530959548 From afb95d1004676f71beb0dab389b19695728726e5 Mon Sep 17 00:00:00 2001 From: "S.H" Date: Sun, 10 Oct 2021 11:40:04 +0900 Subject: [PATCH 06/12] Refactor sym_step_i function --- range.c | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/range.c b/range.c index 31f734181db0c3..96fcfe577b42db 100644 --- a/range.c +++ b/range.c @@ -308,8 +308,8 @@ range_each_func(VALUE range, int (*func)(VALUE, VALUE), VALUE arg) } } -static int -sym_step_i(VALUE i, VALUE arg) +static VALUE* +step_i_iter(VALUE arg) { VALUE *iter = (VALUE *)arg; @@ -319,6 +319,14 @@ sym_step_i(VALUE i, VALUE arg) else { iter[0] = rb_funcall(iter[0], '-', 1, INT2FIX(1)); } + return iter; +} + +static int +sym_step_i(VALUE i, VALUE arg) +{ + VALUE *iter = step_i_iter(arg); + if (iter[0] == INT2FIX(0)) { rb_yield(rb_str_intern(i)); iter[0] = iter[1]; @@ -329,14 +337,8 @@ sym_step_i(VALUE i, VALUE arg) static int step_i(VALUE i, VALUE arg) { - VALUE *iter = (VALUE *)arg; + VALUE *iter = step_i_iter(arg); - if (FIXNUM_P(iter[0])) { - iter[0] -= INT2FIX(1) & ~FIXNUM_FLAG; - } - else { - iter[0] = rb_funcall(iter[0], '-', 1, INT2FIX(1)); - } if (iter[0] == INT2FIX(0)) { rb_yield(i); iter[0] = iter[1]; From 2293547d9b59e0641e26837500986e78f9ba891b Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Sun, 10 Oct 2021 11:41:26 +0900 Subject: [PATCH 07/12] Update iteration step in step_i_iter --- range.c | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/range.c b/range.c index 96fcfe577b42db..cb86f540d8cf83 100644 --- a/range.c +++ b/range.c @@ -308,7 +308,7 @@ range_each_func(VALUE range, int (*func)(VALUE, VALUE), VALUE arg) } } -static VALUE* +static bool step_i_iter(VALUE arg) { VALUE *iter = (VALUE *)arg; @@ -319,17 +319,16 @@ step_i_iter(VALUE arg) else { iter[0] = rb_funcall(iter[0], '-', 1, INT2FIX(1)); } - return iter; + if (iter[0] != INT2FIX(0)) return false; + iter[0] = iter[1]; + return true; } static int sym_step_i(VALUE i, VALUE arg) { - VALUE *iter = step_i_iter(arg); - - if (iter[0] == INT2FIX(0)) { + if (step_i_iter(arg)) { rb_yield(rb_str_intern(i)); - iter[0] = iter[1]; } return 0; } @@ -337,11 +336,8 @@ sym_step_i(VALUE i, VALUE arg) static int step_i(VALUE i, VALUE arg) { - VALUE *iter = step_i_iter(arg); - - if (iter[0] == INT2FIX(0)) { + if (step_i_iter(arg)) { rb_yield(i); - iter[0] = iter[1]; } return 0; } From e2017f8c7cc2066286ab8047d4de47704f871a28 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Sun, 10 Oct 2021 11:45:50 +0900 Subject: [PATCH 08/12] Unify iteration arguments --- range.c | 16 ++-------------- 1 file changed, 2 insertions(+), 14 deletions(-) diff --git a/range.c b/range.c index cb86f540d8cf83..96c059b8068376 100644 --- a/range.c +++ b/range.c @@ -463,6 +463,7 @@ range_step(int argc, VALUE *argv, VALUE range) } step = check_step_domain(step); + VALUE iter[2] = {INT2FIX(1), step}; if (FIXNUM_P(b) && NIL_P(e) && FIXNUM_P(step)) { long i = FIX2LONG(b), unit = FIX2LONG(step); @@ -490,10 +491,6 @@ range_step(int argc, VALUE *argv, VALUE range) } else if (SYMBOL_P(b) && (NIL_P(e) || SYMBOL_P(e))) { /* symbols are special */ - VALUE iter[2]; - iter[0] = INT2FIX(1); - iter[1] = step; - b = rb_sym2str(b); if (NIL_P(e)) { rb_str_upto_endless_each(b, sym_step_i, (VALUE)iter); @@ -522,12 +519,7 @@ range_step(int argc, VALUE *argv, VALUE range) tmp = rb_check_string_type(b); if (!NIL_P(tmp)) { - VALUE iter[2]; - b = tmp; - iter[0] = INT2FIX(1); - iter[1] = step; - if (NIL_P(e)) { rb_str_upto_endless_each(b, step_i, (VALUE)iter); } @@ -536,15 +528,11 @@ range_step(int argc, VALUE *argv, VALUE range) } } else { - VALUE args[2]; - if (!discrete_object_p(b)) { rb_raise(rb_eTypeError, "can't iterate from %s", rb_obj_classname(b)); } - args[0] = INT2FIX(1); - args[1] = step; - range_each_func(range, step_i, (VALUE)args); + range_each_func(range, step_i, (VALUE)iter); } } return range; From fb9ea391cf36f103a960ccb476271dcc912f2e69 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Sun, 10 Oct 2021 18:30:33 +0900 Subject: [PATCH 09/12] Default the test order to random --- tool/lib/test/unit.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tool/lib/test/unit.rb b/tool/lib/test/unit.rb index c113e7e4fda15e..9671df1ad47732 100644 --- a/tool/lib/test/unit.rb +++ b/tool/lib/test/unit.rb @@ -182,7 +182,7 @@ def process_args(args = []) order = options[:test_order] if seed = options[:seed] order ||= :random - elsif order == :random + elsif (order ||= :random) == :random seed = options[:seed] = rand(0x10000) orig_args.unshift "--seed=#{seed}" end From cec61d16d2fb50812a003338a719f186a6bd88ef Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Sun, 10 Oct 2021 19:23:52 +0900 Subject: [PATCH 10/12] Run JIT tests first when random order instead of no-sort --- tool/lib/test/unit.rb | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/tool/lib/test/unit.rb b/tool/lib/test/unit.rb index 9671df1ad47732..15e290e5f1c519 100644 --- a/tool/lib/test/unit.rb +++ b/tool/lib/test/unit.rb @@ -69,6 +69,12 @@ def sort_by_name(list) alias sort_by_string sort_by_name + def group(list) + list + end + end + + module JITFirst def group(list) # JIT first jit, others = list.partition {|e| /test_jit/ =~ e} @@ -77,6 +83,8 @@ def group(list) end class Alpha < NoSort + include JITFirst + def sort_by_name(list) list.sort_by(&:name) end @@ -89,6 +97,8 @@ def sort_by_string(list) # shuffle test suites based on CRC32 of their names Shuffle = Struct.new(:seed, :salt) do + include JITFirst + def initialize(seed) self.class::CRC_TBL ||= (0..255).map {|i| (0..7).inject(i) {|c,| (c & 1 == 1) ? (0xEDB88320 ^ (c >> 1)) : (c >> 1) } @@ -106,10 +116,6 @@ def sort_by_string(list) list.sort_by {|e| randomize_key(e)} end - def group(list) - list - end - private def crc32(str, crc32 = 0xffffffff) From b56bb0cf9bbf402a5ece342a77991b8f623d6248 Mon Sep 17 00:00:00 2001 From: Kazuhiro NISHIYAMA Date: Sun, 10 Oct 2021 20:14:37 +0900 Subject: [PATCH 11/12] Update bundled_gems --- gems/bundled_gems | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gems/bundled_gems b/gems/bundled_gems index c2a9d5f301eaf9..1159644c551c81 100644 --- a/gems/bundled_gems +++ b/gems/bundled_gems @@ -8,7 +8,7 @@ rss 0.2.9 https://github.com/ruby/rss 0.2.9 net-ftp 0.1.3 https://github.com/ruby/net-ftp net-imap 0.2.2 https://github.com/ruby/net-imap net-pop 0.1.1 https://github.com/ruby/net-pop -net-smtp 0.2.1 https://github.com/ruby/net-smtp +net-smtp 0.2.2 https://github.com/ruby/net-smtp matrix 0.4.2 https://github.com/ruby/matrix prime 0.1.2 https://github.com/ruby/prime rbs 1.6.2 https://github.com/ruby/rbs From b16d876ac2d20b3c17a6906860d3a3f279aecf65 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Sun, 10 Oct 2021 20:28:14 +0900 Subject: [PATCH 12/12] Needs time.rb for `Time#iso8601` `Gem::Request.verify_certificate_message` used this method without "time" which defines it. --- lib/rubygems/request.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/rubygems/request.rb b/lib/rubygems/request.rb index 72e25e20abeead..d6100c914b0566 100644 --- a/lib/rubygems/request.rb +++ b/lib/rubygems/request.rb @@ -96,8 +96,10 @@ def self.verify_certificate_message(error_number, cert) return unless cert case error_number when OpenSSL::X509::V_ERR_CERT_HAS_EXPIRED then + require 'time' "Certificate #{cert.subject} expired at #{cert.not_after.iso8601}" when OpenSSL::X509::V_ERR_CERT_NOT_YET_VALID then + require 'time' "Certificate #{cert.subject} not valid until #{cert.not_before.iso8601}" when OpenSSL::X509::V_ERR_CERT_REJECTED then "Certificate #{cert.subject} is rejected"