Skip to content

Commit 7c09357

Browse files
committed
Require each Browser Bridge contract case in live evidence
1 parent 3c871ad commit 7c09357

1 file changed

Lines changed: 20 additions & 0 deletions

File tree

‎scripts/run_browser_bridge_contracts.py‎

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
from urllib.error import URLError
1515
from urllib.parse import quote
1616
from urllib.request import Request, urlopen
17+
from xml.etree import ElementTree
1718
from zipfile import ZipFile
1819

1920
import contract_report
@@ -25,6 +26,12 @@
2526
CHROME_VERSION = '158.0.8127.18'
2627
DAEMON_STATUS = 'http://127.0.0.1:19825/status'
2728
SUITE = 'io.github.easy4j.opencli.contract.OpenCliBrowserBridgeIT'
29+
REQUIRED_CASES = {
30+
'boundTabSurvivesTypedSuccessFailureAndClientShutdown',
31+
'boundedNetworkFollowLeavesTheRealBridgeAndPageAvailable',
32+
'queryAndCaptureUseTheRealBridgeResponses',
33+
'typedResultsFromAnIsolatedChromePage',
34+
}
2835
PAGE = b"""<!doctype html><title>Bridge fixture</title><main><button id="go">Continue</button></main>
2936
<script>
3037
const capture = setInterval(() => fetch('/api/items'), 250);
@@ -127,6 +134,18 @@ def stop(process):
127134
process.wait()
128135

129136

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+
130149
def execute(args, root, evidence):
131150
extension = root / 'extension'
132151
download_zip(f'https://github.com/jackwener/OpenCLI/releases/download/v{OPENCLI_VERSION}/'
@@ -210,6 +229,7 @@ def execute(args, root, evidence):
210229
java_version=(java.stdout + java.stderr).strip(), maven_version=(maven.stdout + maven.stderr).strip(),
211230
exit_code=result.returncode, required_suites={'real-execution': [SUITE]},
212231
)
232+
require_bridge_cases(report, evidence / xml.name)
213233
(evidence / 'report.json').write_text(json.dumps(report, indent=2) + '\n', encoding='utf-8')
214234
print(json.dumps(report['layers']['real-execution']))
215235
return 0 if report['status'] == 'PASS' else 1

0 commit comments

Comments
 (0)