From 5c82cb32ab4de5dac55db1e94b8cdbff04f2646b Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Tue, 2 Nov 2021 23:20:22 +0100 Subject: [PATCH] [libcalamares] Expand tests to show last-output-line --- src/libcalamares/utils/Tests.cpp | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/src/libcalamares/utils/Tests.cpp b/src/libcalamares/utils/Tests.cpp index 9ce09a299..1edae6e31 100644 --- a/src/libcalamares/utils/Tests.cpp +++ b/src/libcalamares/utils/Tests.cpp @@ -921,6 +921,32 @@ LibCalamaresTests::testRunnerOutput() QCOMPARE( spy.count(), 6 ); // 4 from before, +2 here } } + + cDebug() << "Testing cat (again)"; + { + QStringList collectedOutput; + + Calamares::Utils::Runner r( { "cat" } ); + r.enableOutputProcessing( true ).setInput( QStringLiteral( "hello\nworld\n\n!\n" ) ); + QObject::connect( &r, &decltype( r )::output, [&collectedOutput]( QString s ) { collectedOutput << s; } ); + + { + auto result = r.run(); + QCOMPARE( result.getExitCode(), 0 ); + QCOMPARE( result.getOutput(), QString() ); + QCOMPARE( collectedOutput.count(), 4 ); + QVERIFY( collectedOutput.contains( QStringLiteral( "world\n" ) ) ); + } + + r.setInput( QStringLiteral( "yo\ndogg" ) ); + { + auto result = r.run(); + QCOMPARE( result.getExitCode(), 0 ); + QCOMPARE( result.getOutput(), QString() ); + QCOMPARE( collectedOutput.count(), 6 ); + QVERIFY( collectedOutput.contains( QStringLiteral( "dogg" ) ) ); // no newline + } + } }