Skip to content
This repository has been archived by the owner on Jan 31, 2023. It is now read-only.

Commit

Permalink
Fix tests in travis (#1140)
Browse files Browse the repository at this point in the history
Fix broken tests
Move to new way of testing
Disabled coverage as that isn't working with new way of testing
Disabled npm audit
Disabled sysTests

Signed-off-by: Caroline Fletcher <caroline.fletcher@uk.ibm.com>
  • Loading branch information
cazfletch committed Jul 15, 2019
1 parent 39d4ea1 commit 5a80e7d
Show file tree
Hide file tree
Showing 28 changed files with 1,353 additions and 638 deletions.
7 changes: 1 addition & 6 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ before_install:

npm install npm@latest -g;
fi
- nvm install --lts
install: |
./.travis/install.sh
Expand All @@ -20,15 +21,9 @@ jobs:
- script: ./.travis/script.sh
os: osx
env: TASK=unit
language: node_js
node_js:
- "lts/*"
- script: ./.travis/script.sh
os: linux
env: TASK=unit
- script: ./.travis/script.sh
os: linux
env: TASK=systestsNode
- script: ./.travis/script.sh
os: linux
env: TASK=cucumber
Expand Down
14 changes: 9 additions & 5 deletions .travis/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,25 +19,29 @@ set -o pipefail

cd ./client

npm --version

node --version

npm install --no-optional
npm install --ignore-scripts

npm audit
# npm audit

npm run compile

if [ "${TASK}" == "unit" ]; then
npm rebuild grpc --target=4.2.5 --runtime=electron --dist-url=https://atom.io/download/electron
npm rebuild grpc --target=4.1.5 --runtime=electron --dist-url=https://atom.io/download/electron

if [ $TRAVIS_OS_NAME == "linux" ]; then
export CXX="g++-4.9" CC="gcc-4.9" DISPLAY=:99.0;
rm -rf ./node_modules/grpc/src/node/extension_binary/node-v69-linux-x64-glibc
mv ./node_modules/grpc/src/node/extension_binary/electron-v4.2-linux-x64-glibc ./node_modules/grpc/src/node/extension_binary/node-v69-linux-x64-glibc
mv ./node_modules/grpc/src/node/extension_binary/electron-v4.1-linux-x64-glibc ./node_modules/grpc/src/node/extension_binary/node-v69-linux-x64-glibc
elif [ $TRAVIS_OS_NAME == "windows" ]; then
rm -rf ./node_modules/grpc/src/node/extension_binary/node-v69-win32-x64-unknown
mv ./node_modules/grpc/src/node/extension_binary/electron-v4.2-win32-x64-unknown ./node_modules/grpc/src/node/extension_binary/node-v69-win32-x64-unknown
mv ./node_modules/grpc/src/node/extension_binary/electron-v4.1-win32-x64-unknown ./node_modules/grpc/src/node/extension_binary/node-v69-win32-x64-unknown
else
rm -rf ./node_modules/grpc/src/node/extension_binary/node-v69-darwin-x64-unknown
mv ./node_modules/grpc/src/node/extension_binary/electron-v4.2-darwin-x64-unknown ./node_modules/grpc/src/node/extension_binary/node-v69-darwin-x64-unknown
mv ./node_modules/grpc/src/node/extension_binary/electron-v4.1-darwin-x64-unknown ./node_modules/grpc/src/node/extension_binary/node-v69-darwin-x64-unknown
fi
fi
2 changes: 1 addition & 1 deletion client/coverconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@
"text-summary"
],
"verbose": false
}
}
6 changes: 3 additions & 3 deletions client/cucumber/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
*/

// tslint:disable no-var-requires
// tslint:disable typedef
// tslint:disable no-console
import * as Cucumber from 'cucumber';
import * as path from 'path';
import * as fs from 'fs-extra';
Expand Down Expand Up @@ -125,7 +127,7 @@ async function runCucumberTest(): Promise<any> {
return runtime.start();
}

