|
4 | 4 | import lit.Test |
5 | 5 | import lit.util |
6 | 6 | from .base import TestFormat |
7 | | -import difflib, os, re, shutil, random |
| 7 | +import difflib, os, re, shutil, random, sys |
8 | 8 | import tomli |
9 | 9 |
|
| 10 | +CURRENT_OS = 'macos' if sys.platform == 'darwin' else 'linux' |
| 11 | +ENTRY_RE = re.compile(r'(\w+)(?:\s*\(([^)]*)\))?') |
| 12 | + |
10 | 13 | def read_rust_version(): |
11 | 14 | toolchain_path = os.path.join(os.path.dirname(__file__), |
12 | 15 | '../../../../libcc2rs/rust-toolchain.toml') |
@@ -69,17 +72,24 @@ def execute(self, test, litConfig): |
69 | 72 | def matches_model(match, model): |
70 | 73 | if match is None: |
71 | 74 | return False |
72 | | - models = match.group(1) |
73 | | - if models is None or models.strip() == '': |
| 75 | + spec = match.group(1) |
| 76 | + if spec is None or spec.strip() == '': |
74 | 77 | return True |
75 | | - return model in re.split(r'\s*,\s*', models.strip()) |
| 78 | + for entry in ENTRY_RE.finditer(spec): |
| 79 | + if entry.group(1) != model: |
| 80 | + continue |
| 81 | + os_list = entry.group(2) |
| 82 | + if os_list is None: |
| 83 | + return True |
| 84 | + if CURRENT_OS in [o.strip() for o in os_list.split(',')]: |
| 85 | + return True |
| 86 | + return False |
76 | 87 |
|
77 | 88 | should_fail = False |
78 | 89 | fail_code = lit.Test.FAIL |
79 | 90 | xfail = self.regex_xfail.search(text) |
80 | 91 | if xfail: |
81 | | - xfail = re.split(r'\s*,\s*', xfail.group(1)) |
82 | | - should_fail = model in xfail |
| 92 | + should_fail = matches_model(xfail, model) |
83 | 93 | fail_code = lit.Test.XFAIL |
84 | 94 |
|
85 | 95 | should_panic = matches_model(self.regex_panic.search(text), model) |
|
0 commit comments