blob: 5abcf7411eb78743eb9fb634e62c0da7bef61efb [file] [log] [blame]
Stephen Martinisf7bb8232018-06-26 19:47:541#!/usr/bin/env python
2# Copyright 2018 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"""Runs chrome driver tests.
7
8This script attempts to emulate the contract of gtest-style tests
9invoked via recipes. The main contract is that the caller passes the
10argument:
11
12 --isolated-script-test-output=[FILENAME]
13
14json is written to that file in the format detailed here:
15https://www.chromium.org/developers/the-json-test-results-format
16
17Optional argument:
18
19 --isolated-script-test-filter=[TEST_NAMES]
20
21is a double-colon-separated ("::") list of test names, to run just that subset
22of tests. This list is forwarded to the chrome driver test runner.
23"""
24
25import argparse
26import json
27import os
28import shutil
29import sys
30import tempfile
31import traceback
32
33import common
34
Stephen Martinisf7bb8232018-06-26 19:47:5435
Ned Nguyen09dcd002018-10-16 06:01:5036class ChromeDriverAdapter(common.BaseIsolatedScriptArgsAdapter):
Stephen Martinisf7bb8232018-06-26 19:47:5437
Ned Nguyen09dcd002018-10-16 06:01:5038 def generate_test_output_args(self, output):
39 return ['--isolated-script-test-output', output]
Stephen Martinisf7bb8232018-06-26 19:47:5440
Ned Nguyen09dcd002018-10-16 06:01:5041 def generate_test_filter_args(self, test_filter_str):
42 if any('--filter' in arg for arg in self.rest_args):
43 self.parser.error(
Stephen Martinisf7bb8232018-06-26 19:47:5444 'can\'t have the test call filter with the'
45 '--isolated-script-test-filter argument to the wrapper script')
46
Ned Nguyen09dcd002018-10-16 06:01:5047 return ['--filter', test_filter_str.replace('::', ':')]
Stephen Martinisf7bb8232018-06-26 19:47:5448
Ned Nguyen09dcd002018-10-16 06:01:5049
50def main():
51 adapter = ChromeDriverAdapter()
Stephen Martinise45a3de2018-10-19 20:19:2452 return adapter.run_test()
Stephen Martinisf7bb8232018-06-26 19:47:5453
54
55# This is not really a "script test" so does not need to manually add
56# any additional compile targets.
57def main_compile_targets(args):
58 json.dump([], args.output)
59
60
61if __name__ == '__main__':
62 # Conform minimally to the protocol defined by ScriptTest.
63 if 'compile_targets' in sys.argv:
64 funcs = {
65 'run': None,
66 'compile_targets': main_compile_targets,
67 }
68 sys.exit(common.run_script(sys.argv[1:], funcs))
69 sys.exit(main())