File tree Expand file tree Collapse file tree 4 files changed +44
-11
lines changed
.github/actions/easy_compile Expand file tree Collapse file tree 4 files changed +44
-11
lines changed Original file line number Diff line number Diff line change @@ -28211,7 +28211,7 @@ async function run(workingDirectory) {
2821128211 let ccRubies = cp.execSync('easy_compile print_ruby_cc_version', { cwd: workingDirectory, encoding: 'utf-8' })
2821228212
2821328213 await downloadRubies(ccRubies.split(':'))
28214- setupRakeCompilerConfig()
28214+ setupRakeCompilerConfig(workingDirectory )
2821528215}
2821628216
2821728217async function downloadRubies(rubies) {
@@ -28227,11 +28227,11 @@ async function downloadRubies(rubies) {
2822728227 }
2822828228}
2822928229
28230- function setupRakeCompilerConfig() {
28230+ function setupRakeCompilerConfig(workingDirectory ) {
2823128231 let rubiesRbConfig = fs.globSync(`${rubiesPath()}/*/*/lib/ruby/*/*/rbconfig.rb`)
2823228232 let currentRubyVersion = cp.execSync('ruby -v', { encoding: 'utf-8' }).match(/^ruby (\d\.\d\.\d)/)[1]
2823328233 let rbConfigPath = path.join(os.homedir(), ".rake-compiler", "config.yml")
28234- let rubyPlatform = cp.execSync('easy_compile print_normalized_platform', { encoding: 'utf-8' })
28234+ let rubyPlatform = cp.execSync('easy_compile print_normalized_platform', { cwd: workingDirectory, encoding: 'utf-8' })
2823528235
2823628236 fs.mkdirSync(`${os.homedir()}/.rake-compiler`)
2823728237
Original file line number Diff line number Diff line change @@ -10,7 +10,7 @@ async function run(workingDirectory) {
1010 let ccRubies = cp . execSync ( 'easy_compile print_ruby_cc_version' , { cwd : workingDirectory , encoding : 'utf-8' } )
1111
1212 await downloadRubies ( ccRubies . split ( ':' ) )
13- setupRakeCompilerConfig ( )
13+ setupRakeCompilerConfig ( workingDirectory )
1414}
1515
1616async function downloadRubies ( rubies ) {
@@ -26,11 +26,11 @@ async function downloadRubies(rubies) {
2626 }
2727}
2828
29- function setupRakeCompilerConfig ( ) {
29+ function setupRakeCompilerConfig ( workingDirectory ) {
3030 let rubiesRbConfig = fs . globSync ( `${ rubiesPath ( ) } /*/*/lib/ruby/*/*/rbconfig.rb` )
3131 let currentRubyVersion = cp . execSync ( 'ruby -v' , { encoding : 'utf-8' } ) . match ( / ^ r u b y ( \d \. \d \. \d ) / ) [ 1 ]
3232 let rbConfigPath = path . join ( os . homedir ( ) , ".rake-compiler" , "config.yml" )
33- let rubyPlatform = cp . execSync ( 'easy_compile print_normalized_platform' , { encoding : 'utf-8' } )
33+ let rubyPlatform = cp . execSync ( 'easy_compile print_normalized_platform' , { cwd : workingDirectory , encoding : 'utf-8' } )
3434
3535 fs . mkdirSync ( `${ os . homedir ( ) } /.rake-compiler` )
3636
Original file line number Diff line number Diff line change @@ -11,6 +11,7 @@ class CompilationTasks
1111
1212 def initialize ( create_packaging_task = false , gemspec = nil )
1313 @gemspec = Bundler . load_gemspec ( gemspec || find_gemspec )
14+ verify_gemspec!
1415
1516 @create_packaging_task = create_packaging_task
1617 end
@@ -126,5 +127,14 @@ def find_gemspec(glob = "*.gemspec")
126127 Make sure to run any easy_compile commands in the root of your gem folder.
127128 EOM
128129 end
130+
131+ def verify_gemspec!
132+ return if gemspec . extensions . any?
133+
134+ raise GemspecError , <<~EOM
135+ Your gem has no native extention defined in its gemspec.
136+ This tool can't be used on pure Ruby gems.
137+ EOM
138+ end
129139 end
130140end
Original file line number Diff line number Diff line change @@ -122,11 +122,9 @@ def test_when_cli_runs_in_project_with_no_gemspec
122122 out = nil
123123
124124 Dir . chdir ( "lib" ) do
125- Kernel . stub ( :exit , -> ( _ ) { raise } ) do
126- out , _ = capture_subprocess_io do
127- assert_raises ( StandardError ) do
128- CLI . start ( [ "print_ruby_cc_version" ] )
129- end
125+ out , _ = capture_subprocess_io do
126+ raise_instead_of_exit do
127+ CLI . start ( [ "print_ruby_cc_version" ] )
130128 end
131129 end
132130 end
@@ -136,5 +134,30 @@ def test_when_cli_runs_in_project_with_no_gemspec
136134 Make sure to run any easy_compile commands in the root of your gem folder.
137135 MSG
138136 end
137+
138+ def test_when_cli_runs_in_project_with_no_native_extension
139+ out = nil
140+
141+ out , _ = capture_subprocess_io do
142+ raise_instead_of_exit do
143+ CLI . start ( [ "print_ruby_cc_version" ] )
144+ end
145+ end
146+
147+ assert_equal ( <<~MSG , out )
148+ Your gem has no native extention defined in its gemspec.
149+ This tool can't be used on pure Ruby gems.
150+ MSG
151+ end
152+
153+ private
154+
155+ def raise_instead_of_exit ( &block )
156+ Kernel . stub ( :exit , -> ( _ ) { raise } ) do
157+ assert_raises ( StandardError ) do
158+ block . call
159+ end
160+ end
161+ end
139162 end
140163end
You can’t perform that action at this time.
0 commit comments