Skip to content

Commit 7f638ea

Browse files
Filip Pospisildjelinek
authored andcommitted
improve idea|
1 parent 911b108 commit 7f638ea

File tree

5 files changed

+49
-7
lines changed

5 files changed

+49
-7
lines changed

packages/extester/src/browser.ts

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ export class VSBrowser {
3535
private codeVersion: string;
3636
private releaseType: ReleaseQuality;
3737
private logLevel: logging.Level;
38+
private locale: string;
3839
private static _instance: VSBrowser;
3940
private readonly _startTimestamp: string;
4041

@@ -43,13 +44,20 @@ export class VSBrowser {
4344
return `${date.getFullYear()}${pad(date.getMonth() + 1)}${pad(date.getDate())}T${pad(date.getHours())}${pad(date.getMinutes())}${pad(date.getSeconds())}`;
4445
}
4546

46-
constructor(codeVersion: string, releaseType: ReleaseQuality, customSettings: object = {}, logLevel: logging.Level = logging.Level.INFO) {
47+
constructor(
48+
codeVersion: string,
49+
releaseType: ReleaseQuality,
50+
customSettings: object = {},
51+
logLevel: logging.Level = logging.Level.INFO,
52+
locale: string = '',
53+
) {
4754
this.storagePath = process.env.TEST_RESOURCES ? process.env.TEST_RESOURCES : path.resolve(DEFAULT_STORAGE_FOLDER);
4855
this.extensionsFolder = process.env.EXTENSIONS_FOLDER ? process.env.EXTENSIONS_FOLDER : undefined;
4956
this.customSettings = customSettings;
5057
this.codeVersion = codeVersion;
5158
this.releaseType = releaseType;
5259
this.logLevel = logLevel;
60+
this.locale = locale;
5361
this._startTimestamp = this.formatTimestamp(new Date());
5462

5563
VSBrowser._instance = this;
@@ -87,7 +95,12 @@ export class VSBrowser {
8795
fs.writeJSONSync(path.join(userSettings, 'settings.json'), defaultSettings);
8896
console.log(`Writing code settings to ${path.join(userSettings, 'settings.json')}`);
8997

90-
const args = ['--no-sandbox', '--disable-dev-shm-usage', `--user-data-dir=${path.join(this.storagePath, 'settings')}`];
98+
const args = ['--no-sandbox', '--disable-dev-shm-usage', `--user-data-dir=${path.join(this.storagePath, 'settings')}`]; // sem pridam locale
99+
100+
if (this.locale) {
101+
console.log('locale is in args with value ' + this.locale);
102+
args.push(`--locale ${this.locale}`);
103+
}
91104

92105
if (this.extensionsFolder) {
93106
args.push(`--extensions-dir=${this.extensionsFolder}`);
@@ -102,10 +115,14 @@ export class VSBrowser {
102115
args.push(`--extensionDevelopmentPath=${process.env.EXTENSION_DEV_PATH}`);
103116
}
104117

118+
console.log('args', args);
119+
105120
let options = new Options().setChromeBinaryPath(codePath).addArguments(...args) as any;
106121
options['options_'].windowTypes = ['webview'];
107122
options = options as Options;
108123

124+
console.log('options', options);
125+
109126
const prefs = new logging.Preferences();
110127
prefs.setLevel(logging.Type.DRIVER, this.logLevel);
111128
options.setLoggingPrefs(prefs);
@@ -117,6 +134,9 @@ export class VSBrowser {
117134
}
118135

119136
console.log('Launching browser...');
137+
// Print the full launch command for debugging
138+
console.log('Launching VS Code with command:', `"${codePath}" ${args.join(' ')}`);
139+
120140
this._driver = await new Builder()
121141
.setChromeService(new ServiceBuilder(chromeDriverBinaryPath))
122142
.forBrowser(Browser.CHROME)

packages/extester/src/cli.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,7 @@ program
141141
logLevel: cmd.log_level,
142142
offline: cmd.offline,
143143
resources: cmd.open_resource ?? [],
144+
locale: cmd.locale,
144145
});
145146
}),
146147
);
@@ -162,7 +163,7 @@ program
162163
.option('-C, --coverage', 'Enable code coverage using c8')
163164
.option('-r, --open_resource <resources...>', 'Open resources in VS Code. Multiple files and folders can be specified.')
164165
.option('-n, --no_cache', 'Skip using cached version and download fresh copy without caching it', false)
165-
.option('-L, --locale <locale>', 'to be defined')
166+
.option('-L, --locale <locale>', 'to be defined22')
166167
.action(
167168
withErrors(async (testFiles, cmd) => {
168169
const extest = new ExTester(cmd.storage, codeStream(cmd.type), cmd.extensions_dir, cmd.coverage);
@@ -180,6 +181,7 @@ program
180181
config: cmd.mocha_config,
181182
logLevel: cmd.log_level,
182183
resources: cmd.open_resource ?? [],
184+
locale: cmd.locale,
183185
},
184186
);
185187
}),

