mirror of
https://github.com/atom/atom.git
synced 2026-04-06 03:02:13 -04:00
Weird-ass concurrent mkdir() error
This commit is contained in:
@@ -11,7 +11,7 @@ import FileSystemManager, {stopAllWatchers} from '../src/filesystem-manager'
|
||||
tempCb.track()
|
||||
|
||||
const fs = promisifySome(fsCb, ['writeFile', 'mkdir', 'symlink', 'appendFile', 'realpath'])
|
||||
const temp = promisifySome(tempCb, ['mkdir', 'cleanup'])
|
||||
const temp = promisifySome(tempCb, ['mkdir'])
|
||||
|
||||
describe('FileSystemManager', function () {
|
||||
let subs, manager
|
||||
@@ -51,7 +51,7 @@ describe('FileSystemManager', function () {
|
||||
|
||||
describe('getWatcher()', function () {
|
||||
it('resolves getStartPromise() when the watcher begins listening', async function () {
|
||||
const rootDir = await temp.mkdir('atom-fsmanager-')
|
||||
const rootDir = await temp.mkdir('atom-fsmanager-test-')
|
||||
|
||||
const watcher = manager.getWatcher(rootDir)
|
||||
watcher.onDidChange(() => {})
|
||||
@@ -60,7 +60,7 @@ describe('FileSystemManager', function () {
|
||||
})
|
||||
|
||||
it('does not start actually watching until an onDidChange subscriber is registered', async function () {
|
||||
const rootDir = await temp.mkdir('atom-fsmanager-')
|
||||
const rootDir = await temp.mkdir('atom-fsmanager-test-')
|
||||
const watcher = manager.getWatcher(rootDir)
|
||||
|
||||
let started = false
|
||||
@@ -86,7 +86,7 @@ describe('FileSystemManager', function () {
|
||||
})
|
||||
|
||||
it('automatically stops and removes the watcher when all onDidChange subscribers dispose', async function () {
|
||||
const dir = await temp.mkdir('atom-fsmanager-')
|
||||
const dir = await temp.mkdir('atom-fsmanager-test-')
|
||||
const watcher = manager.getWatcher(dir)
|
||||
|
||||
const sub0 = watcher.onDidChange(() => {})
|
||||
@@ -107,7 +107,7 @@ describe('FileSystemManager', function () {
|
||||
})
|
||||
|
||||
it('reuses an existing native watcher and resolves getStartPromise immediately if attached to a running watcher', async function () {
|
||||
const rootDir = await temp.mkdir('atom-fsmanager-')
|
||||
const rootDir = await temp.mkdir('atom-fsmanager-test-')
|
||||
|
||||
const watcher0 = manager.getWatcher(rootDir)
|
||||
watcher0.onDidChange(() => {})
|
||||
@@ -121,7 +121,7 @@ describe('FileSystemManager', function () {
|
||||
})
|
||||
|
||||
it("reuses existing native watchers even while they're still starting", async function () {
|
||||
const rootDir = await temp.mkdir('atom-fsmanager-')
|
||||
const rootDir = await temp.mkdir('atom-fsmanager-test-')
|
||||
|
||||
const watcher0 = manager.getWatcher(rootDir)
|
||||
watcher0.onDidChange(() => {})
|
||||
@@ -138,7 +138,7 @@ describe('FileSystemManager', function () {
|
||||
})
|
||||
|
||||
it("doesn't attach new watchers to a native watcher that's stopping", async function () {
|
||||
const rootDir = await temp.mkdir('atom-fsmanager-')
|
||||
const rootDir = await temp.mkdir('atom-fsmanager-test-')
|
||||
|
||||
const watcher0 = manager.getWatcher(rootDir)
|
||||
const sub = watcher0.onDidChange(() => {})
|
||||
@@ -154,7 +154,7 @@ describe('FileSystemManager', function () {
|
||||
})
|
||||
|
||||
it('reuses an existing native watcher on a parent directory and filters events', async function () {
|
||||
const rootDir = await temp.mkdir('atom-fsmanager-0-').then(fs.realpath)
|
||||
const rootDir = await temp.mkdir('atom-fsmanager-test-').then(fs.realpath)
|
||||
const rootFile = path.join(rootDir, 'rootfile.txt')
|
||||
const subDir = path.join(rootDir, 'subdir')
|
||||
const subFile = path.join(subDir, 'subfile.txt')
|
||||
@@ -190,23 +190,21 @@ describe('FileSystemManager', function () {
|
||||
})
|
||||
|
||||
it('adopts existing child watchers and filters events appropriately to them', async function () {
|
||||
const parentDir = await temp.mkdir('atom-fsmanager-').then(fs.realpath)
|
||||
const parentDir = await temp.mkdir('atom-fsmanager-test-').then(fs.realpath)
|
||||
|
||||
// Create the directory tree
|
||||
const rootFile = path.join(parentDir, 'rootfile.txt')
|
||||
const subDir0 = path.join(parentDir, 'subdir0')
|
||||
const subFile0 = path.join(subDir0, 'subfile1.txt')
|
||||
const subFile0 = path.join(subDir0, 'subfile0.txt')
|
||||
const subDir1 = path.join(parentDir, 'subdir1')
|
||||
const subFile1 = path.join(subDir1, 'subfile1.txt')
|
||||
|
||||
await fs.mkdir(subDir0)
|
||||
await fs.mkdir(subDir1)
|
||||
await Promise.all([
|
||||
fs.writeFile(rootFile, 'rootfile\n', {encoding: 'utf8'}),
|
||||
fs.mkdir(subDir0).then(
|
||||
fs.writeFile(subFile0, 'subfile 0\n', {encoding: 'utf8'})
|
||||
),
|
||||
fs.mkdir(subDir1).then(
|
||||
fs.writeFile(subFile1, 'subfile 1\n', {encoding: 'utf8'})
|
||||
)
|
||||
fs.writeFile(subFile0, 'subfile 0\n', {encoding: 'utf8'}),
|
||||
fs.writeFile(subFile1, 'subfile 1\n', {encoding: 'utf8'})
|
||||
])
|
||||
|
||||
// Begin the child watchers and keep them alive
|
||||
|
||||
Reference in New Issue
Block a user