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

Unified Diff: Tools/Scripts/webkitpy/test/main_unittest.py

Issue 399193006: Clean up .coverage left around by test-webkitpy (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 5 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 | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Tools/Scripts/webkitpy/test/main_unittest.py
diff --git a/Tools/Scripts/webkitpy/test/main_unittest.py b/Tools/Scripts/webkitpy/test/main_unittest.py
index 79b2b03a986bec914d7fcd7bc3df8aefaf0e46f3..d5f05031b2f14733be461c33d52c7c2d53113783 100644
--- a/Tools/Scripts/webkitpy/test/main_unittest.py
+++ b/Tools/Scripts/webkitpy/test/main_unittest.py
@@ -105,13 +105,30 @@ class TesterTest(unittest.TestCase):
])
def test_coverage_works(self):
+ # This is awkward; by design, running test-webkitpy -c will
+ # create a .coverage file in Tools/Scripts, so we need to be
+ # careful not to clobber an existing one, and to clean up.
+ # FIXME: This design needs to change since it means we can't actually
+ # run this method itself under coverage properly.
filesystem = FileSystem()
executive = Executive()
module_path = filesystem.path_to_module(self.__module__)
script_dir = module_path[0:module_path.find('webkitpy') - 1]
- proc = executive.popen([sys.executable, filesystem.join(script_dir, 'test-webkitpy'), '-c', STUBS_CLASS + '.test_empty'],
- stdout=executive.PIPE, stderr=executive.PIPE)
- out, _ = proc.communicate()
- retcode = proc.returncode
- self.assertEqual(retcode, 0)
- self.assertIn('Cover', out)
+ coverage_file = filesystem.join(script_dir, '.coverage')
+ coverage_file_orig = None
+ if filesystem.exists(coverage_file):
+ coverage_file_orig = coverage_file + '.orig'
+ filesystem.move(coverage_file, coverage_file_orig)
+
+ try:
+ proc = executive.popen([sys.executable, filesystem.join(script_dir, 'test-webkitpy'), '-c', STUBS_CLASS + '.test_empty'],
+ stdout=executive.PIPE, stderr=executive.PIPE)
+ out, _ = proc.communicate()
+ retcode = proc.returncode
+ self.assertEqual(retcode, 0)
+ self.assertIn('Cover', out)
+ finally:
+ if coverage_file_orig:
+ filesystem.move(coverage_file_orig, coverage_file)
+ elif filesystem.exists(coverage_file):
+ filesystem.remove(coverage_file)
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698