1212# Use of this source code is governed by a BSD-style license that can be found
1313# in the LICENSE file.
1414
15- import argparse
1615import logging
1716import os
1817import sys
1918
20- from subprocess import CompletedProcess
21- from typing import Any , Iterable , List , Mapping , NamedTuple , Set
19+ from typing import Any , Iterable , List , Mapping , Set
2220
2321# The import is coming from vpython wheel and pylint cannot find it.
2422import yaml # pylint: disable=import-error
3331)
3432
3533# pylint: disable=import-error, wrong-import-position
36- import run_test
34+ from bundled_test_runner import run_tests , TestCase
3735from common import DIR_SRC_ROOT
38- from run_executable_test import ExecutableTestRunner
39- from test_runner import TestRunner
36+ from compatible_utils import force_running_unattended
4037
4138if len (sys .argv ) == 2 :
4239 VARIANT = sys .argv [1 ]
4845OUT_DIR = os .path .join (DIR_SRC_ROOT , 'out' , VARIANT )
4946
5047
51- # Visible for testing
52- class TestCase (NamedTuple ):
53- package : str
54- args : str = ''
55-
56-
57- class _BundledTestRunner (TestRunner ):
58-
59- # private, use bundled_test_runner_of function instead.
60- def __init__ (self , target_id : str , package_deps : Set [str ], tests : List [TestCase ], logs_dir : str ):
61- super ().__init__ (OUT_DIR , [], None , target_id , list (package_deps ))
62- self .tests = tests
63- self .logs_dir = logs_dir
64-
65- def run_test (self ) -> CompletedProcess :
66- returncode = 0
67- for test in self .tests :
68- assert test .package .endswith ('.cm' )
69- test_runner = ExecutableTestRunner (
70- OUT_DIR , test .args .split (), test .package , self ._target_id , None , self .logs_dir , [], None
71- )
72- # pylint: disable=protected-access
73- test_runner ._package_deps = self ._package_deps
74- result = test_runner .run_test ().returncode
75- logging .info ('Result of test %s is %s' , test , result )
76- if result != 0 :
77- returncode = result
78- return CompletedProcess (args = '' , returncode = returncode )
79-
80-
8148# Visible for testing
8249def resolve_packages (tests : Iterable [Mapping [str , Any ]]) -> Set [str ]:
8350 packages = set ()
@@ -121,8 +88,15 @@ def build_test_cases(tests: Iterable[Mapping[str, Any]]) -> List[TestCase]:
12188 return test_cases
12289
12390
124- def _bundled_test_runner_of (target_id : str ) -> _BundledTestRunner :
125- log_dir = os .environ .get ('FLUTTER_LOGS_DIR' , '/tmp/log' )
91+ def main () -> int :
92+ logging .basicConfig (level = logging .INFO )
93+ logging .info ('Running tests in %s' , OUT_DIR )
94+ force_running_unattended ()
95+ sys .argv .append ('--out-dir=' + OUT_DIR )
96+ if VARIANT .endswith ('_arm64' ) or VARIANT .endswith ('_arm64_tester' ):
97+ sys .argv .append ('--product=terminal.qemu-arm64' )
98+
99+ sys .argv .append ('--logs-dir=' + os .environ .get ('FLUTTER_LOGS_DIR' , '/tmp/log' ))
126100 with open (os .path .join (os .path .dirname (__file__ ), 'test_suites.yaml' ), 'r' ) as file :
127101 tests = yaml .safe_load (file )
128102 # TODO(zijiehe-google-com): Run all tests in release build,
@@ -131,21 +105,10 @@ def variant(test) -> bool:
131105 return 'variant' not in test or test ['variant' ] in VARIANT
132106
133107 tests = [t for t in tests if variant (t )]
134- return _BundledTestRunner (target_id , resolve_packages (tests ), build_test_cases (tests ), log_dir )
135-
136-
137- def _get_test_runner (runner_args : argparse .Namespace , * _ ) -> TestRunner :
138- return _bundled_test_runner_of (runner_args .target_id )
108+ for package in resolve_packages (tests ):
109+ sys .argv .append ('--packages=' + package )
110+ return run_tests (build_test_cases (tests ))
139111
140112
141113if __name__ == '__main__' :
142- logging .basicConfig (level = logging .INFO )
143- logging .info ('Running tests in %s' , OUT_DIR )
144- sys .argv .append ('--out-dir=' + OUT_DIR )
145- if VARIANT .endswith ('_arm64' ) or VARIANT .endswith ('_arm64_tester' ):
146- sys .argv .append ('--product=terminal.qemu-arm64' )
147- # The 'flutter-test-type' is a place holder and has no specific meaning; the
148- # _get_test_runner is overrided.
149- sys .argv .append ('flutter-test-type' )
150- run_test ._get_test_runner = _get_test_runner # pylint: disable=protected-access
151- sys .exit (run_test .main ())
114+ sys .exit (main ())
0 commit comments