[libcalamares] Test Runner output-processing
This commit is contained in:
parent
953b899f75
commit
0a339a5402
@ -74,6 +74,7 @@ private Q_SLOTS:
|
|||||||
/** @section Test Runner directory-manipulation. */
|
/** @section Test Runner directory-manipulation. */
|
||||||
void testRunnerDirs();
|
void testRunnerDirs();
|
||||||
void testCalculateWorkingDirectory();
|
void testCalculateWorkingDirectory();
|
||||||
|
void testRunnerOutput();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void recursiveCompareMap( const QVariantMap& a, const QVariantMap& b, int depth );
|
void recursiveCompareMap( const QVariantMap& a, const QVariantMap& b, int depth );
|
||||||
@ -884,6 +885,44 @@ LibCalamaresTests::testCalculateWorkingDirectory()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
LibCalamaresTests::testRunnerOutput()
|
||||||
|
{
|
||||||
|
cDebug() << "Testing ls";
|
||||||
|
{
|
||||||
|
Calamares::Utils::Runner r( { "ls", "-d", "." } );
|
||||||
|
QSignalSpy spy( &r, &decltype( r )::output );
|
||||||
|
r.enableOutputProcessing( true );
|
||||||
|
|
||||||
|
auto result = r.run();
|
||||||
|
QCOMPARE( result.getExitCode(), 0 );
|
||||||
|
QCOMPARE( result.getOutput(), QString() );
|
||||||
|
QCOMPARE( spy.count(), 1 );
|
||||||
|
}
|
||||||
|
|
||||||
|
cDebug() << "Testing cat";
|
||||||
|
{
|
||||||
|
Calamares::Utils::Runner r( { "cat" } );
|
||||||
|
QSignalSpy spy( &r, &decltype( r )::output );
|
||||||
|
r.enableOutputProcessing( true ).setInput( QStringLiteral( "hello\nworld\n\n!\n" ) );
|
||||||
|
|
||||||
|
{
|
||||||
|
auto result = r.run();
|
||||||
|
QCOMPARE( result.getExitCode(), 0 );
|
||||||
|
QCOMPARE( result.getOutput(), QString() );
|
||||||
|
QCOMPARE( spy.count(), 4 );
|
||||||
|
}
|
||||||
|
|
||||||
|
r.setInput( QStringLiteral( "yo\ndogg" ) );
|
||||||
|
{
|
||||||
|
auto result = r.run();
|
||||||
|
QCOMPARE( result.getExitCode(), 0 );
|
||||||
|
QCOMPARE( result.getOutput(), QString() );
|
||||||
|
QCOMPARE( spy.count(), 6 ); // 4 from before, +2 here
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
QTEST_GUILESS_MAIN( LibCalamaresTests )
|
QTEST_GUILESS_MAIN( LibCalamaresTests )
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user