Skip to content

Commit

Permalink
tests: merge consolelog/ with lib-core/
Browse files Browse the repository at this point in the history
  • Loading branch information
gperciva committed Dec 6, 2023
1 parent c0c3ec6 commit 1eff3b1
Show file tree
Hide file tree
Showing 8 changed files with 31 additions and 96 deletions.
1 change: 0 additions & 1 deletion Tarsnap.pro
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,6 @@ UNIT_TESTS = \
tests/customfilesystemmodel \
tests/small-widgets \
tests/lib-widgets \
tests/consolelog \
tests/task \
tests/lib-core

Expand Down
2 changes: 0 additions & 2 deletions tests/consolelog/.gitignore

This file was deleted.

11 changes: 0 additions & 11 deletions tests/consolelog/confdir/test-consolelog.conf

This file was deleted.

62 changes: 0 additions & 62 deletions tests/consolelog/test-consolelog.cpp

This file was deleted.

19 changes: 0 additions & 19 deletions tests/consolelog/test-consolelog.pro

This file was deleted.

26 changes: 26 additions & 0 deletions tests/lib-core/test-lib-core.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,14 @@

WARNINGS_DISABLE
#include <QCoreApplication>
#include <QDir>
#include <QObject>
#include <QString>
#include <QTest>
#include <QVariant>
WARNINGS_ENABLE

#include "ConsoleLog.h"
#include "TSettings.h"

class TestLibCore : public QObject
Expand All @@ -21,16 +23,20 @@ private slots:
void settings_default();
void settings_custom();
void settings_default_after_custom();

void log_saveMessage();
};

void TestLibCore::initTestCase()
{
QCoreApplication::setOrganizationName(TEST_NAME);
LOG.initializeConsoleLog();
}

void TestLibCore::cleanupTestCase()
{
TSettings::destroy();
ConsoleLog::destroy();
}

void TestLibCore::settings_default()
Expand Down Expand Up @@ -73,6 +79,26 @@ void TestLibCore::settings_default_after_custom()
QVERIFY(user == "default_init");
}

void TestLibCore::log_saveMessage()
{
TSettings settings;

QString appdata = settings.value("app/app_data", "").toString();
QString logFile = appdata + QDir::separator() + TEST_NAME + ".log";

// Don't record this message
LOG << "don't write this\n";

// Save a message
LOG.setFilename(logFile);
LOG.setWriteToFile(true);
LOG << "write this\n";

// Disable saving again
LOG.setWriteToFile(false);
LOG << "don't write this\n";
}

QTEST_MAIN(TestLibCore)
WARNINGS_DISABLE
#include "test-lib-core.moc"
Expand Down
4 changes: 4 additions & 0 deletions tests/lib-core/test-lib-core.pro
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,16 @@ TOPDIR = ../..
VALGRIND = true

HEADERS += \
$$TOPDIR/lib/core/ConsoleLog.h \
$$TOPDIR/lib/core/TSettings.h

SOURCES += test-lib-core.cpp \
$$TOPDIR/lib/core/ConsoleLog.cpp \
$$TOPDIR/lib/core/TSettings.cpp

include(../tests-include.pri)

# We need the extra "appdata" to save the logfile.
test_home_prep.commands += ; mkdir -p "$${TEST_HOME}/$${TARGET}"; \
mkdir -p "$${TEST_HOME}/$${TARGET}/appdata"; \
cp confdir/*.conf "$${TEST_HOME}/$${TARGET}"
2 changes: 1 addition & 1 deletion tests/run-valgrind-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ set -e

# Command-line
DIRS_C=""
DIRS_C="${DIRS_C} lib-core consolelog"
DIRS_C="${DIRS_C} lib-core"
DIRS_C="${DIRS_C} task taskmanager persistent"
DIRS_C="${DIRS_C} app-cmdline cli"

Expand Down

0 comments on commit 1eff3b1

Please sign in to comment.