OSDN Git Service

Squish: Remove also versioned .user files
authorChristian Stenger <christian.stenger@nokia.com>
Tue, 27 Sep 2011 09:39:01 +0000 (11:39 +0200)
committerChristian Stenger <christian.stenger@nokia.com>
Tue, 27 Sep 2011 12:03:06 +0000 (14:03 +0200)
Change-Id: Icf4325930f5e1bd908fef9cbd87658b4cc8fc110
Reviewed-on: http://codereview.qt-project.org/5601
Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com>
Reviewed-by: Robert Löhning <robert.loehning@nokia.com>
Reviewed-by: Bill King <bill.king@nokia.com>
tests/system/shared/utils.py
tests/system/suite_general/tst_basic_cpp_support/test.py
tests/system/suite_general/tst_build_speedcrunch/test.py
tests/system/suite_general/tst_cmake_speedcrunch/test.py
tests/system/suite_general/tst_openqt_creator/test.py

index e4d59dd..0631361 100644 (file)
@@ -1,4 +1,4 @@
-import tempfile, shutil, os
+import tempfile
 
 def neededFilePresent(path):
     found = os.path.exists(path)
@@ -94,3 +94,28 @@ def prepareForSignal(object, signal):
     installLazySignalHandler(object, signal, "__callbackFunction__")
     return realName
 
+# this function removes the user files of given pro file(s)
+# can be called with a single string object or a list of strings holding path(s) to
+# the pro file(s) returns False if it could not remove all user files or has been
+# called with an unsupported object
+def cleanUpUserFiles(pathsToProFiles=None):
+    if pathsToProFiles==None:
+        return False
+    if className(pathsToProFiles) in ("str", "unicode"):
+        filelist = glob.glob(pathsToProFiles+".user*")
+    elif className(pathsToProFiles)=="list":
+        filelist = []
+        for p in pathsToProFiles:
+            filelist.extend(glob.glob(p+".user*"))
+    else:
+        test.fatal("Got an unsupported object.")
+        return False
+    doneWithoutErrors = True
+    for file in filelist:
+        try:
+            file = os.path.abspath(file)
+            os.remove(file)
+        except:
+            doneWithoutErrors = False
+    return doneWithoutErrors
+
index 87116d6..028a2f8 100644 (file)
@@ -74,16 +74,14 @@ def main():
     test.compare(lineUnderCursor(findObject(":Qt Creator_CppEditor::Internal::CPPEditorWidget")), "Dummy::Dummy(int)")
 
     invokeMenuItem("File", "Exit")
-
+    waitForCleanShutdown()
 
 def init():
     cleanup()
 
 def cleanup():
     # Make sure the .user files are gone
-
-    if os.access(srcPath + "/creator/tests/manual/cplusplus-tools/cplusplus-tools.pro.user", os.F_OK):
-        os.remove(srcPath + "/creator/tests/manual/cplusplus-tools/cplusplus-tools.pro.user")
+    cleanUpUserFiles(srcPath + "/creator/tests/manual/cplusplus-tools/cplusplus-tools.pro")
 
     BuildPath = glob.glob(srcPath + "/qtcreator-build-*")
     BuildPath += glob.glob(srcPath + "/projects-build-*")
index e57c6a1..defebf0 100644 (file)
@@ -40,6 +40,7 @@ def main():
     # Add a new run configuration
 
     invokeMenuItem("File", "Exit")
+    waitForCleanShutdown()
 
 def init():
     global SpeedCrunchPath
@@ -48,8 +49,7 @@ def init():
 
 def cleanup():
     # Make sure the .user files are gone
-    if os.access(SpeedCrunchPath + ".user", os.F_OK):
-        os.remove(SpeedCrunchPath + ".user")
+    cleanUpUserFiles(SpeedCrunchPath)
 
     BuildPath = glob.glob(srcPath + "/creator-test-data/speedcrunch/speedcrunch-build-*")
     BuildPath += glob.glob(srcPath + "/creator-test-data/speedcrunch/qtcreator-build-*")
index bd94315..1ef29af 100644 (file)
@@ -30,6 +30,7 @@ def main():
     checkLastBuild()
 
     invokeMenuItem("File", "Exit")
+    waitForCleanShutdown()
 
 def init():
     global SpeedCrunchPath
@@ -38,8 +39,7 @@ def init():
 
 def cleanup():
     # Make sure the .user files are gone
-    if os.access(SpeedCrunchPath + ".user", os.F_OK):
-        os.remove(SpeedCrunchPath + ".user")
+    cleanUpUserFiles(SpeedCrunchPath)
 
     BuildPath = srcPath + "/creator-test-data/speedcrunch/src/qtcreator-build"
 
index d49d4ee..804ffc9 100644 (file)
@@ -35,15 +35,13 @@ def main():
     test.compare(wordUnderCursor(waitForObject(":Qt Creator_CppEditor::Internal::CPPEditorWidget")), "QList")
 
     invokeMenuItem("File", "Exit")
-
+    waitForCleanShutdown()
 
 def init():
     cleanup()
 
 def cleanup():
     # Make sure the .user files are gone
+    cleanUpUserFiles([srcPath + "/creator-test-data/speedcrunch/src/speedcrunch.pro",
+                      srcPath + "/creator/qtcreator.pro"])
 
-    if os.access(srcPath + "/creator-test-data/speedcrunch/src/speedcrunch.pro.user", os.F_OK):
-        os.remove(srcPath + "/creator-test-data/speedcrunch/src/speedcrunch.pro.user")
-    if os.access(srcPath + "/creator/qtcreator.pro.user", os.F_OK):
-        os.remove(srcPath + "/creator/qtcreator.pro.user")