Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 #!/usr/bin/env python | |
| 2 # | |
| 3 # Copyright 2016 Google Inc. | |
| 4 # | |
| 5 # Use of this source code is governed by a BSD-style license that can be | |
| 6 # found in the LICENSE file. | |
| 7 | |
| 8 | |
| 9 """Run all infrastructure-related tests.""" | |
| 10 | |
| 11 | |
| 12 import os | |
| 13 import subprocess | |
| 14 import sys | |
| 15 | |
| 16 | |
| 17 INFRA_BOTS_DIR = os.path.abspath(os.path.realpath(os.path.join( | |
| 18 os.path.dirname(os.path.abspath(__file__))))) | |
|
rmistry
2016/10/14 11:36:28
1. You already have os.path.abspath(__file__) I am
borenet
2016/10/14 13:03:46
Done.
| |
| 19 SKIA_DIR = os.path.abspath(os.path.join(INFRA_BOTS_DIR, os.pardir, os.pardir)) | |
| 20 | |
| 21 | |
| 22 def test(cmd, cwd): | |
| 23 try: | |
| 24 subprocess.check_output(cmd, cwd=cwd, stderr=subprocess.STDOUT) | |
| 25 except subprocess.CalledProcessError as e: | |
| 26 return e.output | |
| 27 | |
| 28 | |
| 29 def python_tests(): | |
|
rmistry
2016/10/14 11:36:28
maybe unit_tests or python_unit_tests is a better
borenet
2016/10/14 13:03:46
Done.
| |
| 30 return test( | |
| 31 ['python', '-m', 'unittest', 'discover', '-s', '.', '-p', '*_test.py'], | |
| 32 INFRA_BOTS_DIR) | |
| 33 | |
| 34 | |
| 35 def recipe_simulation_test(): | |
| 36 return test( | |
| 37 ['python', os.path.join(INFRA_BOTS_DIR, 'recipes.py'), 'simulation_test'], | |
| 38 SKIA_DIR) | |
| 39 | |
| 40 | |
| 41 def gen_tasks_test(): | |
| 42 cmd = ['go', 'run', 'gen_tasks.go', '--test'] | |
| 43 try: | |
| 44 output = test(cmd, INFRA_BOTS_DIR) | |
| 45 except OSError: | |
| 46 return ('Failed to run "%s"; do you have Go installed on your machine?' | |
| 47 % ' '.join(cmd)) | |
| 48 if output and 'cannot find package "go.skia.org/infra' in output: | |
| 49 return ('Failed to run gen_tests.go:\n\n%s\nMaybe you need to run:\n\n' | |
| 50 '$ go get -u go.skia.org/infra/...' % output) | |
| 51 return output | |
| 52 | |
| 53 | |
| 54 def main(): | |
| 55 tests = ( | |
| 56 python_tests, | |
| 57 recipe_simulation_test, | |
| 58 gen_tasks_test, | |
| 59 ) | |
| 60 errs = [] | |
| 61 for t in tests: | |
| 62 err = t() | |
| 63 if err: | |
| 64 errs.append(err) | |
| 65 | |
| 66 if len(errs) > 0: | |
| 67 print >> sys.stderr, 'Test failures:\n' | |
| 68 for err in errs: | |
| 69 print >> sys.stderr, '==============================' | |
| 70 print >> sys.stderr, err | |
| 71 print >> sys.stderr, '==============================' | |
| 72 sys.exit(1) | |
| 73 | |
| 74 print 'All tests passed!' | |
| 75 | |
| 76 | |
| 77 if __name__ == '__main__': | |
| 78 main() | |
| OLD | NEW |