Skip to content

Commit

Permalink
Merge pull request #725 from DustinCampbell/clean-up-and-unit-tests
Browse files Browse the repository at this point in the history
Clean up npm scripts and start running tests
  • Loading branch information
DustinCampbell authored Sep 2, 2016
2 parents ed6ea8c + 00977b5 commit 3f50222
Show file tree
Hide file tree
Showing 21 changed files with 135 additions and 16 deletions.
15 changes: 15 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# EditorConfig is awesome: http://EditorConfig.org

# top-most EditorConfig file
root = true

# 4 space indentation
[*]
indent_style = space
indent_size = 4
trim_trailing_whitespace = true

# 2 space indentation for .travis.yml and package.json
[{.travis.yml},package.json]
indent_style = space
indent_size = 2
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ os:

install:
- npm install
- npm run compile
- npm install -g vsce
- vsce package

Expand Down
12 changes: 11 additions & 1 deletion .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,17 @@
],
"stopOnEntry": false,
"sourceMaps": true,
"outDir": "${workspaceRoot}/out"
"outDir": "${workspaceRoot}/out/src"
},
{
"name": "Launch Tests",
"type": "extensionHost",
"request": "launch",
"runtimeExecutable": "${execPath}",
"args": ["--extensionDevelopmentPath=${workspaceRoot}", "--extensionTestsPath=${workspaceRoot}/out/test" ],
"stopOnEntry": false,
"sourceMaps": true,
"outDir": "${workspaceRoot}/out/test"
}
]
}
13 changes: 13 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
{
"editor.tabSize": 4,
"editor.insertSpaces": true,

"files.exclude": {
"out": true,
"typings": false
},

"search.exclude": {
"**/node_modules": true,
"out/": true
},

"tslint.rulesDirectory": "node_modules/tslint-microsoft-contrib"
}
5 changes: 5 additions & 0 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@
"command": "gulp",
"isShellCommand": true,
"tasks": [
{
"taskName": "test",
"showOutput": "always",
"isTestCommand": true
},
{
"taskName": "tslint",
"args": [],
Expand Down
11 changes: 7 additions & 4 deletions .vscodeignore
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
**/*.gitignore
tsconfig.json

.vscode/**
typings/**
out/test/**
test/**
src/**
**/*.map

.vscode/**
.gitignore
.travis.yml
tsconfig.json

**/.nyc_output/**
**/coverage/**
Expand Down
25 changes: 19 additions & 6 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,16 @@ const path = require('path');
const del = require('del');
const gulp = require('gulp');
const gulpUtil = require('gulp-util');
const mocha = require('gulp-mocha');
const tslint = require('gulp-tslint');
const vsce = require('vsce');
const debugUtil = require('./out/coreclr-debug/util.js');
const debugInstall = require('./out/coreclr-debug/install.js');
const debugUtil = require('./out/src/coreclr-debug/util');
const debugInstall = require('./out/src/coreclr-debug/install');
const fs_extra = require('fs-extra-promise');
const omnisharp = require('./out/omnisharp/omnisharp');
const download = require('./out/omnisharp/download');
const logger = require('./out/omnisharp/logger');
const platform = require('./out/platform');
const omnisharp = require('./out/src/omnisharp/omnisharp');
const download = require('./out/src/omnisharp/download');
const logger = require('./out/src/omnisharp/logger');
const platform = require('./out/src/platform');
const child_process = require('child_process');

const Flavor = omnisharp.Flavor;
Expand Down Expand Up @@ -154,6 +155,18 @@ gulp.task('package:offline', ['clean'], () => {
return promise;
});

/// Test Task
gulp.task('test', () => {
gulp.src('out/test/*.tests.js')
.pipe(mocha({ui: "tdd"}))
.once('error', () => {
process.exit(1);
})
.once('end', () => {
process.exit();
});
});

/// Misc Tasks
const allTypeScript = [
'src/**/*.ts',
Expand Down
7 changes: 6 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,10 @@
],
"main": "./out/main",
"scripts": {
"postinstall": "node ./node_modules/vscode/bin/install && tsc"
"compile": "node ./node_modules/vscode/bin/compile -p ./",
"watch": "node ./node_modules/vscode/bin/compile -watch -p ./",
"test": "mocha --timeout 15000 -u tdd ./out/test/*.tests.js",
"postinstall": "node ./node_modules/vscode/bin/install"
},
"dependencies": {
"decompress": "^4.0.0",
Expand All @@ -35,7 +38,9 @@
},
"devDependencies": {
"gulp": "^3.9.1",
"gulp-mocha": "^2.1.3",
"gulp-tslint": "^4.3.0",
"mocha": "^2.2.5",
"tslint": "^3.3.0",
"tslint-microsoft-contrib": "^2.0.0",
"typescript": "^1.7.3",
Expand Down
27 changes: 27 additions & 0 deletions test/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/

//
// PLEASE DO NOT MODIFY / DELETE UNLESS YOU KNOW WHAT YOU ARE DOING
//
// This file is providing the test runner to use when running extension tests.
// By default the test runner in use is Mocha based.
//
// You can provide your own test runner if you want to override it by exporting
// a function run(testRoot: string, clb: (error:Error) => void) that the extension
// host can call to run the tests. The test runner is expected to use console.log
// to report the results back to the caller. When the tests are finished, return
// a possible error to the callback or null if none.

var testRunner = require('vscode/lib/testrunner');

// You can directly control Mocha options by uncommenting the following lines
// See https://github.com/mochajs/mocha/wiki/Using-mocha-programmatically#set-options for more info
testRunner.configure({
ui: 'tdd', // the TDD UI is being used in extension.test.ts (suite, test, etc.)
useColors: true // colored output from test results
});

module.exports = testRunner;
26 changes: 26 additions & 0 deletions test/sanity.tests.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/

//
// Note: This example test is leveraging the Mocha test framework.
// Please refer to their documentation on https://mochajs.org/ for help.
//

// The module 'assert' provides assertion methods from node
import * as assert from 'assert';

// You can import and use all API from the 'vscode' module
// as well as import your extension to test it
import * as vscode from 'vscode';
import * as myExtension from '../src/main';

suite("Sanity Tests", () => {
test("Boolean checks", () => {
assert.equal(true, true, "true is not true");
assert.notEqual(true, false, "true is false");
assert.equal(false, false, "false is not false");
assert.notEqual(false, true, "false is true");
});
});
5 changes: 3 additions & 2 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
{
"compilerOptions": {
"noLib": true,
"target": "es5",
"module": "commonjs",
"outDir": "out",
"sourceMap": true
"noLib": true,
"sourceMap": true,
"rootDir": "."
},
"exclude": [
"node_modules"
Expand Down
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions src/typings/ref.d.ts → typings/ref.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/

/// <reference path='../../node_modules/vscode/typings/index.d.ts'/>
/// <reference path='../../node_modules/vscode/typings/glob.d.ts'/>
/// <reference path='../node_modules/vscode/typings/index.d.ts'/>
/// <reference path='../node_modules/vscode/typings/glob.d.ts'/>
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit 3f50222

Please sign in to comment.