提交 3f2b4def 编写于 作者: J Joao

fix up smoketest dependencies

上级 819b1b93
......@@ -3,24 +3,25 @@
"version": "0.1.0",
"main": "./src/main.js",
"scripts": {
"compile": "tsc",
"pretest": "tsc",
"test": "node out/main.js"
"postinstall": "tsc",
"watch": "tsc --watch"
},
"devDependencies": {
"@types/mocha": "^2.2.41",
"@types/node": "^6.0.70",
"@types/webdriverio": "^4.6.1",
"@types/commander": "^2.9.2",
"@types/electron": "~1.4.37",
"@types/rimraf": "^0.0.28",
"@types/htmlparser2": "^3.7.29",
"@types/mkdirp": "^0.5.1",
"@types/mocha": "^2.2.41",
"@types/node": "^8.0.26",
"@types/rimraf": "^0.0.28",
"@types/webdriverio": "^4.6.1",
"commander": "^2.9.0",
"htmlparser2": "^3.9.2",
"mocha": "^3.2.0",
"spectron": "~3.6.4",
"typescript": "^2.2.2",
"rimraf": "^2.6.1",
"commander": "^2.9.0",
"simple-git": "^1.73.0",
"spectron": "~3.6.4",
"strip-json-comments": "^2.0.1",
"htmlparser2": "^3.9.2"
"typescript": "^2.2.2"
}
}
\ No newline at end of file
}
......@@ -3,13 +3,15 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
const fs = require('fs');
const https = require('https');
const program = require('commander');
const git = require('simple-git')();
const child_process = require('child_process');
const path = require('path');
const mkdirp = require('mkdirp');
import * as fs from 'fs';
import * as https from 'https';
import * as program from 'commander';
import * as simplegit from 'simple-git';
import * as cp from 'child_process';
import * as path from 'path';
import * as mkdirp from 'mkdirp';
const git = simplegit();
const testDataPath = path.join(process.cwd(), 'test_data');
const codeWorkspacePath = path.join(testDataPath, 'smoketest.code-workspace');
......@@ -33,12 +35,13 @@ program.on('--help', () => {
console.log(' $ npm test -- -l path/to/latest/binary -s path/to/stable/binary');
console.log('');
});
program.parse(process.argv);
if (!program.latest) {
fail('You must specify the binary to run the smoke test against');
}
if (!binaryExists(program.latest) || (program.stable && !binaryExists(program.stable))) {
if (!fs.existsSync(program.latest) || (program.stable && !fs.existsSync(program.stable))) {
fail('The file path to electron binary does not exist or permissions do not allow to execute it. Please check the path provided.');
}
if (parseInt(process.version.substr(1)) < 6) {
......@@ -81,7 +84,7 @@ async function main(): Promise<void> {
await createWorkspaceFile(codeWorkspacePath, workspace);
await cleanOrClone(testRepoUrl, testRepoLocalDir);
await execute('npm install', testRepoLocalDir);
cp.execSync('npm install', { cwd: testRepoLocalDir });
await runTests();
}
......@@ -100,7 +103,7 @@ function toUri(path: string): string {
function runTests(): void {
console.log('Running tests...');
var proc = child_process.spawn(process.execPath, [
var proc = cp.spawn(process.execPath, [
'out/mocha-runner.js'
]);
proc.stdout.on('data', data => {
......@@ -122,7 +125,7 @@ function runTests(): void {
async function cleanOrClone(repo: string, dir: string): Promise<any> {
console.log('Cleaning or cloning test project repository...');
if (!folderExists(dir)) {
if (!fs.existsSync(dir)) {
await gitClone(repo, dir);
} else {
git.cwd(dir);
......@@ -146,22 +149,6 @@ async function gitResetAndClean(): Promise<any> {
console.log('Test project was successfully reset to initial state.');
}
function execute(cmd: string, dir: string): Promise<any> {
return new Promise((res, rej) => {
console.log(`Running ${cmd}...`);
child_process.exec(cmd, { cwd: dir, stdio: [0, 1, 2] }, (error, stdout, stderr) => {
if (error) {
rej(error);
}
if (stderr) {
console.error(stderr);
}
console.log(stdout);
res();
});
});
}
function getKeybindings(url: string, location: string): Promise<any> {
console.log(`Fetching keybindings from ${url}...`);
return new Promise((resolve, reject) => {
......@@ -171,7 +158,7 @@ function getKeybindings(url: string, location: string): Promise<any> {
}
var buffer: Buffer[] = [];
res.on('data', (chunk) => buffer.push(chunk));
res.on('data', (chunk: Buffer) => buffer.push(chunk));
res.on('end', () => {
fs.writeFile(location, Buffer.concat(buffer), 'utf8', () => {
console.log('Keybindings were successfully fetched.');
......@@ -201,22 +188,4 @@ function createWorkspaceFile(path: string, workspace: any): Promise<any> {
});
});
});
}
function folderExists(folder: string): boolean {
try {
fs.accessSync(folder, 'rw');
return true;
} catch (e) {
return false;
}
}
function binaryExists(filePath: string): boolean {
try {
fs.accessSync(filePath, 'x');
return true;
} catch (e) {
return false;
}
}
\ No newline at end of file
......@@ -9,10 +9,10 @@ import { Screenshot } from '../helpers/screenshot';
var fs = require('fs');
var path = require('path');
export const LATEST_PATH = process.env.VSCODE_LATEST_PATH;
export const STABLE_PATH = process.env.VSCODE_STABLE_PATH;
export const WORKSPACE_PATH = process.env.SMOKETEST_REPO;
export const CODE_WORKSPACE_PATH = process.env.VSCODE_WORKSPACE_PATH;
export const LATEST_PATH = process.env.VSCODE_LATEST_PATH || '';
export const STABLE_PATH = process.env.VSCODE_STABLE_PATH || '';
export const WORKSPACE_PATH = process.env.SMOKETEST_REPO || '';
export const CODE_WORKSPACE_PATH = process.env.VSCODE_WORKSPACE_PATH || '';
export const USER_DIR = 'test_data/temp_user_dir';
export const EXTENSIONS_DIR = 'test_data/temp_extensions_dir';
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册