packages/extester/src/extester.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,10 @@ export class ExTester {
232232
setupOptions: Omit<SetupOptions, 'vscodeVersion'> = DEFAULT_SETUP_OPTIONS,
233233
runOptions: Omit<RunOptions, 'vscodeVersion'> = DEFAULT_RUN_OPTIONS,
234234
): Promise<number> {
235+
console.log('setupAndRunTests');
236+
console.log('setup options:', JSON.stringify(setupOptions, null, 2));
237+
console.log('run options:', JSON.stringify(runOptions, null, 2));
238+
235239
await this.setupRequirements({ ...setupOptions, vscodeVersion }, runOptions.offline, runOptions.cleanup);
236240
return await this.runTests(testFilesPattern, {
237241
...runOptions,
@@ -247,6 +251,9 @@ export class ExTester {
247251
* @returns Promise resolving to the mocha process exit code - 0 for no failures, 1 otherwise
248252
*/
249253
async runTests(testFilesPattern: string | string[], runOptions: RunOptions = DEFAULT_RUN_OPTIONS): Promise<number> {
254+
console.log('runTests');
255+
console.log('run options:', JSON.stringify(runOptions, null, 2));
256+
250257
runOptions.vscodeVersion = loadCodeVersion(runOptions.vscodeVersion);
251258
const patterns = typeof testFilesPattern === 'string' ? [testFilesPattern] : testFilesPattern;
252259
return await this.code.runTests(patterns, runOptions);

packages/extester/src/suite/runner.ts

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,15 +38,25 @@ export class VSRunner {
3838
private cleanup: boolean;
3939
private tmpLink = path.join(os.tmpdir(), 'extest-code');
4040
private releaseType: ReleaseQuality;
41-
42-
constructor(bin: string, codeVersion: string, customSettings: object = {}, cleanup: boolean = false, releaseType: ReleaseQuality, config?: string) {
41+
private locale: string | undefined;
42+
43+
constructor(
44+
bin: string,
45+
codeVersion: string,
46+
customSettings: object = {},
47+
cleanup: boolean = false,
48+
releaseType: ReleaseQuality,
49+
config?: string,
50+
locale?: string,
51+
) {
4352
const conf = this.loadConfig(config);
4453
this.mocha = new Mocha(conf);
4554
this.chromeBin = bin;
4655
this.customSettings = customSettings;
4756
this.codeVersion = codeVersion;
4857
this.cleanup = cleanup;
4958
this.releaseType = releaseType;
59+
this.locale = locale;
5060
}
5161

5262
/**
@@ -58,7 +68,7 @@ export class VSRunner {
5868
runTests(testFilesPattern: string[], code: CodeUtil, logLevel: logging.Level = logging.Level.INFO, resources: string[]): Promise<number> {
5969
return new Promise((resolve) => {
6070
const self = this;
61-
const browser: VSBrowser = new VSBrowser(this.codeVersion, this.releaseType, this.customSettings, logLevel);
71+
const browser: VSBrowser = new VSBrowser(this.codeVersion, this.releaseType, this.customSettings, logLevel, this.locale);
6272
let coverage: Coverage | undefined;
6373

6474
const testFiles = new Set<string>();

packages/extester/src/util/codeUtil.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ export interface RunOptions {
4646
offline?: boolean;
4747
/** list of resources to be opened by VS Code */
4848
resources: string[];
49+
/** tbd */
50+
locale?: string;
4951
}
5052

5153
/** defaults for the [[RunOptions]] */
@@ -55,7 +57,7 @@ export const DEFAULT_RUN_OPTIONS = {
5557
logLevel: logging.Level.INFO,
5658
offline: false,
5759
resources: [],
58-
noCache: false,
60+
noCache: false, //???
5961
};
6062

6163
/**
@@ -321,6 +323,7 @@ export class CodeUtil {
321323
runOptions.cleanup,
322324
this.releaseType,
323325
runOptions.config,
326+
runOptions.locale,
324327
);
325328
return await runner.runTests(testFilesPattern, this, runOptions.logLevel, runOptions.resources);
326329
}

0 commit comments

Comments
 (0)