Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add TruffleRuby support and add it in CI #44

Merged
merged 1 commit into from
May 29, 2023
Merged
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
3 changes: 2 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ jobs:
ruby-versions:
uses: ruby/actions/.github/workflows/ruby_versions.yml@master
with:
engine: cruby-jruby
min_version: 2.5
test:
needs: ruby-versions
Expand All @@ -22,6 +21,8 @@ jobs:
- { os: windows-latest, ruby: jruby }
- { os: macos-latest, ruby: jruby-head }
- { os: windows-latest, ruby: jruby-head }
- { os: windows-latest, ruby: truffleruby }
- { os: windows-latest, ruby: truffleruby-head }
include:
- { os: windows-latest, ruby: mingw }
- { os: windows-latest, ruby: mswin }
Expand Down
4 changes: 2 additions & 2 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Rake::JavaExtensionTask.new("escape") do |ext|
task :build => :compile
end

unless RUBY_ENGINE == 'jruby'
if RUBY_ENGINE == 'ruby'
require 'rake/extensiontask'
extask = Rake::ExtensionTask.new("cgi/escape") do |x|
x.lib_dir.sub!(%r[(?=/|\z)], "/#{RUBY_VERSION}/#{x.platform}")
Expand All @@ -22,7 +22,7 @@ Rake::TestTask.new(:test) do |t|
t.libs << "test/lib"
if RUBY_ENGINE == 'jruby'
t.libs << "ext/java/org/jruby/ext/cgi/escape/lib"
else
elsif RUBY_ENGINE == 'ruby'
t.libs << "lib/#{RUBY_VERSION}/#{extask.platform}"
end
t.ruby_opts << "-rhelper"
Expand Down
6 changes: 5 additions & 1 deletion ext/cgi/escape/extconf.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
require 'mkmf'

create_makefile 'cgi/escape'
if RUBY_ENGINE == 'truffleruby'
File.write("Makefile", dummy_makefile($srcdir).join(""))
else
create_makefile 'cgi/escape'
end
9 changes: 6 additions & 3 deletions lib/cgi/util.rb
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,12 @@ def escapeHTML(string)
end
end

begin
require 'cgi/escape'
rescue LoadError
# TruffleRuby runs the pure-Ruby variant faster, do not use the C extension there
unless RUBY_ENGINE == 'truffleruby'
begin
require 'cgi/escape'
rescue LoadError
end
end

# Unescape a string that has been HTML-escaped
Expand Down
4 changes: 2 additions & 2 deletions test/cgi/test_cgi_util.rb
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ def setup
remove_method :escapeHTML
alias _unescapeHTML unescapeHTML
remove_method :unescapeHTML
end
end if defined?(CGI::Escape)
end

def teardown
Expand All @@ -271,7 +271,7 @@ def teardown
remove_method :_escapeHTML
alias unescapeHTML _unescapeHTML
remove_method :_unescapeHTML
end
end if defined?(CGI::Escape)
end

def test_cgi_escapeHTML_with_invalid_byte_sequence
Expand Down