Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(7149)

Unified Diff: chrome/test/chromedriver/run_all_tests.py

Issue 14301024: [chromedriver] Clean tmp directory and kill Chrome processes before each run cycle. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | chrome/test/chromedriver/test_expectations » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/test/chromedriver/run_all_tests.py
diff --git a/chrome/test/chromedriver/run_all_tests.py b/chrome/test/chromedriver/run_all_tests.py
index 741b3f2231cbb8c7df5bbdcfe282c864bc081f5f..c5c469751759387bb2064b224bba0f200530ace6 100755
--- a/chrome/test/chromedriver/run_all_tests.py
+++ b/chrome/test/chromedriver/run_all_tests.py
@@ -5,8 +5,10 @@
"""Runs all ChromeDriver end to end tests."""
+import atexit
import optparse
import os
+import shutil
import sys
_THIS_DIR = os.path.abspath(os.path.dirname(__file__))
@@ -91,6 +93,24 @@ def RunCppTests(cpp_tests):
return code
+def KillChromes(chrome_path):
kkania 2013/04/29 18:25:43 i think it would make more sense to put all this i
chrisgao (Use stgao instead) 2013/04/29 22:10:26 Done.
+ if util.IsWindows():
+ util.RunCommand(['taskkill', '/F', '/IM', os.path.basename(chrome_path)])
+ else:
+ util.RunCommand(['pkill', '-9', os.path.basename(chrome_path)])
chrisgao (Use stgao instead) 2013/04/27 00:48:43 Is there a way to kill the chrome processes based
craigdh 2013/04/29 17:31:40 This also doesn't work on Android, for obvious rea
chrisgao (Use stgao instead) 2013/04/29 22:10:26 Right, let us just ignore Android.
+
+
+def CleanTmpDir():
+ tmp_dir = os.path.dirname(util.MakeTempDir())
+ print 'cleaning temp directory:', tmp_dir
+ for file_name in os.listdir(tmp_dir):
+ if not os.path.isdir(os.path.join(tmp_dir, file_name)):
+ continue
+ if file_name.startswith('jetty-0.0.0.0-') or file_name.startswith('tmp'):
+ print 'deleting sub-directory', file_name
+ shutil.rmtree(os.path.join(tmp_dir, file_name), True)
+
+
def main():
parser = optparse.OptionParser()
parser.add_option(
@@ -142,6 +162,8 @@ def main():
# For Windows bots: add ant, java(jre) and the like to system path.
_AddToolsToSystemPathForWindows()
+ CleanTmpDir()
+ atexit.register(CleanTmpDir)
craigdh 2013/04/29 17:31:40 It would be more pythonic to have a try/finally bl
chrisgao (Use stgao instead) 2013/04/29 22:10:26 Done.
if options.android_package:
os.environ['PATH'] += os.pathsep + os.path.join(_THIS_DIR, 'chrome')
code1 = RunPythonTests(chromedriver,
@@ -171,6 +193,7 @@ def main():
chrome_version=chrome['version'])
code2 = RunJavaTests(chromedriver_server, chrome=chrome['path'],
chrome_version=chrome['version'])
+ KillChromes(chrome['path'])
code = code or code1 or code2
return RunCppTests(cpp_tests) or code
« no previous file with comments | « no previous file | chrome/test/chromedriver/test_expectations » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698