[libcalamaresui] Fix up test for logfile

- this test would fail if the logfile already exists for
  any reason (including "I just ran the test")
- remove the file before expecting an empty logfile
- improve messages; a missing logfile is not a "things cannot
  work" situation, it's a warning
main
Adriaan de Groot 4 years ago
parent cdbc5a7b4b
commit 1998405dbb

@ -28,10 +28,11 @@ using namespace CalamaresUtils::Units;
STATICTEST QByteArray
logFileContents()
{
QFile pasteSourceFile( Logger::logFile() );
const QString name = Logger::logFile();
QFile pasteSourceFile( name );
if ( !pasteSourceFile.open( QIODevice::ReadOnly | QIODevice::Text ) )
{
cError() << "Could not open log file";
cWarning() << "Could not open log file" << name;
return QByteArray();
}
QFileInfo fi( pasteSourceFile );

@ -35,15 +35,16 @@ private Q_SLOTS:
void
TestPaste::testGetLogFile()
{
QFile::remove( Logger::logFile() );
// This test assumes nothing **else** has set up logging yet
QByteArray b = logFileContents();
QVERIFY( b.isEmpty() );
QByteArray contentsOfLogfileBefore = logFileContents();
QVERIFY( contentsOfLogfileBefore.isEmpty() );
Logger::setupLogLevel( Logger::LOGDEBUG );
Logger::setupLogfile();
b = logFileContents();
QVERIFY( !b.isEmpty() );
QByteArray contentsOfLogfileAfterSetup = logFileContents();
QVERIFY( !contentsOfLogfileAfterSetup.isEmpty() );
}
void

Loading…
Cancel
Save