[WIP] Add script to enable testing with external dependencies (#244)

* Add sample test to appease code coverage collection
* Enable +x on all scripts
* Run tests using script so that we can use process.cwd
This commit is contained in:
Nick Chen 2018-01-05 12:03:56 -08:00 коммит произвёл GitHub
Родитель c3a266a224
Коммит f09c9b9ebe
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
7 изменённых файлов: 104 добавлений и 1 удалений

3
.gitignore поставляемый
Просмотреть файл

@ -87,3 +87,6 @@ packages/system-tests/project_*
# Node 8 files (not yet used)
package-lock.json
# External extension dependencies
packages/dbaeumer*

Просмотреть файл

@ -48,8 +48,9 @@
"clean":
"shx rm -rf node_modules && shx rm -rf out && shx rm -rf coverage && shx rm -rf .nyc_output",
"postinstall": "node ./node_modules/vscode/bin/install",
"pretest": "node ../../scripts/download-vscode-for-system-tests",
"test":
"cross-env CODE_TESTS_WORKSPACE='../system-tests/assets/sfdx-simple' node ./node_modules/vscode/bin/test"
"node ../../scripts/install-vsix-dependencies dbaeumer.vscode-eslint && node ../../scripts/run-test-with-top-level-extensions"
},
"activationEvents": [
"workspaceContains:package.json",

Просмотреть файл

@ -0,0 +1,15 @@
/*
* Copyright (c) 2017, salesforce.com, inc.
* All rights reserved.
* Licensed under the BSD 3-Clause license.
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
*/
import { expect } from 'chai';
describe('LWC Extension Tests', () => {
it('Simple sample', () => {
expect([1, 2, 3].indexOf(5)).to.equal(-1);
expect([1, 2, 3].indexOf(0)).to.equal(-1);
});
});

0
scripts/download-vscode-for-system-tests.js Normal file → Executable file
Просмотреть файл

Просмотреть файл

@ -0,0 +1,67 @@
#!/usr/bin/env node
const path = require('path');
const shell = require('shelljs');
// Installs a list of extensions passed on the command line
const testRunFolder = '.vscode-test';
const testRunFolderAbsolute = path.join(process.cwd(), testRunFolder);
const version = process.env.CODE_VERSION || '*';
const downloadPlatform =
process.platform === 'darwin'
? 'darwin'
: process.platform === 'win32' ? 'win32-archive' : 'linux-x64';
const windowsExecutable = path.join(testRunFolderAbsolute, 'Code');
const darwinExecutable = path.join(
testRunFolderAbsolute,
'Visual Studio Code.app',
'Contents',
'Resources',
'app',
'bin',
'code'
);
const linuxExecutable = path.join(
testRunFolderAbsolute,
'VSCode-linux-x64',
'code'
);
if (
[
'0.10.1',
'0.10.2',
'0.10.3',
'0.10.4',
'0.10.5',
'0.10.6',
'0.10.7',
'0.10.8',
'0.10.9'
].indexOf(version) >= 0
) {
linuxExecutable = path.join(
testRunFolderAbsolute,
'VSCode-linux-x64',
'Code'
);
}
const extensionsDir = path.join(__dirname, '..', 'packages');
const executable =
process.platform === 'darwin'
? darwinExecutable
: process.platform === 'win32' ? windowsExecutable : linuxExecutable;
// We always invoke this script with 'node install-vsix-dependencies arg'
// so position2 is where the first argument is
for (let arg = 2; arg < process.argv.length; arg++) {
shell.exec(
`'${executable}' --extensions-dir ${extensionsDir} --install-extension ${process
.argv[arg]}`
);
}

0
scripts/instrument-salesforcedx-vscode-extensions.js Normal file → Executable file
Просмотреть файл

Просмотреть файл

@ -0,0 +1,17 @@
#!/usr/bin/env node
const shell = require('shelljs');
shell.set('-e');
shell.set('+v');
const path = require('path');
// Executes the test, using the top-level packages as the CODE_EXTENSIONS_PATH
shell.exec(
`cross-env CODE_EXTENSIONS_PATH='${path.join(
__dirname,
'..',
'packages'
)}' node ./node_modules/vscode/bin/test`
);