| Index: mojo/tools/check_mojob.py
|
| diff --git a/mojo/tools/check_mojob.py b/mojo/tools/check_mojob.py
|
| new file mode 100755
|
| index 0000000000000000000000000000000000000000..52c13e950abe87ead4f50345fae41407da43cfcc
|
| --- /dev/null
|
| +++ b/mojo/tools/check_mojob.py
|
| @@ -0,0 +1,82 @@
|
| +#!/usr/bin/env python
|
| +# Copyright 2014 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.
|
| +
|
| +import argparse
|
| +import os.path
|
| +import platform
|
| +import subprocess
|
| +import sys
|
| +from mopy.paths import Paths
|
| +
|
| +
|
| +paths = Paths()
|
| +
|
| +
|
| +def main():
|
| + parser = argparse.ArgumentParser()
|
| + parser.add_argument("--generate_golden_files", action="store_true",
|
| + help="generate golden files")
|
| + args = parser.parse_args()
|
| +
|
| + commands = [
|
| + "sync",
|
| + "gn",
|
| + "build",
|
| + "test",
|
| + "perftest",
|
| + "pytest",
|
| + "darttest",
|
| + ]
|
| +
|
| + build_types = [
|
| + "debug",
|
| + "release",
|
| + ]
|
| +
|
| + target_platforms = [
|
| + "",
|
| + "android",
|
| + "chromeos",
|
| + ]
|
| +
|
| + mojob_file = os.path.join(paths.src_root, "mojo", "tools", "mojob.py")
|
| + tests_dir = os.path.join(paths.src_root, "mojo", "tools", "tests")
|
| +
|
| + for command in commands:
|
| + for build_type in build_types:
|
| + for target_platform in target_platforms:
|
| + golden_file = "mojob-golden-%s-%s-%s" % (
|
| + command, build_type, platform.system())
|
| + commands = [
|
| + "python",
|
| + mojob_file,
|
| + command,
|
| + "--dry-run",
|
| + "--%s" % build_type,
|
| + ]
|
| + if target_platform:
|
| + golden_file = "%s-%s" % (golden_file, target_platform)
|
| + commands.append("--%s" % target_platform)
|
| + process = subprocess.Popen(commands,
|
| + env={'GOMA_DIR': '/tmp'},
|
| + stdout=subprocess.PIPE)
|
| + text = process.communicate()[0]
|
| + process.wait()
|
| + if args.generate_golden_files:
|
| + with open(os.path.join(tests_dir, golden_file), 'w') as f:
|
| + f.write(text)
|
| + else:
|
| + with open(os.path.join(tests_dir, golden_file), 'r') as f:
|
| + expected = f.read()
|
| + if text != expected:
|
| + print 'Error for file %s. Expected:[%s], but got [%s].' % (
|
| + golden_file, expected, text)
|
| + return 0
|
| +
|
| + return 0
|
| +
|
| +
|
| +if __name__ == '__main__':
|
| + sys.exit(main())
|
|
|