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

Load extension ('json/ext') consistently in test_ext #536

Merged
merged 1 commit into from
Sep 13, 2023

Conversation

aeroastro
Copy link
Contributor

@aeroastro aeroastro commented Aug 14, 2023

Summary

This patch fixes the issue that rake test does not actually test
C extension for CRuby.

The Bug

The test task is defined as follows:

json/Rakefile

Lines 109 to 110 in 7ec73ad

desc "Testing library (pure ruby and extension)"
task :test => [ :test_pure, :test_ext ]

This invokes :test_pure and :test_ext consecutively.

:test_pure assigns ENV['JSON'] = 'pure' as follows:

json/Rakefile

Lines 97 to 98 in 7ec73ad

task :test_pure => [ :set_env_pure, :check_env, :do_test_pure ]
task(:set_env_pure) { ENV['JSON'] = 'pure' }

However, :test_ext for CRuby does not change ENV['JSON'].

json/Rakefile

Line 252 in 7ec73ad

task :test_ext => [ :check_env, :compile, :do_test_ext ]

This lead to require 'json/pure' in test_helper.rb, which test only the pure version.

when 'pure'
$:.unshift File.join(__dir__, '../lib')
require 'json/pure'

How to Fix It

I have added :set_env_ext to guarantee that :test_ext assigns ENV['JSON'] = 'ext'.
This is just like test_ext in JRuby version

@hsbt hsbt merged commit 66950ee into flori:master Sep 13, 2023
47 of 65 checks passed
@aeroastro aeroastro deleted the feature/fix-running-ext-test branch September 14, 2023 02:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants