Skip to content

Commit

Permalink
Fix metro tests to run with high parallelism (#1410)
Browse files Browse the repository at this point in the history
Summary:

Changelog: Fix a bug when metro tests could not have been run in parallel, e.g. in a stress-test.

Differential Revision: D67332012
  • Loading branch information
mijay authored and facebook-github-bot committed Dec 17, 2024
1 parent a6e9f7f commit d54b5a4
Showing 1 changed file with 10 additions and 16 deletions.
26 changes: 10 additions & 16 deletions packages/metro-symbolicate/src/__tests__/symbolicate-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

const symbolicate = require('../symbolicate');
const fs = require('fs');
const os = require('os');
const path = require('path');
const {PassThrough} = require('stream');

Expand Down Expand Up @@ -53,9 +54,11 @@ const execute = async (
return stdout.join('');
};

const TEMP_DIR = fs.mkdtempSync(path.join(os.tmpdir(), 'symbolicate-'));
const TEMP_FILE = path.resolve(TEMP_DIR, 'testfile.temp.cpuprofile');
afterAll(() => {
try {
fs.unlinkSync(resolve('testfile.temp.cpuprofile'));
fs.rmdirSync(TEMP_DIR);
} catch (e) {}
});

Expand Down Expand Up @@ -400,32 +403,23 @@ describe('symbolicating an attribution file specifying unmapped offsets', () =>
});

test('symbolicating with a cpuprofile', async () => {
fs.copyFileSync(
resolve('testfile.cpuprofile'),
resolve('testfile.temp.cpuprofile'),
);
fs.copyFileSync(resolve('testfile.cpuprofile'), TEMP_FILE);

await execute([
resolve('testfile.cpuprofile.map'),
resolve('testfile.temp.cpuprofile'),
]);
await execute([resolve('testfile.cpuprofile.map'), TEMP_FILE]);

expect(JSON.parse(read('testfile.temp.cpuprofile'))).toMatchSnapshot();
expect(JSON.parse(read(TEMP_FILE))).toMatchSnapshot();
});

test('symbolicating with a cpuprofile ignoring a function map', async () => {
fs.copyFileSync(
resolve('testfile.cpuprofile'),
resolve('testfile.temp.cpuprofile'),
);
fs.copyFileSync(resolve('testfile.cpuprofile'), TEMP_FILE);

await execute([
'--no-function-names',
resolve('testfile.cpuprofile.map'),
resolve('testfile.temp.cpuprofile'),
TEMP_FILE,
]);

expect(JSON.parse(read('testfile.temp.cpuprofile'))).toMatchSnapshot();
expect(JSON.parse(read(TEMP_FILE))).toMatchSnapshot();
});

test('symbolicating a stack trace with a function map', async () =>
Expand Down

0 comments on commit d54b5a4

Please sign in to comment.