test: fix nan tests on macOS (#47583)

This commit is contained in:
Shelley Vohr 2025-06-29 21:57:44 +02:00 committed by GitHub
commit 61c245761c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -46,20 +46,23 @@ async function main () {
const platformFlags = []; const platformFlags = [];
if (process.platform === 'darwin') { if (process.platform === 'darwin') {
const sdkPath = path.resolve(BASE, 'out', outDir, 'sdk', 'xcode_links'); const sdkPath = path.resolve(BASE, 'out', outDir, 'sdk', 'xcode_links');
const sdks = (await fs.promises.readdir(sdkPath)).filter(fileName => fileName.endsWith('.sdk')); const sdks = (await fs.promises.readdir(sdkPath)).filter(f => f.endsWith('.sdk'));
const sdkToUse = sdks[0];
if (!sdkToUse) { if (!sdks.length) {
console.error('Could not find an SDK to use for the NAN tests'); console.error('Could not find an SDK to use for the NAN tests');
process.exit(1); process.exit(1);
} }
if (sdks.length) { const sdkToUse = sdks.sort((a, b) => {
console.warn(`Multiple SDKs found in the xcode_links directory - using ${sdkToUse}`); const getVer = s => s.match(/(\d+)\.?(\d*)/)?.[0] || '0';
return getVer(b).localeCompare(getVer(a), undefined, { numeric: true });
})[0];
if (sdks.length > 1) {
console.warn(`Multiple SDKs found - using ${sdkToUse}`);
} }
platformFlags.push( platformFlags.push(`-isysroot ${path.resolve(sdkPath, sdkToUse)}`);
`-isysroot ${path.resolve(sdkPath, sdkToUse)}`
);
} }
// TODO(ckerr) this is cribbed from read obj/electron/electron_app.ninja. // TODO(ckerr) this is cribbed from read obj/electron/electron_app.ninja.