Skip to content

Commit 483a4cc

Browse files
authored
Merge pull request #71 from ruby/workaround-for-jruby
Workaround for jruby
2 parents 4f96851 + 163e077 commit 483a4cc

File tree

3 files changed

+25
-7
lines changed

3 files changed

+25
-7
lines changed

.github/workflows/test.yml

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ jobs:
66
ruby-versions:
77
uses: ruby/actions/.github/workflows/ruby_versions.yml@master
88
with:
9-
engine: cruby
9+
engine: cruby-jruby
1010
min_version: 2.5
1111

1212
build:
@@ -32,3 +32,19 @@ jobs:
3232
bundler-cache: true
3333
- name: Run test
3434
run: bundle exec rake test
35+
- name: Build package
36+
id: build
37+
shell: bash
38+
run: |
39+
if ruby -e 'exit RUBY_VERSION>="3.0."'; then
40+
bundle exec rake build
41+
set pkg/*.gem
42+
echo pkg=$1 >> $GITHUB_OUTPUT
43+
fi
44+
- name: Install gem
45+
run: |
46+
gem install ${{ steps.build.outputs.pkg }}
47+
ruby -rresolv -e 'puts $LOADED_FEATURES.grep(/resolv/)'
48+
ruby -rresolv -e 'puts Resolv::VERSION'
49+
if: ${{ steps.build.outputs.pkg }}
50+
continue-on-error: ${{ startsWith(matrix.ruby, 'jruby') }}

Rakefile

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
require "bundler/gem_tasks"
22
require "rake/testtask"
3-
require "ruby-core/extensiontask"
43

5-
helper = Bundler::GemHelper.instance
6-
extask = RubyCore::ExtensionTask.new(helper.gemspec)
7-
task :test => :compile
4+
if RUBY_ENGINE == "ruby"
5+
require "ruby-core/extensiontask"
6+
helper = Bundler::GemHelper.instance
7+
extask = RubyCore::ExtensionTask.new(helper.gemspec)
8+
task :test => :compile
9+
end
810

911
Rake::TestTask.new(:test) do |t|
10-
t.libs.unshift(*extask.libs)
12+
t.libs.unshift(*extask.libs) if extask
1113
t.libs << "test/lib"
1214
t.ruby_opts << "-rhelper"
1315
t.test_files = FileList["test/**/test_*.rb"]

ext/win32/resolv/extconf.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
require 'mkmf'
2-
if have_library('iphlpapi', 'GetNetworkParams')
2+
if RUBY_ENGINE == "ruby" and have_library('iphlpapi', 'GetNetworkParams')
33
create_makefile('win32/resolv')
44
else
55
File.write('Makefile', "all clean install:\n\t@echo Done: $(@)\n")

0 commit comments

Comments
 (0)