async function run(testsRoot: string, clb: (error: any, failures?: number) => void): Promise<void> {
export async function run(testsRoot: string, clb: (error: any, failures?: number) => void): Promise<void> {
console.log(testsRoot);
try {

Expand Down Expand Up @@ -162,5 +164,3 @@ async function run(testsRoot: string, clb: (error: any, failures?: number) => vo
clb(error);
}
}

exports.run = run;
39 changes: 39 additions & 0 deletions client/cucumber/runCucumberTests.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

import * as path from 'path';

import { runTests } from 'vscode-test';

async function main(): Promise<void> {
try {
// The folder containing the Extension Manifest package.json
// Passed to `--extensionDevelopmentPath`
const extensionDevelopmentPath: string = path.resolve(__dirname, '..', '..');

// The path to the extension test runner script
// Passed to --extensionTestsPath
const extensionTestsPath: string = path.resolve(__dirname);

const workspacePath: string = path.resolve(__dirname, '..', '..', 'cucumber', 'data', 'cucumber.code-workspace');

// Download VS Code, unzip it and run the integration test
await runTests({ extensionDevelopmentPath, extensionTestsPath, launchArgs: [workspacePath] });
} catch (err) {
console.error('Failed to run tests');
process.exit(1);
}
}

main();
4 changes: 2 additions & 2 deletions client/cucumber/steps/walletAndIdentity.steps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,11 +80,11 @@ module.exports = function(): any {
* When
*/

this.When(/^I create a wallet '(.*?)' using (certs|enrollId|json file) with identity name '(.*?)' and mspid '(.*?)'$/, this.timeout, async (wallet: string, method: string, identityName: string, mspid: string) => {
this.When(/^I create a wallet '(.*?)' using (certs|enrollId|JSON file) with identity name '(.*?)' and mspid '(.*?)'$/, this.timeout, async (wallet: string, method: string, identityName: string, mspid: string) => {
await this.walletAndIdentityHelper.createWallet(wallet, identityName, mspid, method);
});

this.When(/^I create an identity using (certs|enrollId|json file) with identity name '(.*?)' and mspid '(.*?)' in wallet '(.*?)'$/, this.timeout, async (method: string, identityName: string, mspid: string, wallet: string) => {
this.When(/^I create an identity using (certs|enrollId|JSON file) with identity name '(.*?)' and mspid '(.*?)' in wallet '(.*?)'$/, this.timeout, async (method: string, identityName: string, mspid: string, wallet: string) => {
await this.walletAndIdentityHelper.createIdentity(wallet, identityName, mspid, method);
});
};
23 changes: 0 additions & 23 deletions client/integrationTest/index.ts

This file was deleted.

34 changes: 28 additions & 6 deletions client/integrationTest/nodeTests/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,33 @@
*/

// tslint:disable no-var-requires
const nodeTestRunner: any = require('vscode/lib/testrunner');
// tslint:disable typedef
import * as path from 'path';
import * as Mocha from 'mocha';
import * as glob from 'glob';

nodeTestRunner.configure({
ui: 'bdd',
useColors: true
});
export async function run(testsRoot: string, clb: (error: any, failures?: number) => void): Promise<void> {
// Create the mocha test
const mocha = new Mocha({
ui: 'bdd'
});
mocha.useColors(true);

module.exports = nodeTestRunner;
glob('**/**.test.js', {cwd: testsRoot}, (err, files) => {
if (err) {
return clb(err);
}

// Add files to the test suite
files.forEach((f) => mocha.addFile(path.resolve(testsRoot, f)));

try {
// Run the mocha test
mocha.run((failures) => {
clb(null, failures);
});
} catch (err) {
clb(err);
}
});
}
39 changes: 39 additions & 0 deletions client/integrationTest/nodeTests/runIntegrationTests.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

import * as path from 'path';

import { runTests } from 'vscode-test';

async function main(): Promise<void> {
try {
// The folder containing the Extension Manifest package.json
// Passed to `--extensionDevelopmentPath`
const extensionDevelopmentPath: string = path.resolve(__dirname, '..', '..', '..');

// The path to the extension test runner script
// Passed to --extensionTestsPath
const extensionTestsPath: string = path.resolve(__dirname);

const workspacePath: string = path.resolve(__dirname, '..', '..', '..', 'integrationTest', 'nodeTests', 'data', 'integrationTestsNode.code-workspace');

// Download VS Code, unzip it and run the integration test
await runTests({ extensionDevelopmentPath, extensionTestsPath, launchArgs: [workspacePath]});
} catch (err) {
console.error('Failed to run tests');
process.exit(1);
}
}

main();
Loading

0 comments on commit 5a80e7d

Please sign in to comment.