diff options
author | Benoit Daloze <[email protected]> | 2023-05-29 13:53:49 +0200 |
---|---|---|
committer | git <[email protected]> | 2023-05-29 19:33:38 +0000 |
commit | f61bd3ca806dab1de8052f70bb72938b8ef64edc (patch) | |
tree | fdfef12cd6bbb6fd15bbf2c52cd574ed36bd3eb1 | |
parent | 610038f3bf6eae50c0ad4f16af02d4c50a812e2a (diff) |
[ruby/cgi] Add TruffleRuby support and add it in CI
https://github.com/ruby/cgi/commit/1240fec9c9
-rw-r--r-- | ext/cgi/escape/extconf.rb | 6 | ||||
-rw-r--r-- | lib/cgi/util.rb | 9 | ||||
-rw-r--r-- | test/cgi/test_cgi_util.rb | 4 |
3 files changed, 13 insertions, 6 deletions
diff --git a/ext/cgi/escape/extconf.rb b/ext/cgi/escape/extconf.rb index 16e8ff224d..73acd89ca8 100644 --- a/ext/cgi/escape/extconf.rb +++ b/ext/cgi/escape/extconf.rb @@ -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 diff --git a/lib/cgi/util.rb b/lib/cgi/util.rb index 5a5c77ac97..5f335898dc 100644 --- a/lib/cgi/util.rb +++ b/lib/cgi/util.rb @@ -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 diff --git a/test/cgi/test_cgi_util.rb b/test/cgi/test_cgi_util.rb index a3be193a13..b3a46a1c25 100644 --- a/test/cgi/test_cgi_util.rb +++ b/test/cgi/test_cgi_util.rb @@ -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 |