Skip to content

Commit ea1d681

Browse files
chrfalchclaude
andcommitted
test(spm): mock plutil in swap-flavor-test for Linux CI
plutil is macOS-only; the destructured execFileSync requires a hoisted module mock. Portable plist-parse stand-in keeps the suite hermetic. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
1 parent b04cd15 commit ea1d681

1 file changed

Lines changed: 24 additions & 0 deletions

File tree

packages/react-native/scripts/spm/__tests__/swap-flavor-test.js

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,30 @@
1010

1111
'use strict';
1212

13+
// swap-flavor.js shells out to `plutil` to read an xcframework's Info.plist as
14+
// JSON — plutil is macOS-only, so on Linux CI the real spawn ENOENTs and
15+
// jest-worker can't serialize the resulting error, killing the whole suite.
16+
// Stand in with a portable plist-parse. Mocked at the `child_process` module
17+
// level (not via jest.spyOn) because swap-flavor.js destructures
18+
// `execFileSync` at require time, so a post-import spy would never be seen.
19+
jest.mock('child_process', () => {
20+
const actual = jest.requireActual('child_process');
21+
return {
22+
...actual,
23+
execFileSync: (cmd, args, opts) => {
24+
if (cmd === 'plutil') {
25+
const fs = require('fs');
26+
const plist = require('plist');
27+
const file = args[args.length - 1];
28+
return Buffer.from(
29+
JSON.stringify(plist.parse(fs.readFileSync(file, 'utf8'))),
30+
);
31+
}
32+
return actual.execFileSync(cmd, args, opts);
33+
},
34+
};
35+
});
36+
1337
const {matchSlice, swapFlavorFrameworks} = require('../swap-flavor');
1438
const fs = require('fs');
1539
const os = require('os');

0 commit comments

Comments
 (0)