From edb5aff81097d9a4b06d92e40919bbda919d8b17 Mon Sep 17 00:00:00 2001 From: Atsuo INOUE Date: Wed, 18 Aug 2021 02:03:18 +0900 Subject: [PATCH 1/3] Add Run and Debug buttons to Spec Explorer Signed-off-by: Atsuo INOUE --- package.json | 32 ++++++++++++++++++++++++++++++++ src/constants.ts | 2 ++ src/execution/debug.ts | 6 +++--- src/execution/lineProcessors.ts | 4 ++-- src/explorer/specExplorer.ts | 16 +++++++++++++++- 5 files changed, 54 insertions(+), 6 deletions(-) diff --git a/package.json b/package.json index e7c7c3d..59dcf68 100644 --- a/package.json +++ b/package.json @@ -115,6 +115,18 @@ "dark": "resources/dark/play.svg" } }, + { + "command": "gauge.specexplorer.runNode", + "title": "Run", + "category": "Gauge", + "icon": "$(debug-start)" + }, + { + "command": "gauge.specexplorer.debugNode", + "title": "Debug", + "category": "Gauge", + "icon": "$(bug)" + }, { "command": "gauge.execute.scenario", "title": "Run Scenario", @@ -193,6 +205,14 @@ { "command": "gauge.specexplorer.runAllActiveProjectSpecs", "when": "false" + }, + { + "command": "gauge.specexplorer.runNode", + "when": "false" + }, + { + "command": "gauge.specexplorer.debugNode", + "when": "false" } ], "view/title": [ @@ -206,6 +226,18 @@ "when": "view == gauge:specExplorer", "group": "navigation" } + ], + "view/item/context": [ + { + "command": "gauge.specexplorer.runNode", + "when": "view == gauge:specExplorer", + "group": "inline" + }, + { + "command": "gauge.specexplorer.debugNode", + "when": "view == gauge:specExplorer", + "group": "inline" + } ] }, "configuration": { diff --git a/src/constants.ts b/src/constants.ts index cd398ba..7c61a5a 100644 --- a/src/constants.ts +++ b/src/constants.ts @@ -22,6 +22,8 @@ export enum GaugeVSCodeCommands { ExecuteSpec = 'gauge.execute.specification', ExecuteAllSpecs = 'gauge.execute.specification.all', ExecuteAllSpecExplorer = 'gauge.specexplorer.runAllActiveProjectSpecs', + ExecuteNode = 'gauge.specexplorer.runNode', + DebugNode = 'gauge.specexplorer.debugNode', ExecuteScenario = 'gauge.execute.scenario', ExecuteScenarios = 'gauge.execute.scenarios', GenerateStepStub = 'gauge.generate.step', diff --git a/src/execution/debug.ts b/src/execution/debug.ts index 3e20197..17d49e3 100644 --- a/src/execution/debug.ts +++ b/src/execution/debug.ts @@ -1,7 +1,7 @@ 'use strict'; import getPort = require('get-port'); -import { debug, DebugSession, window, workspace } from 'vscode'; +import { debug, DebugSession, Uri, workspace } from 'vscode'; import { GaugeRunners } from '../constants'; import { GaugeClients } from '../gaugeClients'; import { ExecutionConfig } from './executionConfig'; @@ -135,8 +135,8 @@ export class GaugeDebugger { public startDebugger() { return new Promise((res, rej) => { - let folder = workspace.getWorkspaceFolder(window.activeTextEditor.document.uri); - let root = this.clientsMap.get(window.activeTextEditor.document.uri.fsPath).project.root(); + const root = this.config.getProject().root(); + const folder = workspace.getWorkspaceFolder(Uri.parse(root)); if (!folder) { throw new Error(`The debugger does not work for a stand alone file. Please open the folder ${root}.`); } diff --git a/src/execution/lineProcessors.ts b/src/execution/lineProcessors.ts index 6a1c580..6fba5b2 100644 --- a/src/execution/lineProcessors.ts +++ b/src/execution/lineProcessors.ts @@ -44,8 +44,8 @@ export class DebuggerAttachedEventProcessor extends BaseProcessor { public process(lineText: string, gaugeDebugger: GaugeDebugger): void { if (!this.canProcess(lineText)) return; gaugeDebugger.addProcessId(+lineText.replace(/^\D+/g, '')); - gaugeDebugger.startDebugger().catch((reason) => { - window.showErrorMessage(reason); + gaugeDebugger.startDebugger().catch(error => { + window.showErrorMessage(`Failed to start debugger: ${error.message}`); this.executor.cancel(false); }); } diff --git a/src/explorer/specExplorer.ts b/src/explorer/specExplorer.ts index 0b7d3a5..aa79601 100644 --- a/src/explorer/specExplorer.ts +++ b/src/explorer/specExplorer.ts @@ -69,7 +69,21 @@ export class SpecNodeProvider extends Disposable implements vscode.TreeDataProvi }), commands.registerCommand(GaugeVSCodeCommands.Open, (node: GaugeNode) => workspace.openTextDocument(node.file) - .then(this.showDocumentWithSelection(node))) + .then(this.showDocumentWithSelection(node))), + + commands.registerCommand(GaugeVSCodeCommands.ExecuteNode, (node: GaugeNode) => + this.gaugeWorkspace.getGaugeExecutor().execute( + node instanceof Scenario ? node.executionIdentifier : node.file, + new ExecutionConfig().setStatus(node.file) + .setProject(this.gaugeWorkspace.getClientsMap().get(node.file).project)) + ), + + commands.registerCommand(GaugeVSCodeCommands.DebugNode, (node: GaugeNode) => + this.gaugeWorkspace.getGaugeExecutor().execute( + node instanceof Scenario ? node.executionIdentifier : node.file, + new ExecutionConfig().setStatus(node.file).setDebug() + .setProject(this.gaugeWorkspace.getClientsMap().get(node.file).project)) + ) ); } } From 9952432d8a639ed37430e8f81a491e11eadb7c48 Mon Sep 17 00:00:00 2001 From: Atsuo INOUE Date: Sat, 28 Aug 2021 01:39:17 +0900 Subject: [PATCH 2/3] Replace false to config.noExists Signed-off-by: Atsuo INOUE --- package.json | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/package.json b/package.json index 59dcf68..1cd0a19 100644 --- a/package.json +++ b/package.json @@ -160,7 +160,7 @@ }, { "command": "gauge.specexplorer.switchProject", - "when": "false" + "when": "config.noExists" }, { "command": "gauge.execute.repeat", @@ -204,15 +204,15 @@ }, { "command": "gauge.specexplorer.runAllActiveProjectSpecs", - "when": "false" + "when": "config.noExists" }, { "command": "gauge.specexplorer.runNode", - "when": "false" + "when": "config.noExists" }, { "command": "gauge.specexplorer.debugNode", - "when": "false" + "when": "config.noExists" } ], "view/title": [ From be724258f506b95475caec5522cb8d99cf31a43a Mon Sep 17 00:00:00 2001 From: Atsuo INOUE Date: Sat, 4 Sep 2021 18:02:15 +0900 Subject: [PATCH 3/3] bumped to 0.0.21 Signed-off-by: Atsuo INOUE --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 557aa49..9aa90eb 100644 --- a/package.json +++ b/package.json @@ -8,7 +8,7 @@ "description": "Gauge support for VScode.", "author": "ThoughtWorks", "license": "MIT", - "version": "0.0.20", + "version": "0.0.21", "publisher": "getgauge", "engines": { "vscode": "^1.59.0"