Squish: Use sets instead of lists for kits in use

They fit our use-case much better.

Task-number: QTCREATORBUG-20874
Change-Id: Ifa06ce00f3e6999a99c3bc2bb7e9ba759fa02e94
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
Robert Loehning
2018-08-02 20:50:03 +02:00
parent 6564922254
commit 21bcc7f38b
4 changed files with 31 additions and 39 deletions

View File

@@ -44,7 +44,7 @@ class Targets:
@staticmethod
def availableTargetClasses():
availableTargets = list(Targets.ALL_TARGETS)
availableTargets = set(Targets.ALL_TARGETS)
if platform.system() in ('Windows', 'Microsoft'):
availableTargets.remove(Targets.EMBEDDED_LINUX)
elif platform.system() == 'Darwin':
@@ -54,8 +54,7 @@ class Targets:
@staticmethod
def desktopTargetClasses():
desktopTargets = Targets.availableTargetClasses()
if Targets.EMBEDDED_LINUX in desktopTargets:
desktopTargets.remove(Targets.EMBEDDED_LINUX)
desktopTargets.discard(Targets.EMBEDDED_LINUX)
return desktopTargets
@staticmethod
@@ -64,10 +63,7 @@ class Targets:
@staticmethod
def getTargetsAsStrings(targets):
if not isinstance(targets, (tuple,list)):
test.fatal("Wrong usage... This function handles only tuples or lists.")
return None
return map(Targets.getStringForTarget, targets)
return set(map(Targets.getStringForTarget, targets))
@staticmethod
def getIdForTargetName(targetName):

View File

@@ -155,8 +155,8 @@ def __createProjectHandleQtQuickSelection__(minimumQtVersion):
# withoutQt4 if True Qt4 will get unchecked / not selected while checking the targets
def __selectQtVersionDesktop__(checks, available=None, withoutQt4=False):
wanted = Targets.desktopTargetClasses()
if withoutQt4 and Targets.DESKTOP_4_8_7_DEFAULT in wanted:
wanted.remove(Targets.DESKTOP_4_8_7_DEFAULT)
if withoutQt4:
wanted.discard(Targets.DESKTOP_4_8_7_DEFAULT)
checkedTargets = __chooseTargets__(wanted, available)
if checks:
for target in checkedTargets:
@@ -197,8 +197,7 @@ def __modifyAvailableTargets__(available, requiredQt, asStrings=False):
toBeRemoved = Targets.EMBEDDED_LINUX
if asStrings:
toBeRemoved = Targets.getStringForTarget(toBeRemoved)
if toBeRemoved in available:
available.remove(toBeRemoved)
available.discard(toBeRemoved)
for currentItem in tmp:
if asStrings:
item = currentItem
@@ -207,7 +206,7 @@ def __modifyAvailableTargets__(available, requiredQt, asStrings=False):
found = versionFinder.search(item)
if found:
if Qt5Path.toVersionTuple(found.group(1)) < Qt5Path.toVersionTuple(requiredQt):
available.remove(currentItem)
available.discard(currentItem)
# Creates a Qt GUI project
# param path specifies where to create the project
@@ -398,14 +397,14 @@ def __chooseTargets__(targets, availableTargets=None, additionalFunc=None):
else:
# following targets depend on the build environment - added for further/later tests
available = Targets.availableTargetClasses()
checkedTargets = []
checkedTargets = set()
for current in available:
mustCheck = current in targets
try:
ensureChecked("{type='QCheckBox' text='%s' visible='1'}" % Targets.getStringForTarget(current),
mustCheck, 3000)
if mustCheck:
checkedTargets.append(current)
checkedTargets.add(current)
# perform additional function on detailed kits view
if additionalFunc:
@@ -517,26 +516,26 @@ def __getSupportedPlatforms__(text, templateName, getAsStrings=False):
version = None
if templateName.startswith("Qt Quick Application - "):
if templateName == "Qt Quick Application - Empty":
result = [Targets.DESKTOP_5_6_1_DEFAULT, Targets.DESKTOP_5_10_1_DEFAULT]
result = set([Targets.DESKTOP_5_6_1_DEFAULT, Targets.DESKTOP_5_10_1_DEFAULT])
else:
result = [Targets.DESKTOP_5_10_1_DEFAULT]
result = set([Targets.DESKTOP_5_10_1_DEFAULT])
elif 'Supported Platforms' in text:
supports = text[text.find('Supported Platforms'):].split(":")[1].strip().split(" ")
result = []
result = set()
if 'Desktop' in supports:
if (version == None or version < "5.0"):
result.append(Targets.DESKTOP_4_8_7_DEFAULT)
result.add(Targets.DESKTOP_4_8_7_DEFAULT)
if platform.system() in ("Linux", "Darwin"):
result.append(Targets.EMBEDDED_LINUX)
result.extend([Targets.DESKTOP_5_6_1_DEFAULT, Targets.DESKTOP_5_10_1_DEFAULT])
result.add(Targets.EMBEDDED_LINUX)
result = result.union(set([Targets.DESKTOP_5_6_1_DEFAULT, Targets.DESKTOP_5_10_1_DEFAULT]))
if platform.system() != 'Darwin':
result.append(Targets.DESKTOP_5_4_1_GCC)
result.add(Targets.DESKTOP_5_4_1_GCC)
elif 'Platform independent' in text:
result = Targets.desktopTargetClasses()
else:
test.warning("Returning None (__getSupportedPlatforms__())",
"Parsed text: '%s'" % text)
return [], None
return set(), None
if getAsStrings:
result = Targets.getTargetsAsStrings(result)
return result, version

