From bc4a22f97a623aed0809052b42dd3fa60d861a3a Mon Sep 17 00:00:00 2001 From: Ash Wilson Date: Wed, 17 Apr 2019 10:22:51 -0400 Subject: [PATCH] Resolve root and editor paths during spec parsing for consistency --- .../main-process/atom-application.new.test.js | 36 ++++++++++++++----- 1 file changed, 28 insertions(+), 8 deletions(-) diff --git a/spec/main-process/atom-application.new.test.js b/spec/main-process/atom-application.new.test.js index e11c62e3b..411f4346d 100644 --- a/spec/main-process/atom-application.new.test.js +++ b/spec/main-process/atom-application.new.test.js @@ -153,14 +153,19 @@ class LaunchScenario { const app = this.addApplication() const windowPromises = [] for (const windowSpec of this.parseWindowSpecs(source)) { - const fullRootPaths = windowSpec.roots.map(rootPath => this.projectRootPool.get(rootPath)) - const fullEditorPaths = windowSpec.editors.map(filePath => this.filePathPool.get(filePath)) + const expectOpenEvent = windowSpec.roots.length > 0 || windowSpec.editors.length > 0 + + if (windowSpec.editors.length === 0) { + windowSpec.editors.push(null) + } windowPromises.push((async (theApp, foldersToOpen, pathsToOpen) => { const window = await theApp.openPaths({ newWindow: true, foldersToOpen, pathsToOpen }) - await emitterEventPromise(window, 'window:locations-opened') + if (expectOpenEvent) { + await emitterEventPromise(window, 'window:locations-opened') + } return window - })(app, fullRootPaths, fullEditorPaths)) + })(app, windowSpec.roots, windowSpec.editors)) } for (const window of await Promise.all(windowPromises)) { this.windows.add(window) @@ -396,6 +401,22 @@ class LaunchScenario { return [missing, extra] } + convertRootPath (shortRootPath) { + const fullRootPath = this.projectRootPool.get(shortRootPath) + if (!fullRootPath) { + throw new Error(`Unexpected short project root path: ${shortRootPath}`) + } + return fullRootPath + } + + convertEditorPath (shortEditorPath) { + const fullEditorPath = this.filePathPool.get(shortEditorPath) + if (!fullEditorPath) { + throw new Error(`Unexpected short editor path: ${shortEditorPath}`) + } + return fullEditorPath + } + convertPaths (paths) { return paths.map(shortPath => { const fullRoot = this.projectRootPool.get(shortPath) @@ -413,10 +434,9 @@ class LaunchScenario { let match = rx.exec(source) while (match) { - specs.push({ - roots: (match[1] || '').split(','), - editors: (match[2] || '').split(',') - }) + const roots = match[1] ? match[1].split(',').map(shortPath => this.convertRootPath(shortPath)) : [] + const editors = match[2] ? match[2].split(',').map(shortPath => this.convertEditorPath(shortPath)) : [] + specs.push({ roots, editors }) match = rx.exec(source) }