2013-12-12 16:27:52 +00:00
|
|
|
#!/usr/bin/env python3
|
|
|
|
#############################################################################
|
|
|
|
##
|
2016-01-15 12:36:27 +00:00
|
|
|
## Copyright (C) 2016 The Qt Company Ltd.
|
|
|
|
## Contact: https://www.qt.io/licensing/
|
2013-12-12 16:27:52 +00:00
|
|
|
##
|
|
|
|
## This file is part of the release tools of the Qt Toolkit.
|
|
|
|
##
|
2016-01-15 12:36:27 +00:00
|
|
|
## $QT_BEGIN_LICENSE:GPL-EXCEPT$
|
2013-12-12 16:27:52 +00:00
|
|
|
## Commercial License Usage
|
|
|
|
## Licensees holding valid commercial Qt licenses may use this file in
|
|
|
|
## accordance with the commercial license agreement provided with the
|
|
|
|
## Software or, alternatively, in accordance with the terms contained in
|
2015-01-28 08:44:43 +00:00
|
|
|
## a written agreement between you and The Qt Company. For licensing terms
|
2016-01-15 12:36:27 +00:00
|
|
|
## and conditions see https://www.qt.io/terms-conditions. For further
|
|
|
|
## information use the contact form at https://www.qt.io/contact-us.
|
2013-12-12 16:27:52 +00:00
|
|
|
##
|
2016-01-15 12:36:27 +00:00
|
|
|
## GNU General Public License Usage
|
|
|
|
## Alternatively, this file may be used under the terms of the GNU
|
|
|
|
## General Public License version 3 as published by the Free Software
|
|
|
|
## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
|
|
|
|
## included in the packaging of this file. Please review the following
|
|
|
|
## information to ensure the GNU General Public License requirements will
|
|
|
|
## be met: https://www.gnu.org/licenses/gpl-3.0.html.
|
2013-12-12 16:27:52 +00:00
|
|
|
##
|
|
|
|
## $QT_END_LICENSE$
|
|
|
|
##
|
|
|
|
#############################################################################
|
|
|
|
|
Major re-write of generate_expected_output.py
Restructured, separated the canonicalising of output lines out (into
an object that prepares the necessary regexes and replacements)
suppress more, changed the path-stripping to strip qtbase's parent
rather than os.getcwd() and took account of shadow builds (so both
source tree and build tree provide prefixes we want to strip from
paths). Also cope with $PWD potentially having symlinks in it, where
os.getcwd() is canonical.
It's possible some output might name files elsewhere in the source
tree; these won't be filtered by the prior cwd prefix removal; and, in
any case, the problem with cwd is only that the ancestry of qtbase is
apt to vary; paths relative to there should be consistent between test
runs. This change shall lead to a one-off rewrite of all expected_*
files; but it should now catch all paths. By stripping both build
root and source root (when different) it also avoids differences for
those doing out-of-source ("shadow") builds.
In our XML formats, any hyphens in root paths (e.g. I had Qt-5.6 in my
build root's path) got represented by a character entity, confounding
the replacement; so also do replacement that catches this. We may
discover other character entity subsitutions needed along with this.
Now filtering line numbers and timing information, including benchmark
results; these numbers all get replaced with 0 to avoid noisy diffs.
Also purging dangling hspace, to placate sanity-bot.
The module can now be imported - the code it runs is packaged as a
main() function that a __name__ == '__main__' stanza runs - and all
data is localised to where it's needed, rather than held in globals.
Tidied up and organized the existing regexes. There are doc-strings;
there is a short usage comment. Data is localised rather than global
and modern pythonic idioms get used where apt.
Regexes are compiled once instead of repeatedly. An object looks
after the list of patterns to apply and its construction handles all
anticipated problems. Failures are mediated by an exception.
The output file now gets written once, instead of twice (once before
editing, then over-write to edit), and Popen uses text mode, so that
write can do the same. Its command is delivered as an array, avoiding
the need to invoke a shell.
Instead of relying on qmake being in our path (which might give us a
bogus QT_VERSION if the one in path doesn't match our build tree), use
the relative path to qmake - we rely on being run in a specific
directory in the build tree, after all. Escape dots in the version
properly, so that 51730 doesn't get mistaken for 5.7.0 (for example),
and moved this check later in the sequence (matching a smaller target
makes it more likely to falsely match).
Overtly check we are in the right directory and tell the user what we
actually need, if run from the wrong place. Simplify handling of the
unsupported use-case for MS-Windows (but note what would be needed for
it).
Change-Id: Ibdff8f8cae173f6c31492648148cc345ae29022b
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
Reviewed-by: Frederik Gladhorn <frederik.gladhorn@qt.io>
2016-07-25 13:55:47 +00:00
|
|
|
# Regenerate all tests' output.
|
|
|
|
#
|
|
|
|
# Usage: cd to the build directory corresponding to this script's
|
|
|
|
# location; invoke this script; optionally pass the names of sub-dirs
|
|
|
|
# to limit which tests to regenerate expected_* files for.
|
2016-07-29 09:40:11 +00:00
|
|
|
#
|
|
|
|
# The saved test output is used by ./tst_selftests.cpp, which compares
|
|
|
|
# it to the output of each test, ignoring various boring changes.
|
|
|
|
# This script canonicalises the parts that would exhibit those boring
|
|
|
|
# changes, so as to avoid noise in git (and conflicts in merges) for
|
2018-05-04 09:20:01 +00:00
|
|
|
# the saved copies of the output.
|
2013-12-12 16:27:52 +00:00
|
|
|
|
|
|
|
import os
|
|
|
|
import subprocess
|
2016-07-29 09:40:11 +00:00
|
|
|
import re
|
Major re-write of generate_expected_output.py
Restructured, separated the canonicalising of output lines out (into
an object that prepares the necessary regexes and replacements)
suppress more, changed the path-stripping to strip qtbase's parent
rather than os.getcwd() and took account of shadow builds (so both
source tree and build tree provide prefixes we want to strip from
paths). Also cope with $PWD potentially having symlinks in it, where
os.getcwd() is canonical.
It's possible some output might name files elsewhere in the source
tree; these won't be filtered by the prior cwd prefix removal; and, in
any case, the problem with cwd is only that the ancestry of qtbase is
apt to vary; paths relative to there should be consistent between test
runs. This change shall lead to a one-off rewrite of all expected_*
files; but it should now catch all paths. By stripping both build
root and source root (when different) it also avoids differences for
those doing out-of-source ("shadow") builds.
In our XML formats, any hyphens in root paths (e.g. I had Qt-5.6 in my
build root's path) got represented by a character entity, confounding
the replacement; so also do replacement that catches this. We may
discover other character entity subsitutions needed along with this.
Now filtering line numbers and timing information, including benchmark
results; these numbers all get replaced with 0 to avoid noisy diffs.
Also purging dangling hspace, to placate sanity-bot.
The module can now be imported - the code it runs is packaged as a
main() function that a __name__ == '__main__' stanza runs - and all
data is localised to where it's needed, rather than held in globals.
Tidied up and organized the existing regexes. There are doc-strings;
there is a short usage comment. Data is localised rather than global
and modern pythonic idioms get used where apt.
Regexes are compiled once instead of repeatedly. An object looks
after the list of patterns to apply and its construction handles all
anticipated problems. Failures are mediated by an exception.
The output file now gets written once, instead of twice (once before
editing, then over-write to edit), and Popen uses text mode, so that
write can do the same. Its command is delivered as an array, avoiding
the need to invoke a shell.
Instead of relying on qmake being in our path (which might give us a
bogus QT_VERSION if the one in path doesn't match our build tree), use
the relative path to qmake - we rely on being run in a specific
directory in the build tree, after all. Escape dots in the version
properly, so that 51730 doesn't get mistaken for 5.7.0 (for example),
and moved this check later in the sequence (matching a smaller target
makes it more likely to falsely match).
Overtly check we are in the right directory and tell the user what we
actually need, if run from the wrong place. Simplify handling of the
unsupported use-case for MS-Windows (but note what would be needed for
it).
Change-Id: Ibdff8f8cae173f6c31492648148cc345ae29022b
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
Reviewed-by: Frederik Gladhorn <frederik.gladhorn@qt.io>
2016-07-25 13:55:47 +00:00
|
|
|
|
|
|
|
class Fail (Exception): pass
|
|
|
|
|
|
|
|
class Cleaner (object):
|
|
|
|
"""Tool to clean up test output to make diff-ing runs useful.
|
|
|
|
|
|
|
|
We care about whether tests pass or fail - if that changes,
|
|
|
|
something that matters has happened - and we care about some
|
|
|
|
changes to what they say when they do fail; but we don't care
|
|
|
|
exactly what line of what file the failing line of code now
|
|
|
|
occupies, nor do we care how many milliseconds each test took to
|
|
|
|
run; and changes to the Qt version number mean nothing to us.
|
|
|
|
|
|
|
|
Create one singleton instance; it'll do mildly expensive things
|
|
|
|
once and you can use its .clean() method to tidy up your test
|
|
|
|
output."""
|
|
|
|
|
|
|
|
def __init__(self, here, command):
|
|
|
|
"""Set up the details we need for later cleaning.
|
|
|
|
|
2016-08-30 11:56:30 +00:00
|
|
|
Takes two parameters: here is os.getcwd() and command is how
|
|
|
|
this script was invoked, from which we'll work out where it
|
|
|
|
is; in a shadow build, the former is the build tree's location
|
2016-07-29 09:40:11 +00:00
|
|
|
corresponding to this last. Saves the directory of this
|
|
|
|
script as self.sourceDir, so client can find tst_selftests.cpp
|
2016-08-30 11:56:30 +00:00
|
|
|
there. Checks here does look as expected in a build tree -
|
2016-07-29 09:40:11 +00:00
|
|
|
raising Fail() if not - then invokes qmake to discover Qt
|
|
|
|
version (saved as .version for the benefit of clients) and
|
|
|
|
prepares the sequence of (regex, replace) pairs that .clean()
|
|
|
|
needs to do its job."""
|
|
|
|
self.version, self.sourceDir, self.__replace = self.__getPatterns(here, command)
|
|
|
|
|
Major re-write of generate_expected_output.py
Restructured, separated the canonicalising of output lines out (into
an object that prepares the necessary regexes and replacements)
suppress more, changed the path-stripping to strip qtbase's parent
rather than os.getcwd() and took account of shadow builds (so both
source tree and build tree provide prefixes we want to strip from
paths). Also cope with $PWD potentially having symlinks in it, where
os.getcwd() is canonical.
It's possible some output might name files elsewhere in the source
tree; these won't be filtered by the prior cwd prefix removal; and, in
any case, the problem with cwd is only that the ancestry of qtbase is
apt to vary; paths relative to there should be consistent between test
runs. This change shall lead to a one-off rewrite of all expected_*
files; but it should now catch all paths. By stripping both build
root and source root (when different) it also avoids differences for
those doing out-of-source ("shadow") builds.
In our XML formats, any hyphens in root paths (e.g. I had Qt-5.6 in my
build root's path) got represented by a character entity, confounding
the replacement; so also do replacement that catches this. We may
discover other character entity subsitutions needed along with this.
Now filtering line numbers and timing information, including benchmark
results; these numbers all get replaced with 0 to avoid noisy diffs.
Also purging dangling hspace, to placate sanity-bot.
The module can now be imported - the code it runs is packaged as a
main() function that a __name__ == '__main__' stanza runs - and all
data is localised to where it's needed, rather than held in globals.
Tidied up and organized the existing regexes. There are doc-strings;
there is a short usage comment. Data is localised rather than global
and modern pythonic idioms get used where apt.
Regexes are compiled once instead of repeatedly. An object looks
after the list of patterns to apply and its construction handles all
anticipated problems. Failures are mediated by an exception.
The output file now gets written once, instead of twice (once before
editing, then over-write to edit), and Popen uses text mode, so that
write can do the same. Its command is delivered as an array, avoiding
the need to invoke a shell.
Instead of relying on qmake being in our path (which might give us a
bogus QT_VERSION if the one in path doesn't match our build tree), use
the relative path to qmake - we rely on being run in a specific
directory in the build tree, after all. Escape dots in the version
properly, so that 51730 doesn't get mistaken for 5.7.0 (for example),
and moved this check later in the sequence (matching a smaller target
makes it more likely to falsely match).
Overtly check we are in the right directory and tell the user what we
actually need, if run from the wrong place. Simplify handling of the
unsupported use-case for MS-Windows (but note what would be needed for
it).
Change-Id: Ibdff8f8cae173f6c31492648148cc345ae29022b
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
Reviewed-by: Frederik Gladhorn <frederik.gladhorn@qt.io>
2016-07-25 13:55:47 +00:00
|
|
|
@staticmethod
|
|
|
|
def __getPatterns(here, command,
|
|
|
|
patterns = (
|
|
|
|
# Timings:
|
|
|
|
(r'( *<Duration msecs=)"[\d\.]+"/>', r'\1"0"/>'), # xml, lightxml
|
|
|
|
(r'(Totals:.*,) *[0-9.]+ms', r'\1 0ms'), # txt
|
|
|
|
# Benchmarks:
|
|
|
|
(r'[0-9,.]+( (?:CPU ticks|msecs) per iteration \(total:) [0-9,.]+ ', r'0\1 0, '), # txt
|
|
|
|
(r'(<BenchmarkResult metric="(?:CPUTicks|WalltimeMilliseconds)".*\bvalue=)"[^"]+"', r'\1"0"'), # xml, lightxml
|
|
|
|
# Build details:
|
|
|
|
(r'(Config: Using QtTest library).*', r'\1'), # txt
|
|
|
|
(r'( *<QtBuild)>[^<]+</QtBuild>', r'\1/>'), # xml, lightxml
|
|
|
|
(r'(<property value=")[^"]+(" name="QtBuild"/>)', r'\1\2'), # xunitxml
|
|
|
|
# Line numbers in source files:
|
2016-08-30 11:56:30 +00:00
|
|
|
(r'(ASSERT: ".*" in file .*, line) \d+', r'\1 0'), # lightxml
|
Major re-write of generate_expected_output.py
Restructured, separated the canonicalising of output lines out (into
an object that prepares the necessary regexes and replacements)
suppress more, changed the path-stripping to strip qtbase's parent
rather than os.getcwd() and took account of shadow builds (so both
source tree and build tree provide prefixes we want to strip from
paths). Also cope with $PWD potentially having symlinks in it, where
os.getcwd() is canonical.
It's possible some output might name files elsewhere in the source
tree; these won't be filtered by the prior cwd prefix removal; and, in
any case, the problem with cwd is only that the ancestry of qtbase is
apt to vary; paths relative to there should be consistent between test
runs. This change shall lead to a one-off rewrite of all expected_*
files; but it should now catch all paths. By stripping both build
root and source root (when different) it also avoids differences for
those doing out-of-source ("shadow") builds.
In our XML formats, any hyphens in root paths (e.g. I had Qt-5.6 in my
build root's path) got represented by a character entity, confounding
the replacement; so also do replacement that catches this. We may
discover other character entity subsitutions needed along with this.
Now filtering line numbers and timing information, including benchmark
results; these numbers all get replaced with 0 to avoid noisy diffs.
Also purging dangling hspace, to placate sanity-bot.
The module can now be imported - the code it runs is packaged as a
main() function that a __name__ == '__main__' stanza runs - and all
data is localised to where it's needed, rather than held in globals.
Tidied up and organized the existing regexes. There are doc-strings;
there is a short usage comment. Data is localised rather than global
and modern pythonic idioms get used where apt.
Regexes are compiled once instead of repeatedly. An object looks
after the list of patterns to apply and its construction handles all
anticipated problems. Failures are mediated by an exception.
The output file now gets written once, instead of twice (once before
editing, then over-write to edit), and Popen uses text mode, so that
write can do the same. Its command is delivered as an array, avoiding
the need to invoke a shell.
Instead of relying on qmake being in our path (which might give us a
bogus QT_VERSION if the one in path doesn't match our build tree), use
the relative path to qmake - we rely on being run in a specific
directory in the build tree, after all. Escape dots in the version
properly, so that 51730 doesn't get mistaken for 5.7.0 (for example),
and moved this check later in the sequence (matching a smaller target
makes it more likely to falsely match).
Overtly check we are in the right directory and tell the user what we
actually need, if run from the wrong place. Simplify handling of the
unsupported use-case for MS-Windows (but note what would be needed for
it).
Change-Id: Ibdff8f8cae173f6c31492648148cc345ae29022b
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
Reviewed-by: Frederik Gladhorn <frederik.gladhorn@qt.io>
2016-07-25 13:55:47 +00:00
|
|
|
(r'(Loc: \[[^[\]()]+)\(\d+\)', r'\1(0)'), # txt
|
2016-09-05 04:39:30 +00:00
|
|
|
(r'(\[Loc: [^[\]()]+)\(\d+\)', r'\1(0)'), # teamcity
|
2016-08-30 11:56:30 +00:00
|
|
|
(r'(<(?:Incident|Message)\b.*\bfile=.*\bline=)"\d+"', r'\1"0"'), # lightxml, xml
|
Major re-write of generate_expected_output.py
Restructured, separated the canonicalising of output lines out (into
an object that prepares the necessary regexes and replacements)
suppress more, changed the path-stripping to strip qtbase's parent
rather than os.getcwd() and took account of shadow builds (so both
source tree and build tree provide prefixes we want to strip from
paths). Also cope with $PWD potentially having symlinks in it, where
os.getcwd() is canonical.
It's possible some output might name files elsewhere in the source
tree; these won't be filtered by the prior cwd prefix removal; and, in
any case, the problem with cwd is only that the ancestry of qtbase is
apt to vary; paths relative to there should be consistent between test
runs. This change shall lead to a one-off rewrite of all expected_*
files; but it should now catch all paths. By stripping both build
root and source root (when different) it also avoids differences for
those doing out-of-source ("shadow") builds.
In our XML formats, any hyphens in root paths (e.g. I had Qt-5.6 in my
build root's path) got represented by a character entity, confounding
the replacement; so also do replacement that catches this. We may
discover other character entity subsitutions needed along with this.
Now filtering line numbers and timing information, including benchmark
results; these numbers all get replaced with 0 to avoid noisy diffs.
Also purging dangling hspace, to placate sanity-bot.
The module can now be imported - the code it runs is packaged as a
main() function that a __name__ == '__main__' stanza runs - and all
data is localised to where it's needed, rather than held in globals.
Tidied up and organized the existing regexes. There are doc-strings;
there is a short usage comment. Data is localised rather than global
and modern pythonic idioms get used where apt.
Regexes are compiled once instead of repeatedly. An object looks
after the list of patterns to apply and its construction handles all
anticipated problems. Failures are mediated by an exception.
The output file now gets written once, instead of twice (once before
editing, then over-write to edit), and Popen uses text mode, so that
write can do the same. Its command is delivered as an array, avoiding
the need to invoke a shell.
Instead of relying on qmake being in our path (which might give us a
bogus QT_VERSION if the one in path doesn't match our build tree), use
the relative path to qmake - we rely on being run in a specific
directory in the build tree, after all. Escape dots in the version
properly, so that 51730 doesn't get mistaken for 5.7.0 (for example),
and moved this check later in the sequence (matching a smaller target
makes it more likely to falsely match).
Overtly check we are in the right directory and tell the user what we
actually need, if run from the wrong place. Simplify handling of the
unsupported use-case for MS-Windows (but note what would be needed for
it).
Change-Id: Ibdff8f8cae173f6c31492648148cc345ae29022b
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
Reviewed-by: Frederik Gladhorn <frederik.gladhorn@qt.io>
2016-07-25 13:55:47 +00:00
|
|
|
),
|
|
|
|
precook = re.compile):
|
|
|
|
"""Private implementation details of __init__()."""
|
|
|
|
|
|
|
|
qmake = ('..',) * 4 + ('bin', 'qmake')
|
|
|
|
qmake = os.path.join(*qmake)
|
|
|
|
|
|
|
|
if os.path.sep in command:
|
|
|
|
scriptPath = os.path.abspath(command)
|
|
|
|
elif os.path.exists(command):
|
|
|
|
# e.g. if you typed "python3 generate_expected_output.py"
|
|
|
|
scriptPath = os.path.join(here, command)
|
|
|
|
else:
|
|
|
|
# From py 3.2: could use os.get_exec_path() here.
|
|
|
|
for d in os.environ.get('PATH', '').split(os.pathsep):
|
|
|
|
scriptPath = os.path.join(d, command)
|
|
|
|
if os.path.isfile(scriptPath):
|
|
|
|
break
|
|
|
|
else: # didn't break
|
|
|
|
raise Fail('Unable to find', command, 'in $PATH')
|
|
|
|
|
|
|
|
# Are we being run from the right place ?
|
2017-11-22 19:00:33 +00:00
|
|
|
scriptPath, myName = os.path.split(scriptPath)
|
|
|
|
hereNames, depth = scriptPath.split(os.path.sep), 5
|
|
|
|
hereNames = hereNames[-depth:] # path components from qtbase down
|
|
|
|
assert hereNames[0] == 'qtbase', ('Script moved: please correct depth', hereNames)
|
|
|
|
if not (here.split(os.path.sep)[-depth:] == hereNames
|
Major re-write of generate_expected_output.py
Restructured, separated the canonicalising of output lines out (into
an object that prepares the necessary regexes and replacements)
suppress more, changed the path-stripping to strip qtbase's parent
rather than os.getcwd() and took account of shadow builds (so both
source tree and build tree provide prefixes we want to strip from
paths). Also cope with $PWD potentially having symlinks in it, where
os.getcwd() is canonical.
It's possible some output might name files elsewhere in the source
tree; these won't be filtered by the prior cwd prefix removal; and, in
any case, the problem with cwd is only that the ancestry of qtbase is
apt to vary; paths relative to there should be consistent between test
runs. This change shall lead to a one-off rewrite of all expected_*
files; but it should now catch all paths. By stripping both build
root and source root (when different) it also avoids differences for
those doing out-of-source ("shadow") builds.
In our XML formats, any hyphens in root paths (e.g. I had Qt-5.6 in my
build root's path) got represented by a character entity, confounding
the replacement; so also do replacement that catches this. We may
discover other character entity subsitutions needed along with this.
Now filtering line numbers and timing information, including benchmark
results; these numbers all get replaced with 0 to avoid noisy diffs.
Also purging dangling hspace, to placate sanity-bot.
The module can now be imported - the code it runs is packaged as a
main() function that a __name__ == '__main__' stanza runs - and all
data is localised to where it's needed, rather than held in globals.
Tidied up and organized the existing regexes. There are doc-strings;
there is a short usage comment. Data is localised rather than global
and modern pythonic idioms get used where apt.
Regexes are compiled once instead of repeatedly. An object looks
after the list of patterns to apply and its construction handles all
anticipated problems. Failures are mediated by an exception.
The output file now gets written once, instead of twice (once before
editing, then over-write to edit), and Popen uses text mode, so that
write can do the same. Its command is delivered as an array, avoiding
the need to invoke a shell.
Instead of relying on qmake being in our path (which might give us a
bogus QT_VERSION if the one in path doesn't match our build tree), use
the relative path to qmake - we rely on being run in a specific
directory in the build tree, after all. Escape dots in the version
properly, so that 51730 doesn't get mistaken for 5.7.0 (for example),
and moved this check later in the sequence (matching a smaller target
makes it more likely to falsely match).
Overtly check we are in the right directory and tell the user what we
actually need, if run from the wrong place. Simplify handling of the
unsupported use-case for MS-Windows (but note what would be needed for
it).
Change-Id: Ibdff8f8cae173f6c31492648148cc345ae29022b
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
Reviewed-by: Frederik Gladhorn <frederik.gladhorn@qt.io>
2016-07-25 13:55:47 +00:00
|
|
|
and os.path.isfile(qmake)):
|
2017-11-22 19:00:33 +00:00
|
|
|
raise Fail('Run', myName, 'in its directory of a completed build')
|
Major re-write of generate_expected_output.py
Restructured, separated the canonicalising of output lines out (into
an object that prepares the necessary regexes and replacements)
suppress more, changed the path-stripping to strip qtbase's parent
rather than os.getcwd() and took account of shadow builds (so both
source tree and build tree provide prefixes we want to strip from
paths). Also cope with $PWD potentially having symlinks in it, where
os.getcwd() is canonical.
It's possible some output might name files elsewhere in the source
tree; these won't be filtered by the prior cwd prefix removal; and, in
any case, the problem with cwd is only that the ancestry of qtbase is
apt to vary; paths relative to there should be consistent between test
runs. This change shall lead to a one-off rewrite of all expected_*
files; but it should now catch all paths. By stripping both build
root and source root (when different) it also avoids differences for
those doing out-of-source ("shadow") builds.
In our XML formats, any hyphens in root paths (e.g. I had Qt-5.6 in my
build root's path) got represented by a character entity, confounding
the replacement; so also do replacement that catches this. We may
discover other character entity subsitutions needed along with this.
Now filtering line numbers and timing information, including benchmark
results; these numbers all get replaced with 0 to avoid noisy diffs.
Also purging dangling hspace, to placate sanity-bot.
The module can now be imported - the code it runs is packaged as a
main() function that a __name__ == '__main__' stanza runs - and all
data is localised to where it's needed, rather than held in globals.
Tidied up and organized the existing regexes. There are doc-strings;
there is a short usage comment. Data is localised rather than global
and modern pythonic idioms get used where apt.
Regexes are compiled once instead of repeatedly. An object looks
after the list of patterns to apply and its construction handles all
anticipated problems. Failures are mediated by an exception.
The output file now gets written once, instead of twice (once before
editing, then over-write to edit), and Popen uses text mode, so that
write can do the same. Its command is delivered as an array, avoiding
the need to invoke a shell.
Instead of relying on qmake being in our path (which might give us a
bogus QT_VERSION if the one in path doesn't match our build tree), use
the relative path to qmake - we rely on being run in a specific
directory in the build tree, after all. Escape dots in the version
properly, so that 51730 doesn't get mistaken for 5.7.0 (for example),
and moved this check later in the sequence (matching a smaller target
makes it more likely to falsely match).
Overtly check we are in the right directory and tell the user what we
actually need, if run from the wrong place. Simplify handling of the
unsupported use-case for MS-Windows (but note what would be needed for
it).
Change-Id: Ibdff8f8cae173f6c31492648148cc345ae29022b
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
Reviewed-by: Frederik Gladhorn <frederik.gladhorn@qt.io>
2016-07-25 13:55:47 +00:00
|
|
|
|
|
|
|
try:
|
|
|
|
qtver = subprocess.check_output([qmake, '-query', 'QT_VERSION'])
|
|
|
|
except OSError as what:
|
|
|
|
raise Fail(what.strerror)
|
|
|
|
qtver = qtver.strip().decode('utf-8')
|
|
|
|
|
2017-11-22 19:00:33 +00:00
|
|
|
hereNames = tuple(hereNames)
|
|
|
|
# Add path to specific sources and to tst_*.cpp if missing (for in-source builds):
|
|
|
|
patterns += ((r'(^|[^/])\b(qtestcase.cpp)\b', r'\1qtbase/src/testlib/\2'),
|
|
|
|
# Add more special cases here, if they show up !
|
2019-01-30 11:02:27 +00:00
|
|
|
(r'([\[" ])\.\./(counting/tst_counting.cpp)\b',
|
2017-11-22 19:00:33 +00:00
|
|
|
r'\1' + os.path.sep.join(hereNames + (r'\2',))),
|
|
|
|
# The common pattern:
|
|
|
|
(r'(^|[^/])\b(tst_)?([a-z]+\d*)\.cpp\b',
|
|
|
|
r'\1' + os.path.sep.join(hereNames + (r'\3', r'\2\3.cpp'))))
|
|
|
|
|
|
|
|
sentinel = os.path.sep + hereNames[0] + os.path.sep # '/qtbase/'
|
Major re-write of generate_expected_output.py
Restructured, separated the canonicalising of output lines out (into
an object that prepares the necessary regexes and replacements)
suppress more, changed the path-stripping to strip qtbase's parent
rather than os.getcwd() and took account of shadow builds (so both
source tree and build tree provide prefixes we want to strip from
paths). Also cope with $PWD potentially having symlinks in it, where
os.getcwd() is canonical.
It's possible some output might name files elsewhere in the source
tree; these won't be filtered by the prior cwd prefix removal; and, in
any case, the problem with cwd is only that the ancestry of qtbase is
apt to vary; paths relative to there should be consistent between test
runs. This change shall lead to a one-off rewrite of all expected_*
files; but it should now catch all paths. By stripping both build
root and source root (when different) it also avoids differences for
those doing out-of-source ("shadow") builds.
In our XML formats, any hyphens in root paths (e.g. I had Qt-5.6 in my
build root's path) got represented by a character entity, confounding
the replacement; so also do replacement that catches this. We may
discover other character entity subsitutions needed along with this.
Now filtering line numbers and timing information, including benchmark
results; these numbers all get replaced with 0 to avoid noisy diffs.
Also purging dangling hspace, to placate sanity-bot.
The module can now be imported - the code it runs is packaged as a
main() function that a __name__ == '__main__' stanza runs - and all
data is localised to where it's needed, rather than held in globals.
Tidied up and organized the existing regexes. There are doc-strings;
there is a short usage comment. Data is localised rather than global
and modern pythonic idioms get used where apt.
Regexes are compiled once instead of repeatedly. An object looks
after the list of patterns to apply and its construction handles all
anticipated problems. Failures are mediated by an exception.
The output file now gets written once, instead of twice (once before
editing, then over-write to edit), and Popen uses text mode, so that
write can do the same. Its command is delivered as an array, avoiding
the need to invoke a shell.
Instead of relying on qmake being in our path (which might give us a
bogus QT_VERSION if the one in path doesn't match our build tree), use
the relative path to qmake - we rely on being run in a specific
directory in the build tree, after all. Escape dots in the version
properly, so that 51730 doesn't get mistaken for 5.7.0 (for example),
and moved this check later in the sequence (matching a smaller target
makes it more likely to falsely match).
Overtly check we are in the right directory and tell the user what we
actually need, if run from the wrong place. Simplify handling of the
unsupported use-case for MS-Windows (but note what would be needed for
it).
Change-Id: Ibdff8f8cae173f6c31492648148cc345ae29022b
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
Reviewed-by: Frederik Gladhorn <frederik.gladhorn@qt.io>
2016-07-25 13:55:47 +00:00
|
|
|
# Identify the path prefix of our qtbase ancestor directory
|
|
|
|
# (source, build and $PWD, when different); trim such prefixes
|
|
|
|
# off all paths we see.
|
|
|
|
roots = tuple(r[:r.find(sentinel) + 1].encode('unicode-escape').decode('utf-8')
|
|
|
|
for r in set((here, scriptPath, os.environ.get('PWD', '')))
|
|
|
|
if sentinel in r)
|
|
|
|
patterns += tuple((root, r'') for root in roots) + (
|
|
|
|
(r'\.'.join(qtver.split('.')), r'@INSERT_QT_VERSION_HERE@'),)
|
|
|
|
if any('-' in r for r in roots):
|
|
|
|
# Our xml formats replace hyphens with a character entity:
|
|
|
|
patterns += tuple((root.replace('-', '�*2D;'), r'')
|
|
|
|
for root in roots if '-' in root)
|
|
|
|
|
2016-07-29 09:40:11 +00:00
|
|
|
return qtver, scriptPath, tuple((precook(p), r) for p, r in patterns)
|
Major re-write of generate_expected_output.py
Restructured, separated the canonicalising of output lines out (into
an object that prepares the necessary regexes and replacements)
suppress more, changed the path-stripping to strip qtbase's parent
rather than os.getcwd() and took account of shadow builds (so both
source tree and build tree provide prefixes we want to strip from
paths). Also cope with $PWD potentially having symlinks in it, where
os.getcwd() is canonical.
It's possible some output might name files elsewhere in the source
tree; these won't be filtered by the prior cwd prefix removal; and, in
any case, the problem with cwd is only that the ancestry of qtbase is
apt to vary; paths relative to there should be consistent between test
runs. This change shall lead to a one-off rewrite of all expected_*
files; but it should now catch all paths. By stripping both build
root and source root (when different) it also avoids differences for
those doing out-of-source ("shadow") builds.
In our XML formats, any hyphens in root paths (e.g. I had Qt-5.6 in my
build root's path) got represented by a character entity, confounding
the replacement; so also do replacement that catches this. We may
discover other character entity subsitutions needed along with this.
Now filtering line numbers and timing information, including benchmark
results; these numbers all get replaced with 0 to avoid noisy diffs.
Also purging dangling hspace, to placate sanity-bot.
The module can now be imported - the code it runs is packaged as a
main() function that a __name__ == '__main__' stanza runs - and all
data is localised to where it's needed, rather than held in globals.
Tidied up and organized the existing regexes. There are doc-strings;
there is a short usage comment. Data is localised rather than global
and modern pythonic idioms get used where apt.
Regexes are compiled once instead of repeatedly. An object looks
after the list of patterns to apply and its construction handles all
anticipated problems. Failures are mediated by an exception.
The output file now gets written once, instead of twice (once before
editing, then over-write to edit), and Popen uses text mode, so that
write can do the same. Its command is delivered as an array, avoiding
the need to invoke a shell.
Instead of relying on qmake being in our path (which might give us a
bogus QT_VERSION if the one in path doesn't match our build tree), use
the relative path to qmake - we rely on being run in a specific
directory in the build tree, after all. Escape dots in the version
properly, so that 51730 doesn't get mistaken for 5.7.0 (for example),
and moved this check later in the sequence (matching a smaller target
makes it more likely to falsely match).
Overtly check we are in the right directory and tell the user what we
actually need, if run from the wrong place. Simplify handling of the
unsupported use-case for MS-Windows (but note what would be needed for
it).
Change-Id: Ibdff8f8cae173f6c31492648148cc345ae29022b
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
Reviewed-by: Frederik Gladhorn <frederik.gladhorn@qt.io>
2016-07-25 13:55:47 +00:00
|
|
|
|
|
|
|
def clean(self, data):
|
|
|
|
"""Remove volatile details from test output.
|
|
|
|
|
|
|
|
Takes the full test output as a single (possibly huge)
|
|
|
|
multi-line string; iterates over cleaned lines of output."""
|
|
|
|
for line in data.split('\n'):
|
|
|
|
# Replace all occurrences of each regex:
|
|
|
|
for searchRe, replaceExp in self.__replace:
|
|
|
|
line = searchRe.sub(replaceExp, line)
|
|
|
|
yield line
|
|
|
|
|
2016-07-29 09:40:11 +00:00
|
|
|
class Scanner (object):
|
|
|
|
"""Knows which subdirectories to generate output for.
|
|
|
|
|
|
|
|
Tell its constructor the name of this source directory (see
|
|
|
|
Cleaner's .sourceDir) and it'll scan tst_selftests.cpp for the
|
|
|
|
list. Its .subdirs() can then filter a user-supplied list of
|
|
|
|
subdirs or generate the full list, when the user supplied
|
|
|
|
none."""
|
|
|
|
def __init__(self, srcDir):
|
|
|
|
self.__tested = tuple(self.__scan_cpp(os.path.join(srcDir, 'tst_selftests.cpp')))
|
|
|
|
|
|
|
|
@staticmethod
|
|
|
|
def __scan_cpp(name,
|
|
|
|
trimc = re.compile(r'/\*.*?\*/').sub,
|
|
|
|
trimcpp = re.compile(r'//.*$').sub,
|
|
|
|
first = re.compile(r'(QStringList|auto)\s+tests\s*=\s*QStringList\(\)').match,
|
|
|
|
match = re.compile(r'(?:tests\s*)?<<\s*"(\w+)"').match,
|
|
|
|
last = re.compile(r'\bfor.*\b(LoggerSet|auto)\b.*\ballLoggerSets\(\)').search):
|
|
|
|
"""Scans tst_selftests.cpp to find which subdirs matter.
|
|
|
|
|
|
|
|
There's a list, tests, to which all subdir names get added, if
|
|
|
|
they're to be tested. Other sub-dirs aren't tested, so
|
|
|
|
there's no sense in generating output for them."""
|
|
|
|
scan = False
|
|
|
|
with open(name) as src:
|
|
|
|
for line in src:
|
|
|
|
line = trimcpp('', trimc('', line.strip())).strip()
|
|
|
|
if not scan:
|
|
|
|
got = first(line)
|
|
|
|
if got:
|
|
|
|
scan, line = True, line[len(got.group()):]
|
|
|
|
if scan:
|
|
|
|
if last(line): break
|
|
|
|
got = match(line)
|
|
|
|
while got:
|
|
|
|
yield got.group(1)
|
|
|
|
line = line[len(got.group()):].strip()
|
|
|
|
got = match(line)
|
|
|
|
|
|
|
|
def subdirs(self, given):
|
|
|
|
if given:
|
|
|
|
for d in given:
|
|
|
|
if not os.path.isdir(d):
|
|
|
|
print('No such directory:', d, '- skipped')
|
|
|
|
elif d in self.__tested:
|
|
|
|
yield d
|
|
|
|
else:
|
|
|
|
print('Directory', d, 'is not tested by tst_selftests.cpp')
|
|
|
|
else:
|
|
|
|
for d in self.__tested:
|
|
|
|
if os.path.isdir(d):
|
|
|
|
yield d
|
|
|
|
else:
|
|
|
|
print('tst_selftests.cpp names', d, "as a test, but it doesn't exist")
|
|
|
|
del re
|
|
|
|
|
Major re-write of generate_expected_output.py
Restructured, separated the canonicalising of output lines out (into
an object that prepares the necessary regexes and replacements)
suppress more, changed the path-stripping to strip qtbase's parent
rather than os.getcwd() and took account of shadow builds (so both
source tree and build tree provide prefixes we want to strip from
paths). Also cope with $PWD potentially having symlinks in it, where
os.getcwd() is canonical.
It's possible some output might name files elsewhere in the source
tree; these won't be filtered by the prior cwd prefix removal; and, in
any case, the problem with cwd is only that the ancestry of qtbase is
apt to vary; paths relative to there should be consistent between test
runs. This change shall lead to a one-off rewrite of all expected_*
files; but it should now catch all paths. By stripping both build
root and source root (when different) it also avoids differences for
those doing out-of-source ("shadow") builds.
In our XML formats, any hyphens in root paths (e.g. I had Qt-5.6 in my
build root's path) got represented by a character entity, confounding
the replacement; so also do replacement that catches this. We may
discover other character entity subsitutions needed along with this.
Now filtering line numbers and timing information, including benchmark
results; these numbers all get replaced with 0 to avoid noisy diffs.
Also purging dangling hspace, to placate sanity-bot.
The module can now be imported - the code it runs is packaged as a
main() function that a __name__ == '__main__' stanza runs - and all
data is localised to where it's needed, rather than held in globals.
Tidied up and organized the existing regexes. There are doc-strings;
there is a short usage comment. Data is localised rather than global
and modern pythonic idioms get used where apt.
Regexes are compiled once instead of repeatedly. An object looks
after the list of patterns to apply and its construction handles all
anticipated problems. Failures are mediated by an exception.
The output file now gets written once, instead of twice (once before
editing, then over-write to edit), and Popen uses text mode, so that
write can do the same. Its command is delivered as an array, avoiding
the need to invoke a shell.
Instead of relying on qmake being in our path (which might give us a
bogus QT_VERSION if the one in path doesn't match our build tree), use
the relative path to qmake - we rely on being run in a specific
directory in the build tree, after all. Escape dots in the version
properly, so that 51730 doesn't get mistaken for 5.7.0 (for example),
and moved this check later in the sequence (matching a smaller target
makes it more likely to falsely match).
Overtly check we are in the right directory and tell the user what we
actually need, if run from the wrong place. Simplify handling of the
unsupported use-case for MS-Windows (but note what would be needed for
it).
Change-Id: Ibdff8f8cae173f6c31492648148cc345ae29022b
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
Reviewed-by: Frederik Gladhorn <frederik.gladhorn@qt.io>
2016-07-25 13:55:47 +00:00
|
|
|
def generateTestData(testname, clean,
|
2018-03-01 16:06:23 +00:00
|
|
|
formats = ('xml', 'txt', 'xunitxml', 'lightxml', 'teamcity', 'tap'),
|
Major re-write of generate_expected_output.py
Restructured, separated the canonicalising of output lines out (into
an object that prepares the necessary regexes and replacements)
suppress more, changed the path-stripping to strip qtbase's parent
rather than os.getcwd() and took account of shadow builds (so both
source tree and build tree provide prefixes we want to strip from
paths). Also cope with $PWD potentially having symlinks in it, where
os.getcwd() is canonical.
It's possible some output might name files elsewhere in the source
tree; these won't be filtered by the prior cwd prefix removal; and, in
any case, the problem with cwd is only that the ancestry of qtbase is
apt to vary; paths relative to there should be consistent between test
runs. This change shall lead to a one-off rewrite of all expected_*
files; but it should now catch all paths. By stripping both build
root and source root (when different) it also avoids differences for
those doing out-of-source ("shadow") builds.
In our XML formats, any hyphens in root paths (e.g. I had Qt-5.6 in my
build root's path) got represented by a character entity, confounding
the replacement; so also do replacement that catches this. We may
discover other character entity subsitutions needed along with this.
Now filtering line numbers and timing information, including benchmark
results; these numbers all get replaced with 0 to avoid noisy diffs.
Also purging dangling hspace, to placate sanity-bot.
The module can now be imported - the code it runs is packaged as a
main() function that a __name__ == '__main__' stanza runs - and all
data is localised to where it's needed, rather than held in globals.
Tidied up and organized the existing regexes. There are doc-strings;
there is a short usage comment. Data is localised rather than global
and modern pythonic idioms get used where apt.
Regexes are compiled once instead of repeatedly. An object looks
after the list of patterns to apply and its construction handles all
anticipated problems. Failures are mediated by an exception.
The output file now gets written once, instead of twice (once before
editing, then over-write to edit), and Popen uses text mode, so that
write can do the same. Its command is delivered as an array, avoiding
the need to invoke a shell.
Instead of relying on qmake being in our path (which might give us a
bogus QT_VERSION if the one in path doesn't match our build tree), use
the relative path to qmake - we rely on being run in a specific
directory in the build tree, after all. Escape dots in the version
properly, so that 51730 doesn't get mistaken for 5.7.0 (for example),
and moved this check later in the sequence (matching a smaller target
makes it more likely to falsely match).
Overtly check we are in the right directory and tell the user what we
actually need, if run from the wrong place. Simplify handling of the
unsupported use-case for MS-Windows (but note what would be needed for
it).
Change-Id: Ibdff8f8cae173f6c31492648148cc345ae29022b
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
Reviewed-by: Frederik Gladhorn <frederik.gladhorn@qt.io>
2016-07-25 13:55:47 +00:00
|
|
|
extraArgs = {
|
|
|
|
"commandlinedata": "fiveTablePasses fiveTablePasses:fiveTablePasses_data1 -v2",
|
|
|
|
"benchlibcallgrind": "-callgrind",
|
|
|
|
"benchlibeventcounter": "-eventcounter",
|
|
|
|
"benchliboptions": "-eventcounter",
|
|
|
|
"benchlibtickcounter": "-tickcounter",
|
|
|
|
"badxml": "-eventcounter",
|
|
|
|
"benchlibcounting": "-eventcounter",
|
|
|
|
"printdatatags": "-datatags",
|
|
|
|
"printdatatagswithglobaltags": "-datatags",
|
|
|
|
"silent": "-silent",
|
|
|
|
"verbose1": "-v1",
|
|
|
|
"verbose2": "-v2",
|
|
|
|
}):
|
|
|
|
"""Run one test and save its cleaned results.
|
|
|
|
|
|
|
|
Required arguments are the name of the test directory (the binary
|
|
|
|
it contains is expected to have the same name) and a function
|
|
|
|
that'll clean a test-run's output; see Cleaner.clean().
|
|
|
|
"""
|
|
|
|
# MS-Win: shall need to add .exe to this
|
|
|
|
path = os.path.join(testname, testname)
|
|
|
|
if not os.path.isfile(path):
|
|
|
|
print("Warning: directory", testname, "contains no test executable")
|
|
|
|
return
|
|
|
|
|
|
|
|
print(" running", testname)
|
2013-12-12 16:27:52 +00:00
|
|
|
for format in formats:
|
Major re-write of generate_expected_output.py
Restructured, separated the canonicalising of output lines out (into
an object that prepares the necessary regexes and replacements)
suppress more, changed the path-stripping to strip qtbase's parent
rather than os.getcwd() and took account of shadow builds (so both
source tree and build tree provide prefixes we want to strip from
paths). Also cope with $PWD potentially having symlinks in it, where
os.getcwd() is canonical.
It's possible some output might name files elsewhere in the source
tree; these won't be filtered by the prior cwd prefix removal; and, in
any case, the problem with cwd is only that the ancestry of qtbase is
apt to vary; paths relative to there should be consistent between test
runs. This change shall lead to a one-off rewrite of all expected_*
files; but it should now catch all paths. By stripping both build
root and source root (when different) it also avoids differences for
those doing out-of-source ("shadow") builds.
In our XML formats, any hyphens in root paths (e.g. I had Qt-5.6 in my
build root's path) got represented by a character entity, confounding
the replacement; so also do replacement that catches this. We may
discover other character entity subsitutions needed along with this.
Now filtering line numbers and timing information, including benchmark
results; these numbers all get replaced with 0 to avoid noisy diffs.
Also purging dangling hspace, to placate sanity-bot.
The module can now be imported - the code it runs is packaged as a
main() function that a __name__ == '__main__' stanza runs - and all
data is localised to where it's needed, rather than held in globals.
Tidied up and organized the existing regexes. There are doc-strings;
there is a short usage comment. Data is localised rather than global
and modern pythonic idioms get used where apt.
Regexes are compiled once instead of repeatedly. An object looks
after the list of patterns to apply and its construction handles all
anticipated problems. Failures are mediated by an exception.
The output file now gets written once, instead of twice (once before
editing, then over-write to edit), and Popen uses text mode, so that
write can do the same. Its command is delivered as an array, avoiding
the need to invoke a shell.
Instead of relying on qmake being in our path (which might give us a
bogus QT_VERSION if the one in path doesn't match our build tree), use
the relative path to qmake - we rely on being run in a specific
directory in the build tree, after all. Escape dots in the version
properly, so that 51730 doesn't get mistaken for 5.7.0 (for example),
and moved this check later in the sequence (matching a smaller target
makes it more likely to falsely match).
Overtly check we are in the right directory and tell the user what we
actually need, if run from the wrong place. Simplify handling of the
unsupported use-case for MS-Windows (but note what would be needed for
it).
Change-Id: Ibdff8f8cae173f6c31492648148cc345ae29022b
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
Reviewed-by: Frederik Gladhorn <frederik.gladhorn@qt.io>
2016-07-25 13:55:47 +00:00
|
|
|
cmd = [path, '-' + format]
|
|
|
|
if testname in extraArgs:
|
|
|
|
cmd += extraArgs[testname].split()
|
|
|
|
|
|
|
|
data = subprocess.Popen(cmd, stdout=subprocess.PIPE,
|
|
|
|
universal_newlines=True).communicate()[0]
|
|
|
|
with open('expected_' + testname + '.' + format, 'w') as out:
|
|
|
|
out.write('\n'.join(clean(data))) # write() appends a newline, too
|
|
|
|
|
|
|
|
def main(name, *args):
|
|
|
|
"""Minimal argument parsing and driver for the real work"""
|
2017-10-10 11:43:15 +00:00
|
|
|
os.environ.update(
|
|
|
|
LC_ALL = 'C', # Use standard locale
|
|
|
|
# Avoid interference from any qtlogging.ini files, e.g. in
|
|
|
|
# /etc/xdg/QtProject/, (must match tst_selftests.cpp's
|
|
|
|
# processEnvironment()'s value):
|
2018-03-09 11:03:01 +00:00
|
|
|
QT_LOGGING_RULES = '*.debug=true;qt.*=false')
|
2017-10-10 11:43:15 +00:00
|
|
|
|
Major re-write of generate_expected_output.py
Restructured, separated the canonicalising of output lines out (into
an object that prepares the necessary regexes and replacements)
suppress more, changed the path-stripping to strip qtbase's parent
rather than os.getcwd() and took account of shadow builds (so both
source tree and build tree provide prefixes we want to strip from
paths). Also cope with $PWD potentially having symlinks in it, where
os.getcwd() is canonical.
It's possible some output might name files elsewhere in the source
tree; these won't be filtered by the prior cwd prefix removal; and, in
any case, the problem with cwd is only that the ancestry of qtbase is
apt to vary; paths relative to there should be consistent between test
runs. This change shall lead to a one-off rewrite of all expected_*
files; but it should now catch all paths. By stripping both build
root and source root (when different) it also avoids differences for
those doing out-of-source ("shadow") builds.
In our XML formats, any hyphens in root paths (e.g. I had Qt-5.6 in my
build root's path) got represented by a character entity, confounding
the replacement; so also do replacement that catches this. We may
discover other character entity subsitutions needed along with this.
Now filtering line numbers and timing information, including benchmark
results; these numbers all get replaced with 0 to avoid noisy diffs.
Also purging dangling hspace, to placate sanity-bot.
The module can now be imported - the code it runs is packaged as a
main() function that a __name__ == '__main__' stanza runs - and all
data is localised to where it's needed, rather than held in globals.
Tidied up and organized the existing regexes. There are doc-strings;
there is a short usage comment. Data is localised rather than global
and modern pythonic idioms get used where apt.
Regexes are compiled once instead of repeatedly. An object looks
after the list of patterns to apply and its construction handles all
anticipated problems. Failures are mediated by an exception.
The output file now gets written once, instead of twice (once before
editing, then over-write to edit), and Popen uses text mode, so that
write can do the same. Its command is delivered as an array, avoiding
the need to invoke a shell.
Instead of relying on qmake being in our path (which might give us a
bogus QT_VERSION if the one in path doesn't match our build tree), use
the relative path to qmake - we rely on being run in a specific
directory in the build tree, after all. Escape dots in the version
properly, so that 51730 doesn't get mistaken for 5.7.0 (for example),
and moved this check later in the sequence (matching a smaller target
makes it more likely to falsely match).
Overtly check we are in the right directory and tell the user what we
actually need, if run from the wrong place. Simplify handling of the
unsupported use-case for MS-Windows (but note what would be needed for
it).
Change-Id: Ibdff8f8cae173f6c31492648148cc345ae29022b
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
Reviewed-by: Frederik Gladhorn <frederik.gladhorn@qt.io>
2016-07-25 13:55:47 +00:00
|
|
|
herePath = os.getcwd()
|
|
|
|
cleaner = Cleaner(herePath, name)
|
|
|
|
|
2016-07-29 09:40:11 +00:00
|
|
|
tests = tuple(Scanner(cleaner.sourceDir).subdirs(args))
|
Major re-write of generate_expected_output.py
Restructured, separated the canonicalising of output lines out (into
an object that prepares the necessary regexes and replacements)
suppress more, changed the path-stripping to strip qtbase's parent
rather than os.getcwd() and took account of shadow builds (so both
source tree and build tree provide prefixes we want to strip from
paths). Also cope with $PWD potentially having symlinks in it, where
os.getcwd() is canonical.
It's possible some output might name files elsewhere in the source
tree; these won't be filtered by the prior cwd prefix removal; and, in
any case, the problem with cwd is only that the ancestry of qtbase is
apt to vary; paths relative to there should be consistent between test
runs. This change shall lead to a one-off rewrite of all expected_*
files; but it should now catch all paths. By stripping both build
root and source root (when different) it also avoids differences for
those doing out-of-source ("shadow") builds.
In our XML formats, any hyphens in root paths (e.g. I had Qt-5.6 in my
build root's path) got represented by a character entity, confounding
the replacement; so also do replacement that catches this. We may
discover other character entity subsitutions needed along with this.
Now filtering line numbers and timing information, including benchmark
results; these numbers all get replaced with 0 to avoid noisy diffs.
Also purging dangling hspace, to placate sanity-bot.
The module can now be imported - the code it runs is packaged as a
main() function that a __name__ == '__main__' stanza runs - and all
data is localised to where it's needed, rather than held in globals.
Tidied up and organized the existing regexes. There are doc-strings;
there is a short usage comment. Data is localised rather than global
and modern pythonic idioms get used where apt.
Regexes are compiled once instead of repeatedly. An object looks
after the list of patterns to apply and its construction handles all
anticipated problems. Failures are mediated by an exception.
The output file now gets written once, instead of twice (once before
editing, then over-write to edit), and Popen uses text mode, so that
write can do the same. Its command is delivered as an array, avoiding
the need to invoke a shell.
Instead of relying on qmake being in our path (which might give us a
bogus QT_VERSION if the one in path doesn't match our build tree), use
the relative path to qmake - we rely on being run in a specific
directory in the build tree, after all. Escape dots in the version
properly, so that 51730 doesn't get mistaken for 5.7.0 (for example),
and moved this check later in the sequence (matching a smaller target
makes it more likely to falsely match).
Overtly check we are in the right directory and tell the user what we
actually need, if run from the wrong place. Simplify handling of the
unsupported use-case for MS-Windows (but note what would be needed for
it).
Change-Id: Ibdff8f8cae173f6c31492648148cc345ae29022b
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
Reviewed-by: Frederik Gladhorn <frederik.gladhorn@qt.io>
2016-07-25 13:55:47 +00:00
|
|
|
print("Generating", len(tests), "test results for", cleaner.version, "in:", herePath)
|
|
|
|
for path in tests:
|
|
|
|
generateTestData(path, cleaner.clean)
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
# Executed when script is run, not when imported (e.g. to debug)
|
|
|
|
import sys
|
|
|
|
|
|
|
|
if sys.platform.startswith('win'):
|
|
|
|
print("This script does not work on Windows.")
|
|
|
|
exit()
|
|
|
|
|
|
|
|
try:
|
|
|
|
main(*sys.argv)
|
|
|
|
except Fail as what:
|
|
|
|
sys.stderr.write('Failed: ' + ' '.join(what.args) + '\n')
|
|
|
|
exit(1)
|