diff options
author | Christian Kandeler <christian.kandeler@digia.com> | 2013-01-31 18:23:59 +0100 |
---|---|---|
committer | Christian Kandeler <christian.kandeler@digia.com> | 2013-02-06 10:36:05 +0100 |
commit | aea6cbfa9d96f3f76bbc3b81362c54c9322b3fcb (patch) | |
tree | c140b905b53b01e509ad923a12e5b31f043f3361 /tests | |
parent | e5545733e8f63f62d499e73a27a72fc898a58e4e (diff) | |
download | qbs-aea6cbfa9d96f3f76bbc3b81362c54c9322b3fcb.tar.gz |
Remove global log sink.
Applications may not want to use the same log sink for all builds.
The logging facility is also decoupled from the command-line client in other
ways:
- The LogWriter modifiers for output channel and text color are gone,
since this type of decision should not be made by low-level code.
Instead, the "highlight" string can be forwarded to the log sink.
- The console logger now lives in app/shared, as it must never be used
by library code.
Change-Id: I8863a554c9b74577320ef23f6f934a74e0f0cbb0
Reviewed-by: Joerg Bornemann <joerg.bornemann@digia.com>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/buildgraph/buildgraph.pro | 5 | ||||
-rw-r--r-- | tests/auto/buildgraph/tst_buildgraph.cpp | 3 | ||||
-rw-r--r-- | tests/auto/language/language.pro | 5 | ||||
-rw-r--r-- | tests/auto/language/tst_language.cpp | 5 | ||||
-rw-r--r-- | tests/auto/language/tst_language.h | 3 | ||||
-rw-r--r-- | tests/auto/tools/tools.pro | 5 | ||||
-rw-r--r-- | tests/auto/tools/tst_tools.cpp | 19 |
7 files changed, 28 insertions, 17 deletions
diff --git a/tests/auto/buildgraph/buildgraph.pro b/tests/auto/buildgraph/buildgraph.pro index 31255e088..2e9dc3bdf 100644 --- a/tests/auto/buildgraph/buildgraph.pro +++ b/tests/auto/buildgraph/buildgraph.pro @@ -7,10 +7,11 @@ DEFINES += SRCDIR=\\\"$$PWD/\\\" QT = core testlib CONFIG += depend_includepath testcase -include(../../../src/lib/use.pri) - HEADERS += \ tst_buildgraph.h SOURCES += \ tst_buildgraph.cpp + +include(../../../src/lib/use.pri) +include(../../../src/app/shared/logging/logging.pri) diff --git a/tests/auto/buildgraph/tst_buildgraph.cpp b/tests/auto/buildgraph/tst_buildgraph.cpp index b9c2e7354..1d49dd779 100644 --- a/tests/auto/buildgraph/tst_buildgraph.cpp +++ b/tests/auto/buildgraph/tst_buildgraph.cpp @@ -28,6 +28,7 @@ ****************************************************************************/ #include "tst_buildgraph.h" +#include <app/shared/logging/consolelogger.h> #include <buildgraph/artifact.h> #include <buildgraph/buildproduct.h> #include <buildgraph/cycledetector.h> @@ -52,7 +53,7 @@ void TestBuildGraph::cleanupTestCase() static bool cycleDetected(const BuildProductConstPtr &product) { try { - CycleDetector().visitProduct(product); + CycleDetector(ConsoleLogger::instance()).visitProduct(product); return false; } catch (const Error &) { return true; diff --git a/tests/auto/language/language.pro b/tests/auto/language/language.pro index 235e48d52..2e4b599d8 100644 --- a/tests/auto/language/language.pro +++ b/tests/auto/language/language.pro @@ -7,8 +7,6 @@ DEFINES += SRCDIR=\\\"$$PWD/\\\" QT = core testlib CONFIG += depend_includepath testcase -include(../../../src/lib/use.pri) - HEADERS += \ tst_language.h @@ -18,3 +16,6 @@ SOURCES += \ OTHER_FILES += \ $$PWD/testdata/* \ testdata/outerInGroup.qbs + +include(../../../src/lib/use.pri) +include(../../../src/app/shared/logging/logging.pri) diff --git a/tests/auto/language/tst_language.cpp b/tests/auto/language/tst_language.cpp index e1ff68167..c737b1ccb 100644 --- a/tests/auto/language/tst_language.cpp +++ b/tests/auto/language/tst_language.cpp @@ -29,6 +29,7 @@ #include "tst_language.h" +#include <app/shared/logging/consolelogger.h> #include <language/identifiersearch.h> #include <language/language.h> #include <language/scriptengine.h> @@ -74,8 +75,8 @@ void TestLanguage::initTestCase() { //Logger::instance().setLogSink(new ConsolePrintLogSink); //Logger::instance().setLevel(LoggerTrace); - ScriptEngine *engine = new ScriptEngine(this); - loader = new Loader(engine, m_settings.data()); + ScriptEngine *engine = new ScriptEngine(ConsoleLogger::instance(), this); + loader = new Loader(engine, m_settings.data(), ConsoleLogger::instance()); loader->setSearchPaths(QStringList() << QLatin1String(SRCDIR "../../../share/qbs") << QLatin1String(SRCDIR "testdata")); diff --git a/tests/auto/language/tst_language.h b/tests/auto/language/tst_language.h index 02112c74e..831eebaf6 100644 --- a/tests/auto/language/tst_language.h +++ b/tests/auto/language/tst_language.h @@ -33,12 +33,11 @@ #include <app/shared/qbssettings.h> #include <language/forward_decls.h> #include <language/loader.h> -#include <logging/consolelogger.h> -#include <logging/logger.h> #include <tools/setupprojectparameters.h> #include <QtTest> using namespace qbs; +using namespace Internal; class TestLanguage : public QObject { diff --git a/tests/auto/tools/tools.pro b/tests/auto/tools/tools.pro index 86ba74340..43719a2f0 100644 --- a/tests/auto/tools/tools.pro +++ b/tests/auto/tools/tools.pro @@ -7,8 +7,9 @@ DEFINES += SRCDIR=\\\"$$PWD/\\\" QT = core testlib CONFIG += depend_includepath testcase +SOURCES += tst_tools.cpp ../../../src/app/qbs/qbstool.cpp + include(../../../src/lib/use.pri) include(../../../qbs_version.pri) include(../../../src/app/qbs/parser/parser.pri) - -SOURCES += tst_tools.cpp ../../../src/app/qbs/qbstool.cpp +include(../../../src/app/shared/logging/logging.pri) diff --git a/tests/auto/tools/tst_tools.cpp b/tests/auto/tools/tst_tools.cpp index 658754d01..3bd21f990 100644 --- a/tests/auto/tools/tst_tools.cpp +++ b/tests/auto/tools/tst_tools.cpp @@ -28,8 +28,8 @@ ****************************************************************************/ #include <app/qbs/parser/commandlineparser.h> +#include <app/shared/logging/consolelogger.h> #include <app/shared/qbssettings.h> -#include <logging/logger.h> #include <tools/buildoptions.h> #include <tools/error.h> #include <tools/fileinfo.h> @@ -41,12 +41,19 @@ #include <QtTest> using namespace qbs; +using namespace Internal; static SettingsPtr settings = qbsSettings(); class TestTools : public QObject { Q_OBJECT +public: + TestTools() + { + ConsoleLogger::instance().logSink()->setEnabled(false); + } + private slots: void testValidCommandLine() { @@ -62,7 +69,7 @@ private slots: CommandLineParser parser; QVERIFY(parser.parseCommandLine(args, settings.data())); - QCOMPARE(Logger::instance().level(), LoggerTrace); + QCOMPARE(ConsoleLogger::instance().logSink()->logLevel(), LoggerTrace); QCOMPARE(parser.command(), BuildCommandType); QCOMPARE(parser.products(), QStringList() << "blubb"); QCOMPARE(parser.buildOptions().changedFiles.count(), 2); @@ -70,18 +77,18 @@ private slots: QVERIFY(parser.force()); QVERIFY(parser.parseCommandLine(QStringList() << "-vvvqqq" << fileArgs, settings.data())); - QCOMPARE(Logger::instance().level(), Logger::defaultLevel()); + QCOMPARE(ConsoleLogger::instance().logSink()->logLevel(), defaultLogLevel()); QVERIFY(!parser.force()); QVERIFY(parser.parseCommandLine(QStringList() << "-vvqqq" << fileArgs, settings.data())); - QCOMPARE(Logger::instance().level(), LoggerWarning); + QCOMPARE(ConsoleLogger::instance().logSink()->logLevel(), LoggerWarning); QVERIFY(parser.parseCommandLine(QStringList() << "-vvvqq" << fileArgs, settings.data())); - QCOMPARE(Logger::instance().level(), LoggerDebug); + QCOMPARE(ConsoleLogger::instance().logSink()->logLevel(), LoggerDebug); QVERIFY(parser.parseCommandLine(QStringList() << "--log-level" << "trace" << fileArgs, settings.data())); - QCOMPARE(Logger::instance().level(), LoggerTrace); + QCOMPARE(ConsoleLogger::instance().logSink()->logLevel(), LoggerTrace); } void testInvalidCommandLine() |