diff --git a/.gitignore b/.gitignore index 2d53e09..bd88768 100644 --- a/.gitignore +++ b/.gitignore @@ -2,5 +2,6 @@ out bin server node_modules -.vscode-test -vscode-java-debug-*.vsix \ No newline at end of file +.vscode-test/ +vscode-java-debug-*.vsix +packages/ \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index eb17ceb..ad0dfaf 100644 --- a/package-lock.json +++ b/package-lock.json @@ -314,6 +314,45 @@ "integrity": "sha1-tf1UIgqivFq1eqtxQMlAdUUDwac=", "dev": true }, + "cross-env": { + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/cross-env/-/cross-env-5.2.0.tgz", + "integrity": "sha512-jtdNFfFW1hB7sMhr/H6rW1Z45LFqyI431m3qU6bFXcQ3Eh7LtBuG3h74o7ohHZ3crrRkkqHlo4jYHFPcjroANg==", + "dev": true, + "requires": { + "cross-spawn": "6.0.5", + "is-windows": "1.0.2" + }, + "dependencies": { + "is-windows": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/is-windows/-/is-windows-1.0.2.tgz", + "integrity": "sha512-eXK1UInq2bPmjyX6e3VHIzMLobc4J94i4AWn+Hpq3OU5KkrRC96OAcR3PRJ/pGu6m8TRnBHP9dkXQVsT/COVIA==", + "dev": true + } + } + }, + "cross-spawn": { + "version": "6.0.5", + "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-6.0.5.tgz", + "integrity": "sha512-eTVLrBSt7fjbDygz805pMnstIs2VTBNkRm0qxZd+M7A5XDdxVRWO5MxGBXZhjY4cqLYLdtrGqRf8mBPmzwSpWQ==", + "dev": true, + "requires": { + "nice-try": "1.0.4", + "path-key": "2.0.1", + "semver": "5.5.0", + "shebang-command": "1.2.0", + "which": "1.3.0" + }, + "dependencies": { + "semver": { + "version": "5.5.0", + "resolved": "https://registry.npmjs.org/semver/-/semver-5.5.0.tgz", + "integrity": "sha512-4SJ3dm0WAwWy/NVeioZh5AntkdJoWKxHxcmyP622fOkgHa4z3R0TdBJICINyaSDE6uNwVc8gZr+ZinwZAH4xIA==", + "dev": true + } + } + }, "cryptiles": { "version": "2.0.5", "resolved": "https://registry.npmjs.org/cryptiles/-/cryptiles-2.0.5.tgz", @@ -2143,6 +2182,12 @@ "integrity": "sha1-6f+EFBimsux6SV6TmYT3jxY+bjE=", "dev": true }, + "nice-try": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/nice-try/-/nice-try-1.0.4.tgz", + "integrity": "sha512-2NpiFHqC87y/zFke0fC0spBXL3bBsoh/p5H1EFhshxjCR5+0g2d6BiXbUFz9v1sAcxsk2htp2eQnNIci2dIYcA==", + "dev": true + }, "node.extend": { "version": "1.1.6", "resolved": "https://registry.npmjs.org/node.extend/-/node.extend-1.1.6.tgz", @@ -2343,6 +2388,12 @@ "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=", "dev": true }, + "path-key": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/path-key/-/path-key-2.0.1.tgz", + "integrity": "sha1-QRyttXTFoUDTpLGRDUDYDMn0C0A=", + "dev": true + }, "path-parse": { "version": "1.0.5", "resolved": "https://registry.npmjs.org/path-parse/-/path-parse-1.0.5.tgz", @@ -2615,6 +2666,57 @@ "integrity": "sha1-kM/xnQLgcCf9dn9erT57ldHnOAw=", "dev": true }, + "shebang-command": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-1.2.0.tgz", + "integrity": "sha1-RKrGW2lbAzmJaMOfNj/uXer98eo=", + "dev": true, + "requires": { + "shebang-regex": "1.0.0" + } + }, + "shebang-regex": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/shebang-regex/-/shebang-regex-1.0.0.tgz", + "integrity": "sha1-2kL0l0DAtC2yypcoVxyxkMmO/qM=", + "dev": true + }, + "shelljs": { + "version": "0.8.2", + "resolved": "https://registry.npmjs.org/shelljs/-/shelljs-0.8.2.tgz", + "integrity": "sha512-pRXeNrCA2Wd9itwhvLp5LZQvPJ0wU6bcjaTMywHHGX5XWhVN2nzSu7WV0q+oUY7mGK3mgSkDDzP3MgjqdyIgbQ==", + "dev": true, + "requires": { + "glob": "7.1.2", + "interpret": "1.0.3", + "rechoir": "0.6.2" + }, + "dependencies": { + "glob": { + "version": "7.1.2", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.2.tgz", + "integrity": "sha512-MJTUg1kjuLeQCJ+ccE4Vpa6kKVXkPYJ2mOCQyUuKLcLQsdrMCpBPUi8qVE6+YuaJkozeA9NusTAw3hLr8Xe5EQ==", + "dev": true, + "requires": { + "fs.realpath": "1.0.0", + "inflight": "1.0.6", + "inherits": "2.0.3", + "minimatch": "3.0.4", + "once": "1.4.0", + "path-is-absolute": "1.0.1" + } + }, + "minimatch": { + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", + "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", + "dev": true, + "requires": { + "brace-expansion": "1.1.8" + } + } + } + }, "sigmund": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/sigmund/-/sigmund-1.0.1.tgz", diff --git a/package.json b/package.json index 47a3d10..14f96f8 100644 --- a/package.json +++ b/package.json @@ -363,7 +363,7 @@ "vscode:prepublish": "tsc -p ./", "compile": "tsc -watch -p ./", "postinstall": "node ./node_modules/vscode/bin/install", - "test": "node ./node_modules/vscode/bin/test" + "test": "node ./scripts/download-vscode-for-system-tests && node ./scripts/install-vsix-dependencies redhat.java && node ./scripts/install-vsix-dependencies vscode-java-debug-0.9.0.vsix && node ./scripts/run-vscode-tests" }, "extensionDependencies": [ "redhat.java" @@ -371,9 +371,11 @@ "devDependencies": { "@types/mocha": "^2.2.32", "@types/node": "^6.0.40", + "cross-env": "^5.2.0", "gulp": "^3.9.1", "gulp-tslint": "^8.1.2", "mocha": "^2.3.3", + "shelljs": "^0.8.2", "tslint": "^5.7.0", "typescript": "^2.0.3", "vscode": "^1.1.6" diff --git a/scripts/download-vscode-for-system-tests.js b/scripts/download-vscode-for-system-tests.js new file mode 100644 index 0000000..23c2e6a --- /dev/null +++ b/scripts/download-vscode-for-system-tests.js @@ -0,0 +1,19 @@ +#!/usr/bin/env node + +const shell = require('shelljs'); + +// Downloads an instance of VS Code for tests + +if (shell.test('-e', '.vscode-test')) { + // Already downloaded the instance of vscode-test + shell.echo( + 'Using already downloaded instance in ' + shell.pwd() + '/.vscode-test' + ); +} else { + shell.echo( + 'Invoking ' + + shell.pwd() + + '/node_modules/vscode/bin/test for downloading VS Code' + ); + shell.exec('node ./node_modules/vscode/bin/test', { silent: true }); +} \ No newline at end of file diff --git a/scripts/install-vsix-dependencies.js b/scripts/install-vsix-dependencies.js new file mode 100644 index 0000000..6e91240 --- /dev/null +++ b/scripts/install-vsix-dependencies.js @@ -0,0 +1,59 @@ +#!/usr/bin/env node + +const path = require('path'); +const shell = require('shelljs'); +const glob = require('glob'); + +// Installs a list of extensions passed on the command line +var version = process.env.CODE_VERSION || '*'; +var isInsiders = version === 'insiders'; + +const testRunFolder = path.join( + '.vscode-test', + isInsiders ? 'insiders' : 'stable' +); +const testRunFolderAbsolute = path.join(process.cwd(), testRunFolder); +const codeExecutives = glob.sync('./.vscode-test/**/bin/code'); +const windowsExecutable = codeExecutives[0].replace(/\//g, '\\'); +const darwinExecutable = codeExecutives[0] || path.join( + testRunFolderAbsolute, + 'Visual Studio Code.app', + 'Contents', + 'Resources', + 'app', + 'bin', + 'code' +); +const linuxExecutable = codeExecutives[0] || path.join( + testRunFolderAbsolute, + 'VSCode-linux-x64', + 'bin', + 'code' +); + +const extensionsDir = path.join(__dirname, '..', 'packages'); + +const executable = + process.platform === 'darwin' + ? darwinExecutable + : process.platform === 'win32' ? windowsExecutable : linuxExecutable; + +if (process.platform === 'linux') { + // Somehow the code executable doesn't have +x set on the autobuilds -- set it here + shell.chmod('+x', `${executable}`); +} + +// We always invoke this script with 'node install-vsix-dependencies arg' +// so position2 is where the first argument is +for (let arg = 2; arg < process.argv.length; arg++) { + if (process.platform === 'win32') { + // Windows Powershell doesn't like the single quotes around the executable + shell.exec( + `${executable} --extensions-dir ${extensionsDir} --install-extension ${process.argv[arg]}` + ); + } else { + shell.exec( + `'${executable}' --extensions-dir ${extensionsDir} --install-extension ${process.argv[arg]}` + ); + } +} \ No newline at end of file diff --git a/scripts/run-vscode-tests.js b/scripts/run-vscode-tests.js new file mode 100644 index 0000000..7b810bc --- /dev/null +++ b/scripts/run-vscode-tests.js @@ -0,0 +1,14 @@ +#!/usr/bin/env node + +const shell = require('shelljs'); +shell.set('-e'); +shell.set('+v'); + +const path = require('path'); +shell.exec( + `cross-env CODE_EXTENSIONS_PATH='${path.join( + __dirname, + '..', + 'packages' + )}' node ./node_modules/vscode/bin/test` +); \ No newline at end of file