aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorOla Røer Thorsen <ola@silentwings.no>2019-01-02 15:24:01 +0100
committerOla Røer Thorsen <ola@silentwings.no>2019-01-03 13:22:42 +0000
commita25b4897469a6c1e38eba22f7c615e247efe02d9 (patch)
tree64b112c06237d2a92f9b12319949a8933e423a86 /tests
parent83c43258e0a8f7e45808ecdf60b49938413c85bf (diff)
Add atEnd() function to the Process service
This makes it possible to use readLine in a while loop until the complete stream is read, even when reading empty lines. [ChangeLog] Added atEnd() function to the Process service, to make it possible to use readLine() in a while loop until the complete stream is read. Change-Id: Ie5f047651977195d6a93c4575bd7a8796b83ab5d Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/blackbox/testdata/jsextensions-process/process.qbs18
-rw-r--r--tests/auto/blackbox/tst_blackbox.cpp3
2 files changed, 20 insertions, 1 deletions
diff --git a/tests/auto/blackbox/testdata/jsextensions-process/process.qbs b/tests/auto/blackbox/testdata/jsextensions-process/process.qbs
index be9e718df..eba95d005 100644
--- a/tests/auto/blackbox/testdata/jsextensions-process/process.qbs
+++ b/tests/auto/blackbox/testdata/jsextensions-process/process.qbs
@@ -61,6 +61,24 @@ Project {
output.write(process.readStdOut());
process.close();
+ // readLine and atEnd
+ var testReadlineFile = new TextFile("123.txt", TextFile.WriteOnly);
+ testReadlineFile.writeLine("1");
+ testReadlineFile.writeLine("2");
+ testReadlineFile.writeLine("3");
+ testReadlineFile.close();
+
+ process = new Process();
+ if (product.qbs.hostOS.contains("windows"))
+ process.exec(product.qbs.windowsShellPath,
+ ["/C", "type", "123.txt"],
+ true);
+ else
+ process.exec("cat", ["123.txt"], true);
+
+ while(!process.atEnd())
+ output.write(process.readLine());
+
// TODO: Test all the other Process methods as well.
output.close();
diff --git a/tests/auto/blackbox/tst_blackbox.cpp b/tests/auto/blackbox/tst_blackbox.cpp
index 53cea26e0..50a3bb9c5 100644
--- a/tests/auto/blackbox/tst_blackbox.cpp
+++ b/tests/auto/blackbox/tst_blackbox.cpp
@@ -4055,7 +4055,7 @@ void TestBlackbox::jsExtensionsProcess()
QVERIFY(output.exists());
QVERIFY(output.open(QIODevice::ReadOnly));
const QList<QByteArray> lines = output.readAll().trimmed().split('\n');
- QCOMPARE(lines.size(), 8);
+ QCOMPARE(lines.size(), 9);
QCOMPARE(lines.at(0).trimmed().constData(), "0");
QVERIFY(lines.at(1).startsWith("qbs "));
QCOMPARE(lines.at(2).trimmed().constData(), "true");
@@ -4064,6 +4064,7 @@ void TestBlackbox::jsExtensionsProcess()
QVERIFY(lines.at(5).startsWith("qbs "));
QCOMPARE(lines.at(6).trimmed().constData(), "false");
QCOMPARE(lines.at(7).trimmed().constData(), "should be");
+ QCOMPARE(lines.at(8).trimmed().constData(), "123");
}
void TestBlackbox::jsExtensionsPropertyList()