Setup the skeleton of extension code (#317)

This commit is contained in:
Sheng Chen 2018-09-26 15:32:27 +08:00
Родитель c3d9794073
Коммит 0345683f10
15 изменённых файлов: 8269 добавлений и 14 удалений

Просмотреть файл

@ -1,31 +1,27 @@
language: node_js
node_js:
- '--lts'
- 'lts/*'
os:
- linux
- osx
env:
- CODE_VERSION="1.23.0"
before_install:
- if [ $TRAVIS_OS_NAME == "linux" ]; then
export CXX="g++-4.9" CC="gcc-4.9" DISPLAY=:99.0;
sh -e /etc/init.d/xvfb start;
sleep 3;
fi
# - cd extension
- chmod +x mvnw
- cd extension
# install:
# - npm install -g vsce
# - npm install -g typescript
# - npm install -g gulp
# - npm install
install:
- npm install -g vsce
- npm install
script:
- echo "CI for Java Test Runner"
# - gulp tslint
# - vsce package
# - npm test --silent
- gulp lint
- gulp build-server
- vsce package
- npm test --silent

6
extension/.gitignore поставляемый Normal file
Просмотреть файл

@ -0,0 +1,6 @@
out
node_modules
*.vsix
.vscode-test
.vscode
resources/templates/css/*.css

11
extension/.vscodeignore Normal file
Просмотреть файл

@ -0,0 +1,11 @@
.vscode/**
.vscode-test/**
out/test/**
test/**
src/**
**/*.map
.gitignore
.travis.yml
tsconfig.json
tslint.json
package-lock.json

103
extension/CHANGELOG.md Normal file
Просмотреть файл

@ -0,0 +1,103 @@
# Change Log
All notable changes to the "vscode-java-test" extension will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
## 0.8.0 - 2018-08-08
### Changed
- Refine the logic to consume test output for JUnit test runner.
### Fixed
- Add project info into `TestSuite`, and run the tests per project to avoid the conflict of classpaths between projects.
- Fix the issue that test output would be truncated when it exceeds buffer size.
## 0.7.1 - 2018-07-11
### Fixed
- Fix the issue that the test runer hangs for some tests.
- Fix classpath resolution issue for the scenario that there are multiple projects in a workspace folder. [#176](https://github.com/Microsoft/vscode-java-test/issues/176)
- Fix bug for default working directory. [#229](https://github.com/Microsoft/vscode-java-test/issues/229)
- Fix bug for test output analyzer. [#231](https://github.com/Microsoft/vscode-java-test/issues/231)
- Add environment variable into test configuration schema.(Thanks @thwfreak for contributing the [pull request](https://github.com/Microsoft/vscode-java-test/pull/225))
- Fix bug for environment variables in the test configuration. [#222](https://github.com/Microsoft/vscode-java-test/issues/222)
## 0.7.0 - 2018-06-26
### Added
- Support configuring environment variables in test configuration.
### Changed
- Move test explorer to Test View container(Thanks @sandy081 for contributing to the [pull request](https://github.com/Microsoft/vscode-java-test/commit/79e0c376a0f25aef520ee3cd877d368ee677d34c).)
- Auto refresh test report when files update. And still show previous test report until user reruns the test.
### Fixed
- Fix bug [#205](https://github.com/Microsoft/vscode-java-test/issues/205) and [#198](https://github.com/Microsoft/vscode-java-test/issues/198). Update classpath when user updates build files.
- Fix bug [#216](https://github.com/Microsoft/vscode-java-test/issues/216).
## 0.6.0 - 2018-04-27
### Added
- Support cancelling a test run. Partial test result would be updated.
- Add JSON schema validation for test configuration file.
- Add `default` field in test configuration where user could specify the default config to pick while invoking command `Run Test`.
### Changed
- Behavior change: after a test run, always show the test report and update test status(might be partial) even when test runner failed.
- Removed `Run With Config` and `Debug with Config` codelens for simplicity. Still, you can invoke the command from test explorer.
- Renamed the test configuration file from `test-launch.json` to `launch.test.json`. Original test configuration file won't be removed, but you might need to copy its content to the new one if you have customized config.
## 0.5.0 - 2018-03-29
### Added
- Support test configuration. You can now configure your test setting through command `java.test.configure`. It supports following configuration:
* projectName
* workingDirectory
* args
* vmargs
* preLaunchTask
And you can run/debug with config through codelens or test explorer context menu.
## 0.4.0 - 2018-03-07
### Added
- Support basic feature of JUnit5
### Fixed
- Fix bug [#99](https://github.com/Microsoft/vscode-java-test/issues/99)
- Fix bug [#130](https://github.com/Microsoft/vscode-java-test/issues/130)
## 0.3.0 - 2018-02-11
### Added
- Trigger tests from test explorer. We now support folder/package/class/method levels or you can run all.
- Add command `Java:Open Log` to open log file.
- Add setting `java.test.report.position` to specify the position of test report.
### Fixed
- Fix bug [#83](https://github.com/Microsoft/vscode-java-test/issues/83)
- Fix bug [#86](https://github.com/Microsoft/vscode-java-test/issues/86)
- Fix bug [#90](https://github.com/Microsoft/vscode-java-test/issues/90)
- Fix bug that test explorer would disappear when opening test report.
## 0.2.0 - 2018-01-05
### Added
- Add Test explorer, you can view/locate all tests from the explorer.
- Add status bar item to show test status and statistics.
- Add command to show test output window. By default it wouldn't be open while running tests.
### Changed
- Make test report more user friendly. No need to save test report any more
### Fixed
- Fix bug [#34](https://github.com/Microsoft/vscode-java-test/issues/34)
## 0.1.0 - 2017-12-01
### Added
- Support JUnit (v4.8.0+) test cases
- Run test cases
- Debug test cases
- View test logs

17
extension/LICENSE.txt Normal file
Просмотреть файл

@ -0,0 +1,17 @@
------------------------------------------ START OF LICENSE -----------------------------------------
vscode-java-test
Copyright (c) Microsoft Corporation
All rights reserved.
MIT License
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.
----------------------------------------------- END OF LICENSE ------------------------------------------

50
extension/README.md Normal file
Просмотреть файл

@ -0,0 +1,50 @@
# Java Test Runner
[![Travis CI](https://travis-ci.org/Microsoft/vscode-java-test.svg?branch=master)](https://travis-ci.org/Microsoft/vscode-java-test)
## Overview
A lightweight extension to run and debug Java test cases in Visual Studio Code. It works with [Language Support for Java by Red Hat](https://marketplace.visualstudio.com/items?itemName=redhat.java) and [Debugger for Java](https://marketplace.visualstudio.com/items?itemName=vscjava.vscode-java-debug) to provide the following features:
- Support JUnit (v4.8.0+) test cases
- Run test cases
- Debug test cases
- View test logs
- View test report
- Test Explorer
- Test Configuration
- Cancel a test run
## Use
![Run/debug JUnit test](https://raw.githubusercontent.com/Microsoft/vscode-java-test/master/extension/demo/junit-demo-2-11.gif)
## Available commands
- `Java:Show test output`: open the test output window.
- `Java:Open Log`: open extension log file.
- `Java:Edit Test Configuration`: edit test configuration.
## Supported VSCode settings
- `java.test.report.position`: Specify where to show the test report. Supported values are `sideView`, `currentView`. The default value is `sideView`.
## Requirements
- JDK (version 1.8.0 or later)
- VS Code (version 1.23.0 or later)
- [Language Support for Java by Red Hat](https://marketplace.visualstudio.com/items?itemName=redhat.java) (version 0.14.0 or later)
- [Debugger for Java](https://marketplace.visualstudio.com/items?itemName=vscjava.vscode-java-debug)
- JUnit4: 4.8.0 or later
## Feedback and Questions
You can find the full list of issues at [Issue Tracker](https://github.com/Microsoft/vscode-java-test/issues). You can submit a [bug or feature suggestion](https://github.com/Microsoft/vscode-java-test/issues/new).
## License
This extension is licensed under [MIT License](LICENSE.txt).
## Data/Telemetry
This extension collects telemetry data to help improve our products. Please read [Microsoft privacy statement](https://privacy.microsoft.com/en-us/privacystatement) to learn more. If you opt out to send telemetry data to Microsoft, please set below configuration in settings.json: `telemetry.enableTelemetry = false`. Learn more in our [FAQ](https://code.visualstudio.com/docs/supporting/faq#_how-to-disable-telemetry-reporting).

93
extension/gulpfile.js Normal file
Просмотреть файл

@ -0,0 +1,93 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT license.
const gulp = require('gulp');
const cp = require('child_process');
const tslint = require('gulp-tslint');
const sass = require('gulp-sass');
const decompress = require('gulp-decompress');
const download = require('gulp-download');
const path = require('path');
const fse = require('fs-extra');
const os = require('os');
const serverDir = path.join(__dirname, '..');
const vscodeExtensionsPath = path.join(os.homedir(), '.vscode', 'extensions');
gulp.task('build-plugin', (done) => {
cp.execSync(`${mvnw()} clean package`, { cwd: serverDir, stdio: [0, 1, 2] });
gulp.src(path.join(serverDir, 'com.microsoft.java.test.plugin/target/*.jar'))
.pipe(gulp.dest('./server'));
gulp.src(path.join(serverDir, 'com.microsoft.java.test.runner/target/*.jar'))
.pipe(gulp.dest('./server'));
gulp.src(path.join(serverDir, 'com.microsoft.java.test.runner.junit5/target/*.jar'))
.pipe(gulp.dest('./server'));
done();
});
gulp.task('download-server', (done) => {
download('http://download.eclipse.org/jdtls/snapshots/jdt-language-server-latest.tar.gz')
.pipe(decompress())
.pipe(gulp.dest(path.join(serverDir, 'jdtls')));
done();
});
gulp.task('build-server', gulp.series('build-plugin', 'download-server'));
gulp.task('checkstyle', (done) => {
cp.execSync(`${mvnw()} verify`, { cwd: serverDir, stdio: [0, 1, 2] });
done();
})
gulp.task('tslint', (done) => {
gulp.src(['**/*.ts', '!**/*.d.ts', '!node_modules/**', '!./src/views/node_modules/**'])
.pipe(tslint())
.pipe(tslint.report());
done()
});
gulp.task('lint', gulp.series('checkstyle', 'tslint'));
gulp.task('sass', (done) => {
gulp.src(['resources/templates/scss/*.scss'])
.pipe(sass())
.pipe(gulp.dest('resources/templates/css'));
done();
});
gulp.task('install-java-language-server', async (done) => {
await installExtension('redhat', 'java', '0.31.0');
done();
});
gulp.task('install-java-debug', async (done) => {
await installExtension('vscjava', 'vscode-java-debug', '0.13.0');
done();
});
gulp.task('install-dependency', gulp.series('install-java-language-server', 'install-java-debug'));
async function installExtension(publisher, identifier, version) {
const extensionPath = path.join(vscodeExtensionsPath, `${publisher}.${identifier}-${version}`);
if (!await fse.pathExists(extensionPath)) {
return download(`http://ms-vscode.gallery.vsassets.io/_apis/public/gallery/publisher/${publisher}/extension/${identifier}/${version}/assetbyname/Microsoft.VisualStudio.Services.VSIXPackage`)
.pipe(decompress({
filter: file => file.path.startsWith('extension/'),
map: file => {
file.path = file.path.slice('extension/'.length);
return file;
}
}))
.pipe(gulp.dest(extensionPath));
} else {
console.log(`${publisher}.${identifier}-${version} already installed.`);
}
}
function isWin() {
return /^win/.test(process.platform);
}
function mvnw() {
return isWin() ? 'mvnw.cmd' : './mvnw';
}

7824
extension/package-lock.json сгенерированный Normal file

Разница между файлами не показана из-за своего большого размера Загрузить разницу

62
extension/package.json Normal file
Просмотреть файл

@ -0,0 +1,62 @@
{
"name": "vscode-java-test",
"displayName": "Java Test Runner",
"description": "Run and debug JUnit test cases.",
"repository": {
"url": "https://github.com/Microsoft/vscode-java-test"
},
"version": "0.9.0",
"publisher": "vscjava",
"bugs": {
"url": "https://github.com/Microsoft/vscode-java-test/issues"
},
"homepage": "https://github.com/Microsoft/vscode-java-test/blob/master/extension/README.md",
"preview": true,
"icon": "resources/logo.png",
"keywords": [
"java",
"test",
"junit",
"debug"
],
"aiKey": "90c182a8-8dab-45d4-bfb8-1353eb55aa7f",
"engines": {
"vscode": "^1.23.0"
},
"categories": [
"Other"
],
"activationEvents": [
"onLanguage:java"
],
"main": "./out/src/extension",
"scripts": {
"postinstall": "node ./node_modules/vscode/bin/install",
"compile": "tsc -watch -p ./",
"test": "gulp install-dependency && node ./node_modules/vscode/bin/test",
"lint": "gulp lint",
"buildserver": "gulp build-server",
"sass": "gulp sass",
"vscode:prepublish": "gulp sass && tsc -p ./"
},
"extensionDependencies": [
"vscjava.vscode-java-debug"
],
"devDependencies": {
"@types/fs-extra": "^5.0.4",
"@types/mocha": "^2.2.48",
"@types/node": "^6.0.110",
"gulp": "^4.0.0",
"gulp-decompress": "^2.0.2",
"gulp-download": "0.0.1",
"gulp-sass": "^3.2.1",
"gulp-tslint": "^8.1.3",
"mocha": "^5.2.0",
"tslint": "^5.10.0",
"typescript": "^2.8.3",
"vscode": "^1.1.17"
},
"dependencies": {
"fs-extra": "^7.0.0"
}
}

Двоичные данные
extension/resources/logo.png Normal file

Двоичный файл не отображается.

После

Ширина:  |  Высота:  |  Размер: 20 KiB

Просмотреть файл

@ -0,0 +1,14 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT license.
import { ExtensionContext } from 'vscode';
export function activate(context: ExtensionContext): void {
// tslint:disable-next-line:no-console
console.log(context);
}
export function deactivate(): void {
// do nothing
}

Просмотреть файл

@ -0,0 +1,17 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT license.
import * as assert from 'assert';
import * as vscode from 'vscode';
suite('Extension Tests', () => {
test('Extension should be present', () => {
assert.ok(vscode.extensions.getExtension('vscjava.vscode-java-test'));
});
test('should activate', async () => {
await vscode.extensions.getExtension('vscjava.vscode-java-test')!.activate();
assert.ok(true);
}).timeout(60 * 1000 /* ms */);
});

8
extension/test/index.ts Normal file
Просмотреть файл

@ -0,0 +1,8 @@
import testRunner = require('vscode/lib/testrunner');
testRunner.configure({
ui: 'tdd',
useColors: true,
});
module.exports = testRunner;

22
extension/tsconfig.json Normal file
Просмотреть файл

@ -0,0 +1,22 @@
{
"compilerOptions": {
"module": "commonjs",
"target": "es6",
"outDir": "out",
"lib": [
"es6"
],
"sourceMap": true,
"rootDir": ".",
"noUnusedLocals": true,
"noImplicitThis": true,
"noImplicitReturns": true,
"noUnusedParameters": true,
"strictNullChecks": true,
"alwaysStrict": true
},
"exclude": [
"node_modules",
".vscode-test"
]
}

32
extension/tslint.json Normal file
Просмотреть файл

@ -0,0 +1,32 @@
{
"defaultSeverity": "error",
"extends": [
"tslint:recommended"
],
"jsRules": {},
"rules": {
"object-literal-sort-keys": false,
"indent": [
true,
"spaces"
],
"no-string-literal": false,
"no-namespace": false,
"max-line-length": [
false,
120
],
"typedef": [
true,
"call-signature",
"arrow-call-signature",
"parameter",
"arrow-parameter",
"property-declaration",
"variable-declaration",
"member-variable-declaration"
],
"quotemark": [true, "single", "avoid-escape"]
},
"rulesDirectory": []
}