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