forked from qt-creator/qt-creator
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:
@@ -44,7 +44,7 @@ class Targets:
|
|||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def availableTargetClasses():
|
def availableTargetClasses():
|
||||||
availableTargets = list(Targets.ALL_TARGETS)
|
availableTargets = set(Targets.ALL_TARGETS)
|
||||||
if platform.system() in ('Windows', 'Microsoft'):
|
if platform.system() in ('Windows', 'Microsoft'):
|
||||||
availableTargets.remove(Targets.EMBEDDED_LINUX)
|
availableTargets.remove(Targets.EMBEDDED_LINUX)
|
||||||
elif platform.system() == 'Darwin':
|
elif platform.system() == 'Darwin':
|
||||||
@@ -54,8 +54,7 @@ class Targets:
|
|||||||
@staticmethod
|
@staticmethod
|
||||||
def desktopTargetClasses():
|
def desktopTargetClasses():
|
||||||
desktopTargets = Targets.availableTargetClasses()
|
desktopTargets = Targets.availableTargetClasses()
|
||||||
if Targets.EMBEDDED_LINUX in desktopTargets:
|
desktopTargets.discard(Targets.EMBEDDED_LINUX)
|
||||||
desktopTargets.remove(Targets.EMBEDDED_LINUX)
|
|
||||||
return desktopTargets
|
return desktopTargets
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
@@ -64,10 +63,7 @@ class Targets:
|
|||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def getTargetsAsStrings(targets):
|
def getTargetsAsStrings(targets):
|
||||||
if not isinstance(targets, (tuple,list)):
|
return set(map(Targets.getStringForTarget, targets))
|
||||||
test.fatal("Wrong usage... This function handles only tuples or lists.")
|
|
||||||
return None
|
|
||||||
return map(Targets.getStringForTarget, targets)
|
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def getIdForTargetName(targetName):
|
def getIdForTargetName(targetName):
|
||||||
|
@@ -155,8 +155,8 @@ def __createProjectHandleQtQuickSelection__(minimumQtVersion):
|
|||||||
# withoutQt4 if True Qt4 will get unchecked / not selected while checking the targets
|
# withoutQt4 if True Qt4 will get unchecked / not selected while checking the targets
|
||||||
def __selectQtVersionDesktop__(checks, available=None, withoutQt4=False):
|
def __selectQtVersionDesktop__(checks, available=None, withoutQt4=False):
|
||||||
wanted = Targets.desktopTargetClasses()
|
wanted = Targets.desktopTargetClasses()
|
||||||
if withoutQt4 and Targets.DESKTOP_4_8_7_DEFAULT in wanted:
|
if withoutQt4:
|
||||||
wanted.remove(Targets.DESKTOP_4_8_7_DEFAULT)
|
wanted.discard(Targets.DESKTOP_4_8_7_DEFAULT)
|
||||||
checkedTargets = __chooseTargets__(wanted, available)
|
checkedTargets = __chooseTargets__(wanted, available)
|
||||||
if checks:
|
if checks:
|
||||||
for target in checkedTargets:
|
for target in checkedTargets:
|
||||||
@@ -197,8 +197,7 @@ def __modifyAvailableTargets__(available, requiredQt, asStrings=False):
|
|||||||
toBeRemoved = Targets.EMBEDDED_LINUX
|
toBeRemoved = Targets.EMBEDDED_LINUX
|
||||||
if asStrings:
|
if asStrings:
|
||||||
toBeRemoved = Targets.getStringForTarget(toBeRemoved)
|
toBeRemoved = Targets.getStringForTarget(toBeRemoved)
|
||||||
if toBeRemoved in available:
|
available.discard(toBeRemoved)
|
||||||
available.remove(toBeRemoved)
|
|
||||||
for currentItem in tmp:
|
for currentItem in tmp:
|
||||||
if asStrings:
|
if asStrings:
|
||||||
item = currentItem
|
item = currentItem
|
||||||
@@ -207,7 +206,7 @@ def __modifyAvailableTargets__(available, requiredQt, asStrings=False):
|
|||||||
found = versionFinder.search(item)
|
found = versionFinder.search(item)
|
||||||
if found:
|
if found:
|
||||||
if Qt5Path.toVersionTuple(found.group(1)) < Qt5Path.toVersionTuple(requiredQt):
|
if Qt5Path.toVersionTuple(found.group(1)) < Qt5Path.toVersionTuple(requiredQt):
|
||||||
available.remove(currentItem)
|
available.discard(currentItem)
|
||||||
|
|
||||||
# Creates a Qt GUI project
|
# Creates a Qt GUI project
|
||||||
# param path specifies where to create the project
|
# param path specifies where to create the project
|
||||||
@@ -398,14 +397,14 @@ def __chooseTargets__(targets, availableTargets=None, additionalFunc=None):
|
|||||||
else:
|
else:
|
||||||
# following targets depend on the build environment - added for further/later tests
|
# following targets depend on the build environment - added for further/later tests
|
||||||
available = Targets.availableTargetClasses()
|
available = Targets.availableTargetClasses()
|
||||||
checkedTargets = []
|
checkedTargets = set()
|
||||||
for current in available:
|
for current in available:
|
||||||
mustCheck = current in targets
|
mustCheck = current in targets
|
||||||
try:
|
try:
|
||||||
ensureChecked("{type='QCheckBox' text='%s' visible='1'}" % Targets.getStringForTarget(current),
|
ensureChecked("{type='QCheckBox' text='%s' visible='1'}" % Targets.getStringForTarget(current),
|
||||||
mustCheck, 3000)
|
mustCheck, 3000)
|
||||||
if mustCheck:
|
if mustCheck:
|
||||||
checkedTargets.append(current)
|
checkedTargets.add(current)
|
||||||
|
|
||||||
# perform additional function on detailed kits view
|
# perform additional function on detailed kits view
|
||||||
if additionalFunc:
|
if additionalFunc:
|
||||||
@@ -517,26 +516,26 @@ def __getSupportedPlatforms__(text, templateName, getAsStrings=False):
|
|||||||
version = None
|
version = None
|
||||||
if templateName.startswith("Qt Quick Application - "):
|
if templateName.startswith("Qt Quick Application - "):
|
||||||
if templateName == "Qt Quick Application - Empty":
|
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:
|
else:
|
||||||
result = [Targets.DESKTOP_5_10_1_DEFAULT]
|
result = set([Targets.DESKTOP_5_10_1_DEFAULT])
|
||||||
elif 'Supported Platforms' in text:
|
elif 'Supported Platforms' in text:
|
||||||
supports = text[text.find('Supported Platforms'):].split(":")[1].strip().split(" ")
|
supports = text[text.find('Supported Platforms'):].split(":")[1].strip().split(" ")
|
||||||
result = []
|
result = set()
|
||||||
if 'Desktop' in supports:
|
if 'Desktop' in supports:
|
||||||
if (version == None or version < "5.0"):
|
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"):
|
if platform.system() in ("Linux", "Darwin"):
|
||||||
result.append(Targets.EMBEDDED_LINUX)
|
result.add(Targets.EMBEDDED_LINUX)
|
||||||
result.extend([Targets.DESKTOP_5_6_1_DEFAULT, Targets.DESKTOP_5_10_1_DEFAULT])
|
result = result.union(set([Targets.DESKTOP_5_6_1_DEFAULT, Targets.DESKTOP_5_10_1_DEFAULT]))
|
||||||
if platform.system() != 'Darwin':
|
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:
|
elif 'Platform independent' in text:
|
||||||
result = Targets.desktopTargetClasses()
|
result = Targets.desktopTargetClasses()
|
||||||
else:
|
else:
|
||||||
test.warning("Returning None (__getSupportedPlatforms__())",
|
test.warning("Returning None (__getSupportedPlatforms__())",
|
||||||
"Parsed text: '%s'" % text)
|
"Parsed text: '%s'" % text)
|
||||||
return [], None
|
return set(), None
|
||||||
if getAsStrings:
|
if getAsStrings:
|
||||||
result = Targets.getTargetsAsStrings(result)
|
result = Targets.getTargetsAsStrings(result)
|
||||||
return result, version
|
return result, version
|
||||||
|
@@ -41,7 +41,7 @@ def main():
|
|||||||
return
|
return
|
||||||
# open example project, supports only Qt 5
|
# open example project, supports only Qt 5
|
||||||
targets = Targets.desktopTargetClasses()
|
targets = Targets.desktopTargetClasses()
|
||||||
targets.remove(Targets.DESKTOP_4_8_7_DEFAULT)
|
targets.discard(Targets.DESKTOP_4_8_7_DEFAULT)
|
||||||
openQmakeProject(examplePath, targets)
|
openQmakeProject(examplePath, targets)
|
||||||
# build and wait until finished - on all build configurations
|
# build and wait until finished - on all build configurations
|
||||||
availableConfigs = iterateBuildConfigs()
|
availableConfigs = iterateBuildConfigs()
|
||||||
|
@@ -87,23 +87,20 @@ def main():
|
|||||||
|
|
||||||
def verifyKitCheckboxes(kits, displayedPlatforms):
|
def verifyKitCheckboxes(kits, displayedPlatforms):
|
||||||
waitForObject("{type='QLabel' unnamed='1' visible='1' text='Kit Selection'}")
|
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
|
# verification whether expected, found and configured match
|
||||||
for t in kits:
|
|
||||||
if t in displayedPlatforms:
|
expectedShownKits = availableCheckboxes.intersection(displayedPlatforms)
|
||||||
if t in availableCheckboxes:
|
unexpectedShownKits = availableCheckboxes.difference(displayedPlatforms)
|
||||||
test.passes("Found expected kit '%s' on 'Kit Selection' page." % t)
|
missingKits = displayedPlatforms.difference(availableCheckboxes)
|
||||||
availableCheckboxes.remove(t)
|
|
||||||
else:
|
test.log("Expected kits shown on 'Kit Selection' page:\n%s" % "\n".join(expectedShownKits))
|
||||||
test.fail("Expected kit '%s' missing on 'Kit Selection' page." % t)
|
if len(unexpectedShownKits):
|
||||||
else:
|
test.fail("Kits found on 'Kit Selection' page but not expected:\n%s"
|
||||||
if t in availableCheckboxes:
|
% "\n".join(unexpectedShownKits))
|
||||||
test.fail("Kit '%s' found on 'Kit Selection' page - but was not expected!" % t)
|
if len(missingKits):
|
||||||
else:
|
test.fail("Expected kits missing on 'Kit Selection' page:\n%s"
|
||||||
test.passes("Irrelevant kit '%s' not found on 'Kit Selection' page." % t)
|
% "\n".join(missingKits))
|
||||||
if len(availableCheckboxes) != 0:
|
|
||||||
test.fail("Found unexpected additional kit(s) %s on 'Kit Selection' page."
|
|
||||||
% str(availableCheckboxes))
|
|
||||||
|
|
||||||
def handleBuildSystemVerifyKits(category, template, kits, displayedPlatforms,
|
def handleBuildSystemVerifyKits(category, template, kits, displayedPlatforms,
|
||||||
specialHandlingFunc = None, *args):
|
specialHandlingFunc = None, *args):
|
||||||
|
Reference in New Issue
Block a user