(self)
| 206 | # after running flag contradiction logic. |
| 207 | @property |
| 208 | def expected_outcomes(self): |
| 209 | def is_flag(maybe_flag): |
| 210 | return maybe_flag.startswith("--") # Best-effort heuristic. |
| 211 | |
| 212 | # Filter to flags, e.g.: ["--foo", "3", "--bar"] -> ["--foo", "--bar"]. |
| 213 | def filter_flags(normalized_flags): |
| 214 | return [f for f in normalized_flags if is_flag(f)]; |
| 215 | |
| 216 | def normalize_flag(flag): |
| 217 | return flag.replace("_", "-").replace("--no-", "--no") |
| 218 | |
| 219 | def normalize_flags(flags): |
| 220 | return [normalize_flag(flag) for flag in filter_flags(flags)] |
| 221 | |
| 222 | # Note this can get it wrong if the flag name starts with the characters |
| 223 | # "--no" where "no" is part of the flag name, e.g. "--nobodys-perfect". |
| 224 | # In that case the negation "--bodys-perfect" would be returned. This is |
| 225 | # a weakness we accept and hope to never run into. |
| 226 | def negate_flag(normalized_flag): |
| 227 | return ("--" + normalized_flag[4:] if normalized_flag.startswith("--no") |
| 228 | else "--no" + normalized_flag[2:]) |
| 229 | |
| 230 | def negate_flags(normalized_flags): |
| 231 | return [negate_flag(flag) for flag in normalized_flags] |
| 232 | |
| 233 | def find_flag(conflicting_flag, flags): |
| 234 | conflicting_flag = normalize_flag(conflicting_flag) |
| 235 | if conflicting_flag in flags: |
| 236 | return conflicting_flag |
| 237 | if conflicting_flag.endswith("*"): |
| 238 | conflicting_flag = conflicting_flag[:-1] |
| 239 | for flag in flags: |
| 240 | if flag.startswith(conflicting_flag): |
| 241 | return flag |
| 242 | return None |
| 243 | |
| 244 | def check_flags(incompatible_flags, actual_flags, rule, other_flag=None): |
| 245 | for incompatible_flag in incompatible_flags: |
| 246 | conflicting_flag = find_flag(incompatible_flag, actual_flags) |
| 247 | if conflicting_flag and (conflicting_flag != other_flag): |
| 248 | self._statusfile_outcomes = outproc.OUTCOMES_FAIL |
| 249 | self._expected_outcomes = outproc.OUTCOMES_FAIL |
| 250 | self.expected_failure_reason = ( |
| 251 | "Rule " + rule + " in " + |
| 252 | "tools/testrunner/local/variants.py expected a flag " + |
| 253 | "contradiction error with " + incompatible_flag + ".") |
| 254 | |
| 255 | def remove_flags_after(flags, flag): |
| 256 | try: |
| 257 | pos = flags.index(normalize_flag(flag)) |
| 258 | except: |
| 259 | pass |
| 260 | else: |
| 261 | flags = flags[0:pos] |
| 262 | return flags |
| 263 | |
| 264 | # Flags can be ignored with respect to contradictions by passing |
| 265 | # --fuzzing or --no-abort-on-contradictory-flags, which ignores all |
nothing calls this directly
no test coverage detected