Skip to content
This repository has been archived by the owner on Feb 1, 2019. It is now read-only.

Commit

Permalink
tests: Add behave for server and travis for CI
Browse files Browse the repository at this point in the history
  • Loading branch information
gaocegege committed Feb 11, 2017
1 parent 9fa0946 commit 82bd1df
Show file tree
Hide file tree
Showing 7 changed files with 136 additions and 4 deletions.
48 changes: 48 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
sudo: false
language: python
python:
- 3.4
- 3.5
- 3.6

cache:
pip: true
directories:
- node_modules

os:
- osx
- linux

# Note that in order to run the tests on Linux,
# you need to have a before_install configuration
# to enable Linux to start VS Code from the build.
# ref https://code.visualstudio.com/Docs/extensions/testing-extensions
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:
- pip install -r ./requirements.txt
# beheve is a dev dependeny, so not in requirements.txt.
- pip install behave
- cd ./vscode-client
- npm install
- mkdir ./out
- npm run vscode:prepublish
- cd - > /dev/null

script:
# Server side tests.
- behave ./tests/server.features
# # Integration tests.
# - cd ./vscode-client
# - npm test
# - cd - > /dev/null

# after_success:
# # If the build was triggered by a tag, publish the new version
# - 'if [[ $TRAVIS_TAG == v* ]]; then vsce publish -p $VSCE_TOKEN; fi'
1 change: 1 addition & 0 deletions coala_langserver/uri.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,5 @@ def path_from_uri(uri):


def dir_from_uri(uri):
"""Get the directory name from the path."""
return os.path.dirname(path_from_uri(uri))
45 changes: 45 additions & 0 deletions tests/server.features/steps/uri_steps.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# -*- coding: UTF-8 -*-

# @mark.steps
# ----------------------------------------------------------------------------
# STEPS:
# ----------------------------------------------------------------------------
from behave import given, when, then
from coala_langserver.uri import path_from_uri, dir_from_uri


@given('There is a string with "file://"')
def step_impl(context):
context.str = 'file://Users'


@when('I pass the string with the prefix to path_from_uri')
def step_impl(context):
context.path = path_from_uri(context.str)


@given('There is a string without "file://"')
def step_impl(context):
context.str = '/Users'


@when('I pass the string without the prefix to path_from_uri')
def step_impl(context):
context.path = path_from_uri(context.str)


@then('it should return a string without "file://"')
def step_impl(context):
assert context.failed is False
assert 'file://' not in context.path


@when('I pass the string to dir_from_uri')
def step_impl(context):
context.path = dir_from_uri(context.str)


@then('it should return the directory of the path')
def step_impl(context):
assert context.failed is False
assert context.path is '/'
17 changes: 17 additions & 0 deletions tests/server.features/uri.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
Feature: uri module
uri is a module of language-server.

Scenario: Test path_from_uri
Given There is a string with "file://"
When I pass the string with the prefix to path_from_uri
Then it should return a string without "file://"

Scenario: Test path_from_uri
Given There is a string without "file://"
When I pass the string without the prefix to path_from_uri
Then it should return a string without "file://"

Scenario: Test dir_from_uri
Given There is a string without "file://"
When I pass the string to dir_from_uri
Then it should return the directory of the path
4 changes: 3 additions & 1 deletion vscode-client/.gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
out
server
node_modules
.vscode-dev
.vscode-dev
.vscode-test

8 changes: 5 additions & 3 deletions vscode-client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,15 @@
"vscode:prepublish": "cp -r ../coala-langserver.sh ../coala-langserver.py ../coala_langserver ./out && node ./node_modules/vscode/bin/compile",
"compile": "python3 ../setup.py install && node ./node_modules/vscode/bin/compile -watch -p ./",
"postinstall": "node ./node_modules/vscode/bin/install",
"vscode": "npm run vscode:prepublish && VSCODE=$(which code-insiders || which code || echo echo ERROR: neither the code nor code-insiders vscode executable is installed); USER=dummy-dont-share-vscode-instance $VSCODE --user-data-dir=$PWD/.vscode-dev/user-data --extensionHomePath=$PWD/.vscode-dev/extensions --extensionDevelopmentPath=$PWD $*"
"vscode": "npm run vscode:prepublish && VSCODE=$(which code-insiders || which code || echo echo ERROR: neither the code nor code-insiders vscode executable is installed); USER=dummy-dont-share-vscode-instance $VSCODE --user-data-dir=$PWD/.vscode-dev/user-data --extensionHomePath=$PWD/.vscode-dev/extensions --extensionDevelopmentPath=$PWD $*",
"test": "node ./node_modules/vscode/bin/test"
},
"devDependencies": {
"typescript": "^1.8.9",
"vscode": "^0.11.0"
"vscode": "^0.11.0",
"vsce": "^1.18.0"
},
"dependencies": {
"vscode-languageclient": "^2.4.2-next.12"
}
}
}
17 changes: 17 additions & 0 deletions vscode-client/test/extension.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// 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 '../extension';

// Defines a Mocha test suite to group tests of similar kind together
suite('Extension Tests', () => {

// Defines a Mocha unit test
test('Something 1', () => {
assert.equal(-1, [1, 2, 3].indexOf(5));
assert.equal(-1, [1, 2, 3].indexOf(0));
});
});

0 comments on commit 82bd1df

Please sign in to comment.