summaryrefslogtreecommitdiffstats
path: root/tests/auto
diff options
context:
space:
mode:
authorEdward Welbourne <edward.welbourne@qt.io>2018-10-15 19:48:13 +0200
committerEdward Welbourne <edward.welbourne@qt.io>2018-11-01 15:06:08 +0000
commitb22e50acda53d32f5df12a8567a0c5f206e203ad (patch)
treef791e4eb3b77d9cb04b52cd177547e4ac6ad12ef /tests/auto
parent30101884a6f3ab2f3d4d11426373eca3fca10652 (diff)
generate_expected_output.py: match tst_selftest's test environments
The testlib selftest sets various things in the environment for crashing tests; the generator for its expected output should set the same things, as they affect what output is produced. Change-Id: Iec2ed59982ea1043582573530c33619d8e8ed08e Reviewed-by: Jędrzej Nowacki <jedrzej.nowacki@qt.io>
Diffstat (limited to 'tests/auto')
-rwxr-xr-xtests/auto/testlib/selftests/generate_expected_output.py23
-rw-r--r--tests/auto/testlib/selftests/tst_selftests.cpp3
2 files changed, 24 insertions, 2 deletions
diff --git a/tests/auto/testlib/selftests/generate_expected_output.py b/tests/auto/testlib/selftests/generate_expected_output.py
index 1996416e8c..3c5f922c75 100755
--- a/tests/auto/testlib/selftests/generate_expected_output.py
+++ b/tests/auto/testlib/selftests/generate_expected_output.py
@@ -223,6 +223,7 @@ del re
def generateTestData(testname, clean,
formats = ('xml', 'txt', 'xunitxml', 'lightxml', 'teamcity', 'tap'),
+ # Make sure this matches tst_Selftests::runSubTest_data():
extraArgs = {
"commandlinedata": "fiveTablePasses fiveTablePasses:fiveTablePasses_data1 -v2",
"benchlibcallgrind": "-callgrind",
@@ -236,7 +237,15 @@ def generateTestData(testname, clean,
"silent": "-silent",
"verbose1": "-v1",
"verbose2": "-v2",
- }):
+ },
+ # Make sure this matches tst_Selftests::doRunSubTest():
+ extraEnv = {
+ "crashes": { "QTEST_DISABLE_CORE_DUMP": "1", "QTEST_DISABLE_STACK_DUMP": "1" },
+ },
+ # These are actually *other* crashers, beside those in extraEnv;
+ # must match tst_Selftests::runSubTest_data():
+ crashers = ("assert", "blacklisted", "crashedterminate",
+ "exceptionthrow", "fetchbogus", "silent")):
"""Run one test and save its cleaned results.
Required arguments are the name of the test directory (the binary
@@ -248,6 +257,16 @@ def generateTestData(testname, clean,
if not os.path.isfile(path):
print("Warning: directory", testname, "contains no test executable")
return
+ env = None
+ try:
+ env = extraEnv[testname]
+ except KeyError:
+ if env in crashers:
+ env = extraEnv["crashes"]
+ if env:
+ data = os.environ.copy()
+ data.update(env)
+ env = data
print(" running", testname)
for format in formats:
@@ -255,7 +274,7 @@ def generateTestData(testname, clean,
if testname in extraArgs:
cmd += extraArgs[testname].split()
- data = subprocess.Popen(cmd, stdout=subprocess.PIPE,
+ data = subprocess.Popen(cmd, stdout=subprocess.PIPE, env=env,
universal_newlines=True).communicate()[0]
with open('expected_' + testname + '.' + format, 'w') as out:
out.write('\n'.join(clean(data))) # write() appends a newline, too
diff --git a/tests/auto/testlib/selftests/tst_selftests.cpp b/tests/auto/testlib/selftests/tst_selftests.cpp
index 2d3cfaf176..008cce6218 100644
--- a/tests/auto/testlib/selftests/tst_selftests.cpp
+++ b/tests/auto/testlib/selftests/tst_selftests.cpp
@@ -520,6 +520,7 @@ void tst_Selftests::runSubTest_data()
foreach (QString const& subtest, tests) {
QStringList arguments = loggerSet.arguments;
+ // Keep in sync with generateTestData()'s extraArgs in generate_expected_output.py:
if (subtest == "commandlinedata") {
arguments << QString("fiveTablePasses fiveTablePasses:fiveTablePasses_data1 -v2").split(' ');
}
@@ -612,6 +613,7 @@ void tst_Selftests::runSubTest_data()
if (loggerSet.name.contains("teamcity") && subtest.startsWith("benchlib"))
continue; // Skip benchmark for TeamCity logger
+ // Keep in sync with generateTestData()'s crashers in generate_expected_output.py:
const bool crashes = subtest == QLatin1String("assert") || subtest == QLatin1String("exceptionthrow")
|| subtest == QLatin1String("fetchbogus") || subtest == QLatin1String("crashedterminate")
|| subtest == QLatin1String("crashes") || subtest == QLatin1String("silent")
@@ -687,6 +689,7 @@ void tst_Selftests::doRunSubTest(QString const& subdir, QStringList const& logge
QProcess proc;
QProcessEnvironment environment = processEnvironment();
+ // Keep in sync with generateTestData()'s extraEnv in generate_expected_output.py:
if (crashes) {
environment.insert("QTEST_DISABLE_CORE_DUMP", "1");
environment.insert("QTEST_DISABLE_STACK_DUMP", "1");