diff --git a/Gemfile b/Gemfile index c16218b..b2a8e50 100644 --- a/Gemfile +++ b/Gemfile @@ -12,3 +12,4 @@ gem 'guard-coffeescript' gem 'growl' gem 'rake', '0.8.7' gem 'mocha', '0.9.12' +gem 'facter' diff --git a/ext/jasmine-webkit-specrunner/ConsoleOutput.h b/ext/jasmine-webkit-specrunner/ConsoleOutput.h index d63e3ac..0861aa3 100644 --- a/ext/jasmine-webkit-specrunner/ConsoleOutput.h +++ b/ext/jasmine-webkit-specrunner/ConsoleOutput.h @@ -15,8 +15,8 @@ namespace HeadlessSpecRunner { std::ostream *outputIO; QStack successes; QStack failures; - private: bool showColors; + private: void green(); void clear(); void red(); diff --git a/ext/jasmine-webkit-specrunner/Runner.cpp b/ext/jasmine-webkit-specrunner/Runner.cpp index b5c5ee2..0c3fae2 100644 --- a/ext/jasmine-webkit-specrunner/Runner.cpp +++ b/ext/jasmine-webkit-specrunner/Runner.cpp @@ -66,6 +66,7 @@ namespace HeadlessSpecRunner { void Runner::setColors(bool colors) { showColors = colors; + consoleOutput.showColors = colors; } void Runner::reportFile(const QString &file) diff --git a/ext/jasmine-webkit-specrunner/jhw-test b/ext/jasmine-webkit-specrunner/jhw-test index ed6d280..347fe5a 100755 Binary files a/ext/jasmine-webkit-specrunner/jhw-test and b/ext/jasmine-webkit-specrunner/jhw-test differ diff --git a/ext/jasmine-webkit-specrunner/test.rb b/ext/jasmine-webkit-specrunner/test.rb index 6934d3e..4585da1 100644 --- a/ext/jasmine-webkit-specrunner/test.rb +++ b/ext/jasmine-webkit-specrunner/test.rb @@ -1,7 +1,14 @@ #!/usr/bin/env ruby +system %{make clean} + Dir['*_test.pro'].each do |test| - system %{make clean && qmake #{test} && make && ./jhw-test} + $: << File.expand_path("../../../lib", __FILE__) + + require 'qt/qmake' + Qt::Qmake.make!('jasmine-headless-webkit', test) + + system %{./jhw-test} if $?.exitstatus != 0 exit 1 end diff --git a/lib/qt/qmake.rb b/lib/qt/qmake.rb index ec5b951..94ec745 100644 --- a/lib/qt/qmake.rb +++ b/lib/qt/qmake.rb @@ -1,6 +1,12 @@ require 'rbconfig' require 'rubygems/version' +begin + require 'facter' +rescue LoadError + warn 'Including Facter allows for detection of # of cpus, resulting in faster compilations.' +end + module Qt class NotInstalledError < StandardError; end class Qmake @@ -37,7 +43,12 @@ module Qt check_qmake! system command(project_file) - system %{make} + + system %{make #{make_options}} + end + + def make_options + "-j#{number_of_cpus}" end # @@ -83,6 +94,14 @@ module Qt end private + def number_of_cpus + if defined?(Facter) + Facter.sp_number_processors rescue Facter.processorcount + else + 1 + end + end + def get_exe_path(command) path = %x{which #{command}}.strip path = nil if path == '' diff --git a/spec/lib/qt/qmake_spec.rb b/spec/lib/qt/qmake_spec.rb index 64d2dd9..4cc7016 100644 --- a/spec/lib/qt/qmake_spec.rb +++ b/spec/lib/qt/qmake_spec.rb @@ -136,5 +136,16 @@ describe Qt::Qmake do end end end + + describe '.make_options' do + let(:cpu_count) { 3 } + subject { Qt::Qmake.make_options } + + before do + Qt::Qmake.stubs(:number_of_cpus).returns(cpu_count) + end + + it { should == "-j#{cpu_count}" } + end end