summaryrefslogtreecommitdiff
path: root/chromium/mojo/tools
diff options
context:
space:
mode:
authorZeno Albisser <zeno.albisser@theqtcompany.com>2014-12-05 15:04:29 +0100
committerAndras Becsi <andras.becsi@theqtcompany.com>2014-12-09 10:49:28 +0100
commitaf6588f8d723931a298c995fa97259bb7f7deb55 (patch)
tree060ca707847ba1735f01af2372e0d5e494dc0366 /chromium/mojo/tools
parent2fff84d821cc7b1c785f6404e0f8091333283e74 (diff)
downloadqtwebengine-chromium-af6588f8d723931a298c995fa97259bb7f7deb55.tar.gz
BASELINE: Update chromium to 40.0.2214.28 and ninja to 1.5.3.
Change-Id: I759465284fd64d59ad120219cbe257f7402c4181 Reviewed-by: Andras Becsi <andras.becsi@theqtcompany.com>
Diffstat (limited to 'chromium/mojo/tools')
-rwxr-xr-xchromium/mojo/tools/check_mojom_golden_files.py99
-rw-r--r--chromium/mojo/tools/data/unittests26
-rw-r--r--chromium/mojo/tools/generate_java_callback_interfaces.py59
-rw-r--r--chromium/mojo/tools/message_generator.cc63
-rwxr-xr-xchromium/mojo/tools/mojob.sh186
-rwxr-xr-xchromium/mojo/tools/mojosh.sh71
-rw-r--r--chromium/mojo/tools/pylib/transitive_hash.py89
-rwxr-xr-xchromium/mojo/tools/run_mojo_python_tests.py74
-rwxr-xr-xchromium/mojo/tools/test_runner.py116
9 files changed, 0 insertions, 783 deletions
diff --git a/chromium/mojo/tools/check_mojom_golden_files.py b/chromium/mojo/tools/check_mojom_golden_files.py
deleted file mode 100755
index 6c2e187c8ae..00000000000
--- a/chromium/mojo/tools/check_mojom_golden_files.py
+++ /dev/null
@@ -1,99 +0,0 @@
-#!/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 sys
-from filecmp import dircmp
-from shutil import rmtree
-from tempfile import mkdtemp
-
-_script_dir = os.path.dirname(os.path.abspath(__file__))
-_mojo_dir = os.path.join(_script_dir, os.pardir)
-sys.path.insert(0, os.path.join(_mojo_dir, "public", "tools", "bindings",
- "pylib"))
-from mojom_tests.support.find_files import FindFiles
-from mojom_tests.support.run_bindings_generator import RunBindingsGenerator
-
-
-def _ProcessDircmpResults(results, verbose=False):
- """Prints results of directory comparison and returns true if they are
- identical (note: the "left" directory should be the golden directory)."""
- rv = not (bool(results.left_only) or bool(results.right_only) or \
- bool(results.common_funny) or bool(results.funny_files) or \
- bool(results.diff_files))
- if verbose:
- for f in results.left_only:
- print "%s exists in golden directory but not in current output" % f
- for f in results.right_only:
- print "%s exists in current output but not in golden directory" % f
- for f in results.common_funny + results.funny_files:
- print "Unable to compare %s between golden directory and current output" \
- % f
- for f in results.diff_files:
- print "%s differs between golden directory and current output" % f
- for r in results.subdirs.values():
- # If we're being verbose, check subdirectories even if we know that there
- # are differences. Note that it's "... and rv" to avoid the short-circuit.
- if rv or verbose:
- rv = _ProcessDircmpResults(r, verbose=verbose) and rv
- return rv
-
-
-def main():
- parser = argparse.ArgumentParser()
- parser.add_argument("--generate_golden_files", action="store_true",
- help=("generate golden files (does not obliterate "
- "directory"))
- parser.add_argument("--keep_temp_dir", action="store_true",
- help="don't delete the temporary directory")
- parser.add_argument("--verbose", action="store_true",
- help="spew excess verbiage")
- parser.add_argument("golden_dir", metavar="GOLDEN_DIR",
- help="directory with the golden files")
- args = parser.parse_args()
-
- if args.generate_golden_files:
- if os.path.exists(args.golden_dir):
- print "WARNING: golden directory %s already exists" % args.golden_dir
- out_dir = args.golden_dir
- else:
- if not os.path.exists(args.golden_dir):
- print "ERROR: golden directory %s does not exist" % args.golden_dir
- return 1
- out_dir = mkdtemp()
- if args.verbose:
- print "Generating files to %s ..." % out_dir
-
- mojom_files = FindFiles(_mojo_dir, "*.mojom")
- for mojom_file in mojom_files:
- if args.verbose:
- print " Processing %s ..." % os.path.relpath(mojom_file, _mojo_dir)
- RunBindingsGenerator(out_dir, _mojo_dir, mojom_file)
-
- if args.generate_golden_files:
- return 0
-
- identical = _ProcessDircmpResults(dircmp(args.golden_dir, out_dir, ignore=[]),
- verbose=args.verbose)
-
- if args.keep_temp_dir:
- if args.verbose:
- print "Not removing %s ..." % out_dir
- else:
- if args.verbose:
- print "Removing %s ..." % out_dir
- rmtree(out_dir)
-
- if not identical:
- print "FAILURE: current output differs from golden files"
- return 1
-
- print "SUCCESS: current output identical to golden files"
- return 0
-
-
-if __name__ == '__main__':
- sys.exit(main())
diff --git a/chromium/mojo/tools/data/unittests b/chromium/mojo/tools/data/unittests
deleted file mode 100644
index 7939ae24970..00000000000
--- a/chromium/mojo/tools/data/unittests
+++ /dev/null
@@ -1,26 +0,0 @@
-# This file contains a list of Mojo gtest unit tests.
-# Prepend * to indicate that results shouldn't be cached (e.g., if the test has
-# other data dependencies).
-# TODO(vtl): Add a way of specifying data dependencies instead.
-
-# System tests:
-mojo_system_unittests
-
-# Public tests:
-*mojo_public_bindings_unittests
-mojo_public_environment_unittests
-mojo_public_system_unittests
-mojo_public_utility_unittests
-
-# Non-system, non-public tests:
-mojo_common_unittests
-mojo_service_manager_unittests
-mojo_view_manager_lib_unittests
-mojo_view_manager_unittests
-
-# JavaScript tests:
-*mojo_apps_js_unittests
-*mojo_js_unittests
-
-# Shell integration tests:
-*mojo_shell_tests
diff --git a/chromium/mojo/tools/generate_java_callback_interfaces.py b/chromium/mojo/tools/generate_java_callback_interfaces.py
deleted file mode 100644
index fdf1f74d8a9..00000000000
--- a/chromium/mojo/tools/generate_java_callback_interfaces.py
+++ /dev/null
@@ -1,59 +0,0 @@
-"""Generate the org.chromium.mojo.bindings.Callbacks interface"""
-
-import argparse
-import sys
-
-CALLBACK_TEMPLATE = ("""
- /**
- * A generic %d-argument callback.
- *
- * %s
- */
- interface Callback%d<%s> {
- /**
- * Call the callback.
- */
- public void call(%s);
- }
-""")
-
-INTERFACE_TEMPLATE = (
-"""// 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.
-
-// This file was generated using
-// mojo/tools/generate_java_callback_interfaces.py
-
-package org.chromium.mojo.bindings;
-
-/**
- * Contains a generic interface for callbacks.
- */
-public interface Callbacks {
-%s
-}""")
-
-def GenerateCallback(nb_args):
- params = '\n * '.join(
- ['@param <T%d> the type of argument %d.' % (i+1, i+1)
- for i in xrange(nb_args)])
- template_parameters = ', '.join(['T%d' % (i+1) for i in xrange(nb_args)])
- callback_parameters = ', '.join(['T%d arg%d' % ((i+1), (i+1))
- for i in xrange(nb_args)])
- return CALLBACK_TEMPLATE % (nb_args, params, nb_args, template_parameters,
- callback_parameters)
-
-def main():
- parser = argparse.ArgumentParser(
- description="Generate org.chromium.mojo.bindings.Callbacks")
- parser.add_argument("max_args", nargs=1, type=int,
- help="maximal number of arguments to generate callbacks for")
- args = parser.parse_args()
- max_args = args.max_args[0]
- print INTERFACE_TEMPLATE % ''.join([GenerateCallback(i+1)
- for i in xrange(max_args)])
- return 0
-
-if __name__ == "__main__":
- sys.exit(main())
diff --git a/chromium/mojo/tools/message_generator.cc b/chromium/mojo/tools/message_generator.cc
deleted file mode 100644
index 86fcab21af1..00000000000
--- a/chromium/mojo/tools/message_generator.cc
+++ /dev/null
@@ -1,63 +0,0 @@
-// 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.
-
-#include "base/file_util.h"
-#include "base/files/file_path.h"
-#include "base/strings/string_util.h"
-#include "base/strings/stringprintf.h"
-#include "mojo/public/cpp/bindings/lib/message_builder.h"
-#include "mojo/public/cpp/bindings/lib/message_internal.h"
-#include "mojo/public/cpp/bindings/message.h"
-
-// This file is used to generate various files corresponding to mojo
-// messages. The various binding implementations can parse these to verify they
-// correctly decode messages.
-//
-// The output consists of each byte of the message encoded in a hex string with
-// a newline after it.
-namespace mojo {
-namespace {
-
-std::string BinaryToHex(const base::StringPiece& piece) {
- std::string result("// File generated by mojo_message_generator.\n");;
- result.reserve(result.size() + (piece.size() * 5));
- for (size_t i = 0; i < piece.size(); ++i)
- base::StringAppendF(&result, "0X%.2X\n", static_cast<int>(piece.data()[i]));
- return result;
-}
-
-void WriteMessageToFile(const Message& message, const base::FilePath& path) {
- const std::string hex_message(BinaryToHex(
- base::StringPiece(reinterpret_cast<const char*>(message.data()),
- message.data_num_bytes())));
- CHECK_EQ(static_cast<int>(hex_message.size()),
- base::WriteFile(path, hex_message.data(),
- static_cast<int>(hex_message.size())));
-}
-
-// Generates a message of type MessageData. The message uses the name 21,
-// with 4 bytes of payload: 0x9, 0x8, 0x7, 0x6.
-void GenerateMessageDataMessage() {
- internal::MessageBuilder builder(static_cast<uint32_t>(21),
- static_cast<size_t>(4));
- char* data = static_cast<char*>(builder.buffer()->Allocate(4));
- DCHECK(data);
- data[0] = 9;
- data[1] = 8;
- data[2] = 7;
- data[3] = 6;
-
- Message message;
- builder.Finish(&message);
- WriteMessageToFile(message,
- base::FilePath(FILE_PATH_LITERAL("message_data")));
-}
-
-} // namespace
-} // namespace mojo
-
-int main(int argc, char** argv) {
- mojo::GenerateMessageDataMessage();
- return 0;
-}
diff --git a/chromium/mojo/tools/mojob.sh b/chromium/mojo/tools/mojob.sh
deleted file mode 100755
index b870cd13014..00000000000
--- a/chromium/mojo/tools/mojob.sh
+++ /dev/null
@@ -1,186 +0,0 @@
-#!/bin/bash
-# Copyright 2013 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.
-
-# This a simple script to make building/testing Mojo components easier (on
-# Linux).
-
-# TODO(vtl): Maybe make the test runner smart and not run unchanged test
-# binaries.
-# TODO(vtl) Maybe also provide a way to pass command-line arguments to the test
-# binaries.
-
-do_help() {
- cat << EOF
-Usage: $(basename "$0") [command|option ...]
-
-command should be one of:
- build - Build.
- test - Run unit tests (does not build).
- perftest - Run perf tests (does not build).
- pytest - Run Python unit tests.
- gyp - Run gyp for mojo (does not sync), with clang.
- sync - Sync using gclient (does not run gyp).
- show-bash-alias - Outputs an appropriate bash alias for mojob. In bash do:
- \$ eval \`mojo/tools/mojob.sh show-bash-alias\`
-
-option (which will only apply to following commands) should be one of:
- Build/test options (specified before build/test/perftest):
- --debug - Build/test in Debug mode.
- --release - Build/test in Release mode.
- --debug-and-release - Build/test in both Debug and Release modes (default).
- Compiler options (specified before gyp):
- --clang - Use clang (default).
- --gcc - Use gcc.
- Component options:
- --shared Build components as shared libraries (default).
- --static Build components as static libraries.
- Mojo in chromium/content (crbug.com/353602):
- --use-mojo - Enabled (default).
- --no-use-mojo - Disabled.
-
-Note: It will abort on the first failure (if any).
-EOF
-}
-
-do_build() {
- echo "Building in out/$1 ..."
- ninja -C "out/$1" mojo || exit 1
-}
-
-do_unittests() {
- echo "Running unit tests in out/$1 ..."
- mojo/tools/test_runner.py mojo/tools/data/unittests "out/$1" \
- mojob_test_successes || exit 1
-}
-
-do_perftests() {
- echo "Running perf tests in out/$1 ..."
- "out/$1/mojo_public_system_perftests" || exit 1
-}
-
-do_pytests() {
- python mojo/tools/run_mojo_python_tests.py || exit 1
-}
-
-do_gyp() {
- local gyp_defines="$(make_gyp_defines)"
- echo "Running gyp with GYP_DEFINES=$gyp_defines ..."
- GYP_DEFINES="$gyp_defines" build/gyp_chromium mojo/mojo.gyp || exit 1
-}
-
-do_sync() {
- # Note: sync only (with hooks, but no gyp-ing).
- GYP_CHROMIUM_NO_ACTION=1 gclient sync || exit 1
-}
-
-# Valid values: Debug, Release, or Debug_and_Release.
-BUILD_TEST_TYPE=Debug_and_Release
-should_do_Debug() {
- test "$BUILD_TEST_TYPE" = Debug -o "$BUILD_TEST_TYPE" = Debug_and_Release
-}
-should_do_Release() {
- test "$BUILD_TEST_TYPE" = Release -o "$BUILD_TEST_TYPE" = Debug_and_Release
-}
-
-# Valid values: clang or gcc.
-COMPILER=clang
-# Valid values: shared or static.
-COMPONENT=shared
-make_gyp_defines() {
- local options=()
- # Always include these options.
- options+=("use_aura=1")
- case "$COMPILER" in
- clang)
- options+=("clang=1")
- ;;
- gcc)
- options+=("clang=0")
- ;;
- esac
- case "$COMPONENT" in
- shared)
- options+=("component=shared_library")
- ;;
- static)
- options+=("component=static_library")
- ;;
- esac
- echo ${options[*]}
-}
-
-# We're in src/mojo/tools. We want to get to src.
-cd "$(realpath "$(dirname "$0")")/../.."
-
-if [ $# -eq 0 ]; then
- do_help
- exit 0
-fi
-
-for arg in "$@"; do
- case "$arg" in
- # Commands -----------------------------------------------------------------
- help|--help)
- do_help
- exit 0
- ;;
- build)
- should_do_Debug && do_build Debug
- should_do_Release && do_build Release
- ;;
- test)
- should_do_Debug && do_unittests Debug
- should_do_Release && do_unittests Release
- ;;
- perftest)
- should_do_Debug && do_perftests Debug
- should_do_Release && do_perftests Release
- ;;
- pytest)
- do_pytests
- ;;
- gyp)
- do_gyp
- ;;
- sync)
- do_sync
- ;;
- show-bash-alias)
- # You want to type something like:
- # alias mojob=\
- # '"$(pwd | sed '"'"'s/\(.*\/src\).*/\1/'"'"')/mojo/tools/mojob.sh"'
- # This is quoting hell, so we simply escape every non-alphanumeric
- # character.
- echo alias\ mojob\=\'\"\$\(pwd\ \|\ sed\ \'\"\'\"\'s\/\\\(\.\*\\\/src\\\)\
-\.\*\/\\1\/\'\"\'\"\'\)\/mojo\/tools\/mojob\.sh\"\'
- ;;
- # Options ------------------------------------------------------------------
- --debug)
- BUILD_TEST_TYPE=Debug
- ;;
- --release)
- BUILD_TEST_TYPE=Release
- ;;
- --debug-and-release)
- BUILD_TEST_TYPE=Debug_and_Release
- ;;
- --clang)
- COMPILER=clang
- ;;
- --gcc)
- COMPILER=gcc
- ;;
- --shared)
- COMPONENT=shared
- ;;
- --static)
- COMPONENT=static
- ;;
- *)
- echo "Unknown command \"${arg}\". Try \"$(basename "$0") help\"."
- exit 1
- ;;
- esac
-done
diff --git a/chromium/mojo/tools/mojosh.sh b/chromium/mojo/tools/mojosh.sh
deleted file mode 100755
index bb8a2cdca4a..00000000000
--- a/chromium/mojo/tools/mojosh.sh
+++ /dev/null
@@ -1,71 +0,0 @@
-#!/bin/bash
-# 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.
-
-# This a simple script to make running Mojo shell easier (on Linux).
-
-DIRECTORY="$(dirname "$0")"/../../out/Debug
-PORT=$(($RANDOM % 8192 + 2000))
-
-do_help() {
- cat << EOF
-Usage: $(basename "$0") [-d DIRECTORY] [-|--] <mojo_shell arguments ...>
-
-DIRECTORY defaults to $DIRECTORY.
-
-Example:
- $(basename "$0") mojo:mojo_sample_app
-EOF
-}
-
-kill_http_server() {
- echo "Killing SimpleHTTPServer ..."
- kill $HTTP_SERVER_PID
- wait $HTTP_SERVER_PID
-}
-
-while [ $# -gt 0 ]; do
- case "$1" in
- -h|--help)
- do_help
- exit 0
- ;;
- -d)
- shift
- if [ $# -eq 0 ]; then
- do_help
- exit 1
- fi
- DIRECTORY="$1"
- ;;
- --show-bash-alias)
- echo alias\ mojosh\=\'\"\$\(pwd\ \|\ sed\ \'\"\'\"\'s\/\\\(\.\*\\\/src\\\
-\)\.\*\/\\1\/\'\"\'\"\'\)\/mojo\/tools\/mojosh\.sh\"\'
- exit 0
- ;;
- # Separate arguments to mojo_shell (e.g., in case you want to pass it -d).
- -|--)
- shift
- break
- ;;
- *)
- break
- ;;
- esac
- shift
-done
-
-echo "Base directory: $DIRECTORY"
-
-echo "Running SimpleHTTPServer in directory $DIRECTORY/lib on port $PORT"
-cd $DIRECTORY/lib || exit 1
-python -m SimpleHTTPServer $PORT &
-# Kill the HTTP server on exit (even if the user kills everything using ^C).
-HTTP_SERVER_PID=$!
-trap kill_http_server EXIT
-cd ..
-
-echo "Running:"
-echo "./mojo_shell --origin=http://127.0.0.1:$PORT --disable-cache $*"
-./mojo_shell --origin=http://127.0.0.1:$PORT --disable-cache $*
diff --git a/chromium/mojo/tools/pylib/transitive_hash.py b/chromium/mojo/tools/pylib/transitive_hash.py
deleted file mode 100644
index 93e8dc4e75e..00000000000
--- a/chromium/mojo/tools/pylib/transitive_hash.py
+++ /dev/null
@@ -1,89 +0,0 @@
-# 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 logging
-import subprocess
-import sys
-
-from hashlib import sha256
-from os.path import basename, realpath
-
-_logging = logging.getLogger()
-
-# Based on/taken from
-# http://code.activestate.com/recipes/578231-probably-the-fastest-memoization-decorator-in-the-/
-# (with cosmetic changes).
-def _memoize(f):
- """Memoization decorator for a function taking a single argument."""
- class Memoize(dict):
- def __missing__(self, key):
- rv = self[key] = f(key)
- return rv
- return Memoize().__getitem__
-
-@_memoize
-def _file_hash(filename):
- """Returns a string representing the hash of the given file."""
- _logging.debug("Hashing %s ...", filename)
- rv = subprocess.check_output(['sha256sum', '-b', filename]).split(None, 1)[0]
- _logging.debug(" => %s", rv)
- return rv
-
-@_memoize
-def _get_dependencies(filename):
- """Returns a list of filenames for files that the given file depends on."""
- _logging.debug("Getting dependencies for %s ...", filename)
- lines = subprocess.check_output(['ldd', filename]).splitlines()
- rv = []
- for line in lines:
- i = line.find('/')
- if i < 0:
- _logging.debug(" => no file found in line: %s", line)
- continue
- rv.append(line[i:].split(None, 1)[0])
- _logging.debug(" => %s", rv)
- return rv
-
-def transitive_hash(filename):
- """Returns a string that represents the "transitive" hash of the given
- file. The transitive hash is a hash of the file and all the shared libraries
- on which it depends (done in an order-independent way)."""
- hashes = set()
- to_hash = [filename]
- while to_hash:
- current_filename = realpath(to_hash.pop())
- current_hash = _file_hash(current_filename)
- if current_hash in hashes:
- _logging.debug("Already seen %s (%s) ...", current_filename, current_hash)
- continue
- _logging.debug("Haven't seen %s (%s) ...", current_filename, current_hash)
- hashes.add(current_hash)
- to_hash.extend(_get_dependencies(current_filename))
- return sha256('|'.join(sorted(hashes))).hexdigest()
-
-def main(argv):
- logging.basicConfig()
- # Uncomment to debug:
- # _logging.setLevel(logging.DEBUG)
-
- if len(argv) < 2:
- print """\
-Usage: %s [file] ...
-
-Prints the \"transitive\" hash of each (executable) file. The transitive
-hash is a hash of the file and all the shared libraries on which it
-depends (done in an order-independent way).""" % basename(argv[0])
- return 0
-
- rv = 0
- for filename in argv[1:]:
- try:
- print transitive_hash(filename), filename
- except:
- print "ERROR", filename
- rv = 1
- return rv
-
-if __name__ == '__main__':
- sys.exit(main(sys.argv))
diff --git a/chromium/mojo/tools/run_mojo_python_tests.py b/chromium/mojo/tools/run_mojo_python_tests.py
deleted file mode 100755
index c96aba36d2c..00000000000
--- a/chromium/mojo/tools/run_mojo_python_tests.py
+++ /dev/null
@@ -1,74 +0,0 @@
-#!/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 optparse
-import os
-import re
-import sys
-import unittest
-
-
-def main():
- parser = optparse.OptionParser()
- parser.usage = 'run_mojo_python_tests.py [options] [tests...]'
- parser.add_option('-v', '--verbose', action='count', default=0)
- parser.add_option('--unexpected-failures', metavar='FILENAME', action='store',
- help=('path to write a list of any tests that fail '
- 'unexpectedly.'))
- parser.epilog = ('If --unexpected-failures is passed, a list of the tests '
- 'that failed (one per line) will be written to the file. '
- 'If no tests failed, the file will be truncated (empty). '
- 'If the test run did not completely properly, or something '
- 'else weird happened, any existing file will be left '
- 'unmodified. '
- 'If --unexpected-failures is *not* passed, any existing '
- 'file will be ignored and left unmodified.')
- options, args = parser.parse_args()
-
- chromium_src_dir = os.path.join(os.path.dirname(__file__),
- os.pardir,
- os.pardir)
-
- loader = unittest.loader.TestLoader()
- print "Running Python unit tests under mojo/public/tools/bindings/pylib ..."
-
- pylib_dir = os.path.join(chromium_src_dir, 'mojo', 'public',
- 'tools', 'bindings', 'pylib')
- if args:
- if not pylib_dir in sys.path:
- sys.path.append(pylib_dir)
- suite = unittest.TestSuite()
- for test_name in args:
- suite.addTests(loader.loadTestsFromName(test_name))
- else:
- suite = loader.discover(pylib_dir, pattern='*_unittest.py')
-
- runner = unittest.runner.TextTestRunner(verbosity=(options.verbose + 1))
- result = runner.run(suite)
-
- if options.unexpected_failures:
- WriteUnexpectedFailures(result, options.unexpected_failures)
-
- return 0 if result.wasSuccessful() else 1
-
-
-def WriteUnexpectedFailures(result, path):
-
- # This regex and UnitTestName() extracts the test_name in a way
- # that can be handed back to the loader successfully.
-
- test_description = re.compile("(\w+) \(([\w.]+)\)")
-
- def UnitTestName(test):
- m = test_description.match(str(test))
- return "%s.%s" % (m.group(2), m.group(1))
-
- with open(path, 'w') as fp:
- for (test, _) in result.failures + result.errors:
- fp.write(UnitTestName(test) + '\n')
-
-
-if __name__ == '__main__':
- sys.exit(main())
diff --git a/chromium/mojo/tools/test_runner.py b/chromium/mojo/tools/test_runner.py
deleted file mode 100755
index b0bb4d9f94b..00000000000
--- a/chromium/mojo/tools/test_runner.py
+++ /dev/null
@@ -1,116 +0,0 @@
-#!/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.
-
-"""A "smart" test runner for gtest unit tests (that caches successes)."""
-
-import logging
-import os
-import subprocess
-import sys
-
-_logging = logging.getLogger()
-
-_script_dir = os.path.dirname(os.path.abspath(__file__))
-sys.path.insert(0, os.path.join(_script_dir, "pylib"))
-
-from transitive_hash import transitive_hash
-
-def main(argv):
- logging.basicConfig()
- # Uncomment to debug:
- # _logging.setLevel(logging.DEBUG)
-
- if len(argv) < 3 or len(argv) > 4:
- print "Usage: %s gtest_list_file root_dir [successes_cache_file]" % \
- os.path.basename(argv[0])
- return 0 if len(argv) < 2 else 1
-
- _logging.debug("Test list file: %s", argv[1])
- with open(argv[1], 'rb') as f:
- gtest_list = [y for y in [x.strip() for x in f.readlines()] \
- if y and y[0] != '#']
- _logging.debug("Test list: %s" % gtest_list)
-
- print "Running tests in directory: %s" % argv[2]
- os.chdir(argv[2])
-
- if len(argv) == 4 and argv[3]:
- successes_cache_filename = argv[3]
- print "Successes cache file: %s" % successes_cache_filename
- else:
- successes_cache_filename = None
- print "No successes cache file (will run all tests unconditionally)"
-
- if successes_cache_filename:
- # This file simply contains a list of transitive hashes of tests that
- # succeeded.
- try:
- _logging.debug("Trying to read successes cache file: %s",
- successes_cache_filename)
- with open(argv[3], 'rb') as f:
- successes = set([x.strip() for x in f.readlines()])
- _logging.debug("Successes: %s", successes)
- except:
- # Just assume that it didn't exist, or whatever.
- print "Failed to read successes cache file %s (will create)" % argv[3]
- successes = set()
-
- # Run gtests with color if we're on a TTY (and we're not being told explicitly
- # what to do).
- if sys.stdout.isatty() and 'GTEST_COLOR' not in os.environ:
- _logging.debug("Setting GTEST_COLOR=yes")
- os.environ['GTEST_COLOR'] = 'yes'
-
- # TODO(vtl): We may not close this file on failure.
- successes_cache_file = open(successes_cache_filename, 'ab') \
- if successes_cache_filename else None
- for gtest in gtest_list:
- if gtest[0] == '*':
- gtest = gtest[1:]
- _logging.debug("%s is marked as non-cacheable" % gtest)
- cacheable = False
- else:
- cacheable = True
-
- if successes_cache_file and cacheable:
- _logging.debug("Getting transitive hash for %s ... " % gtest)
- try:
- gtest_hash = transitive_hash(gtest)
- except:
- print "Failed to get transitive hash for %s" % gtest
- return 1
- _logging.debug(" Transitive hash: %s" % gtest_hash)
-
- if gtest_hash in successes:
- print "Skipping %s (previously succeeded)" % gtest
- continue
-
- print "Running %s...." % gtest,
- sys.stdout.flush()
- try:
- subprocess.check_output(["./" + gtest], stderr=subprocess.STDOUT)
- print "Succeeded"
- # Record success.
- if successes_cache_filename and cacheable:
- successes.add(gtest_hash)
- successes_cache_file.write(gtest_hash + '\n')
- successes_cache_file.flush()
- except subprocess.CalledProcessError as e:
- print "Failed with exit code %d and output:" % e.returncode
- print 72 * '-'
- print e.output
- print 72 * '-'
- return 1
- except OSError as e:
- print " Failed to start test"
- return 1
- print "All tests succeeded"
- if successes_cache_file:
- successes_cache_file.close()
-
- return 0
-
-if __name__ == '__main__':
- sys.exit(main(sys.argv))