9 from datetime import datetime,timedelta;
14 testSettings.logScreenshotOnFail = True
16 source("../../shared/utils.py")
17 source("../../shared/build_utils.py")
18 source("../../shared/project.py")
19 source("../../shared/qtquick.py")
20 source("../../shared/editor_utils.py")
22 def waitForCleanShutdown(timeOut=10):
23 appCtxt = currentApplicationContext()
25 if platform.system() in ('Windows','Microsoft'):
26 endtime = datetime.utcnow() + timedelta(seconds=timeOut)
27 while not shutdownDone:
28 # following work-around because os.kill() works for win not until python 2.7
29 tasks = subprocess.Popen("tasklist /FI \"PID eq %d\"" % appCtxt.pid, shell=True,stdout=subprocess.PIPE)
30 output = tasks.communicate()[0]
32 if (output=="INFO: No tasks are running which match the specified criteria."
33 or output=="" or output.find("ERROR")==0):
35 if not shutdownDone and datetime.utcnow() > endtime:
38 endtime = datetime.utcnow() + timedelta(seconds=timeOut)
39 while not shutdownDone:
41 os.kill(appCtxt.pid,0)
43 if err.errno == errno.EPERM or err.errno == errno.ESRCH:
45 if not shutdownDone and datetime.utcnow() > endtime:
48 def __removeTmpSettingsDir__():
49 waitForCleanShutdown()
50 deleteDirIfExists(os.path.dirname(tmpSettingsDir))
52 if platform.system() in ('Windows', 'Microsoft'):
54 cwd = os.getcwd() # current dir is directory holding qtcreator.py
55 cwd+="\\..\\..\\settings\\windows"
56 defaultQtVersion = "Qt 4.7.4 for Desktop - MinGW 4.4 (Qt SDK)"
58 sdkPath = os.path.expanduser("~/QtSDK")
59 cwd = os.getcwd() # current dir is directory holding qtcreator.py
60 cwd+="/../../settings/unix"
61 defaultQtVersion = "Desktop Qt 4.7.4 for GCC (Qt SDK)"
62 srcPath = sdkPath + "/src"
64 cwd = os.path.abspath(cwd)
65 tmpSettingsDir = tempDir()
66 tmpSettingsDir = os.path.abspath(tmpSettingsDir+"/settings")
67 shutil.copytree(cwd, tmpSettingsDir)
68 # the following only doesn't work if the test ends in an exception
69 atexit.register(__removeTmpSettingsDir__)
70 SettingsPath = " -settingspath %s" % tmpSettingsDir