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

[DRAFT] fix: add ability to cancel, API not implemented on server W-17867176 #28

Draft
wants to merge 1 commit 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
4 changes: 1 addition & 3 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ on:
label:
description: Label for the generated vsix artifact
required: false
default: EFDExtension-${{ github.sha }}
default: AFDXExtension-${{ github.sha }}
type: string

jobs:
Expand All @@ -25,8 +25,6 @@ jobs:
with:
node-version-file: '.nvmrc'
cache: npm
# - name: Configure Git for private repo access
# run: git config --global --add url."https://${{ secrets.IDEE_GH_TOKEN }}@github.com/".insteadOf "https://github.com/"
- run: npm ci
- run: npm --version
- run: node --version
Expand Down
26 changes: 21 additions & 5 deletions src/views/testRunner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,15 +100,30 @@ export class AgentTestRunner {
channelService.showChannelOutput();
const tester = new AgentTester(org.getConnection());
channelService.appendLine(`Starting ${test.name} tests: ${new Date().toLocaleString()}`);
let testRunId = '';
vscode.window.withProgress(
{
//TODO: once we can cancel in progress tests
cancellable: false,
cancellable: true,
location: vscode.ProgressLocation.Notification,
title: `Running ${test.name}`
},
async progress => {
async (progress, cancellationToken) => {
return new Promise((resolve, reject) => {
cancellationToken.onCancellationRequested(() => {
tester
.cancel(testRunId)
.then(() => {
progress.report({ increment: 0, message: 'Status: Cancelled' });
channelService.appendLine('Test run cancelled');
this.testOutline.getTestGroup(test.name)?.updateOutcome('TERMINATED', true);
setTimeout(() => reject(), 1500);
})
.catch(e => {
const error = e as Error;
channelService.appendLine(`Error cancelling test: ${error.message}`);
telemetryService.sendException(error.name, error.message);
});
});
lifecycle.on(
'AGENT_TEST_POLLING_EVENT',
async (data: {
Expand Down Expand Up @@ -147,11 +162,12 @@ export class AgentTestRunner {
);

const response = await tester.start(test.name);
testRunId = response.runId;
// begin in-progress
this.testOutline.getTestGroup(test.name)?.updateOutcome('IN_PROGRESS', true);
channelService.appendLine(`Job Id: ${response.runId}`);
channelService.appendLine(`Job Id: ${testRunId}`);

const result = await tester.poll(response.runId, { timeout: Duration.minutes(100) });
const result = await tester.poll(testRunId, { timeout: Duration.minutes(100) });
this.testGroupNameToResult.set(test.name, result);
this.testOutline.getTestGroup(test.name)?.updateOutcome('IN_PROGRESS', true);
let hasFailure = false;
Expand Down