[libcalamares] Move tests of the utils classes into utils/
- while here, adjust include paths (to changed dir) - while here, apply new code formatting
This commit is contained in:
parent
31e78ff0c2
commit
0685e3a96c
@ -147,7 +147,7 @@ install( FILES ${utilsHeaders} DESTINATION include/libcalam
|
|||||||
#
|
#
|
||||||
if ( ECM_FOUND AND BUILD_TESTING )
|
if ( ECM_FOUND AND BUILD_TESTING )
|
||||||
ecm_add_test(
|
ecm_add_test(
|
||||||
Tests.cpp
|
utils/Tests.cpp
|
||||||
TEST_NAME
|
TEST_NAME
|
||||||
libcalamarestest
|
libcalamarestest
|
||||||
LINK_LIBRARIES
|
LINK_LIBRARIES
|
||||||
|
@ -18,9 +18,9 @@
|
|||||||
|
|
||||||
#include "Tests.h"
|
#include "Tests.h"
|
||||||
|
|
||||||
#include "utils/CalamaresUtilsSystem.h"
|
#include "CalamaresUtilsSystem.h"
|
||||||
#include "utils/Logger.h"
|
#include "Logger.h"
|
||||||
#include "utils/Yaml.h"
|
#include "Yaml.h"
|
||||||
|
|
||||||
#include <QTemporaryFile>
|
#include <QTemporaryFile>
|
||||||
|
|
||||||
@ -28,13 +28,9 @@
|
|||||||
|
|
||||||
QTEST_GUILESS_MAIN( LibCalamaresTests )
|
QTEST_GUILESS_MAIN( LibCalamaresTests )
|
||||||
|
|
||||||
LibCalamaresTests::LibCalamaresTests()
|
LibCalamaresTests::LibCalamaresTests() {}
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
LibCalamaresTests::~LibCalamaresTests()
|
LibCalamaresTests::~LibCalamaresTests() {}
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
void
|
||||||
LibCalamaresTests::initTestCase()
|
LibCalamaresTests::initTestCase()
|
||||||
@ -67,7 +63,9 @@ LibCalamaresTests::testLoadSaveYaml()
|
|||||||
QFile f( "settings.conf" );
|
QFile f( "settings.conf" );
|
||||||
// Find the nearest settings.conf to read
|
// Find the nearest settings.conf to read
|
||||||
for ( unsigned int up = 0; !f.exists() && ( up < 4 ); ++up )
|
for ( unsigned int up = 0; !f.exists() && ( up < 4 ); ++up )
|
||||||
|
{
|
||||||
f.setFileName( QString( "../" ) + f.fileName() );
|
f.setFileName( QString( "../" ) + f.fileName() );
|
||||||
|
}
|
||||||
cDebug() << QDir().absolutePath() << f.fileName() << f.exists();
|
cDebug() << QDir().absolutePath() << f.fileName() << f.exists();
|
||||||
QVERIFY( f.exists() );
|
QVERIFY( f.exists() );
|
||||||
|
|
||||||
@ -121,10 +119,7 @@ void
|
|||||||
LibCalamaresTests::testCommands()
|
LibCalamaresTests::testCommands()
|
||||||
{
|
{
|
||||||
using CalamaresUtils::System;
|
using CalamaresUtils::System;
|
||||||
auto r = System::runCommand(
|
auto r = System::runCommand( System::RunLocation::RunInHost, { "/bin/ls", "/tmp" } );
|
||||||
System::RunLocation::RunInHost,
|
|
||||||
{ "/bin/ls", "/tmp" }
|
|
||||||
);
|
|
||||||
|
|
||||||
QVERIFY( r.getExitCode() == 0 );
|
QVERIFY( r.getExitCode() == 0 );
|
||||||
|
|
||||||
@ -136,25 +131,13 @@ LibCalamaresTests::testCommands()
|
|||||||
QVERIFY( !r.getOutput().contains( tfn.fileName() ) );
|
QVERIFY( !r.getOutput().contains( tfn.fileName() ) );
|
||||||
|
|
||||||
// Run ls again, now that the file exists
|
// Run ls again, now that the file exists
|
||||||
r = System::runCommand(
|
r = System::runCommand( System::RunLocation::RunInHost, { "/bin/ls", "/tmp" } );
|
||||||
System::RunLocation::RunInHost,
|
|
||||||
{ "/bin/ls", "/tmp" }
|
|
||||||
);
|
|
||||||
QVERIFY( r.getOutput().contains( tfn.fileName() ) );
|
QVERIFY( r.getOutput().contains( tfn.fileName() ) );
|
||||||
|
|
||||||
// .. and without a working directory set, assume builddir != /tmp
|
// .. and without a working directory set, assume builddir != /tmp
|
||||||
r = System::runCommand(
|
r = System::runCommand( System::RunLocation::RunInHost, { "/bin/ls" } );
|
||||||
System::RunLocation::RunInHost,
|
|
||||||
{ "/bin/ls" }
|
|
||||||
);
|
|
||||||
QVERIFY( !r.getOutput().contains( tfn.fileName() ) );
|
QVERIFY( !r.getOutput().contains( tfn.fileName() ) );
|
||||||
|
|
||||||
r = System::runCommand(
|
r = System::runCommand( System::RunLocation::RunInHost, { "/bin/ls" }, "/tmp" );
|
||||||
System::RunLocation::RunInHost,
|
|
||||||
{ "/bin/ls" },
|
|
||||||
"/tmp"
|
|
||||||
);
|
|
||||||
QVERIFY( r.getOutput().contains( tfn.fileName() ) );
|
QVERIFY( r.getOutput().contains( tfn.fileName() ) );
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user