[ruby/cgi] Add TruffleRuby support and add it in CI

https://github.com/ruby/cgi/commit/1240fec9c9
This commit is contained in:
Benoit Daloze 2023-05-29 13:53:49 +02:00 committed by git
parent 610038f3bf
commit f61bd3ca80
3 changed files with 13 additions and 6 deletions

View File

@ -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

View File

@ -90,9 +90,12 @@ module CGI::Util
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

View File

@ -262,7 +262,7 @@ class CGIUtilPureRubyTest < Test::Unit::TestCase
remove_method :escapeHTML
alias _unescapeHTML unescapeHTML
remove_method :unescapeHTML
end
end if defined?(CGI::Escape)
end
def teardown
@ -271,7 +271,7 @@ class CGIUtilPureRubyTest < Test::Unit::TestCase
remove_method :_escapeHTML
alias unescapeHTML _unescapeHTML
remove_method :_unescapeHTML
end
end if defined?(CGI::Escape)
end
def test_cgi_escapeHTML_with_invalid_byte_sequence