mirror of
https://github.com/pulsar-edit/pulsar.git
synced 2024-09-21 07:58:04 +03:00
First try to modernize the test runner
This commit is contained in:
parent
4a6f752ed1
commit
78fb1f8084
@ -365,7 +365,7 @@ module.exports = class AtomApplication extends EventEmitter {
|
||||
}
|
||||
|
||||
if (test) {
|
||||
return this.runTests({
|
||||
return this.runTestsLegacy({
|
||||
headless: true,
|
||||
devMode,
|
||||
resourcePath: this.resourcePath,
|
||||
@ -899,6 +899,24 @@ module.exports = class AtomApplication extends EventEmitter {
|
||||
ipcHelpers.on(
|
||||
ipcMain,
|
||||
'run-package-specs',
|
||||
(event, packageSpecPath, options = {}) => {
|
||||
this.runTestsLegacy(
|
||||
Object.assign(
|
||||
{
|
||||
resourcePath: this.devResourcePath,
|
||||
pathsToOpen: [packageSpecPath],
|
||||
headless: false
|
||||
},
|
||||
options
|
||||
)
|
||||
);
|
||||
}
|
||||
)
|
||||
);
|
||||
this.disposable.add(
|
||||
ipcHelpers.on(
|
||||
ipcMain,
|
||||
'run-package-tests',
|
||||
(event, packageSpecPath, options = {}) => {
|
||||
this.runTests(
|
||||
Object.assign(
|
||||
@ -1693,6 +1711,75 @@ module.exports = class AtomApplication extends EventEmitter {
|
||||
return this.packages;
|
||||
}
|
||||
|
||||
// Opens up a new {AtomWindow} to run specs within.
|
||||
//
|
||||
// options -
|
||||
// :headless - A Boolean that, if true, will close the window upon
|
||||
// completion.
|
||||
// :resourcePath - The path to include specs from.
|
||||
// :specPath - The directory to load specs from.
|
||||
runTests({
|
||||
headless,
|
||||
resourcePath,
|
||||
executedFrom,
|
||||
pathsToOpen,
|
||||
logFile,
|
||||
env
|
||||
}) {
|
||||
const testPaths = [];
|
||||
if (pathsToOpen != null) {
|
||||
for (let pathToOpen of pathsToOpen) {
|
||||
testPaths.push(path.resolve(executedFrom, fs.normalize(pathToOpen)));
|
||||
}
|
||||
}
|
||||
if (testPaths.length === 0) {
|
||||
process.stderr.write('Error: Specify at least one test path\n\n');
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
const windowInitializationScript = path.join(
|
||||
__dirname, "..", "initialize-new-test-window"
|
||||
);
|
||||
// {
|
||||
// windowInitializationScript: '/home/mauricio/projects/pulsar_repos/pulsar/src/initialize-test-window.js',
|
||||
// resourcePath: '/home/mauricio/projects/pulsar_repos/pulsar',
|
||||
// headless: false,
|
||||
// isSpec: true,
|
||||
// devMode: true,
|
||||
// testRunnerPath: '/home/mauricio/projects/pulsar_repos/pulsar/spec/jasmine-test-runner.js',
|
||||
// legacyTestRunnerPath: '/home/mauricio/projects/pulsar_repos/pulsar/spec/jasmine-test-runner.js',
|
||||
// testPaths: [ '/home/mauricio/projects/pulsar_repos/pulsar/spec' ],
|
||||
// logFile: undefined,
|
||||
// safeMode: false,
|
||||
// env: undefined
|
||||
// }
|
||||
|
||||
// WAAA {
|
||||
// windowInitializationScript: '/home/mauricio/projects/pulsar_repos/pulsar/src/initialize-new-test-window',
|
||||
// resourcePath: '/home/mauricio/projects/pulsar_repos/pulsar',
|
||||
// headless: false,
|
||||
// isSpec: true,
|
||||
// devMode: true,
|
||||
// testPaths: [ '/home/mauricio/projects/pulsar_repos/pulsar/spec' ],
|
||||
// logFile: undefined,
|
||||
// env: undefined
|
||||
// }
|
||||
|
||||
const window = this.createWindow({
|
||||
windowInitializationScript,
|
||||
resourcePath,
|
||||
headless,
|
||||
isSpec: true,
|
||||
devMode: true,
|
||||
testPaths,
|
||||
logFile,
|
||||
env
|
||||
});
|
||||
this.addWindow(window);
|
||||
if (env) window.replaceEnvironment(env);
|
||||
return window;
|
||||
}
|
||||
|
||||
// Opens up a new {AtomWindow} to run specs within.
|
||||
//
|
||||
// options -
|
||||
@ -1702,7 +1789,7 @@ module.exports = class AtomApplication extends EventEmitter {
|
||||
// :specPath - The directory to load specs from.
|
||||
// :safeMode - A Boolean that, if true, won't run specs from ~/.pulsar/packages
|
||||
// and ~/.pulsar/dev/packages, defaults to false.
|
||||
runTests({
|
||||
runTestsLegacy({
|
||||
headless,
|
||||
resourcePath,
|
||||
executedFrom,
|
||||
@ -1757,6 +1844,19 @@ module.exports = class AtomApplication extends EventEmitter {
|
||||
if (safeMode == null) {
|
||||
safeMode = false;
|
||||
}
|
||||
console.log("AW", {
|
||||
windowInitializationScript,
|
||||
resourcePath,
|
||||
headless,
|
||||
isSpec,
|
||||
devMode,
|
||||
testRunnerPath,
|
||||
legacyTestRunnerPath,
|
||||
testPaths,
|
||||
logFile,
|
||||
safeMode,
|
||||
env
|
||||
})
|
||||
const window = this.createWindow({
|
||||
windowInitializationScript,
|
||||
resourcePath,
|
||||
|
@ -144,6 +144,9 @@ module.exports = function({commandRegistry, commandInstaller, config, notificati
|
||||
'window:run-package-specs': function() {
|
||||
return this.runPackageSpecs();
|
||||
},
|
||||
'window:run-package-tests': function() {
|
||||
return this.runPackageTests();
|
||||
},
|
||||
'window:toggle-left-dock': function() {
|
||||
return this.getModel().getLeftDock().toggle();
|
||||
},
|
||||
|
@ -446,6 +446,29 @@ class WorkspaceElement extends HTMLElement {
|
||||
ipcRenderer.send('run-package-specs', specPath, options);
|
||||
}
|
||||
}
|
||||
|
||||
runPackageTests(options = {}) {
|
||||
const activePaneItem = this.model.getActivePaneItem();
|
||||
const activePath =
|
||||
activePaneItem && typeof activePaneItem.getPath === 'function'
|
||||
? activePaneItem.getPath()
|
||||
: null;
|
||||
let projectPath;
|
||||
if (activePath != null) {
|
||||
[projectPath] = this.project.relativizePath(activePath);
|
||||
} else {
|
||||
[projectPath] = this.project.getPaths();
|
||||
}
|
||||
if (projectPath) {
|
||||
let specPath = path.join(projectPath, 'spec');
|
||||
const testPath = path.join(projectPath, 'test');
|
||||
if (!fs.existsSync(specPath) && fs.existsSync(testPath)) {
|
||||
specPath = testPath;
|
||||
}
|
||||
|
||||
ipcRenderer.send('run-package-tests', specPath, options);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function isTab(element) {
|
||||
|
@ -210,6 +210,7 @@ module.exports = class Workspace extends Model {
|
||||
|
||||
this.scandalDirectorySearcher = new DefaultDirectorySearcher();
|
||||
this.ripgrepDirectorySearcher = new RipgrepDirectorySearcher();
|
||||
console.log("PACKAGE?", this.packageManager)
|
||||
this.consumeServices(this.packageManager);
|
||||
|
||||
this.paneContainers = {
|
||||
|
Loading…
Reference in New Issue
Block a user