View File

@@ -41,7 +41,7 @@ def main():
return
# open example project, supports only Qt 5
targets = Targets.desktopTargetClasses()
targets.remove(Targets.DESKTOP_4_8_7_DEFAULT)
targets.discard(Targets.DESKTOP_4_8_7_DEFAULT)
openQmakeProject(examplePath, targets)
# build and wait until finished - on all build configurations
availableConfigs = iterateBuildConfigs()

View File

@@ -87,23 +87,20 @@ def main():
def verifyKitCheckboxes(kits, displayedPlatforms):
waitForObject("{type='QLabel' unnamed='1' visible='1' text='Kit Selection'}")
availableCheckboxes = filter(visibleCheckBoxExists, kits.keys())
availableCheckboxes = frozenset(filter(visibleCheckBoxExists, kits.keys()))
# verification whether expected, found and configured match
for t in kits:
if t in displayedPlatforms:
if t in availableCheckboxes:
test.passes("Found expected kit '%s' on 'Kit Selection' page." % t)
availableCheckboxes.remove(t)
else:
test.fail("Expected kit '%s' missing on 'Kit Selection' page." % t)
else:
if t in availableCheckboxes:
test.fail("Kit '%s' found on 'Kit Selection' page - but was not expected!" % t)
else:
test.passes("Irrelevant kit '%s' not found on 'Kit Selection' page." % t)
if len(availableCheckboxes) != 0:
test.fail("Found unexpected additional kit(s) %s on 'Kit Selection' page."
% str(availableCheckboxes))
expectedShownKits = availableCheckboxes.intersection(displayedPlatforms)
unexpectedShownKits = availableCheckboxes.difference(displayedPlatforms)
missingKits = displayedPlatforms.difference(availableCheckboxes)
test.log("Expected kits shown on 'Kit Selection' page:\n%s" % "\n".join(expectedShownKits))
if len(unexpectedShownKits):
test.fail("Kits found on 'Kit Selection' page but not expected:\n%s"
% "\n".join(unexpectedShownKits))
if len(missingKits):
test.fail("Expected kits missing on 'Kit Selection' page:\n%s"
% "\n".join(missingKits))
def handleBuildSystemVerifyKits(category, template, kits, displayedPlatforms,
specialHandlingFunc = None, *args):