Skip to content

Commit adf5a6f

Browse files
committed
serial tests
1 parent 8cbf75c commit adf5a6f

File tree

2 files changed

+17
-3
lines changed

2 files changed

+17
-3
lines changed

package.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,5 +57,9 @@
5757
"ava": "^6.1.1",
5858
"jest-image-snapshot": "^6.5.1",
5959
"xo": "^0.56.0"
60+
},
61+
"ava": {
62+
"serial": true,
63+
"timeout": "30s"
6064
}
6165
}

test.js

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,17 +14,27 @@ const __dirname = path.dirname(fileURLToPath(import.meta.url));
1414
const assertVolumeIconMatchesSnapshot = (t, dmgPath) => {
1515
// Mount the DMG and extract the volume icon
1616
const existingVolumes = new Set(fs.readdirSync('/Volumes'));
17-
spawnSync('hdiutil', ['mount', dmgPath]);
17+
const mountResult = spawnSync('hdiutil', ['mount', dmgPath], { timeout: 10000 });
18+
19+
if (mountResult.status !== 0) {
20+
throw new Error(`Failed to mount DMG: ${mountResult.stderr?.toString()}`);
21+
}
22+
1823
const volumes = new Set(fs.readdirSync('/Volumes'));
1924
const mountLocation = [...volumes].find(x => !existingVolumes.has(x));
2025
t.truthy(mountLocation);
2126
const dmgIconPath = path.join('/Volumes', mountLocation, '.VolumeIcon.icns')
2227
const dirPath = path.dirname(dmgPath);
2328
const iconPath = path.join(dirPath, 'VolumeIcon.icns');
2429
fs.copyFileSync(dmgIconPath, iconPath);
25-
spawnSync('hdiutil', ['unmount', path.join('/Volumes', mountLocation)]);
30+
const unmountResult = spawnSync('hdiutil', ['unmount', '-force', path.join('/Volumes', mountLocation)], { timeout: 10000 });
31+
32+
if (unmountResult.status !== 0) {
33+
throw new Error(`Failed to unmount ${mountLocation}: ${unmountResult.stderr?.toString()}`);
34+
}
35+
2636
const pngPath = path.join(dirPath, 'VolumeIcon.png');
27-
spawnSync('sips', ['-s', 'format', 'png', iconPath, '--out', pngPath]);
37+
spawnSync('sips', ['-s', 'format', 'png', iconPath, '--out', pngPath], { timeout: 10000 });
2838

2939
// Compare the extracted icon to the snapshot
3040
const image = fs.readFileSync(pngPath);

0 commit comments

Comments
 (0)