Skip to content

Commit

Permalink
fix extension tests (#2000)
Browse files Browse the repository at this point in the history
  • Loading branch information
elahehrashedi committed Jul 21, 2021
1 parent e64ccc8 commit 88b3abc
Show file tree
Hide file tree
Showing 42 changed files with 70 additions and 78 deletions.
3 changes: 1 addition & 2 deletions .eslintignore
@@ -1,4 +1,3 @@
*.js
test/**/index.ts
test/**/runTest.ts
test/extension-tests/successful-build/project-folder/build
tools/prepublish.js
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -4,6 +4,7 @@ dist/
node_modules/
out/
test/fakebin/
test/unit-tests/driver/workspace/test_project/bin/
vscode-extensions-localization-export/
vscode-translations-import/
jobs/loc/LCL
Expand Down
3 changes: 2 additions & 1 deletion gulpfile.js
Expand Up @@ -257,14 +257,15 @@ gulp.task('translations-generate', gulp.series(generatedSrcLocBundle, generatedA

const allTypeScript = [
'src/**/*.ts',
'test/**/*.ts',
'!**/*.d.ts',
'!**/typings**'
];

gulp.task('lint', function () {
// Un-comment these parts for applying auto-fix.
return gulp.src(allTypeScript)
.pipe(eslint({ configFile: ".eslintrc.js" /*, fix: true*/ }))
.pipe(eslint({ configFile: ".eslintrc.js" /*, fix: true */}))
.pipe(eslint.format())
//.pipe(gulp.dest(file => file.base))
.pipe(eslint.failAfterError());
Expand Down
2 changes: 1 addition & 1 deletion scripts/ci.ps1
Expand Up @@ -106,5 +106,5 @@ Invoke-ChronicCommand "yarn pretest" $yarn run pretest
Invoke-ChronicCommand "yarn smokeTests" $yarn run smokeTests
Invoke-ChronicCommand "yarn unitTests" $yarn run unitTests
Invoke-ChronicCommand "yarn extensionTestsSuccessfulBuild" $yarn run extensionTestsSuccessfulBuild
Invoke-ChronicCommand "yarn extensionTestsSingleRoot" $yarn run extensionTestsSingleRoot
#Invoke-ChronicCommand "yarn extensionTestsSingleRoot" $yarn run extensionTestsSingleRoot
Invoke-ChronicCommand "yarn extensionTestsMultioot" $yarn run extensionTestsMultioot
3 changes: 2 additions & 1 deletion test/backend-unit-tests/cmake/strand.test.ts
@@ -1,4 +1,5 @@
require('module-alias/register');
// eslint-disable-next-line import/no-unassigned-import
import 'module-alias/register';

import * as chai from 'chai';
import {expect} from 'chai';
Expand Down
5 changes: 3 additions & 2 deletions test/extension-tests/multi-root-UI/index.ts
@@ -1,3 +1,4 @@
// eslint-disable-next-line import/no-unassigned-import
import 'module-alias/register';
import * as path from 'path';
import * as Mocha from 'mocha';
Expand All @@ -13,7 +14,7 @@ export function run(): Promise<void> {
const testsRoot = __dirname;

return new Promise((c, e) => {
glob('**/**.test.js', { cwd: testsRoot }, (err, files) => {
glob('**/*.test.js', { cwd: testsRoot }, (err, files) => {
if (err) {
return e(err);
}
Expand All @@ -36,4 +37,4 @@ export function run(): Promise<void> {
}
});
});
}
}
2 changes: 1 addition & 1 deletion test/extension-tests/multi-root-UI/runTest.ts
Expand Up @@ -26,4 +26,4 @@ async function main() {
}
}

main();
main();
Expand Up @@ -26,7 +26,7 @@ if (process.env.TRAVIS_OS_NAME) {
suite('Build', async () => {
let testEnv: DefaultEnvironment;
let compdb_cp_path: string;
let cmakeTools : CMakeTools;
let cmakeTools: CMakeTools;

suiteSetup(async function(this: Mocha.Context) {
this.timeout(100000);
Expand Down Expand Up @@ -125,12 +125,11 @@ suite('Build', async () => {

test('Test kit switch after missing preferred generator', async function(this: Mocha.Context) {
// Select compiler build node dependent
const os_compilers: {[osName: string]: {kitLabel: RegExp, compiler: string}[]} = {
const os_compilers: {[osName: string]: {kitLabel: RegExp; compiler: string}[]} = {
linux: [{kitLabel: /^GCC \d/, compiler: 'GNU'}, {kitLabel: /^Clang \d/, compiler: 'Clang'}],
win32: [{kitLabel: /^GCC \d/, compiler: 'GNU'}, {kitLabel: /^VisualStudio/, compiler: 'MSVC'}]
};
if (!(workername in os_compilers))
this.skip();
if (!(workername in os_compilers)) {this.skip(); }
const compiler = os_compilers[workername];

// Run test
Expand All @@ -150,12 +149,11 @@ suite('Build', async () => {
test('Test kit switch between different preferred generators and compilers',
async function(this: Mocha.Context) {
// Select compiler build node dependent
const os_compilers: {[osName: string]: {kitLabel: RegExp, compiler: string}[]} = {
const os_compilers: {[osName: string]: {kitLabel: RegExp; compiler: string}[]} = {
linux: [{kitLabel: /^GCC \d/, compiler: 'GNU'}, {kitLabel: /^Clang \d/, compiler: 'Clang'}],
win32: [{kitLabel: /^GCC \d/, compiler: 'GNU'}, {kitLabel: /^VisualStudio/, compiler: 'MSVC'}]
};
if (!(workername in os_compilers))
this.skip();
if (!(workername in os_compilers)) {this.skip(); }
const compiler = os_compilers[workername];

testEnv.kitSelection.defaultKitLabel = compiler[0].kitLabel;
Expand Down
1 change: 0 additions & 1 deletion test/extension-tests/multi-root-UI/test/debugger.test.ts
Expand Up @@ -2,7 +2,6 @@ import {DefaultEnvironment, expect, getFirstSystemKit} from '@test/util';
import * as vscode from 'vscode';
import CMakeTools from '@cmt/cmake-tools';


suite('[Debug/Launch interface]', async () => {
let testEnv: DefaultEnvironment;
let cmakeTools: CMakeTools;
Expand Down
3 changes: 1 addition & 2 deletions test/extension-tests/multi-root-UI/test/variant-envs.test.ts
@@ -1,4 +1,3 @@

import * as api from '@cmt/api';
import {CMakeCache} from '@cmt/cache';
import {clearExistingKitConfigurationFile, DefaultEnvironment, expect, getFirstSystemKit} from '@test/util';
Expand All @@ -9,7 +8,7 @@ import CMakeTools from '@cmt/cmake-tools';

suite('[Environment Variables in Variants]', async () => {
let testEnv: DefaultEnvironment;
let cmakeTools : CMakeTools;
let cmakeTools: CMakeTools;

setup(async function(this: Mocha.Context) {
this.timeout(100000);
Expand Down
5 changes: 3 additions & 2 deletions test/extension-tests/single-root-UI/index.ts
@@ -1,3 +1,4 @@
// eslint-disable-next-line import/no-unassigned-import
import 'module-alias/register';

import * as path from 'path';
Expand All @@ -14,7 +15,7 @@ export function run(): Promise<void> {
const testsRoot = __dirname;

return new Promise((c, e) => {
glob('**/**.test.js', { cwd: testsRoot }, (err, files) => {
glob('**/*.test.js', { cwd: testsRoot }, (err, files) => {
if (err) {
return e(err);
}
Expand All @@ -37,4 +38,4 @@ export function run(): Promise<void> {
}
});
});
}
}
2 changes: 1 addition & 1 deletion test/extension-tests/single-root-UI/runTest.ts
Expand Up @@ -27,4 +27,4 @@ async function main() {
}
}

main();
main();
5 changes: 3 additions & 2 deletions test/extension-tests/successful-build/index.ts
@@ -1,3 +1,4 @@
// eslint-disable-next-line import/no-unassigned-import
import 'module-alias/register';
import * as path from 'path';
import * as Mocha from 'mocha';
Expand All @@ -13,7 +14,7 @@ export function run(): Promise<void> {
const testsRoot = __dirname;

return new Promise((c, e) => {
glob('**/**.test.js', { cwd: testsRoot }, (err, files) => {
glob('**/*.test.js', { cwd: testsRoot }, (err, files) => {
if (err) {
return e(err);
}
Expand All @@ -36,4 +37,4 @@ export function run(): Promise<void> {
}
});
});
}
}
2 changes: 1 addition & 1 deletion test/extension-tests/successful-build/runTest.ts
Expand Up @@ -27,4 +27,4 @@ async function main() {
}
}

main();
main();
@@ -1,3 +1,4 @@
/* eslint-disable no-unused-expressions */
import {CMakeTools, ConfigureTrigger} from '@cmt/cmake-tools';
import {fs} from '@cmt/pr';
import {TestProgramResult} from '@test/helpers/testprogram/test-program-result';
Expand All @@ -12,7 +13,6 @@ import {
} from '@test/util';
import * as path from 'path';


let workername: string = process.platform;

if (process.env.APPVEYOR_BUILD_WORKER_IMAGE) {
Expand Down Expand Up @@ -93,7 +93,6 @@ suite('Build', async () => {
expect(result['cookie']).to.eq('passed-cookie');
}).timeout(100000);


test('Configure and Build', async () => {
expect(await cmt.configureInternal(ConfigureTrigger.runTests)).to.be.eq(0);
expect(await cmt.build()).to.be.eq(0);
Expand Down Expand Up @@ -129,12 +128,11 @@ suite('Build', async () => {

test('Test kit switch after missing preferred generator', async function(this: Mocha.Context) {
// Select compiler build node dependent
const os_compilers: {[osName: string]: {kitLabel: RegExp, compiler: string}[]} = {
const os_compilers: {[osName: string]: {kitLabel: RegExp; compiler: string}[]} = {
linux: [{kitLabel: /^GCC \d/, compiler: 'GNU'}, {kitLabel: /^Clang \d/, compiler: 'Clang'}],
win32: [{kitLabel: /^GCC \d/, compiler: 'GNU'}, {kitLabel: /^VisualStudio/, compiler: 'MSVC'}]
};
if (!(workername in os_compilers))
this.skip();
if (!(workername in os_compilers)) {this.skip(); }
const compiler = os_compilers[workername];

// Run test
Expand All @@ -153,7 +151,7 @@ suite('Build', async () => {

test('Test kit switch after missing preferred generator #512', async function(this: Mocha.Context) {
// Select compiler build node dependent
const os_compilers: {[osName: string]: {kitLabel: RegExp, generator: string}[]} = {
const os_compilers: {[osName: string]: {kitLabel: RegExp; generator: string}[]} = {
linux: [
{kitLabel: /^Generator switch test GCC Make$/, generator: 'Unix Makefiles'},
{kitLabel: /^Generator switch test GCC no generator$/, generator: ''}
Expand All @@ -163,8 +161,7 @@ suite('Build', async () => {
{kitLabel: /^Generator switch test GCC no generator - Win/, generator: ''}
]
};
if (!(workername in os_compilers))
this.skip();
if (!(workername in os_compilers)) {this.skip(); }
// Remove all preferred generator (Remove config dependenies, auto detection)
testEnv.config.updatePartial({preferredGenerators: []});
const compiler = os_compilers[workername];
Expand Down Expand Up @@ -205,12 +202,11 @@ suite('Build', async () => {
test('Test kit switch between different preferred generators and compilers',
async function(this: Mocha.Context) {
// Select compiler build node dependent
const os_compilers: {[osName: string]: {kitLabel: RegExp, compiler: string}[]} = {
const os_compilers: {[osName: string]: {kitLabel: RegExp; compiler: string}[]} = {
linux: [{kitLabel: /^GCC \d/, compiler: 'GNU'}, {kitLabel: /^Clang \d/, compiler: 'Clang'}],
win32: [{kitLabel: /^GCC \d/, compiler: 'GNU'}, {kitLabel: /^VisualStudio/, compiler: 'MSVC'}]
};
if (!(workername in os_compilers))
this.skip();
if (!(workername in os_compilers)) {this.skip(); }
const compiler = os_compilers[workername];

testEnv.kitSelection.defaultKitLabel = compiler[0].kitLabel;
Expand All @@ -229,7 +225,7 @@ suite('Build', async () => {
test('Test kit switch between different preferred generators and same compiler',
async function(this: Mocha.Context) {
// Select compiler build node dependent
const os_compilers: {[osName: string]: {kitLabel: RegExp, generator: string}[]} = {
const os_compilers: {[osName: string]: {kitLabel: RegExp; generator: string}[]} = {
linux: [
{kitLabel: /^Generator switch test GCC Make$/, generator: 'Unix Makefiles'},
{kitLabel: /^Generator switch test GCC Ninja$/, generator: 'Ninja'}
Expand All @@ -239,8 +235,7 @@ suite('Build', async () => {
{kitLabel: /^Generator switch test GCC Ninja - Win/, generator: 'Ninja'}
]
};
if (!(workername in os_compilers))
this.skip();
if (!(workername in os_compilers)) {this.skip(); }
const compiler = os_compilers[workername];

testEnv.config.updatePartial({preferredGenerators: []});
Expand All @@ -262,7 +257,7 @@ suite('Build', async () => {

test('Test kit switch kits after configure', async function(this: Mocha.Context) {
// Select compiler build node dependent
const os_compilers: {[osName: string]: {kitLabel: RegExp, generator: string}[]} = {
const os_compilers: {[osName: string]: {kitLabel: RegExp; generator: string}[]} = {
linux: [
{kitLabel: /^Generator switch test GCC Make$/, generator: 'Unix Makefiles'},
{kitLabel: /^Generator switch test GCC Ninja$/, generator: 'Ninja'}
Expand All @@ -272,8 +267,7 @@ suite('Build', async () => {
{kitLabel: /^Generator switch test GCC Ninja - Win/, generator: 'Ninja'}
]
};
if (!(workername in os_compilers))
this.skip();
if (!(workername in os_compilers)) {this.skip(); }
const compiler = os_compilers[workername];

testEnv.config.updatePartial({preferredGenerators: []});
Expand Down
@@ -1,10 +1,10 @@
/* eslint-disable no-unused-expressions */
import {CMakeTools} from '@cmt/cmake-tools';
import {DefaultEnvironment, expect, getFirstSystemKit} from '@test/util';
//import sinon = require('sinon');
import * as fs from 'fs';
import * as path from 'path';


suite('[Debug/Launch interface]', async () => {
let cmt: CMakeTools;
let testEnv: DefaultEnvironment;
Expand Down
Expand Up @@ -33,8 +33,8 @@ suite('[Environment]', async () => {
// Set fake settings
testEnv.config.updatePartial({
configureEnvironment: {
_CONFIGURE_ENV: '${workspaceRootFolderName}',
},
_CONFIGURE_ENV: '${workspaceRootFolderName}'
}
});

// Configure
Expand Down
@@ -1,3 +1,4 @@
/* eslint-disable no-unused-expressions */
import {CMakeTools} from '@cmt/cmake-tools';
import {Kit, scanForKits} from '@cmt/kit';
import {clearExistingKitConfigurationFile, DefaultEnvironment, expect} from '@test/util';
Expand Down Expand Up @@ -71,7 +72,7 @@ const DEFAULT_VS_KITS: KitEnvironment[] = [
expectedDefaultGenerator: /^Visual Studio 11 2012/,
path: [''],
isVsNewerThan14: false
},
}
];

const DEFAULT_CYGWIN_KITS: KitEnvironment[] =
Expand Down Expand Up @@ -190,12 +191,10 @@ interface SkipOptions {

function skipTestIf(skipOptions: SkipOptions, testContext: any, context: CMakeContext): void {
// Skip if kit is not available (matched by default name)
if (skipOptions.kitIsNotAvailable && !isKitAvailable(context))
testContext.skip();
if (skipOptions.kitIsNotAvailable && !isKitAvailable(context)) {testContext.skip(); }

if ((skipOptions.preferredGeneratorIsAvailable && isPreferredGeneratorAvailable(context))
|| (skipOptions.preferredGeneratorIsNotAvailable && !isPreferredGeneratorAvailable(context)))
testContext.skip();
|| (skipOptions.preferredGeneratorIsNotAvailable && !isPreferredGeneratorAvailable(context))) {testContext.skip(); }
}

function makeExtensionTestSuite(name: string,
Expand Down Expand Up @@ -279,8 +278,8 @@ KITS_BY_PLATFORM[workername].forEach(buildSystem => {
preferredGenerators: [
'NMake Makefiles',
'Unix Makefiles',
'MinGW Makefiles',
],
'MinGW Makefiles'
]
});
expect(await context.cmt.build()).to.eql(0);
const result = await context.testEnv.result.getResultAsJson();
Expand Down
3 changes: 1 addition & 2 deletions test/extension-tests/successful-build/test/scan_kits.test.ts
Expand Up @@ -2,7 +2,6 @@ import {scanForKits} from '@cmt/kit';
import {fs} from '@cmt/pr';
import {expect} from '@test/util';


suite('[MinGW Tests]', async () => {
const mingw_dirs: string[] = ['C:\\Qt\\Tools\\mingw492_32', 'C:\\mingw-w64\\x86_64-7.2.0-posix-seh-rt_v5-rev1\\mingw64'];

Expand All @@ -13,7 +12,7 @@ suite('[MinGW Tests]', async () => {
test('Test scan of mingw', async () => {
const kits = await scanForKits(undefined, {
scanDirs: [],
minGWSearchDirs: mingw_dirs,
minGWSearchDirs: mingw_dirs
});
const is_kit_MinGW_present = kits.find(kit => kit.name.indexOf('GCC for i686-w64-mingw32 4.9.2') >= 0) ? true : false;
const is_kit_MinGW_w64_present = kits.find(kit => kit.name.indexOf('GCC for x86_64-w64-mingw32 7.2.0') >= 0) ? true : false;
Expand Down
4 changes: 2 additions & 2 deletions test/extension-tests/successful-build/test/toolchain.test.ts
@@ -1,3 +1,4 @@
/* eslint-disable no-unused-expressions */
import * as api from '@cmt/api';
import {CMakeCache} from '@cmt/cache';
import {CMakeTools, ConfigureTrigger} from '@cmt/cmake-tools';
Expand All @@ -11,8 +12,7 @@ suite('[Toolchain Substitution]', async () => {

setup(async function(this: Mocha.Context) {
this.timeout(100000);
if (process.platform === 'win32')
this.skip();
if (process.platform === 'win32') {this.skip(); }

testEnv = new DefaultEnvironment('test/extension-tests/successful-build/project-folder', 'build', 'output.txt');
cmt = await CMakeTools.create(testEnv.vsContext, testEnv.wsContext);
Expand Down

0 comments on commit 88b3abc

Please sign in to comment.