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

Unified Diff: run_unittests

Issue 777413002: Add new tests to presubmit, fix errors (Closed) Base URL: https://skia.googlesource.com/buildbot@master
Patch Set: Run "go vet" once in the root dir Created 6 years 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 | « perf/go/vec/vec_test.go ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: run_unittests
diff --git a/run_unittests b/run_unittests
index 0c5d87a27eae886212a058f6e3680380919ec6f3..2412c3fd56efc911964b1667244ae9f23ebbc274 100755
--- a/run_unittests
+++ b/run_unittests
@@ -14,8 +14,9 @@ import unittest
BUILDBOT_PATH = os.path.dirname(os.path.abspath(__file__))
-GO_TESTS = [
+GO_DIRS = [
'.',
+ 'ct',
tfarina 2014/12/05 16:25:12 maybe we should start sorting this alphabetical? C
borenet 2014/12/05 18:14:06 Alphabetized. Now that goimports and "go vet" wor
'perf',
'monitoring',
'golden',
@@ -24,6 +25,7 @@ GO_TESTS = [
GO_TEST_FAILED = (
'''======================================================================
Go test failed: %s
+CWD: %s
----------------------------------------------------------------------
%s
----------------------------------------------------------------------
@@ -53,30 +55,43 @@ def FilterDirectory(dirpath, filenames):
return True
-def TestGo(testname):
- # TODO(borenet): Switch to 'make test' once we're sure the karma-based tests
- # will run in headless mode.
- p = subprocess.Popen(['make', 'testgo'], cwd=testname,
+def RunGoTest(cmd, cwd):
+ p = subprocess.Popen(cmd, cwd=cwd,
stderr=subprocess.STDOUT,
stdout=subprocess.PIPE)
output = p.communicate()[0]
if p.returncode != 0:
- return GO_TEST_FAILED % (testname, output)
- return None
+ return [GO_TEST_FAILED % (' '.join(cmd), cwd, output)]
+ return []
+
+def GoTests(cwd):
+ # TODO(borenet): Switch to 'make test' once we're sure the karma-based tests
+ # will run in headless mode.
+ return RunGoTest(['make', 'testgo'], cwd)
-def GoImports():
+
+def GoVet():
+ return RunGoTest(['go', 'vet', './...'], '.')
+
+
+def GoImports(cwd):
+ cmd = ['goimports', '-l', 'go']
try:
- diff_files = subprocess.check_output(['goimports', '-l', '.'],
+ diff_files = subprocess.check_output(cmd, cwd=cwd,
stderr=subprocess.PIPE).splitlines()
except subprocess.CalledProcessError:
- return ('goimports failed to run! Is it installed? You may need to run: \n'
- 'go get http://code.google.com/p/go.tools/cmd/goimports')
+ return [GO_TEST_FAILED % (
+ ' '.join(cmd), cwd,
+ ('goimports failed to run! Is it installed? You may need to run:\n'
+ 'go get http://code.google.com/p/go.tools/cmd/goimports'))]
if len(diff_files) > 0:
- return ('goimports found diffs in the following files: %s' %
- ', '.join(diff_files))
- return None
+ return [GO_TEST_FAILED % (
+ ' '.join(cmd), cwd,
+ ('goimports found diffs in the following files: %s' %
+ ', '.join(diff_files)))]
+ return []
if __name__ == '__main__':
@@ -91,9 +106,12 @@ if __name__ == '__main__':
continue
tests_to_run.extend(test_modules)
- builtin_tests = [GoImports]
+ go_tests = [GoVet]
+ go_tests_cwd = [GoTests,
+ GoImports]
- num_tests = len(tests_to_run) + len(GO_TESTS) + len(builtin_tests)
+ num_tests = (len(tests_to_run) + len(go_tests) +
+ len(GO_DIRS) * len(go_tests_cwd))
print 'Found %d tests.' % num_tests
errors = []
for test in tests_to_run:
@@ -102,20 +120,15 @@ if __name__ == '__main__':
if proc.wait() != 0:
errors.append(proc.communicate()[0])
- for go_test in GO_TESTS:
- error = TestGo(go_test)
- if error:
- errors.append(error)
-
- for builtin_test in builtin_tests:
- error = builtin_test()
- if error:
- errors.append(error)
+ for go_dir in GO_DIRS:
+ for test in go_tests_cwd:
+ errors.extend(test(go_dir))
+ for go_test in go_tests:
+ errors.extend(go_test())
if errors:
for error in errors:
print error
- print 'Failed %d of %d.' % (len(errors), num_tests)
sys.exit(1)
else:
print 'All tests succeeded.'
« no previous file with comments | « perf/go/vec/vec_test.go ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698