fix(ci): retain and retry the observed Playwright runtime corruption
This commit is contained in:
@@ -0,0 +1,49 @@
|
||||
"""Exercise the actual workflow's narrow corruption guard, without starting CI."""
|
||||
import os
|
||||
from pathlib import Path
|
||||
import shutil
|
||||
import subprocess
|
||||
import tempfile
|
||||
import unittest
|
||||
|
||||
WORKFLOW = Path(__file__).resolve().parents[1] / '.gitea/workflows/ci-deploy.yml'
|
||||
BASH = str(Path('C:/Program Files/Git/bin/bash.exe')) if os.name == 'nt' else shutil.which('bash')
|
||||
|
||||
|
||||
class BrowserRuntimeRetryTests(unittest.TestCase):
|
||||
def permits_retry(self, log):
|
||||
text = WORKFLOW.read_text(encoding='utf-8')
|
||||
end = text.index(' echo "Browser runtime source appears corrupted')
|
||||
start = text.rfind('\n if ', 0, end) + 1
|
||||
guard = text[start:end]
|
||||
self.assertTrue(guard.strip().startswith('if '))
|
||||
with tempfile.TemporaryDirectory() as folder:
|
||||
fixture = Path(folder) / 'smoke.log'
|
||||
fixture.write_text(log, encoding='utf-8')
|
||||
result = subprocess.run([BASH, '-c', guard + '\nexit 0\nelse\nexit 1\nfi'],
|
||||
env={**os.environ, 'smoke_log': fixture.as_posix()}, capture_output=True, text=True)
|
||||
self.assertIn(result.returncode, [0, 1], result.stderr)
|
||||
return result.returncode == 0
|
||||
|
||||
def test_captured_playwright_source_corruption(self):
|
||||
self.assertTrue(self.permits_retry('/workspace/node_modules/playwright-core/lib/utilsBundle.js:35841\n'
|
||||
'const { items }$= this;\nSyntaxError: Missing initializer in destructuring declaration'))
|
||||
|
||||
def test_existing_axe_source_corruption(self):
|
||||
self.assertTrue(self.permits_retry('AxeBuilder.analyze\npage.evaluate: ReferenceError: invalid runtime source'))
|
||||
|
||||
def test_application_assertion_stays_terminal(self):
|
||||
self.assertFalse(self.permits_retry('expect(region).not.toBeVisible() failed'))
|
||||
|
||||
def test_browser_crash_alone_stays_terminal(self):
|
||||
self.assertFalse(self.permits_retry('Error: page.evaluate: Target crashed'))
|
||||
|
||||
def test_user_javascript_syntax_error_stays_terminal(self):
|
||||
self.assertFalse(self.permits_retry('src/example.js:1\nconst { items }$= this;\nSyntaxError: Missing initializer in destructuring declaration'))
|
||||
|
||||
def test_incomplete_signature_stays_terminal(self):
|
||||
self.assertFalse(self.permits_retry('node_modules/playwright-core/lib/utilsBundle.js:35841\nSyntaxError: Missing initializer in destructuring declaration'))
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
Reference in New Issue
Block a user