Skip to content

Commit

Permalink
fix(app-shell): Fix flaky file system test (#17212)
Browse files Browse the repository at this point in the history
Fix a flaky test by running filesystem commands sequentially instead of in parallel.
  • Loading branch information
mjhuff authored Jan 8, 2025
1 parent 0395804 commit cff47c9
Showing 1 changed file with 55 additions and 54 deletions.
109 changes: 55 additions & 54 deletions app-shell/src/protocol-storage/__tests__/file-system.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,66 +109,67 @@ describe('protocol storage directory utilities', () => {
})

describe('parseProtocolDirs', () => {
it('reads and parses directories', () => {
it('reads and parses directories', async () => {
const protocolsDir = makeEmptyDir()

const firstProtocolDirName = 'protocol_item_1'
const secondProtocolDirName = 'protocol_item_2'

const firstDirPath = path.join(protocolsDir, firstProtocolDirName)
const secondDirPath = path.join(protocolsDir, secondProtocolDirName)

return Promise.all([
fs.emptyDir(path.join(protocolsDir, firstProtocolDirName)),
fs.emptyDir(path.join(protocolsDir, firstProtocolDirName, 'src')),
fs.createFile(
path.join(protocolsDir, firstProtocolDirName, 'src', 'main.py')
),
fs.emptyDir(path.join(protocolsDir, firstProtocolDirName, 'analysis')),
fs.createFile(
path.join(
protocolsDir,
firstProtocolDirName,
'analysis',
'fake_timestamp0.json'
)
),
fs.emptyDir(path.join(protocolsDir, secondProtocolDirName)),
fs.emptyDir(path.join(protocolsDir, secondProtocolDirName, 'src')),
fs.createFile(
path.join(protocolsDir, secondProtocolDirName, 'src', 'main.json')
),
fs.emptyDir(path.join(protocolsDir, secondProtocolDirName, 'analysis')),
fs.createFile(
path.join(
protocolsDir,
secondProtocolDirName,
'analysis',
'fake_timestamp1.json'
)
),
]).then(() => {
return expect(
parseProtocolDirs([firstDirPath, secondDirPath])
).resolves.toEqual([
{
dirPath: firstDirPath,
modified: expect.any(Number),
srcFilePaths: [path.join(firstDirPath, 'src', 'main.py')],
analysisFilePaths: [
path.join(firstDirPath, 'analysis', 'fake_timestamp0.json'),
],
},
{
dirPath: secondDirPath,
modified: expect.any(Number),
srcFilePaths: [path.join(secondDirPath, 'src', 'main.json')],
analysisFilePaths: [
path.join(secondDirPath, 'analysis', 'fake_timestamp1.json'),
],
},
])
})
await fs.emptyDir(path.join(protocolsDir, firstProtocolDirName))
await fs.emptyDir(path.join(protocolsDir, firstProtocolDirName, 'src'))
await fs.emptyDir(
path.join(protocolsDir, firstProtocolDirName, 'analysis')
)
await fs.createFile(
path.join(protocolsDir, firstProtocolDirName, 'src', 'main.py')
)
await fs.createFile(
path.join(
protocolsDir,
firstProtocolDirName,
'analysis',
'fake_timestamp0.json'
)
)

await fs.emptyDir(path.join(protocolsDir, secondProtocolDirName))
await fs.emptyDir(path.join(protocolsDir, secondProtocolDirName, 'src'))
await fs.emptyDir(
path.join(protocolsDir, secondProtocolDirName, 'analysis')
)
await fs.createFile(
path.join(protocolsDir, secondProtocolDirName, 'src', 'main.json')
)
await fs.createFile(
path.join(
protocolsDir,
secondProtocolDirName,
'analysis',
'fake_timestamp1.json'
)
)

const result = await parseProtocolDirs([firstDirPath, secondDirPath])

expect(result).toEqual([
{
dirPath: firstDirPath,
modified: expect.any(Number),
srcFilePaths: [path.join(firstDirPath, 'src', 'main.py')],
analysisFilePaths: [
path.join(firstDirPath, 'analysis', 'fake_timestamp0.json'),
],
},
{
dirPath: secondDirPath,
modified: expect.any(Number),
srcFilePaths: [path.join(secondDirPath, 'src', 'main.json')],
analysisFilePaths: [
path.join(secondDirPath, 'analysis', 'fake_timestamp1.json'),
],
},
])
})
})

Expand Down

0 comments on commit cff47c9

Please sign in to comment.