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

Unified Diff: py/run_unittests

Issue 341193004: Add lots of utils, PRESUBMIT.py (Closed) Base URL: https://skia.googlesource.com/common.git@master
Patch Set: Address comments Created 6 years, 6 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 | « py/__init__.py ('k') | py/utils/__init__.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: py/run_unittests
diff --git a/py/run_unittests b/py/run_unittests
new file mode 100755
index 0000000000000000000000000000000000000000..30c203ec6c5dbdd232deee60ba26b535f7b90930
--- /dev/null
+++ b/py/run_unittests
@@ -0,0 +1,62 @@
+#!/usr/bin/env python
+# Copyright (c) 2012 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+"""Runs all unit tests under this base directory."""
+
+import os
+import subprocess
+import sys
+import unittest
+
+
+NO_CRAWL_DIRS = [
+ '.git',
+ '.svn',
+]
+
+
+SEARCH_PATH = os.path.dirname(os.path.abspath(__file__))
+
+
+def FilterDirectory(dirpath, filenames):
+ """ Determine whether to look for tests in the given directory.
+
+ dirpath: string; path of the directory in question.
+ filenames: list of strings; the files in the directory.
+ """
+ if not dirpath or not filenames:
+ return False
+ for no_crawl_dir in NO_CRAWL_DIRS:
+ if no_crawl_dir in dirpath:
+ return False
+ return True
+
+
+if __name__ == '__main__':
+ print 'Searching for tests.'
+ tests_to_run = []
+
+ for (dirpath, dirnames, filenames) in os.walk(SEARCH_PATH, topdown=True):
+ dirnames[:] = [d for d in dirnames if not d in NO_CRAWL_DIRS]
+ test_modules = [os.path.join(dirpath, filename) for filename in filenames
+ if filename.endswith('_test.py')]
+ if not test_modules:
+ continue
+ tests_to_run.extend(test_modules)
+
+ print 'Found %d tests.' % len(tests_to_run)
+ errors = []
+ for test in tests_to_run:
+ proc = subprocess.Popen(['python', test], stdout=subprocess.PIPE,
+ stderr=subprocess.STDOUT)
+ if proc.wait() != 0:
+ errors.append(proc.communicate()[0])
+ if errors:
+ for error in errors:
+ print error
+ print 'Failed %d of %d.' % (len(errors), len(test_modules))
+ sys.exit(1)
+ else:
+ print 'All tests succeeded.'
« no previous file with comments | « py/__init__.py ('k') | py/utils/__init__.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698