|
14 | 14 | from urllib.error import URLError |
15 | 15 | from urllib.parse import quote |
16 | 16 | from urllib.request import Request, urlopen |
| 17 | +from xml.etree import ElementTree |
17 | 18 | from zipfile import ZipFile |
18 | 19 |
|
19 | 20 | import contract_report |
|
25 | 26 | CHROME_VERSION = '158.0.8127.18' |
26 | 27 | DAEMON_STATUS = 'http://127.0.0.1:19825/status' |
27 | 28 | SUITE = 'io.github.easy4j.opencli.contract.OpenCliBrowserBridgeIT' |
| 29 | +REQUIRED_CASES = { |
| 30 | + 'boundTabSurvivesTypedSuccessFailureAndClientShutdown', |
| 31 | + 'boundedNetworkFollowLeavesTheRealBridgeAndPageAvailable', |
| 32 | + 'queryAndCaptureUseTheRealBridgeResponses', |
| 33 | + 'typedResultsFromAnIsolatedChromePage', |
| 34 | +} |
28 | 35 | PAGE = b"""<!doctype html><title>Bridge fixture</title><main><button id="go">Continue</button></main> |
29 | 36 | <script> |
30 | 37 | const capture = setInterval(() => fetch('/api/items'), 250); |
@@ -127,6 +134,18 @@ def stop(process): |
127 | 134 | process.wait() |
128 | 135 |
|
129 | 136 |
|
| 137 | +def require_bridge_cases(report, xml): |
| 138 | + layer = report['layers']['real-execution'] |
| 139 | + if layer['status'] != 'PASS': |
| 140 | + return |
| 141 | + cases = ElementTree.parse(xml).getroot().findall('testcase') |
| 142 | + missing = sorted(REQUIRED_CASES - {case.get('name') for case in cases}) |
| 143 | + layer['missingCases'] = missing |
| 144 | + if missing: |
| 145 | + layer['status'] = report['status'] = 'FAIL' |
| 146 | + report['problems'].append('Required Browser Bridge cases are missing: ' + ', '.join(missing)) |
| 147 | + |
| 148 | + |
130 | 149 | def execute(args, root, evidence): |
131 | 150 | extension = root / 'extension' |
132 | 151 | download_zip(f'https://github.com/jackwener/OpenCLI/releases/download/v{OPENCLI_VERSION}/' |
@@ -210,6 +229,7 @@ def execute(args, root, evidence): |
210 | 229 | java_version=(java.stdout + java.stderr).strip(), maven_version=(maven.stdout + maven.stderr).strip(), |
211 | 230 | exit_code=result.returncode, required_suites={'real-execution': [SUITE]}, |
212 | 231 | ) |
| 232 | + require_bridge_cases(report, evidence / xml.name) |
213 | 233 | (evidence / 'report.json').write_text(json.dumps(report, indent=2) + '\n', encoding='utf-8') |
214 | 234 | print(json.dumps(report['layers']['real-execution'])) |
215 | 235 | return 0 if report['status'] == 'PASS' else 1 |
|
0 commit comments