public async run()

in src/runners/baseRunner/BaseRunner.ts [31:100]


    public async run(launchConfiguration: DebugConfiguration, token: CancellationToken, progressReporter?: IProgressReporter): Promise<void> {
        let data: string = '';
        this.server.on('connection', (socket: Socket) => {
            this.socket = socket;
            socket.on('error', (err: Error) => {
                throw err;
            });

            socket.on('data', (buffer: Buffer) => {
                data = data.concat(iconv.decode(buffer, launchConfiguration.encoding || 'utf8'));
                const index: number = data.lastIndexOf(os.EOL);
                if (index >= 0) {
                    this.runnerResultAnalyzer.analyzeData(data.substring(0, index + os.EOL.length));
                    data = data.substring(index + os.EOL.length);
                }
            });

            socket.on('error', (err: Error) => {
                throw err;
            });

            this.server.on('error', (err: Error) => {
                throw err;
            });
        });

        // Run from integrated terminal will terminate the debug session immediately after launching,
        // So we force to use internal console here to make sure the session is still under debugger's control.
        launchConfiguration.console = 'internalConsole';

        let debugSession: DebugSession | undefined;
        this.disposables.push(debug.onDidStartDebugSession((session: DebugSession) => {
            if (session.name === launchConfiguration.name) {
                debugSession = session;
            }
        }));

        if (token.isCancellationRequested || progressReporter?.isCancelled()) {
            this.tearDown();
            return;
        }
        return await debug.startDebugging(this.testContext.workspaceFolder, launchConfiguration).then(async (success: boolean) => {
            if (!success || token.isCancellationRequested) {
                this.tearDown();
                return;
            }

            token.onCancellationRequested(() => {
                debugSession?.customRequest('disconnect', { restart: false });
            });

            return await new Promise<void>((resolve: () => void): void => {
                this.disposables.push(
                    debug.onDidTerminateDebugSession((session: DebugSession): void => {
                        if (launchConfiguration.name === session.name) {
                            debugSession = undefined;
                            this.tearDown();
                            if (data.length > 0) {
                                this.runnerResultAnalyzer.analyzeData(data);
                            }
                            return resolve();
                        }
                    }),
                );
            });
        }, ((): any => {
            this.tearDown();
            return;
        }));
    }