Skip to content

Add logging for test failure (3) #11556

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 6 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions src/interactive-window/debugger/jupyter/kernelDebugAdapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { DebugAdapterTracker, DebugSession, NotebookDocument, Uri } from 'vscode
import { DebugProtocol } from 'vscode-debugprotocol';
import { IKernel, IKernelConnectionSession } from '../../../kernels/types';
import { IPlatformService } from '../../../platform/common/platform/types';
import { IDumpCellResponse, IDebugLocationTrackerFactory } from '../../../notebooks/debugger/debuggingTypes';
import { IDebugLocationTrackerFactory } from '../../../notebooks/debugger/debuggingTypes';
import { traceError, traceInfo, traceInfoIfCI } from '../../../platform/logging';
import { getInteractiveCellMetadata } from '../../../interactive-window/helpers';
import { KernelDebugAdapterBase } from '../../../notebooks/debugger/kernelDebugAdapterBase';
Expand Down Expand Up @@ -90,7 +90,8 @@ export class KernelDebugAdapter extends KernelDebugAdapterBase {
const response = await this.session.customRequest('dumpCell', { code });

// We know jupyter will strip out leading white spaces, hence take that into account.
const norm = path.normalize((response as IDumpCellResponse).sourcePath);
const norm = KernelDebugAdapterBase.normalizeFsAware(response.sourcePath);
traceInfoIfCI(`KernelDebugAdapter::dumpCell ${response.sourcePath} -> ${norm}`);
this.fileToCell.set(norm, Uri.parse(metadata.interactive.uristring));

// If this cell doesn't have a cell marker, then
Expand Down
12 changes: 6 additions & 6 deletions src/notebooks/debugger/kernelDebugAdapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,10 @@

'use strict';

import * as path from '../../platform/vscode-path/path';
import { IDumpCellResponse } from './debuggingTypes';
import { traceError } from '../../platform/logging';
import { traceError, traceInfoIfCI } from '../../platform/logging';
import { KernelDebugAdapterBase } from './kernelDebugAdapterBase';
import { DebugProtocol } from 'vscode-debugprotocol';
import { IDumpCellResponse } from './debuggingTypes';

/**
* Concrete implementation of the KernelDebugAdapterBase class that will dump cells
Expand All @@ -19,10 +18,11 @@ export class KernelDebugAdapter extends KernelDebugAdapterBase {
protected override async dumpCell(index: number): Promise<void> {
const cell = this.notebookDocument.cellAt(index);
try {
const response = await this.session.customRequest('dumpCell', {
const response = (await this.session.customRequest('dumpCell', {
code: cell.document.getText().replace(/\r\n/g, '\n')
});
const norm = path.normalize((response as IDumpCellResponse).sourcePath);
})) as IDumpCellResponse;
const norm = KernelDebugAdapterBase.normalizeFsAware(response.sourcePath);
traceInfoIfCI(`KernelDebugAdapter::dumpCell ${response.sourcePath} -> ${norm}`);
this.fileToCell.set(norm, cell.document.uri);
this.cellToFile.set(cell.document.uri.toString(), norm);
} catch (err) {
Expand Down
17 changes: 17 additions & 0 deletions src/notebooks/debugger/kernelDebugAdapterBase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,23 @@ export abstract class KernelDebugAdapterBase implements DebugAdapter, IKernelDeb
});
}

static normalizeFsAware(sourcePath: string) {
// If the kernel runs on Windows, then do windows-style path normalization
// (see https://github.com/ipython/ipykernel/issues/995).
let norm = '';
if (sourcePath.match(/^[A-Za-z]:/)) {
norm = path.win32.normalize(sourcePath);
} else {
traceInfoIfCI(
`KernelDebugAdapter::normalizeFsAware ${sourcePath} would normalize to ${path.posix.normalize(
sourcePath
)}`
);
norm = path.posix.normalize(sourcePath);
}
return norm;
}

private lookupCellByLongName(sourcePath: string) {
if (!this.platformService.isWindows) {
return undefined;
Expand Down