mirror of
https://github.com/parchlinux/calamares.git
synced 2025-02-24 10:55:46 -05:00
[libcalamares] Test Runner output-processing
This commit is contained in:
parent
953b899f75
commit
0a339a5402
1 changed files with 39 additions and 0 deletions
|
@ -74,6 +74,7 @@ private Q_SLOTS:
|
|||
/** @section Test Runner directory-manipulation. */
|
||||
void testRunnerDirs();
|
||||
void testCalculateWorkingDirectory();
|
||||
void testRunnerOutput();
|
||||
|
||||
private:
|
||||
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 )
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue