Skip to content

Commit

Permalink
Tests: Fixes VSCodeVim#15 enabling all tests to be run within Travis
Browse files Browse the repository at this point in the history
  • Loading branch information
jpoon committed Jan 2, 2016
1 parent b79cad3 commit 92862cc
Show file tree
Hide file tree
Showing 16 changed files with 146 additions and 90 deletions.
3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
out
node_modules
typings
.vscode-test
typings
24 changes: 17 additions & 7 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,17 +1,27 @@
notifications:
email: false
email: false

sudo: false

language: node_js

node_js:
- "4.1.1"
- "0.12"

env:
- TSD_GITHUB_TOKEN=8742b29e67faa29aa25564ff7317b50fd7c1327d
- TSD_GITHUB_TOKEN=8742b29e67faa29aa25564ff7317b50fd7c1327d

install:
- npm install -g gulp
- npm install
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

install:
- npm install
- npm run vscode:prepublish

script:
- gulp
- gulp
- npm test --silent
4 changes: 2 additions & 2 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"args": ["--extensionDevelopmentPath=${workspaceRoot}" ],
"stopOnEntry": false,
"sourceMaps": true,
"outDir": "out",
"outDir": "out/src",
"preLaunchTask": "npm"
},
{
Expand All @@ -21,7 +21,7 @@
"args": ["--extensionDevelopmentPath=${workspaceRoot}", "--extensionTestsPath=${workspaceRoot}/out/test" ],
"stopOnEntry": false,
"sourceMaps": true,
"outDir": "out",
"outDir": "out/test",
"preLaunchTask": "npm"
}
]
Expand Down
5 changes: 3 additions & 2 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"out": false // set this to true to hide the "out" folder with the compiled JS files
},
"search.exclude": {
"out": true
}
"out": true // set this to false to include "out" folder in search results
},
"typescript.tsdk": "./node_modules/typescript/lib" // we want to use the TS server from our node_modules folder to control its version
}
1 change: 0 additions & 1 deletion .vscodeignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,3 @@ test/**
**/*.map
.gitignore
tsconfig.json
vsc-extension-quickstart.md
8 changes: 2 additions & 6 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,9 @@ environment:
clone_depth: 1

install:
- ps: start-filedownload https://az764295.vo.msecnd.net/public/0.10.1-release/VSCode-win32.zip
- ps: 7z.exe x .\VSCode-win32.zip -oC:\VSCode > $null
- ps: install-product node $env:node_js_version
- npm install
- npm install -g gulp
- gulp init
- C:\VSCode\bin\code.cmd
- npm install
- npm run vscode:prepublish

build: off

Expand Down
25 changes: 5 additions & 20 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,7 @@ var gulp = require('gulp'),

var paths = {
scripts_ts: "src/**/*.ts",
tests_ts: "test/**/*.ts",
tests_js: [
// test with dependencies on 'vscode' do not run
"out/test/cmd_line/lexer.test.js",
"out/test/cmd_line/scanner.test.js",
]
tests_ts: "test/**/*.ts"
};

gulp.task('tsd', function (callback) {
Expand All @@ -23,7 +18,7 @@ gulp.task('tsd', function (callback) {
}, callback));
});

gulp.task('trim-whitespace', function() {
gulp.task('fix-whitespace', function() {
return gulp.src([paths.scripts_ts, paths.tests_ts], { base: "./" })
.pipe(soften(4))
.pipe(trimlines({
Expand All @@ -32,27 +27,17 @@ gulp.task('trim-whitespace', function() {
.pipe(gulp.dest('./'));
});

gulp.task('compile', ['trim-whitespace'], shell.task([
gulp.task('compile', ['fix-whitespace'], shell.task([
'node ./node_modules/vscode/bin/compile -p ./',
]));

gulp.task('tslint', ['trim-whitespace'], function() {
gulp.task('tslint', ['fix-whitespace'], function() {
return gulp.src([paths.scripts_ts, paths.tests_ts])
.pipe(tslint())
.pipe(tslint.report('prose', {
summarizeFailureOutput: true
}));
});

gulp.task('test', ['compile'], function () {
return gulp.src(paths.tests_js, {
read: false
})
.pipe(mocha({
ui: 'tdd',
reporter: 'spec'
}));
});

gulp.task('init', ['tsd']);
gulp.task('default', ['trim-whitespace', 'tslint', 'test']);
gulp.task('default', ['fix-whitespace', 'tslint']);
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"url": "https://github.com/VSCodeVim/Vim/issues"
},
"engines": {
"vscode": "0.10.x"
"vscode": "^0.10.1"
},
"categories": [
"Other"
Expand Down Expand Up @@ -140,7 +140,7 @@
"devDependencies": {
"gulp": "^3.9.0",
"gulp-mocha": "^2.2.0",
"gulp-soften": "0.0.1",
"gulp-soften": "^0.0.1",
"gulp-shell": "^0.5.1",
"gulp-tsd": "^0.0.4",
"gulp-tslint": "^3.6.0",
Expand All @@ -149,7 +149,7 @@
"tsd": "^0.6.5",
"tslint": "^3.2.1",
"typescript": "^1.6.2",
"vscode": "^0.10.7"
"vscode": "0.10.x"
},
"dependencies": {
"lodash": "^3.10.1"
Expand Down
5 changes: 5 additions & 0 deletions test/mode/modeHandler.test.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
import * as assert from 'assert';
import {setupWorkspace, cleanUpWorkspace} from './../testUtils';
import {ModeName} from '../../src/mode/mode';
import ModeHandler from '../../src/mode/modeHandler';

suite("Mode Handler", () => {

setup(setupWorkspace);

teardown(cleanUpWorkspace);

test("ctor", () => {
var modeHandler = new ModeHandler();

Expand Down
38 changes: 18 additions & 20 deletions test/mode/modeInsert.test.ts
Original file line number Diff line number Diff line change
@@ -1,26 +1,24 @@
import * as assert from 'assert';

import {setupWorkspace, cleanUpWorkspace, assertEqualLines} from './../testUtils';
import ModeInsert from '../../src/mode/modeInsert';
import {ModeName} from '../../src/mode/mode';
import {Motion, MotionMode} from '../../src/motion/motion';
import TextEditor from '../../src/textEditor';
import TestHelpers from '../testHelpers';

let modeInsert: ModeInsert = null;
let motion : Motion = null;

suite("Mode Insert", () => {
setup((done) => {
motion = new Motion(MotionMode.Cursor);
modeInsert = new ModeInsert(motion);
TextEditor.delete().then(() => done());
});

teardown((done) => {
modeInsert = null;
TextEditor.delete().then(() => done());
let motion : Motion;
let modeInsert : ModeInsert;

setup(() => {
return setupWorkspace().then(() => {
motion = new Motion(MotionMode.Cursor);
modeInsert = new ModeInsert(motion);
});
});

teardown(cleanUpWorkspace);

test("can be activated", () => {
let activationKeys = ['i', 'I', 'o', 'O', 'a', 'A'];

Expand All @@ -33,7 +31,7 @@ suite("Mode Insert", () => {
test("can handle key events", () => {
return modeInsert.HandleKeyEvent("!")
.then(() => {
return TestHelpers.assertEqualLines(["!"]);
return assertEqualLines(["!"]);
});
});

Expand All @@ -43,7 +41,7 @@ suite("Mode Insert", () => {
return modeInsert.HandleActivation("o");
})
.then(() => {
return TestHelpers.assertEqualLines(["text", ""]);
return assertEqualLines(["text", ""]);
});
});

Expand All @@ -53,7 +51,7 @@ suite("Mode Insert", () => {
return modeInsert.HandleActivation("O");
})
.then(() => {
return TestHelpers.assertEqualLines(["", "text"]);
return assertEqualLines(["", "text"]);
});
});

Expand All @@ -69,7 +67,7 @@ suite("Mode Insert", () => {
return modeInsert.HandleKeyEvent("!");
})
.then(() => {
return TestHelpers.assertEqualLines(["text!text"]);
return assertEqualLines(["text!text"]);
});
});

Expand All @@ -85,7 +83,7 @@ suite("Mode Insert", () => {
return modeInsert.HandleKeyEvent("!");
})
.then(() => {
return TestHelpers.assertEqualLines(["!text"]);
return assertEqualLines(["!text"]);
});
});

Expand All @@ -98,7 +96,7 @@ suite("Mode Insert", () => {
}).then(() => {
return modeInsert.HandleKeyEvent("!");
}).then(() => {
return TestHelpers.assertEqualLines(["textt!ext"]);
return assertEqualLines(["textt!ext"]);
});
});

Expand All @@ -111,7 +109,7 @@ suite("Mode Insert", () => {
}).then(() => {
return modeInsert.HandleKeyEvent("!");
}).then(() => {
return TestHelpers.assertEqualLines(["text!"]);
return assertEqualLines(["text!"]);
});
});
});
7 changes: 6 additions & 1 deletion test/mode/modeNormal.test.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
import * as assert from 'assert';

import {setupWorkspace, cleanUpWorkspace} from './../testUtils';
import ModeNormal from '../../src/mode/modeNormal';
import {ModeName} from '../../src/mode/mode';
import {Motion} from '../../src/motion/motion';

suite("Mode Normal", () => {

setup(setupWorkspace);

teardown(cleanUpWorkspace);

test("can be activated", () => {
let activationKeys = ['esc', 'ctrl+['];
let motion = new Motion();
Expand Down
11 changes: 6 additions & 5 deletions test/motion.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import * as assert from 'assert';
import * as vscode from "vscode";
import TextEditor from './../src/textEditor';
import {Motion, MotionMode} from './../src/motion/motion';
import {setupWorkspace, cleanUpWorkspace} from './testUtils';

suite("motion", () => {
let motionModes = [MotionMode.Caret, MotionMode.Cursor];
Expand All @@ -12,13 +13,13 @@ suite("motion", () => {
" whose fleece was "
];

setup(done => {
TextEditor.insert(text.join('\n')).then(() => done());
suiteSetup(() => {
return setupWorkspace().then(() => {
return TextEditor.insert(text.join('\n'));
});
});

teardown(done => {
TextEditor.delete().then(() => done());
});
suiteTeardown(cleanUpWorkspace);

test("char right: should move one column right", () => {
motionModes.forEach(o => {
Expand Down
14 changes: 0 additions & 14 deletions test/testHelpers.ts

This file was deleted.

Loading

0 comments on commit 92862cc

Please sign in to comment.