1# Copyright 2022 The Chromium Authors 2# Use of this source code is governed by a BSD-style license that can be 3# found in the LICENSE file. 4"""Implements commands for running blink web tests.""" 5 6import os 7import subprocess 8 9from argparse import Namespace 10from typing import Optional 11 12from common import DIR_SRC_ROOT 13from test_runner import TestRunner 14 15_BLINK_TEST_SCRIPT = os.path.join(DIR_SRC_ROOT, 'third_party', 'blink', 16 'tools', 'run_web_tests.py') 17 18 19class BlinkTestRunner(TestRunner): 20 """Test runner for running blink web tests.""" 21 22 def __init__(self, out_dir: str, test_args: Namespace, 23 target_id: Optional[str]) -> None: 24 super().__init__(out_dir, test_args, ['content_shell'], target_id) 25 26 # TODO(crbug.com/1278939): Remove when blink tests use CFv2 content_shell. 27 @staticmethod 28 def is_cfv2() -> bool: 29 return False 30 31 def run_test(self): 32 test_cmd = [_BLINK_TEST_SCRIPT, '-t', os.path.basename(self._out_dir)] 33 34 if self._test_args: 35 test_cmd.extend(self._test_args) 36 return subprocess.run(test_cmd, check=True) 37