Skip to content
This repository
Browse code

Generate dummy cross-compile target when no configuration exists.

This fixes issue #16.
  • Loading branch information...
commit 8ae0a59ecca73994bc481ecbdb15a9e88b04c0a8 1 parent fdb8f76
Matijs van Zuijlen mvz authored
11 lib/rake/extensiontask.rb
@@ -278,7 +278,7 @@ def define_cross_platform_tasks_with_version(for_platform, ruby_ver)
278 278
279 279 # warn the user about the need of configuration to use cross compilation.
280 280 unless File.exist?(config_path)
281   - warn "rake-compiler must be configured first to enable cross-compilation"
  281 + define_dummy_cross_platform_tasks
282 282 return
283 283 end
284 284
@@ -355,6 +355,15 @@ def define_cross_platform_tasks_with_version(for_platform, ruby_ver)
355 355 end
356 356 end
357 357
  358 + def define_dummy_cross_platform_tasks
  359 + task 'cross' do
  360 + Rake::Task['compile'].clear
  361 + task 'compile' do
  362 + raise "rake-compiler must be configured first to enable cross-compilation"
  363 + end
  364 + end
  365 + end
  366 +
358 367 def extconf
359 368 "#{@ext_dir}/#{@config_script}"
360 369 end
25 spec/lib/rake/extensiontask_spec.rb
@@ -283,16 +283,29 @@
283 283 File.stub!(:open).and_yield(mock_fake_rb)
284 284 end
285 285
286   - it 'should warn if no rake-compiler configuration exist' do
287   - File.should_receive(:exist?).with(@config_file).and_return(false)
  286 + context 'if no rake-compiler configuration exists' do
  287 + before :each do
  288 + File.should_receive(:exist?).with(@config_file).and_return(false)
288 289
289   - out, err = capture_output do
290   - Rake::ExtensionTask.new('extension_one') do |ext|
291   - ext.cross_compile = true
  290 + _, @err = capture_output do
  291 + Rake::ExtensionTask.new('extension_one') do |ext|
  292 + ext.cross_compile = true
  293 + end
292 294 end
293 295 end
294 296
295   - err.should match(/rake-compiler must be configured first to enable cross-compilation/)
  297 + it 'should not generate a warning' do
  298 + @err.should eq("")
  299 + end
  300 +
  301 + it 'should create a dummy nested cross-compile target that raises an error' do
  302 + Rake::Task.should have_defined("cross")
  303 + Rake::Task["cross"].invoke
  304 + lambda {
  305 + Rake::Task["compile"].invoke
  306 + }.should raise_error(RuntimeError,
  307 + /rake-compiler must be configured first to enable cross-compilation/)
  308 + end
296 309 end
297 310
298 311 it 'should parse the config file using YAML' do

0 comments on commit 8ae0a59

Please sign in to comment.
Something went wrong with that request. Please try again.