(self, tests: TestList | None = None)
| 165 | self.logger.log(line) |
| 166 | |
| 167 | def find_tests(self, tests: TestList | None = None) -> tuple[TestTuple, TestList | None]: |
| 168 | if tests is None: |
| 169 | tests = [] |
| 170 | if self.single_test_run: |
| 171 | self.next_single_filename = os.path.join(self.tmp_dir, 'pynexttest') |
| 172 | try: |
| 173 | with open(self.next_single_filename, 'r') as fp: |
| 174 | next_test = fp.read().strip() |
| 175 | tests = [next_test] |
| 176 | except OSError: |
| 177 | pass |
| 178 | |
| 179 | if self.fromfile: |
| 180 | tests = [] |
| 181 | # regex to match 'test_builtin' in line: |
| 182 | # '0:00:00 [ 4/400] test_builtin -- test_dict took 1 sec' |
| 183 | regex = re.compile(r'\btest_[a-zA-Z0-9_]+\b') |
| 184 | with open(os.path.join(os_helper.SAVEDCWD, self.fromfile)) as fp: |
| 185 | for line in fp: |
| 186 | line = line.split('#', 1)[0] |
| 187 | line = line.strip() |
| 188 | match = regex.search(line) |
| 189 | if match is not None: |
| 190 | tests.append(match.group()) |
| 191 | |
| 192 | strip_py_suffix(tests) |
| 193 | |
| 194 | exclude_tests = set() |
| 195 | if self.exclude: |
| 196 | for arg in self.cmdline_args: |
| 197 | exclude_tests.add(arg) |
| 198 | self.cmdline_args = [] |
| 199 | |
| 200 | if self.pgo: |
| 201 | # add default PGO tests if no tests are specified |
| 202 | setup_pgo_tests(self.cmdline_args, self.pgo_extended) |
| 203 | |
| 204 | if self.tsan: |
| 205 | setup_tsan_tests(self.cmdline_args) |
| 206 | |
| 207 | if self.tsan_parallel: |
| 208 | setup_tsan_parallel_tests(self.cmdline_args) |
| 209 | |
| 210 | alltests = findtests(testdir=self.test_dir, |
| 211 | exclude=exclude_tests) |
| 212 | |
| 213 | if not self.fromfile: |
| 214 | selected = tests or self.cmdline_args |
| 215 | if exclude_tests: |
| 216 | # Support "--pgo/--tsan -x test_xxx" command |
| 217 | selected = [name for name in selected |
| 218 | if name not in exclude_tests] |
| 219 | if selected: |
| 220 | selected = split_test_packages(selected) |
| 221 | else: |
| 222 | selected = alltests |
| 223 | else: |
| 224 | selected = tests |
no test coverage detected