clean up cpp some more

This commit is contained in:
John Bintz 2011-08-26 11:18:04 -04:00
parent a46e72c1e2
commit e3923335b8
9 changed files with 34 additions and 8 deletions

View File

@ -36,4 +36,12 @@ namespace HeadlessSpecRunner {
void ConsoleOutput::red() { void ConsoleOutput::red() {
if (showColors) std::cout << "\033[0;31m"; if (showColors) std::cout << "\033[0;31m";
} }
void ConsoleOutput::errorLog(const QString &msg, int lineNumber, const QString &sourceID) {
red();
*outputIO << "[error] ";
clear();
*outputIO << qPrintable(sourceID) << ":" << lineNumber << " : " << qPrintable(msg);
*outputIO << std::endl;
}
} }

View File

@ -12,6 +12,7 @@ namespace HeadlessSpecRunner {
ConsoleOutput(); ConsoleOutput();
void passed(const QString &specDetail); void passed(const QString &specDetail);
void failed(const QString &specDetail); void failed(const QString &specDetail);
void errorLog(const QString &msg, int lineNumber, const QString &sourceID);
std::ostream *outputIO; std::ostream *outputIO;
QStack<QString> successes; QStack<QString> successes;
QStack<QString> failures; QStack<QString> failures;

View File

@ -30,6 +30,15 @@ namespace HeadlessSpecRunner {
QVERIFY(output.successes.size() == 0); QVERIFY(output.successes.size() == 0);
QVERIFY(output.failures.size() == 1); QVERIFY(output.failures.size() == 1);
} }
void ConsoleOutputTest::testErrorLog() {
stringstream buffer;
HeadlessSpecRunner::ConsoleOutput output;
output.outputIO = &buffer;
output.errorLog("message", 1, "source");
QVERIFY(buffer.str() == "[error] source:1 : message\n");
}
} }
QTEST_MAIN(HeadlessSpecRunner::ConsoleOutputTest); QTEST_MAIN(HeadlessSpecRunner::ConsoleOutputTest);

View File

@ -17,6 +17,7 @@ namespace HeadlessSpecRunner {
private slots: private slots:
void testPassed(); void testPassed();
void testFailed(); void testFailed();
void testErrorLog();
}; };
} }

View File

@ -1,5 +1,6 @@
#include <QtGui> #include <QtGui>
#include <QtWebKit> #include <QtWebKit>
#include <iostream>
#include "Page.h" #include "Page.h"

View File

@ -114,11 +114,7 @@ namespace HeadlessSpecRunner {
void Runner::errorLog(const QString &msg, int lineNumber, const QString &sourceID) void Runner::errorLog(const QString &msg, int lineNumber, const QString &sourceID)
{ {
red(); consoleOutput.errorLog(msg, lineNumber, sourceID);
std::cout << "[error] ";
clear();
std::cout << qPrintable(sourceID) << ":" << lineNumber << " : " << qPrintable(msg);
std::cout << std::endl;
hasErrors = true; hasErrors = true;
m_runs = 0; m_runs = 0;

View File

@ -32,7 +32,7 @@ module Qt
"macx-g++" "macx-g++"
end) end)
command = "#{path} -spec #{spec}" command = "#{path} #{envs} -spec #{spec}"
command << " #{project_file}" if project_file command << " #{project_file}" if project_file
command command
end end
@ -95,6 +95,14 @@ module Qt
end end
private private
def envs
%w{QMAKE_CC QMAKE_CXX}.collect do |env|
if ENV[env]
"#{env}=#{ENV[env]}"
end
end.compact.join(" ")
end
def number_of_cpus def number_of_cpus
if defined?(Facter) if defined?(Facter)
Facter.sp_number_processors rescue Facter.processorcount Facter.sp_number_processors rescue Facter.processorcount

View File

@ -55,13 +55,15 @@ describe Qt::Qmake do
context 'linux' do context 'linux' do
let(:platform) { :linux } let(:platform) { :linux }
it { should == "qmake -spec linux-g++" } it { should =~ /^qmake/ }
it { should =~ /-spec linux-g\+\+$/ }
end end
context 'mac os x' do context 'mac os x' do
let(:platform) { :mac_os_x } let(:platform) { :mac_os_x }
it { should == "qmake -spec macx-g++" } it { should =~ /^qmake/ }
it { should =~ /-spec macx-g\+\+$/ }
end end
end end