diff --git a/node_modules/.package-lock.json b/node_modules/.package-lock.json new file mode 100644 index 00000000..1f086fec --- /dev/null +++ b/node_modules/.package-lock.json @@ -0,0 +1,12 @@ +{ + "name": "cobol-check", + "lockfileVersion": 3, + "requires": true, + "packages": { + "node_modules/kill-process-by-name": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/kill-process-by-name/-/kill-process-by-name-1.0.5.tgz", + "integrity": "sha512-uxgO15GtTsK5ofd/c17saZ7GagZEJrMt5VY4AL5X+vVS3kw5uHfzyIk5+npRD8gowWvx3cB37vrCy/yr0PyD8A==" + } + } +} diff --git a/node_modules/kill-process-by-name/LICENSE b/node_modules/kill-process-by-name/LICENSE new file mode 100644 index 00000000..f276eec7 --- /dev/null +++ b/node_modules/kill-process-by-name/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2019 rwolf449 + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/node_modules/kill-process-by-name/README.md b/node_modules/kill-process-by-name/README.md new file mode 100644 index 00000000..1d79b78b --- /dev/null +++ b/node_modules/kill-process-by-name/README.md @@ -0,0 +1,47 @@ +Kill-Process-By-Name +========= + +Kill all processes of a program with the programname. + + +Examples +======= + +Kill every process with the name "electron": + +```js +var killProcess = require('kill-process-by-name'); + +killProcess('electron'); +``` + +You don´t have to add any file endings, typing in the name of the program is enough. + +Install +======= + +With [npm](https://npmjs.org) do: + +``` +npm install kill-process-by-name +``` + +License +======= + +MIT + +Changelog +========= + +## [1.0.1] - 2019-03-07 +### Added +- README.md + +## [1.0.2] - 2019-03-07 +### Changed +- README.md + +## [1.0.5] - 2019-03-07 +### Removed +- Console.log \ No newline at end of file diff --git a/node_modules/kill-process-by-name/index.js b/node_modules/kill-process-by-name/index.js new file mode 100644 index 00000000..e567ad15 --- /dev/null +++ b/node_modules/kill-process-by-name/index.js @@ -0,0 +1,15 @@ +'use strict'; + +var childProcess = require('child_process'); +var exec = childProcess.exec; + +module.exports = function (programname) { + switch(process.platform) { + case 'win32': + exec('taskkill /F /IM ' + programname + '.exe /T'); + break; + default: //Linux + Darwin + exec('pkill -f ' + programname); + break; + } +} \ No newline at end of file diff --git a/node_modules/kill-process-by-name/package.json b/node_modules/kill-process-by-name/package.json new file mode 100644 index 00000000..10040136 --- /dev/null +++ b/node_modules/kill-process-by-name/package.json @@ -0,0 +1,18 @@ +{ + "name": "kill-process-by-name", + "version": "1.0.5", + "description": "Kills all processes by a certain program", + "main": "index.js", + "scripts": { + "test": "mocha" + }, + "keywords": [ + "Process", + "killall", + "kill", + "subprocess", + "child" + ], + "author": "Richard Wolf", + "license": "MIT" +} diff --git a/package-lock.json b/package-lock.json new file mode 100644 index 00000000..d204594a --- /dev/null +++ b/package-lock.json @@ -0,0 +1,17 @@ +{ + "name": "cobol-check", + "lockfileVersion": 3, + "requires": true, + "packages": { + "": { + "dependencies": { + "kill-process-by-name": "^1.0.5" + } + }, + "node_modules/kill-process-by-name": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/kill-process-by-name/-/kill-process-by-name-1.0.5.tgz", + "integrity": "sha512-uxgO15GtTsK5ofd/c17saZ7GagZEJrMt5VY4AL5X+vVS3kw5uHfzyIk5+npRD8gowWvx3cB37vrCy/yr0PyD8A==" + } + } +} diff --git a/package.json b/package.json new file mode 100644 index 00000000..20866dbd --- /dev/null +++ b/package.json @@ -0,0 +1,5 @@ +{ + "dependencies": { + "kill-process-by-name": "^1.0.5" + } +} diff --git a/vs-code-extension/Cobol-check/scripts/windows_gnucobol_run_tests.cmd b/vs-code-extension/Cobol-check/scripts/windows_gnucobol_run_tests.cmd index e0c2d9ba..0938bcc2 100644 --- a/vs-code-extension/Cobol-check/scripts/windows_gnucobol_run_tests.cmd +++ b/vs-code-extension/Cobol-check/scripts/windows_gnucobol_run_tests.cmd @@ -4,7 +4,4 @@ rem rem Assumptions: rem rem GnuCOBOL 3.+ is installed and on the path. Its executable or alias or symlink is named "cobc". -%~d1 -cd %~p1 -cobc -xj %* -%~n1 \ No newline at end of file +cobc -xj %* \ No newline at end of file diff --git a/vs-code-extension/client/src/services/CobolCheckLauncher.ts b/vs-code-extension/client/src/services/CobolCheckLauncher.ts index fb8fca2d..af4b5779 100644 --- a/vs-code-extension/client/src/services/CobolCheckLauncher.ts +++ b/vs-code-extension/client/src/services/CobolCheckLauncher.ts @@ -3,6 +3,9 @@ import { integer } from 'vscode-languageclient'; import * as LOGGER from '../utils/Logger' import * as CobParser from './CobolCheckOutputParser' import { getConfigurationValueFor } from './CobolCheckConfiguration'; +import { subProcess, subProcessSync } from 'subspawn'; + + const windowsPlatform = 'Windows'; const macPlatform = 'MacOS'; @@ -71,7 +74,7 @@ export function getCobolCheckRunArgumentsBasedOnSuiteDirectory(vsCodeInstallPath } export async function runCobolCheck(path : string, commandLineArgs : string) : Promise { - return new Promise(async resolve => { + return new Promise(async (resolve, reject) => { // Getting the right command based on platform let executeJarCommand = ''; if (currentPlatform === windowsPlatform){ @@ -86,15 +89,21 @@ export async function runCobolCheck(path : string, commandLineArgs : string) : P LOGGER.log("Running Cobol Check with arguments: " + commandLineArgs, LOGGER.INFO) try{ + var killProcess = require('kill-process-by-name'); + let maxWaitMillisec = vscode.workspace.getConfiguration("cut").maxWaitTime; + LOGGER.log("MAX WAIT TIME SET TO: " + maxWaitMillisec, LOGGER.INFO); var exec = require('child_process').exec; const testPath = appendPath(externalVsCodeInstallationDir, "Cobol-check"); // fix for MacOS const tmpStr = "cd " + testPath + " && " + //Run Cobol Check jar with arguments - var child = exec(tmpStr + executeJarCommand + ' ' + commandLineArgs, (error : string, stdout : string, stderr : string) => { + var child = exec(tmpStr + executeJarCommand + ' ' + commandLineArgs, {timeout:maxWaitMillisec}, (error : string, stdout : string, stderr : string) => { if(error !== null){ LOGGER.log("*** COBOL CHECK ERROR: " + error, LOGGER.ERROR); } + killProcess('cobc'); + LOGGER.log("child.pid: " + child.pid, LOGGER.INFO); LOGGER.log("Cobol Check out:\n" + stdout, LOGGER.INFO) LOGGER.log("Cobol Check log:\n" + stderr, LOGGER.INFO) resolve(new CobParser.CobolCheckOutputParser(stdout, stderr, error)) diff --git a/vs-code-extension/package.json b/vs-code-extension/package.json index a34c8d4c..8097812b 100644 --- a/vs-code-extension/package.json +++ b/vs-code-extension/package.json @@ -26,7 +26,8 @@ ], "main": "./client/out/extension", "contributes": { - "languages": [ { + "languages": [ + { "id": "cut", "aliases": [ "COBOL unit test", @@ -55,6 +56,11 @@ "type": "object", "title": "COBOL unit test syntax", "properties": { + "cut.maxWaitTime": { + "type": "number", + "default": 5000, + "description": "Max wait time before kill the process." + }, "cut.maxNumberOfProblems": { "scope": "resource", "type": "number", @@ -186,6 +192,8 @@ "typescript": "^4.9.5" }, "dependencies": { - "@types/vscode-webview": "^1.57.0" + "@types/vscode-webview": "^1.57.0", + "kill-process-by-name": "^1.0.5", + "subspawn": "^1.0.2" } }