[libcalamares] Expand tests on Runner internals
This commit is contained in:
parent
e5fa58b890
commit
f0104af1c3
@ -40,7 +40,7 @@ relativeChangeDirectory( QDir& directory, const QString& subdir )
|
|||||||
|
|
||||||
|
|
||||||
STATICTEST std::pair< bool, QDir >
|
STATICTEST std::pair< bool, QDir >
|
||||||
calculateWorkingDirectory( Calamares::Utils::RunLocation location, QString directory )
|
calculateWorkingDirectory( Calamares::Utils::RunLocation location, const QString& directory )
|
||||||
{
|
{
|
||||||
Calamares::GlobalStorage* gs
|
Calamares::GlobalStorage* gs
|
||||||
= Calamares::JobQueue::instance() ? Calamares::JobQueue::instance()->globalStorage() : nullptr;
|
= Calamares::JobQueue::instance() ? Calamares::JobQueue::instance()->globalStorage() : nullptr;
|
||||||
|
@ -13,6 +13,7 @@
|
|||||||
#include "Entropy.h"
|
#include "Entropy.h"
|
||||||
#include "Logger.h"
|
#include "Logger.h"
|
||||||
#include "RAII.h"
|
#include "RAII.h"
|
||||||
|
#include "Runner.h"
|
||||||
#include "String.h"
|
#include "String.h"
|
||||||
#include "Traits.h"
|
#include "Traits.h"
|
||||||
#include "UMask.h"
|
#include "UMask.h"
|
||||||
@ -72,6 +73,7 @@ private Q_SLOTS:
|
|||||||
|
|
||||||
/** @section Test Runner directory-manipulation. */
|
/** @section Test Runner directory-manipulation. */
|
||||||
void testRunnerDirs();
|
void testRunnerDirs();
|
||||||
|
void testCalculateWorkingDirectory();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void recursiveCompareMap( const QVariantMap& a, const QVariantMap& b, int depth );
|
void recursiveCompareMap( const QVariantMap& a, const QVariantMap& b, int depth );
|
||||||
@ -836,6 +838,52 @@ LibCalamaresTests::testRunnerDirs()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Method under test
|
||||||
|
extern std::pair< bool, QDir > calculateWorkingDirectory( Calamares::Utils::RunLocation location,
|
||||||
|
const QString& directory );
|
||||||
|
|
||||||
|
void
|
||||||
|
LibCalamaresTests::testCalculateWorkingDirectory()
|
||||||
|
{
|
||||||
|
Calamares::GlobalStorage* gs
|
||||||
|
= Calamares::JobQueue::instance() ? Calamares::JobQueue::instance()->globalStorage() : nullptr;
|
||||||
|
|
||||||
|
if ( !gs )
|
||||||
|
{
|
||||||
|
cDebug() << "Creating new JobQueue";
|
||||||
|
(void)new Calamares::JobQueue();
|
||||||
|
gs = Calamares::JobQueue::instance() ? Calamares::JobQueue::instance()->globalStorage() : nullptr;
|
||||||
|
}
|
||||||
|
QVERIFY( gs );
|
||||||
|
|
||||||
|
// Working with a rootMountPoint set
|
||||||
|
QTemporaryDir tempRoot( QDir::tempPath() + QStringLiteral( "/test-job-XXXXXX" ) );
|
||||||
|
gs->insert( "rootMountPoint", tempRoot.path() );
|
||||||
|
|
||||||
|
{
|
||||||
|
auto [ ok, d ] = calculateWorkingDirectory( CalamaresUtils::System::RunLocation::RunInHost, QString() );
|
||||||
|
QVERIFY( ok );
|
||||||
|
QCOMPARE( d, QDir::current() );
|
||||||
|
}
|
||||||
|
{
|
||||||
|
auto [ ok, d ] = calculateWorkingDirectory( CalamaresUtils::System::RunLocation::RunInTarget, QString() );
|
||||||
|
QVERIFY( ok );
|
||||||
|
QCOMPARE( d.absolutePath(), tempRoot.path() );
|
||||||
|
}
|
||||||
|
|
||||||
|
gs->remove( "rootMountPoint" );
|
||||||
|
{
|
||||||
|
auto [ ok, d ] = calculateWorkingDirectory( CalamaresUtils::System::RunLocation::RunInHost, QString() );
|
||||||
|
QVERIFY( ok );
|
||||||
|
QCOMPARE( d, QDir::current() );
|
||||||
|
}
|
||||||
|
{
|
||||||
|
auto [ ok, d ] = calculateWorkingDirectory( CalamaresUtils::System::RunLocation::RunInTarget, QString() );
|
||||||
|
QVERIFY( !ok );
|
||||||
|
QCOMPARE( d, QDir::current() );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
QTEST_GUILESS_MAIN( LibCalamaresTests )
|
QTEST_GUILESS_MAIN( LibCalamaresTests )
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user