Skip to content

Commit 0392e17

Browse files
committed
test(android): retain capture failures when evidence cleanup fails
1 parent f0f1c1d commit 0392e17

1 file changed

Lines changed: 17 additions & 3 deletions

File tree

‎test/integration/android-emulator-e2e/live-demo-permission-scenario.ts‎

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ export async function assertScreenshotDemoPermissionRestoration(options: {
4747
assert.ok(Number.isInteger(apiLevel) && apiLevel > 0, 'Android must report its API level');
4848
const initial = await readPermission();
4949
const cases: PermissionCase[] = [];
50+
const failures: unknown[] = [];
5051
fs.mkdirSync(options.artifactDir, { recursive: true });
5152
try {
5253
for (const value of [undefined, '0', '1']) {
@@ -65,15 +66,28 @@ export async function assertScreenshotDemoPermissionRestoration(options: {
6566
item.after = await readPermission();
6667
assert.equal(item.after, before, `normalized capture changed the ${item.state} permission`);
6768
}
68-
} finally {
69+
} catch (error) {
70+
failures.push(error);
71+
}
72+
let restored: string | null | undefined;
73+
try {
6974
await writePermission(
7075
initial === null ? undefined : initial.slice(DEMO_PERMISSION_PREFIX.length),
7176
);
72-
const restored = await readPermission();
77+
restored = await readPermission();
78+
assert.equal(restored, initial, 'the native test must restore its initial global setting');
79+
} catch (error) {
80+
failures.push(error);
81+
}
82+
try {
7383
fs.writeFileSync(
7484
path.join(options.artifactDir, 'demo-permission-evidence.json'),
7585
`${JSON.stringify({ serial: options.serial, apiLevel, initial, restored, cases }, null, 2)}\n`,
7686
);
77-
assert.equal(restored, initial, 'the native test must restore its initial global setting');
87+
} catch (error) {
88+
failures.push(error);
7889
}
90+
if (failures.length === 1) throw failures[0];
91+
if (failures.length > 1)
92+
throw new AggregateError(failures, 'Android screenshot evidence and cleanup failed');
7993
}

0 commit comments

Comments
 (0)