Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 #!/usr/bin/env python | |
|
viettrungluu
2014/11/21 22:18:41
I don't think golden files are a good way to test
qsr
2014/11/24 12:00:48
Do you have a suggestion? You asked me to test thi
| |
| 2 # Copyright 2014 The Chromium Authors. All rights reserved. | |
| 3 # Use of this source code is governed by a BSD-style license that can be | |
| 4 # found in the LICENSE file. | |
| 5 | |
| 6 import argparse | |
| 7 import os.path | |
| 8 import platform | |
| 9 import subprocess | |
| 10 import sys | |
| 11 from mopy.paths import Paths | |
| 12 | |
| 13 | |
| 14 paths = Paths() | |
| 15 | |
| 16 | |
| 17 def main(): | |
| 18 parser = argparse.ArgumentParser() | |
| 19 parser.add_argument("--generate_golden_files", action="store_true", | |
| 20 help="generate golden files") | |
| 21 args = parser.parse_args() | |
| 22 | |
| 23 commands = [ | |
| 24 "sync", | |
| 25 "gn", | |
| 26 "build", | |
| 27 "test", | |
| 28 "perftest", | |
| 29 "pytest", | |
| 30 "darttest", | |
| 31 ] | |
| 32 | |
| 33 build_types = [ | |
| 34 "debug", | |
| 35 "release", | |
| 36 ] | |
| 37 | |
| 38 target_platforms = [ | |
| 39 "", | |
| 40 "android", | |
| 41 "chromeos", | |
| 42 ] | |
| 43 | |
| 44 mojob_file = os.path.join(paths.src_root, "mojo", "tools", "mojob.py") | |
| 45 tests_dir = os.path.join(paths.src_root, "mojo", "tools", "tests") | |
| 46 | |
| 47 for command in commands: | |
| 48 for build_type in build_types: | |
| 49 for target_platform in target_platforms: | |
| 50 golden_file = "mojob-golden-%s-%s-%s" % ( | |
| 51 command, build_type, platform.system()) | |
| 52 commands = [ | |
| 53 "python", | |
| 54 mojob_file, | |
| 55 command, | |
| 56 "--dry-run", | |
| 57 "--%s" % build_type, | |
| 58 ] | |
| 59 if target_platform: | |
| 60 golden_file = "%s-%s" % (golden_file, target_platform) | |
| 61 commands.append("--%s" % target_platform) | |
| 62 process = subprocess.Popen(commands, | |
| 63 env={'GOMA_DIR': '/tmp'}, | |
| 64 stdout=subprocess.PIPE) | |
| 65 text = process.communicate()[0] | |
| 66 process.wait() | |
| 67 if args.generate_golden_files: | |
| 68 with open(os.path.join(tests_dir, golden_file), 'w') as f: | |
| 69 f.write(text) | |
| 70 else: | |
| 71 with open(os.path.join(tests_dir, golden_file), 'r') as f: | |
| 72 expected = f.read() | |
| 73 if text != expected: | |
| 74 print 'Error for file %s. Expected:[%s], but got [%s].' % ( | |
| 75 golden_file, expected, text) | |
| 76 return 0 | |
| 77 | |
| 78 return 0 | |
| 79 | |
| 80 | |
| 81 if __name__ == '__main__': | |
| 82 sys.exit(main()) | |
| OLD | NEW |