Skip to content

Commit

Permalink
issue-485: Avoid to get invalid socket file which causes webdriver un…
Browse files Browse the repository at this point in the history
…known error (#978)

Signed-off-by: Dominik Jelinek <[email protected]>
  • Loading branch information
djelinek authored Oct 17, 2023
1 parent d0b325f commit 2b779c5
Show file tree
Hide file tree
Showing 9 changed files with 14 additions and 7 deletions.
1 change: 1 addition & 0 deletions .github/workflows/insiders.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ jobs:

env:
CODE_TYPE: insider
TEST_RESOURCES: test-resources

steps:
- name: Checkout Repository
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ jobs:

env:
CODE_VERSION: ${{ matrix.version }}
TEST_RESOURCES: test-resources

steps:
- name: Checkout Repository
Expand Down
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
out
node_modules
test-resources
./.vscode
docs
resources/api-handler.vsix
Expand Down
3 changes: 2 additions & 1 deletion src/browser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { WebDriver, Builder, until, initPageObjects, logging, By } from 'monaco-
import { Options, ServiceBuilder } from 'selenium-webdriver/chrome';
import { getLocatorsPath } from 'vscode-extension-tester-locators';
import { CodeUtil, ReleaseQuality } from './util/codeUtil';
import { DEFAULT_STORAGE_FOLDER } from './extester';

export class VSBrowser {
static readonly baseVersion = '1.37.0';
Expand All @@ -21,7 +22,7 @@ export class VSBrowser {
private static _instance: VSBrowser;

constructor(codeVersion: string, releaseType: ReleaseQuality, customSettings: Object = {}, logLevel: logging.Level = logging.Level.INFO) {
this.storagePath = process.env.TEST_RESOURCES ? process.env.TEST_RESOURCES : path.resolve('test-resources');
this.storagePath = process.env.TEST_RESOURCES ? process.env.TEST_RESOURCES : path.resolve(DEFAULT_STORAGE_FOLDER);
this.extensionsFolder = process.env.EXTENSIONS_FOLDER ? process.env.EXTENSIONS_FOLDER : undefined;
this.customSettings = customSettings;
this.codeVersion = codeVersion;
Expand Down
5 changes: 4 additions & 1 deletion src/extester.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { CodeUtil, DEFAULT_RUN_OPTIONS, ReleaseQuality, RunOptions } from './uti
import { DriverUtil } from './util/driverUtil';
import * as fs from 'fs-extra';
import * as path from 'path';
import * as os from 'os';
import { URL } from 'url';

export { ReleaseQuality }
Expand All @@ -26,6 +27,8 @@ export const DEFAULT_SETUP_OPTIONS = {
installDependencies: false
}

export const DEFAULT_STORAGE_FOLDER = process.env.TEST_RESOURCES ? process.env.TEST_RESOURCES : path.join(os.tmpdir(), 'test-resources');

export const VSCODE_VERSION_MIN = '1.81.1';
export const VSCODE_VERSION_MAX = '1.83.1';

Expand All @@ -42,7 +45,7 @@ export class ExTester {
private code: CodeUtil;
private chrome: DriverUtil;

constructor(storageFolder: string = 'test-resources', releaseType: ReleaseQuality = ReleaseQuality.Stable, extensionsDir?: string) {
constructor(storageFolder: string = DEFAULT_STORAGE_FOLDER, releaseType: ReleaseQuality = ReleaseQuality.Stable, extensionsDir?: string) {
this.code = new CodeUtil(storageFolder, releaseType, extensionsDir);
this.chrome = new DriverUtil(storageFolder);

Expand Down
3 changes: 2 additions & 1 deletion src/util/codeUtil.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { VSRunner } from "../suite/runner";
import { Unpack } from "./unpack";
import { logging } from "selenium-webdriver";
import { Download } from './download';
import { DEFAULT_STORAGE_FOLDER } from '../extester';

export enum ReleaseQuality {
Stable = 'stable',
Expand Down Expand Up @@ -60,7 +61,7 @@ export class CodeUtil {
* @param folder Path to folder where all the artifacts will be stored.
* @param extensionsFolder Path to use as extensions directory by VSCode
*/
constructor(folder: string = 'test-resources', type: ReleaseQuality = ReleaseQuality.Stable, extensionsFolder?: string) {
constructor(folder: string = DEFAULT_STORAGE_FOLDER, type: ReleaseQuality = ReleaseQuality.Stable, extensionsFolder?: string) {
this.availableVersions = [];
this.downloadPlatform = this.getPlatform();
this.downloadFolder = path.resolve(folder);
Expand Down
3 changes: 2 additions & 1 deletion src/util/driverUtil.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import * as path from 'path';
import * as child_process from 'child_process';
import { Unpack } from './unpack';
import { Download } from './download';
import { DEFAULT_STORAGE_FOLDER } from '../extester';

/**
* Handles version checks and download of ChromeDriver
Expand All @@ -16,7 +17,7 @@ export class DriverUtil {
* Create an instance of chrome driver handler
* @param folder path to a folder to store all artifacts
*/
constructor(folder: string = 'test-resources') {
constructor(folder: string = DEFAULT_STORAGE_FOLDER) {
this.downloadFolder = path.resolve(folder);
}

Expand Down
2 changes: 1 addition & 1 deletion wiki/Taking Screenshots.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Screenshot can be captured by calling:
VSBrowser.instance.takeScreenshot(basename: string)
```

Captured screenshots will be saved in *screenshots* folder which can be found in *test-resources* folder.
Captured screenshots will be saved in *screenshots* folder which can be found in a test storage folder (`$TMPDIR/test-resources` by default).
File name will be generated from given basename in the following format: `${basename}.png`.

#### Mocha integration
Expand Down
2 changes: 1 addition & 1 deletion wiki/Test-Setup.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
The Extension Tester offers both CLI and API to perform all the setup actions. That way you can simply integrate it into your npm scripts, or just call it from your code if that is more preferable.

## Using the CLI
All the CLI actions are available with the command ```extest``` which is available to your npm scripts once the package is installed. The default storage folder for all test resources is ```test-resources``` in the extension's root. To avoid build problems, make sure to exclude it from your ```tsconfig``` and ```vsce```.
All the CLI actions are available with the command ```extest``` which is available to your npm scripts once the package is installed. The default storage folder for all test resources is a ```$TMPDIR/test-resources```.

#### Download VS Code
If you wish to manually download VS Code of a given version
Expand Down

0 comments on commit 2b779c5

Please sign in to comment.