From b54f163d3e7c460e26dfbf5a409c6a6f308dcc2e Mon Sep 17 00:00:00 2001 From: John Bintz Date: Tue, 23 Aug 2011 19:49:47 -0400 Subject: [PATCH] make cleanups and color fixes --- Gemfile | 1 + ext/jasmine-webkit-specrunner/ConsoleOutput.h | 2 +- ext/jasmine-webkit-specrunner/Runner.cpp | 1 + ext/jasmine-webkit-specrunner/jhw-test | Bin 69912 -> 69912 bytes ext/jasmine-webkit-specrunner/test.rb | 9 +++++++- lib/qt/qmake.rb | 21 +++++++++++++++++- spec/lib/qt/qmake_spec.rb | 11 +++++++++ 7 files changed, 42 insertions(+), 3 deletions(-) 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 ed6d28006ecd1772f00f68c55bd83e3da35f3b4c..347fe5ae741c42789bdafcac17441fd6dda4a8f4 100755 GIT binary patch delta 995 zcmXw1ZA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n7RDUoBV<+5A;cWwEGl;yj0RMlO0Atmq=D9Uo{x_6F~i|-44v!Eigvz;pnTfe zVUz4#eP%LDr+OX4FU3Fi8HtUK^gD=C+UOr6M5H4F4&s$I2D0>)2KBMY>TE-a%Hxwt z2K)3D=7T|0s?7MSjF3cL9ZtdbSMark9GHDTzyKkPpv!hO!f(ADFse z$~5@x3c9ZTK4os!o;sd1Y{S)>nhPoxRaI2Qn#xZq4ypA`6>I7bVK3INQgw4l#iEJ_ zBUtjy)av3jj}s<s(5<=J=*Lk`1X#->R71A(CN6#lTB9=3WwXW}Oe~@MNru H>-+x$?5Q}n 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