Skip to content
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

debug: log progress in NamedPipeDebugAdapter tests #170713

Merged
merged 1 commit into from Jan 6, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -46,28 +46,40 @@ function serverConnection(socket: net.Socket) {
suite('Debug - StreamDebugAdapter', () => {

test(`StreamDebugAdapter (NamedPipeDebugAdapter) can initialize a connection`, async () => {
// todo@connor4312: debug test failure that seems to only happen in CI.
// Even running this test on a loop on my machine for an hour doesn't hit failures :(
const progress: string[] = [];
const timeout = setTimeout(() => {
console.log('NamedPipeDebugAdapter test might fail. Progress:', progress.join(','));
}, 1000); // should usually finish is <10ms

const pipeName = crypto.randomBytes(10).toString('hex');
const pipePath = platform.isWindows ? join('\\\\.\\pipe\\', pipeName) : join(tmpdir(), pipeName);
progress.push(`listen on ${pipePath}`);
const server = await new Promise<net.Server>((resolve, reject) => {
const server = net.createServer(serverConnection);
server.once('listening', () => resolve(server));
server.once('error', reject);
server.listen(pipePath);
});
progress.push('server up');

const debugAdapter = new NamedPipeDebugAdapter({
type: 'pipeServer',
path: pipePath
});
try {
await debugAdapter.startSession();
progress.push('started session');
const response: DebugProtocol.Response = await sendInitializeRequest(debugAdapter);
progress.push('got response');
assert.strictEqual(response.command, 'initialize');
assert.strictEqual(response.request_seq, 1);
assert.strictEqual(response.success, true, response.message);
} finally {
await debugAdapter.stopSession();
progress.push('stopped session');
clearTimeout(timeout);
server.close();
debugAdapter.dispose();
}
Expand Down