diff options
author | Janek Bevendorff <janek@jbev.net> | 2018-10-28 21:55:00 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-10-28 21:55:00 +0300 |
commit | 7263dcddfe52552747c478da941f1f078d8d91e0 (patch) | |
tree | 25d59274d8bdcb1d99dac7ee9e484ef9d6bf2375 /tests/TestCli.cpp | |
parent | c9cab250c7f35b0a277eb2626b50e580b8a410a0 (diff) |
Fix stdin/stdout encoding on Windows. (#2425)
QTextStream uses the system default locale, but this breaks in
various situations: (1) It does not work on the native Windows shell
(cmd.exe, Powershell), since the default Windows locale is Windows-1252,
but the shell uses Windows-850. (2) It also breaks on *nix systems where
the locale is Latin1 or C, which is the case for most CI systems or
build servers.
We allow overriding the detected codec by setting the ENCODING_OVERRIDE
environment variable, but otherwise prefer Windows-850 on Windows and
UTF-8 on any other system, even if LANG is set to something else.
This resolves #2413
Diffstat (limited to 'tests/TestCli.cpp')
-rw-r--r-- | tests/TestCli.cpp | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/tests/TestCli.cpp b/tests/TestCli.cpp index e10a651d7..c95b1f32b 100644 --- a/tests/TestCli.cpp +++ b/tests/TestCli.cpp @@ -455,12 +455,13 @@ void TestCli::testGenerate() qint64 pos = 0; // run multiple times to make accidental passes unlikely + TextStream stream(m_stdoutFile.data()); for (int i = 0; i < 10; ++i) { generateCmd.execute(parameters); - m_stdoutFile->seek(pos); + stream.seek(pos); QRegularExpression regex(pattern); - QString password = QString::fromUtf8(m_stdoutFile->readLine()); - pos = m_stdoutFile->pos(); + QString password = stream.readLine(); + pos = stream.pos(); QVERIFY2(regex.match(password).hasMatch(), qPrintable("Password " + password + " does not match pattern " + pattern)); } } |