|
85 | 85 | DISABLE_JIT_ENV = {'GRAAL_PYTHON_VM_ARGS': '--experimental-options --engine.Compilation=false'} |
86 | 86 |
|
87 | 87 | GITHUB_CI = os.environ.get("GITHUB_CI", None) |
| 88 | +if GITHUB_CI: |
| 89 | + PLATFORM_KEYS.add("github") |
| 90 | + CURRENT_PLATFORM += "-github" |
88 | 91 |
|
89 | 92 | # We leave the JIT enabled for the tests themselves, but disable it for subprocesses |
90 | 93 | # noinspection PyUnresolvedReferences |
@@ -907,7 +910,13 @@ def run_in_subprocess_and_watch(self): |
907 | 910 |
|
908 | 911 |
|
909 | 912 | def platform_keys_match(items: typing.Iterable[str]): |
910 | | - return any(all(key in PLATFORM_KEYS for key in item.split('-')) for item in items) |
| 913 | + matches = [] |
| 914 | + for item in items: |
| 915 | + if GITHUB_CI: |
| 916 | + if not "github" in item.split('-'): |
| 917 | + continue |
| 918 | + matches.append(all(key in PLATFORM_KEYS for key in item.split('-'))) |
| 919 | + return any(matches) |
911 | 920 |
|
912 | 921 |
|
913 | 922 | @dataclass |
@@ -1132,7 +1141,7 @@ def collect_module(test_file: TestFile, specifiers: list[TestSpecifier], use_tag |
1132 | 1141 | loader = TopLevelFunctionLoader() if config.run_top_level_functions else unittest.TestLoader() |
1133 | 1142 | tagged_ids = None |
1134 | 1143 | if use_tags and config.tags_dir: |
1135 | | - tagged_ids = [tag.test_id for tag in read_tags(test_file) if platform_keys_match(tag.keys) and not tag.is_platform_excluded(CURRENT_PLATFORM)] |
| 1144 | + tagged_ids = [tag.test_id for tag in read_tags(test_file) if platform_keys_match(tag.keys)] |
1136 | 1145 | if not tagged_ids: |
1137 | 1146 | return None |
1138 | 1147 | test_module = test_path_to_module(test_file) |
@@ -1208,52 +1217,36 @@ def collect(all_specifiers: list[TestSpecifier], *, use_tags=False, ignore=None, |
1208 | 1217 | class Tag: |
1209 | 1218 | test_id: TestId |
1210 | 1219 | keys: frozenset[str] |
1211 | | - excluded_keys: frozenset[str] |
1212 | 1220 | is_exclusion: bool |
1213 | 1221 | comment: str | None = False |
1214 | 1222 |
|
1215 | 1223 | @classmethod |
1216 | 1224 | def for_key(cls, test_id, key) -> 'Tag': |
1217 | | - return Tag(test_id, frozenset({key}), excluded_keys=frozenset(), is_exclusion=False) |
| 1225 | + return Tag(test_id, frozenset({key}), is_exclusion=False) |
1218 | 1226 |
|
1219 | 1227 | def with_key(self, key: str) -> 'Tag': |
1220 | | - if GITHUB_CI: |
1221 | | - return Tag(self.test_id, self.keys, self.excluded_keys - {key}, is_exclusion=self.is_exclusion) |
1222 | | - |
1223 | | - return Tag(self.test_id, self.keys | {key}, self.excluded_keys, is_exclusion=self.is_exclusion) |
| 1228 | + return Tag(self.test_id, self.keys | {key}, is_exclusion=self.is_exclusion) |
1224 | 1229 |
|
1225 | 1230 | def without_key(self, key: str) -> 'Tag | None': |
1226 | 1231 | return self.without_keys({key}) |
1227 | 1232 |
|
1228 | 1233 | def without_keys(self, keys: set[str]) -> 'Tag | None': |
1229 | | - # disable test/platform only for github, not completely for internal ci |
1230 | | - if GITHUB_CI: |
1231 | | - exclusions = frozenset(list(self.excluded_keys) + list(keys)) |
1232 | | - return Tag(self.test_id, self.keys, exclusions, is_exclusion=self.is_exclusion) |
1233 | | - |
1234 | 1234 | keys = self.keys - keys |
1235 | 1235 | if keys: |
1236 | 1236 | if keys == self.keys: |
1237 | 1237 | return self |
1238 | | - return Tag(self.test_id, keys, self.excluded_keys, is_exclusion=self.is_exclusion) |
| 1238 | + return Tag(self.test_id, keys, is_exclusion=self.is_exclusion) |
1239 | 1239 |
|
1240 | 1240 | def is_platform_excluded(self, key: str) -> bool: |
1241 | | - return key in self.excluded_keys |
| 1241 | + return key not in self.keys |
1242 | 1242 |
|
1243 | | - def get_keys_as_str(self) -> list[str]: |
1244 | | - keys = [] |
1245 | | - for key in sorted(self.keys): |
1246 | | - if "$" in key: print(f"[WARNING]: Invalid key with $ found in tag keys: {key}, {self.keys}, {self.excluded_keys}") |
1247 | | - keys.append(key if key not in self.excluded_keys else f"${key}") |
1248 | | - return keys |
1249 | | - |
1250 | 1243 | def __str__(self): |
1251 | 1244 | s = '' |
1252 | 1245 | if self.is_exclusion: |
1253 | 1246 | s += '!' |
1254 | 1247 | s += self.test_id.test_name |
1255 | 1248 | if self.keys: |
1256 | | - s += f' @ {",".join(self.get_keys_as_str())}' |
| 1249 | + s += f' @ {",".join(sorted(self.keys))}' |
1257 | 1250 | if self.comment: |
1258 | 1251 | s = f'{self.comment}{s}' |
1259 | 1252 | return s |
@@ -1282,19 +1275,13 @@ def read_tags(test_file: TestFile, allow_exclusions=False) -> list[Tag]: |
1282 | 1275 | is_exclusion = True |
1283 | 1276 | test = test.removeprefix('!') |
1284 | 1277 |
|
| 1278 | + |
1285 | 1279 | if not keys and not is_exclusion: |
1286 | 1280 | log(f'WARNING: invalid tag {test}: missing platform keys') |
1287 | 1281 |
|
1288 | | - keys = keys.split(',') if keys else [] |
1289 | | - excluded_keys = [] |
1290 | | - for key in keys: |
1291 | | - if key.startswith('$'): |
1292 | | - excluded_keys.append(key.removeprefix('$')) |
1293 | | - |
1294 | 1282 | tag = Tag( |
1295 | 1283 | TestId(test_path, test), |
1296 | | - frozenset(keys), |
1297 | | - excluded_keys=frozenset(excluded_keys), |
| 1284 | + frozenset(keys.split(',')) if keys else frozenset(keys), |
1298 | 1285 | is_exclusion=is_exclusion, |
1299 | 1286 | comment=comment, |
1300 | 1287 | ) |
|
0 commit comments