From 303df0dce5d3314633ba0f235145f1a93d36e00d Mon Sep 17 00:00:00 2001 From: Kenichi Kamiya Date: Sat, 27 Mar 2021 15:32:50 +0900 Subject: [PATCH 1/6] Bump supported ruby version Follow 0d1b754d3a32c2e26e5f9ed21a02b74489c0910a On ruby 2.7.2p137 (2020-10-01 revision 5445e04352) [x86_64-darwin20], `bin/setup; rake` failed as below ``` install -c tmp/x86_64-darwin20/pathname/2.7.2/pathname.bundle lib/pathname.bundle cp tmp/x86_64-darwin20/pathname/2.7.2/pathname.bundle tmp/x86_64-darwin20/stage/lib/pathname.bundle Loaded suite /Users/kachick/.gem/ruby/2.7.2/gems/rake-13.0.3/lib/rake/rake_test_loader Started ............................................................................... ............................................................................... ............................................................................... ..............................................E =============================================================================== Error: test_ractor_shareable(TestPathnameRactor): NameError: undefined local variable or method `skip' for # /Users/kachick/repos/pathname/test/pathname/test_ractor.rb:7:in `setup' =============================================================================== Finished in 0.196045 seconds. ------------------------------------------------------------------------------- 284 tests, 368 assertions, 0 failures, 1 errors, 0 pendings, 0 omissions, 0 notifications 99.6479% passed ------------------------------------------------------------------------------- 1448.65 tests/s, 1877.12 assertions/s rake aborted! Command failed with status (1) /Users/kachick/.gem/ruby/2.7.2/gems/rake-13.0.3/exe/rake:27:in `' Tasks: TOP => default => test (See full trace by running task with --trace) ``` --- pathname.gemspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pathname.gemspec b/pathname.gemspec index 8593f9e..642f3ce 100644 --- a/pathname.gemspec +++ b/pathname.gemspec @@ -7,7 +7,7 @@ Gem::Specification.new do |spec| spec.summary = %q{Representation of the name of a file or directory on the filesystem} spec.description = %q{Representation of the name of a file or directory on the filesystem} spec.homepage = "https://github.com/ruby/pathname" - spec.required_ruby_version = Gem::Requirement.new(">= 2.3.0") + spec.required_ruby_version = Gem::Requirement.new(">= 3.0.0") spec.licenses = ["Ruby", "BSD-2-Clause"] spec.metadata["homepage_uri"] = spec.homepage From 0d3a8da1736a4817c7aa561a04c708323a7fe58d Mon Sep 17 00:00:00 2001 From: Kenichi Kamiya Date: Tue, 30 Mar 2021 11:02:43 +0900 Subject: [PATCH 2/6] Support ruby 2.6+ again https://github.com/ruby/pathname/pull/3#issuecomment-809470830 https://github.com/ruby/pathname/pull/3#issuecomment-809823084 --- .github/workflows/test.yml | 2 +- pathname.gemspec | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 1adb570..c67a409 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -7,7 +7,7 @@ jobs: name: build (${{ matrix.ruby }} / ${{ matrix.os }}) strategy: matrix: - ruby: [ 3.0, head ] + ruby: [ 3.0, 2.7, 2.6, head ] os: [ ubuntu-latest, macos-latest ] runs-on: ${{ matrix.os }} steps: diff --git a/pathname.gemspec b/pathname.gemspec index 642f3ce..c81dc19 100644 --- a/pathname.gemspec +++ b/pathname.gemspec @@ -7,7 +7,7 @@ Gem::Specification.new do |spec| spec.summary = %q{Representation of the name of a file or directory on the filesystem} spec.description = %q{Representation of the name of a file or directory on the filesystem} spec.homepage = "https://github.com/ruby/pathname" - spec.required_ruby_version = Gem::Requirement.new(">= 3.0.0") + spec.required_ruby_version = Gem::Requirement.new(">= 2.6.0") spec.licenses = ["Ruby", "BSD-2-Clause"] spec.metadata["homepage_uri"] = spec.homepage From 1e2ea655b89afebed50b4b30fe8cf77cf737da58 Mon Sep 17 00:00:00 2001 From: Kenichi Kamiya Date: Tue, 30 Mar 2021 11:10:27 +0900 Subject: [PATCH 3/6] Prefer omit in setup instead of skip for old rubies --- test/pathname/test_ractor.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/pathname/test_ractor.rb b/test/pathname/test_ractor.rb index 9ce43ef..3d7b63d 100644 --- a/test/pathname/test_ractor.rb +++ b/test/pathname/test_ractor.rb @@ -4,7 +4,7 @@ class TestPathnameRactor < Test::Unit::TestCase def setup - skip unless defined? Ractor + omit unless defined? Ractor end def test_ractor_shareable From de8771e0d92ce525dee89808f75e31b716972c38 Mon Sep 17 00:00:00 2001 From: Kenichi Kamiya Date: Tue, 30 Mar 2021 11:29:53 +0900 Subject: [PATCH 4/6] Define using new features with macros to keep compatibilty in old rubies --- ext/pathname/pathname.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/ext/pathname/pathname.c b/ext/pathname/pathname.c index 55577d7..d5f8e41 100644 --- a/ext/pathname/pathname.c +++ b/ext/pathname/pathname.c @@ -341,6 +341,12 @@ path_realdirpath(int argc, VALUE *argv, VALUE self) return rb_class_new_instance(1, &str, rb_obj_class(self)); } +#ifndef RB_PASS_KEYWORDS +/* Only define macros on Ruby <2.7 */ +#define rb_funcallv_kw(o, m, c, v, kw) rb_funcallv(o, m, c, v) +#define rb_block_call_kw(o, m, c, v, f, p, kw) rb_block_call(o, m, c, v, f, p) +#endif + /* * call-seq: * pathname.each_line {|line| ... } From 50596427bd452293ada46b9bd9f93e59b06ab46f Mon Sep 17 00:00:00 2001 From: Kenichi Kamiya Date: Tue, 30 Mar 2021 12:01:14 +0900 Subject: [PATCH 5/6] Passing options like `{10 => 10}` looks can not use in ruby 2.6... --- test/pathname/test_pathname.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/test/pathname/test_pathname.rb b/test/pathname/test_pathname.rb index 46a04ee..939befd 100644 --- a/test/pathname/test_pathname.rb +++ b/test/pathname/test_pathname.rb @@ -1466,6 +1466,7 @@ def test_file_fnmatch end def test_relative_path_from_casefold + omit unless RUBY_VERSION >= '2.7.0' assert_separately([], <<-'end;') # do module File::Constants remove_const :FNM_SYSCASE From dd54500bad8cdc4c438bc7eb33f048936fd1cb6c Mon Sep 17 00:00:00 2001 From: Kenichi Kamiya Date: Tue, 30 Mar 2021 12:13:31 +0900 Subject: [PATCH 6/6] Avoid assert_separately too --- test/pathname/test_pathname.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/test/pathname/test_pathname.rb b/test/pathname/test_pathname.rb index cc468be..30af579 100644 --- a/test/pathname/test_pathname.rb +++ b/test/pathname/test_pathname.rb @@ -1068,6 +1068,7 @@ def test_expand_path def test_split assert_equal([Pathname("dirname"), Pathname("basename")], Pathname("dirname/basename").split) + omit unless RUBY_VERSION >= '2.7.0' assert_separately([], <<-'end;') require 'pathname'