Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge pull request #48 from mvz/silence-cross-configuration-warning

Generate dummy cross-compile target when no configuration exists.

Also closes #16
  • Loading branch information...
commit 27c12db827fb52a92dd1e39819da8b843f64c8a6 2 parents fdb8f76 + 8ae0a59
@luislavena luislavena authored
Showing with 29 additions and 7 deletions.
  1. +10 −1 lib/rake/extensiontask.rb
  2. +19 −6 spec/lib/rake/extensiontask_spec.rb
View
11 lib/rake/extensiontask.rb
@@ -278,7 +278,7 @@ def define_cross_platform_tasks_with_version(for_platform, ruby_ver)
# warn the user about the need of configuration to use cross compilation.
unless File.exist?(config_path)
- warn "rake-compiler must be configured first to enable cross-compilation"
+ define_dummy_cross_platform_tasks
return
end
@@ -355,6 +355,15 @@ def define_cross_platform_tasks_with_version(for_platform, ruby_ver)
end
end
+ def define_dummy_cross_platform_tasks
+ task 'cross' do
+ Rake::Task['compile'].clear
+ task 'compile' do
+ raise "rake-compiler must be configured first to enable cross-compilation"
+ end
+ end
+ end
+
def extconf
"#{@ext_dir}/#{@config_script}"
end
View
25 spec/lib/rake/extensiontask_spec.rb
@@ -283,16 +283,29 @@
File.stub!(:open).and_yield(mock_fake_rb)
end
- it 'should warn if no rake-compiler configuration exist' do
- File.should_receive(:exist?).with(@config_file).and_return(false)
+ context 'if no rake-compiler configuration exists' do
+ before :each do
+ File.should_receive(:exist?).with(@config_file).and_return(false)
- out, err = capture_output do
- Rake::ExtensionTask.new('extension_one') do |ext|
- ext.cross_compile = true
+ _, @err = capture_output do
+ Rake::ExtensionTask.new('extension_one') do |ext|
+ ext.cross_compile = true
+ end
end
end
- err.should match(/rake-compiler must be configured first to enable cross-compilation/)
+ it 'should not generate a warning' do
+ @err.should eq("")
+ end
+
+ it 'should create a dummy nested cross-compile target that raises an error' do
+ Rake::Task.should have_defined("cross")
+ Rake::Task["cross"].invoke
+ lambda {
+ Rake::Task["compile"].invoke
+ }.should raise_error(RuntimeError,
+ /rake-compiler must be configured first to enable cross-compilation/)
+ end
end
it 'should parse the config file using YAML' do
Please sign in to comment.
Something went wrong with that request. Please try again.