SquishTests: Fix tst_rename_file for case ignoring file systems

On Linux, Creator only considers files with the exact extension ".qml"
QML files and places them under a "QML" node in the project tree. On
Mac and Windows, Creator also places files with extension ".QML" there.

Change-Id: Id81989e867fa946081ea7a350b208ddfe09e5460
Reviewed-by: Jukka Nokso <jukka.nokso@qt.io>
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
Robert Löhning
2024-07-19 22:22:28 +02:00
parent 0de1a6cdf7
commit ec735c3a2a

View File

@@ -38,7 +38,7 @@ def main():
previous = filenames[-1] previous = filenames[-1]
for filename in filenames: for filename in filenames:
tempFiletype = filetype tempFiletype = filetype
if filetype == "QML" and not previous.endswith(".qml"): if filetype == "QML" and not fileExtMatchesQml(previous):
tempFiletype = "Other files" tempFiletype = "Other files"
renameFile(templateDir, usedProFile, projectName + "." + tempFiletype, renameFile(templateDir, usedProFile, projectName + "." + tempFiletype,
previous, filename) previous, filename)
@@ -61,6 +61,15 @@ def verifyRenamedIncludes(templateDir, file, oldname, newname):
'Verify that new filename is included in %s' % file)): 'Verify that new filename is included in %s' % file)):
test.log(grep("include", fileText)) test.log(grep("include", fileText))
def fileExtMatchesQml(fileName):
if platform.system() == "Linux":
return fileName.endswith(".qml")
else:
# On case ignoring file systems, ".QML" is the same as ".qml"
return fileName.lower().endswith(".qml")
def renameFile(projectDir, proFile, branch, oldname, newname): def renameFile(projectDir, proFile, branch, oldname, newname):
oldFilePath = os.path.join(projectDir, oldname) oldFilePath = os.path.join(projectDir, oldname)
newFilePath = os.path.join(projectDir, newname) newFilePath = os.path.join(projectDir, newname)
@@ -115,7 +124,7 @@ def renameFile(projectDir, proFile, branch, oldname, newname):
test.verify(oldname not in os.listdir(projectDir), test.verify(oldname not in os.listdir(projectDir),
"Verify that file with old name does not exist: %s" % oldFilePath) "Verify that file with old name does not exist: %s" % oldFilePath)
if newItemText.endswith("\\.qml"): if fileExtMatchesQml(newItemText):
newItemText = newItemText.replace(".Other files.", ".QML.") newItemText = newItemText.replace(".Other files.", ".QML.")
else: else:
newItemText = newItemText.replace(".QML.", ".Other files.") newItemText = newItemText.replace(".QML.", ".Other files.")