1#!/usr/bin/env python 2# Copyright (c) 2015 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 6import argparse 7import os 8import sys 9 10from hooks import install 11import perf_insights_project 12import vinn 13 14 15def _RelPathToUnixPath(p): 16 return p.replace(os.sep, '/') 17 18 19def RunTests(): 20 project = perf_insights_project.PerfInsightsProject() 21 headless_test_module_filenames = [ 22 '/' + _RelPathToUnixPath(x) 23 for x in project.FindAllD8TestModuleRelPaths()] 24 headless_test_module_filenames.sort() 25 26 cmd = """ 27 HTMLImportsLoader.loadHTML('/tracing/base/headless_tests.html'); 28 tr.b.unittest.loadAndRunTests(sys.argv.slice(1)); 29 """ 30 res = vinn.RunJsString( 31 cmd, source_paths=list(project.source_paths), 32 js_args=headless_test_module_filenames, stdout=sys.stdout, stdin=sys.stdin) 33 return res.returncode 34 35 36def Main(argv): 37 parser = argparse.ArgumentParser( 38 description='Run d8 tests.') 39 parser.add_argument( 40 '--no-install-hooks', dest='install_hooks', action='store_false') 41 parser.set_defaults(install_hooks=True) 42 args = parser.parse_args(argv[1:]) 43 if args.install_hooks: 44 install.InstallHooks() 45 46 sys.exit(RunTests()) 47 48