Skip to content

Commit

Permalink
Fix format
Browse files Browse the repository at this point in the history
  • Loading branch information
DonJayamanne committed Sep 15, 2019
1 parent 6dd810e commit c975f89
Show file tree
Hide file tree
Showing 30 changed files with 107 additions and 405 deletions.
6 changes: 5 additions & 1 deletion src/client/common/process/logger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,11 @@ export class ProcessLogger implements IProcessLogger {
) {}

public logProcess(file: string, args: string[], options?: SpawnOptions) {
if (!isTestExecution() && isCI && !workspace.getConfiguration('python', null).get<boolean>('enableProcessLogging', true)) {
if (
!isTestExecution() &&
isCI &&
!workspace.getConfiguration('python', null).get<boolean>('enableProcessLogging', true)
) {
return;
}
const argsList = args.reduce((accumulator, current, index) => {
Expand Down
5 changes: 1 addition & 4 deletions uitests/src/helpers/extensions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,7 @@ String.prototype.normalize = function(this: string, ...args: []): string {
* By default lines are trimmed and empty lines are removed.
* @param {SplitLinesOptions=} splitOptions - Options used for splitting the string.
*/
String.prototype.splitLines = function(
this: string,
splitOptions: { trim: boolean; removeEmptyEntries: boolean } = { removeEmptyEntries: true, trim: true }
): string[] {
String.prototype.splitLines = function(this: string, splitOptions: { trim: boolean; removeEmptyEntries: boolean } = { removeEmptyEntries: true, trim: true }): string[] {
let lines = this.split(/\r?\n/g);
if (splitOptions && splitOptions.trim) {
lines = lines.map(line => line.trim());
Expand Down
4 changes: 1 addition & 3 deletions uitests/src/helpers/misc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,7 @@ export async function retryWrapper<T extends AnyAsyncFunction>(
): Promise<Unpacked<ReturnType<T>>> {
const watch = new StopWatch();
const interval = options.interval || 100;
const iterations = (options as RetryTimeoutOptions).timeout
? (options as RetryTimeoutOptions).timeout / interval
: (options as RetryCounterOptions).count;
const iterations = (options as RetryTimeoutOptions).timeout ? (options as RetryTimeoutOptions).timeout / interval : (options as RetryCounterOptions).count;
const timeout = (options as RetryTimeoutOptions).timeout || (options as RetryCounterOptions).count * interval;

let lastEx: Error | undefined;
Expand Down
10 changes: 2 additions & 8 deletions uitests/src/helpers/python.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,16 +28,10 @@ export async function installPackage(pythonPath: string, moduleName: string): Pr
export async function uninstallModule(pythonPath: string, moduleName: string): Promise<void> {
await installOrUninstallPackage(pythonPath, moduleName, false);
}
export async function installOrUninstallPackage(
pythonPath: string,
moduleName: string,
install: boolean = true
): Promise<void> {
export async function installOrUninstallPackage(pythonPath: string, moduleName: string, install: boolean = true): Promise<void> {
const installCmd = install ? 'install' : 'uninstall';
const extraArgs = install ? [] : ['-y'];
const cmd = `${pythonPath.toCommandArgument()} -m pip ${installCmd} ${moduleName} -q --disable-pip-version-check ${extraArgs.join(
' '
)}`;
const cmd = `${pythonPath.toCommandArgument()} -m pip ${installCmd} ${moduleName} -q --disable-pip-version-check ${extraArgs.join(' ')}`;
// tslint:disable-next-line: no-unnecessary-callback-wrapper
return new Promise<void>(resolve => exec(cmd.trim(), () => resolve()));
}
Expand Down
6 changes: 1 addition & 5 deletions uitests/src/helpers/unzip.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,7 @@ export async function unzipFile(zipFile: string, targetFolder: string) {

export async function unzipTarGz(zipFile: string, targetFolder: string) {
debug(`Unzip (unzipTarGz) ${zipFile} into ${targetFolder}`);
const fileToFixPermissions = [
'VSCode-linux-x64/code',
'VSCode-linux-x64/code-insiders',
'VSCode-linux-x64/resources/app/node_modules*/vscode-ripgrep/**/rg'
];
const fileToFixPermissions = ['VSCode-linux-x64/code', 'VSCode-linux-x64/code-insiders', 'VSCode-linux-x64/resources/app/node_modules*/vscode-ripgrep/**/rg'];
await fs.ensureDir(targetFolder);
await new Promise((resolve, reject) => {
const gulpFilter = filter(fileToFixPermissions, { restore: true });
Expand Down
28 changes: 7 additions & 21 deletions uitests/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,7 @@ import * as yargs from 'yargs';
import { sleep } from './helpers';
import { info, initialize } from './helpers/logger';
import { mergeAndgenerateHtmlReport } from './helpers/report';
import {
downloadVSCode,
getTestOptions,
installExtensions,
TestOptions,
waitForPythonExtensionToActivate
} from './setup';
import { downloadVSCode, getTestOptions, installExtensions, TestOptions, waitForPythonExtensionToActivate } from './setup';
import { start } from './testRunner';
import { Channel } from './types';
import { Application } from './vscode';
Expand Down Expand Up @@ -112,14 +106,8 @@ const parsedArgs = yargs
.example('test', ' # (Runs all tests in stable)')
.example('test', '--channel=insider # (Runs all tests in insiders)')
.example('test', '--channel=insider --pythonPath=c:/python/python.exe # (Runs all tests in insiders)')
.example(
'test',
"-- --tags=@wip # (Runs tests in stable with with tags @wip. Arguments after '--' are cucumberjs args.)"
)
.example(
'test',
"-- --tags='@smoke and @terminal' # (Runs tests in stable with tags '@smoke and @terminal')"
),
.example('test', "-- --tags=@wip # (Runs tests in stable with with tags @wip. Arguments after '--' are cucumberjs args.)")
.example('test', "-- --tags='@smoke and @terminal' # (Runs tests in stable with tags '@smoke and @terminal')"),
handler: async argv => {
initialize(argv.verbose);
const cucumberArgs = argv._.slice(1);
Expand All @@ -130,12 +118,10 @@ const parsedArgs = yargs
.toString()
.trim()
: argv.pythonPath;
await start(argv.channel, path.resolve(argv.destination), argv.verbose, pythonPath, cucumberArgs).catch(
ex => {
console.error('UI Tests Failed', ex);
process.exit(1); // Required for CLI to fail on CI servers.
}
);
await start(argv.channel, path.resolve(argv.destination), argv.verbose, pythonPath, cucumberArgs).catch(ex => {
console.error('UI Tests Failed', ex);
process.exit(1); // Required for CLI to fail on CI servers.
});
}
})
.command({
Expand Down
27 changes: 9 additions & 18 deletions uitests/src/selectors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -172,10 +172,8 @@ export class QuickOpen {
public static QUICK_OPEN_HIDDEN = 'div.monaco-quick-open-widget[aria-hidden="true"]';
public static QUICK_OPEN_INPUT = `${QuickOpen.QUICK_OPEN} .quick-open-input input`;
public static QUICK_OPEN_FOCUSED_ELEMENT = `${QuickOpen.QUICK_OPEN} .quick-open-tree .monaco-tree-row.focused .monaco-highlighted-label`;
public static QUICK_OPEN_ENTRY_SELECTOR =
'div[aria-label="Quick Picker"] .monaco-tree-rows.show-twisties .monaco-tree-row .quick-open-entry';
public static QUICK_OPEN_ENTRY_LABEL_SELECTOR =
'div[aria-label="Quick Picker"] .monaco-tree-rows.show-twisties .monaco-tree-row .quick-open-entry .label-name';
public static QUICK_OPEN_ENTRY_SELECTOR = 'div[aria-label="Quick Picker"] .monaco-tree-rows.show-twisties .monaco-tree-row .quick-open-entry';
public static QUICK_OPEN_ENTRY_LABEL_SELECTOR = 'div[aria-label="Quick Picker"] .monaco-tree-rows.show-twisties .monaco-tree-row .quick-open-entry .label-name';
public static QUICK_OPEN_ENTRY_LINE_LABEL_SELECTOR =
'div[aria-label="Quick Picker"] .monaco-tree-rows.show-twisties .monaco-tree-row.focused .quick-open-entry .monaco-label-description-container .label-name .monaco-highlighted-label span';
}
Expand Down Expand Up @@ -230,23 +228,19 @@ const selectors: Record<Selector, { stable: string } & { insider?: string }> = {
stable: '.notifications-toasts.visible .notification-toast-container .notification-list-item.expanded'
},
[Selector.NotificationError]: {
stable:
'.notifications-toasts.visible .notification-toast-container .notification-list-item.expanded .notification-list-item-icon.icon-error'
stable: '.notifications-toasts.visible .notification-toast-container .notification-list-item.expanded .notification-list-item-icon.icon-error'
},
[Selector.NthNotificationMessage]: {
stable:
'.notifications-toasts.visible .notification-toast-container:nth-child({0}) .notification-list-item.expanded div.notification-list-item-message span'
stable: '.notifications-toasts.visible .notification-toast-container:nth-child({0}) .notification-list-item.expanded div.notification-list-item-message span'
},
[Selector.IndividualNotification]: {
stable: messageBoxSelector
},
[Selector.CloseButtonInNthNotification]: {
stable:
'.notifications-toasts.visible .notification-toast-container:nth-child({0}) .notification-list-item.expanded .action-label.icon.clear-notification-action'
stable: '.notifications-toasts.visible .notification-toast-container:nth-child({0}) .notification-list-item.expanded .action-label.icon.clear-notification-action'
},
[Selector.ButtonInNthNotification]: {
stable:
".notifications-toasts.visible .notification-toast-container:nth-child({0}) .notification-list-item.expanded .monaco-button.monaco-text-button[title='{1}']"
stable: ".notifications-toasts.visible .notification-toast-container:nth-child({0}) .notification-list-item.expanded .monaco-button.monaco-text-button[title='{1}']"
},
[Selector.ProblemsBadge]: {
stable: '.part.panel.bottom .action-item.checked .badge-content'
Expand All @@ -261,12 +255,10 @@ const selectors: Record<Selector, { stable: string } & { insider?: string }> = {
stable: `${quickOpen} .quick-open-input input`
},
[Selector.QuickOpenEntryLabel]: {
stable:
'div[aria-label="Quick Picker"] .monaco-tree-rows.show-twisties .monaco-tree-row .quick-open-entry .label-name'
stable: 'div[aria-label="Quick Picker"] .monaco-tree-rows.show-twisties .monaco-tree-row .quick-open-entry .label-name'
},
[Selector.QuickOpenEntryLabelFocused]: {
stable:
'div[aria-label="Quick Picker"] .monaco-tree-rows.show-twisties .monaco-tree-row.focused .quick-open-entry .label-name .monaco-highlighted-label .highlight'
stable: 'div[aria-label="Quick Picker"] .monaco-tree-rows.show-twisties .monaco-tree-row.focused .quick-open-entry .label-name .monaco-highlighted-label .highlight'
},
[Selector.QuickOpenEntryLineLabel]: {
stable: QuickOpen.QUICK_OPEN_ENTRY_LINE_LABEL_SELECTOR
Expand All @@ -293,8 +285,7 @@ const selectors: Record<Selector, { stable: string } & { insider?: string }> = {
stable: 'div[id="workbench.view.extension.test"] div.monaco-tree-row:nth-child({0}) a.label-name'
},
[Selector.NthTestExplorerNodeIcon]: {
stable:
'div[id="workbench.view.extension.test"] div.monaco-tree-row:nth-child({0}) .custom-view-tree-node-item-icon'
stable: 'div[id="workbench.view.extension.test"] div.monaco-tree-row:nth-child({0}) .custom-view-tree-node-item-icon'
},
[Selector.NthTestExplorerNode]: {
stable: 'div[id="workbench.view.extension.test"] div.monaco-tree-row:nth-child({0})'
Expand Down
34 changes: 5 additions & 29 deletions uitests/src/setup/downloader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,19 +47,9 @@ export function getVSCodeExecutablePath(channel: Channel, testDir: string) {
if (process.platform === 'win32') {
return path.join(testDir, channel, channel === 'stable' ? 'Code.exe' : 'Code - Insiders.exe');
} else if (process.platform === 'darwin') {
return path.join(
testDir,
channel,
channel === 'stable'
? 'Visual Studio Code.app/Contents/MacOS/Electron'
: 'Visual Studio Code - Insiders.app/Contents/MacOS/Electron'
);
return path.join(testDir, channel, channel === 'stable' ? 'Visual Studio Code.app/Contents/MacOS/Electron' : 'Visual Studio Code - Insiders.app/Contents/MacOS/Electron');
} else {
return path.join(
testDir,
channel,
channel === 'stable' ? 'VSCode-linux-x64/code' : 'VSCode-linux-x64/code-insiders'
);
return path.join(testDir, channel, channel === 'stable' ? 'VSCode-linux-x64/code' : 'VSCode-linux-x64/code-insiders');
}
}

Expand All @@ -75,19 +65,9 @@ export function getVSCodeElectronPath(channel: Channel, testDir: string) {
if (process.platform === 'win32') {
return path.join(testDir, channel, channel === 'stable' ? 'Code.exe' : 'Code - Insiders.exe');
} else if (process.platform === 'darwin') {
return path.join(
testDir,
channel,
channel === 'stable'
? 'Visual Studio Code.app/Contents/MacOS/Electron'
: 'Visual Studio Code - Insiders.app/Contents/MacOS/Electron'
);
return path.join(testDir, channel, channel === 'stable' ? 'Visual Studio Code.app/Contents/MacOS/Electron' : 'Visual Studio Code - Insiders.app/Contents/MacOS/Electron');
} else {
return path.join(
testDir,
channel,
channel === 'stable' ? 'VSCode-linux-x64/code' : 'VSCode-linux-x64/code-insiders'
);
return path.join(testDir, channel, channel === 'stable' ? 'VSCode-linux-x64/code' : 'VSCode-linux-x64/code-insiders');
}
}

Expand All @@ -103,11 +83,7 @@ export function getVSCodeDirectory(channel: Channel, testDir: string) {
if (process.platform === 'win32') {
return path.join(testDir, channel);
} else if (process.platform === 'darwin') {
return path.join(
testDir,
channel,
channel === 'stable' ? 'Visual Studio Code.app' : 'Visual Studio Code - Insiders.app'
);
return path.join(testDir, channel, channel === 'stable' ? 'Visual Studio Code.app' : 'Visual Studio Code - Insiders.app');
} else {
return path.join(testDir, channel, channel === 'stable' ? 'VSCode-linux-x64' : 'VSCode-linux-x64');
}
Expand Down
59 changes: 9 additions & 50 deletions uitests/src/setup/driver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,28 +5,13 @@

import { ChildProcess } from 'child_process';
import { EventEmitter } from 'events';
import {
Browser,
ClickOptions,
ElementHandle,
launch,
Page,
UnwrapElementHandle,
WrapElementHandle
} from 'puppeteer-core';
import { Browser, ClickOptions, ElementHandle, launch, Page, UnwrapElementHandle, WrapElementHandle } from 'puppeteer-core';
import { URI } from 'vscode-uri';
import { isCI } from '../constants';
import { noop, RetryOptions, retryWrapper, sleep } from '../helpers';
import { debug, warn } from '../helpers/logger';
import { getSelector, Selector } from '../selectors';
import {
ElementsSelectorPredicate,
IDriver,
ITestOptions,
SelectorRetryOptions,
WaitForSelectorOptions,
WaitForSelectorOptionsHidden
} from '../types';
import { ElementsSelectorPredicate, IDriver, ITestOptions, SelectorRetryOptions, WaitForSelectorOptions, WaitForSelectorOptionsHidden } from '../types';
import { getVSCodeElectronPath } from './downloader';

// Time to wait for UI to react to user typing in a textbox.
Expand Down Expand Up @@ -204,10 +189,7 @@ export class Driver extends EventEmitter implements IDriver {
this.process = undefined;
}
public async waitForSelector(selector: string, options?: WaitForSelectorOptions): Promise<ElementHandle>;
public async waitForSelector(
selector: string,
options?: WaitForSelectorOptionsHidden
): Promise<ElementHandle | undefined>;
public async waitForSelector(selector: string, options?: WaitForSelectorOptionsHidden): Promise<ElementHandle | undefined>;
public async waitForSelector(
selector: string,
options?: WaitForSelectorOptions | WaitForSelectorOptionsHidden
Expand All @@ -223,13 +205,7 @@ export class Driver extends EventEmitter implements IDriver {
// tslint:disable-next-line: no-any
public async $(selector: string, options?: SelectorRetryOptions): Promise<any> {
if (!options) {
return this.mainPage
.$(selector)
.then(ele =>
ele
? Promise.resolve(ele)
: Promise.reject(new Error(`Element not found with selector '${selector}'`))
);
return this.mainPage.$(selector).then(ele => (ele ? Promise.resolve(ele) : Promise.reject(new Error(`Element not found with selector '${selector}'`))));
}
const wrapper = async (): Promise<ElementHandle> => {
const ele = await this.mainPage.$(selector);
Expand All @@ -241,10 +217,7 @@ export class Driver extends EventEmitter implements IDriver {
};
return retryWrapper(Driver.toRetryOptions(options, `Failed to find for selector '${selector}'`), wrapper);
}
public async $$(
selector: string,
options?: SelectorRetryOptions & { predicate?: ElementsSelectorPredicate }
): Promise<ElementHandle[]> {
public async $$(selector: string, options?: SelectorRetryOptions & { predicate?: ElementsSelectorPredicate }): Promise<ElementHandle[]> {
if (!options) {
return this.mainPage.$$(selector);
}
Expand All @@ -262,15 +235,8 @@ export class Driver extends EventEmitter implements IDriver {

return retryWrapper(Driver.toRetryOptions(options, `Failed to find for selector '${selector}'`), wrapper);
}
public $eval<R>(
selector: string,
pageFunction: (element: Element) => R | Promise<R>
): Promise<WrapElementHandle<R>>;
public $eval<R, X1>(
selector: string,
pageFunction: (element: Element, x1: UnwrapElementHandle<X1>) => R | Promise<R>,
x1: X1
): Promise<WrapElementHandle<R>>;
public $eval<R>(selector: string, pageFunction: (element: Element) => R | Promise<R>): Promise<WrapElementHandle<R>>;
public $eval<R, X1>(selector: string, pageFunction: (element: Element, x1: UnwrapElementHandle<X1>) => R | Promise<R>, x1: X1): Promise<WrapElementHandle<R>>;
// tslint:disable-next-line: no-any
public $eval(selector: any, pageFunction: any, x1?: any) {
if (arguments.length === 3) {
Expand All @@ -279,15 +245,8 @@ export class Driver extends EventEmitter implements IDriver {
return this.mainPage.$eval(selector, pageFunction);
}

public $$eval<R>(
selector: string,
pageFunction: (elements: Element[]) => R | Promise<R>
): Promise<WrapElementHandle<R>>;
public $$eval<R, X1>(
selector: string,
pageFunction: (elements: Element[], x1: UnwrapElementHandle<X1>) => R | Promise<R>,
x1: X1
): Promise<WrapElementHandle<R>>;
public $$eval<R>(selector: string, pageFunction: (elements: Element[]) => R | Promise<R>): Promise<WrapElementHandle<R>>;
public $$eval<R, X1>(selector: string, pageFunction: (elements: Element[], x1: UnwrapElementHandle<X1>) => R | Promise<R>, x1: X1): Promise<WrapElementHandle<R>>;
// tslint:disable-next-line: no-any
public $$eval(selector: any, pageFunction: any, x1?: any) {
return this.mainPage.$$eval(selector, pageFunction, x1);
Expand Down
5 changes: 1 addition & 4 deletions uitests/src/setup/environment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,10 +120,7 @@ async function cloneGitRepo({ url }: { url: string }, cwd: string): Promise<void
* @param {string} workspaceFolder
* @returns {(Promise<string | undefined>)}
*/
export async function initializeWorkspace(
scenario: HookScenarioResult,
workspaceFolder: string
): Promise<string | undefined> {
export async function initializeWorkspace(scenario: HookScenarioResult, workspaceFolder: string): Promise<string | undefined> {
const repo = getGitRepo(scenario.pickle.tags);
if (!repo) {
debug('initializeWorkspace without a repo');
Expand Down
Loading

0 comments on commit c975f89

Please sign in to comment.