mirror of
https://github.com/Microsoft/vscode
synced 2024-07-05 01:08:57 +00:00
logs - make sure to attach all logs in browser tests (#181578)
* logs - make sure to attach all logs in browser tests * separate server logs into `server` folder
This commit is contained in:
parent
17c9f969c9
commit
1894181c08
|
@ -28,7 +28,7 @@ export interface ILocalizedStrings {
|
|||
}
|
||||
|
||||
export interface ILogFile {
|
||||
readonly name: string;
|
||||
readonly relativePath: string;
|
||||
readonly contents: string;
|
||||
}
|
||||
|
||||
|
|
|
@ -3,6 +3,8 @@
|
|||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { relativePath } from 'vs/base/common/resources';
|
||||
import { URI } from 'vs/base/common/uri';
|
||||
import { IEnvironmentService } from 'vs/platform/environment/common/environment';
|
||||
import { IFileService } from 'vs/platform/files/common/files';
|
||||
import { AdapterLogger, DEFAULT_LOG_LEVEL, ILogger, LogLevel } from 'vs/platform/log/common/log';
|
||||
|
@ -13,7 +15,7 @@ export interface IAutomatedWindow {
|
|||
}
|
||||
|
||||
export interface ILogFile {
|
||||
readonly name: string;
|
||||
readonly relativePath: string;
|
||||
readonly contents: string;
|
||||
}
|
||||
|
||||
|
@ -25,22 +27,29 @@ export interface ILogFile {
|
|||
export async function getLogs(fileService: IFileService, environmentService: IEnvironmentService): Promise<ILogFile[]> {
|
||||
const result: ILogFile[] = [];
|
||||
|
||||
const logs = await fileService.resolve(environmentService.logsHome);
|
||||
|
||||
for (const { name, isDirectory, resource } of logs.children || []) {
|
||||
if (isDirectory) {
|
||||
continue;
|
||||
}
|
||||
|
||||
const contents = (await fileService.readFile(resource)).value.toString();
|
||||
if (contents) {
|
||||
result.push({ name, contents });
|
||||
}
|
||||
}
|
||||
await doGetLogs(fileService, result, environmentService.logsHome, environmentService.logsHome);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
async function doGetLogs(fileService: IFileService, logs: ILogFile[], curFolder: URI, logsHome: URI): Promise<void> {
|
||||
const stat = await fileService.resolve(curFolder);
|
||||
|
||||
for (const { resource, isDirectory } of stat.children || []) {
|
||||
if (isDirectory) {
|
||||
await doGetLogs(fileService, logs, resource, logsHome);
|
||||
} else {
|
||||
const contents = (await fileService.readFile(resource)).value.toString();
|
||||
if (contents) {
|
||||
const path = relativePath(logsHome, resource);
|
||||
if (path) {
|
||||
logs.push({ relativePath: path, contents });
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function logLevelToString(level: LogLevel): string {
|
||||
switch (level) {
|
||||
case LogLevel.Trace: return 'trace';
|
||||
|
|
|
@ -32,6 +32,7 @@ export async function launch(options: LaunchOptions): Promise<{ serverProcess: C
|
|||
|
||||
async function launchServer(options: LaunchOptions) {
|
||||
const { userDataDir, codePath, extensionsPath, logger, logsPath } = options;
|
||||
const serverLogsPath = join(logsPath, 'server');
|
||||
const codeServerPath = codePath ?? process.env.VSCODE_REMOTE_SERVER_PATH;
|
||||
const agentFolder = userDataDir;
|
||||
await measureAndLog(() => mkdirp(agentFolder), `mkdirp(${agentFolder})`, logger);
|
||||
|
@ -49,7 +50,7 @@ async function launchServer(options: LaunchOptions) {
|
|||
`--extensions-dir=${extensionsPath}`,
|
||||
`--server-data-dir=${agentFolder}`,
|
||||
'--accept-server-license-terms',
|
||||
`--logsPath=${logsPath}`
|
||||
`--logsPath=${serverLogsPath}`
|
||||
];
|
||||
|
||||
if (options.verbose) {
|
||||
|
@ -68,7 +69,7 @@ async function launchServer(options: LaunchOptions) {
|
|||
logger.log(`Starting server out of sources from '${serverLocation}'`);
|
||||
}
|
||||
|
||||
logger.log(`Storing log files into '${logsPath}'`);
|
||||
logger.log(`Storing log files into '${serverLogsPath}'`);
|
||||
|
||||
logger.log(`Command line: '${serverLocation}' ${args.join(' ')}`);
|
||||
const serverProcess = spawn(
|
||||
|
|
|
@ -145,7 +145,7 @@ export class PlaywrightDriver {
|
|||
const logs = await this.getLogs();
|
||||
|
||||
for (const log of logs) {
|
||||
const absoluteLogsPath = join(this.options.logsPath, log.name);
|
||||
const absoluteLogsPath = join(this.options.logsPath, log.relativePath);
|
||||
|
||||
await promises.mkdir(dirname(absoluteLogsPath), { recursive: true });
|
||||
await promises.writeFile(absoluteLogsPath, log.contents);
|
||||
|
|
|
@ -67,10 +67,10 @@ async function runTestsInBrowser(browserType: BrowserType, endpoint: url.UrlWith
|
|||
console[type](...args);
|
||||
});
|
||||
|
||||
await page.exposeFunction('codeAutomationExit', async (logs: Array<{ readonly name: string; readonly contents: string }>, code: number) => {
|
||||
await page.exposeFunction('codeAutomationExit', async (logs: Array<{ readonly relativePath: string; readonly contents: string }>, code: number) => {
|
||||
try {
|
||||
for (const log of logs) {
|
||||
const absoluteLogsPath = path.join(logsPath, log.name);
|
||||
const absoluteLogsPath = path.join(logsPath, log.relativePath);
|
||||
|
||||
await promises.mkdir(path.dirname(absoluteLogsPath), { recursive: true });
|
||||
await promises.writeFile(absoluteLogsPath, log.contents);
|
||||
|
@ -157,8 +157,9 @@ async function launchServer(browserType: BrowserType): Promise<{ endpoint: url.U
|
|||
}
|
||||
}
|
||||
|
||||
console.log(`Storing log files into '${logsPath}'`);
|
||||
serverArgs.push('--logsPath', logsPath);
|
||||
const serverLogsPath = path.join(logsPath, 'server');
|
||||
console.log(`Storing log files into '${serverLogsPath}'`);
|
||||
serverArgs.push('--logsPath', serverLogsPath);
|
||||
|
||||
const stdio: cp.StdioOptions = optimist.argv.debug ? 'pipe' : ['ignore', 'pipe', 'ignore'];
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user