diff --git a/spec/workspace-element-spec.js b/spec/workspace-element-spec.js index 228468d26..7564f6931 100644 --- a/spec/workspace-element-spec.js +++ b/spec/workspace-element-spec.js @@ -895,27 +895,39 @@ describe('WorkspaceElement', () => { // No active item. Use first project directory. atom.commands.dispatch(workspaceElement, 'window:run-package-specs') - expect(ipcRenderer.send).toHaveBeenCalledWith('run-package-specs', path.join(projectPaths[0], 'spec')) + expect(ipcRenderer.send).toHaveBeenCalledWith('run-package-specs', path.join(projectPaths[0], 'spec'), {}) ipcRenderer.send.reset() // Active item doesn't implement ::getPath(). Use first project directory. const item = document.createElement('div') atom.workspace.getActivePane().activateItem(item) atom.commands.dispatch(workspaceElement, 'window:run-package-specs') - expect(ipcRenderer.send).toHaveBeenCalledWith('run-package-specs', path.join(projectPaths[0], 'spec')) + expect(ipcRenderer.send).toHaveBeenCalledWith('run-package-specs', path.join(projectPaths[0], 'spec'), {}) ipcRenderer.send.reset() // Active item has no path. Use first project directory. item.getPath = () => null atom.commands.dispatch(workspaceElement, 'window:run-package-specs') - expect(ipcRenderer.send).toHaveBeenCalledWith('run-package-specs', path.join(projectPaths[0], 'spec')) + expect(ipcRenderer.send).toHaveBeenCalledWith('run-package-specs', path.join(projectPaths[0], 'spec'), {}) ipcRenderer.send.reset() // Active item has path. Use project path for item path. item.getPath = () => path.join(projectPaths[1], 'a-file.txt') atom.commands.dispatch(workspaceElement, 'window:run-package-specs') - expect(ipcRenderer.send).toHaveBeenCalledWith('run-package-specs', path.join(projectPaths[1], 'spec')) + expect(ipcRenderer.send).toHaveBeenCalledWith('run-package-specs', path.join(projectPaths[1], 'spec'), {}) ipcRenderer.send.reset() }) + + it("passes additional options to the spec window", () => { + const workspaceElement = atom.workspace.getElement() + spyOn(ipcRenderer, 'send') + + const projectPath = temp.mkdirSync('dir1-') + atom.project.setPaths([projectPath]) + workspaceElement.runPackageSpecs({env: {ATOM_GITHUB_BABEL_ENV: 'coverage'}}) + + expect(ipcRenderer.send).toHaveBeenCalledWith( + 'run-package-specs', path.join(projectPath, 'spec'), {env: {ATOM_GITHUB_BABEL_ENV: 'coverage'}}) + }) }) }) diff --git a/src/initialize-test-window.coffee b/src/initialize-test-window.coffee index c6aaada0e..4cbd02bfd 100644 --- a/src/initialize-test-window.coffee +++ b/src/initialize-test-window.coffee @@ -24,9 +24,13 @@ module.exports = ({blobStore}) -> ApplicationDelegate = require '../src/application-delegate' Clipboard = require '../src/clipboard' TextEditor = require '../src/text-editor' + {updateProcessEnv} = require('./update-process-env') require './electron-shims' - {testRunnerPath, legacyTestRunnerPath, headless, logFile, testPaths} = getWindowLoadSettings() + ipcRenderer.on 'environment', (event, env) -> + updateProcessEnv(env) + + {testRunnerPath, legacyTestRunnerPath, headless, logFile, testPaths, env} = getWindowLoadSettings() unless headless # Show window synchronously so a focusout doesn't fire on input elements @@ -59,6 +63,8 @@ module.exports = ({blobStore}) -> require('module').globalPaths.push(exportsPath) process.env.NODE_PATH = exportsPath # Set NODE_PATH env variable since tasks may need it. + updateProcessEnv(env) + # Set up optional transpilation for packages under test if any FindParentDir = require 'find-parent-dir' if packageRoot = FindParentDir.sync(testPaths[0], 'package.json') diff --git a/src/main-process/atom-application.js b/src/main-process/atom-application.js index cce859789..a9ff4f731 100644 --- a/src/main-process/atom-application.js +++ b/src/main-process/atom-application.js @@ -511,12 +511,12 @@ class AtomApplication extends EventEmitter { if (this.applicationMenu) this.applicationMenu.update(window, template, menu) })) - this.disposable.add(ipcHelpers.on(ipcMain, 'run-package-specs', (event, packageSpecPath) => { - this.runTests({ + this.disposable.add(ipcHelpers.on(ipcMain, 'run-package-specs', (event, packageSpecPath, options = {}) => { + this.runTests(Object.assign({ resourcePath: this.devResourcePath, pathsToOpen: [packageSpecPath], headless: false - }) + }, options)) })) this.disposable.add(ipcHelpers.on(ipcMain, 'run-benchmarks', (event, benchmarksPath) => { @@ -1168,6 +1168,7 @@ class AtomApplication extends EventEmitter { env }) this.addWindow(window) + if (env) window.replaceEnvironment(env) return window } diff --git a/src/workspace-element.js b/src/workspace-element.js index 5531aafdf..f94dbd6e9 100644 --- a/src/workspace-element.js +++ b/src/workspace-element.js @@ -310,7 +310,7 @@ class WorkspaceElement extends HTMLElement { } } - runPackageSpecs () { + runPackageSpecs (options = {}) { const activePaneItem = this.model.getActivePaneItem() const activePath = activePaneItem && typeof activePaneItem.getPath === 'function' ? activePaneItem.getPath() : null let projectPath @@ -326,7 +326,7 @@ class WorkspaceElement extends HTMLElement { specPath = testPath } - ipcRenderer.send('run-package-specs', specPath) + ipcRenderer.send('run-package-specs', specPath, options) } }