Make generated selftest output match for in-source builds

When generate_expected_output.py is run for an in-source build, the
raw output contains no paths to the sources for the script to whittle
down, as it does for shadow builds, to just the path from qtbase down.
So kludge together some extra regexes that can fix that up and tweak
some relevant code to provide them with the data they need.

Change-Id: I656d7126087bd9ad20b2af6835fba314d90a171d
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
bb10
Edward Welbourne 2017-11-22 20:00:33 +01:00
parent 0b70f5ada9
commit 3ac029f674
1 changed files with 17 additions and 5 deletions

View File

@ -116,10 +116,13 @@ class Cleaner (object):
raise Fail('Unable to find', command, 'in $PATH')
# Are we being run from the right place ?
myNames = scriptPath.split(os.path.sep)
if not (here.split(os.path.sep)[-5:] == myNames[-6:-1]
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
and os.path.isfile(qmake)):
raise Fail('Run', myNames[-1], 'in its directory of a completed build')
raise Fail('Run', myName, 'in its directory of a completed build')
try:
qtver = subprocess.check_output([qmake, '-query', 'QT_VERSION'])
@ -127,8 +130,17 @@ class Cleaner (object):
raise Fail(what.strerror)
qtver = qtver.strip().decode('utf-8')
scriptPath = os.path.dirname(scriptPath) # ditch leaf file-name
sentinel = os.path.sep + 'qtbase' + os.path.sep # '/qtbase/'
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 !
(r'([[" ])\.\./(counting/tst_counting.cpp)\b',
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/'
# Identify the path prefix of our qtbase ancestor directory
# (source, build and $PWD, when different); trim such prefixes
# off all paths we see.