forked from microsoft/vscode-java-test
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutils.ts
More file actions
54 lines (49 loc) · 1.83 KB
/
utils.ts
File metadata and controls
54 lines (49 loc) · 1.83 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT license.
import { Location, TestItem, TestMessage, TestRun, Uri } from 'vscode';
import { JavaTestRunnerCommands } from '../constants';
import { asRange } from '../controller/utils';
import { executeJavaLanguageServerCommand } from '../utils/commandUtils';
export async function findTestLocation(fullName: string): Promise<Location | undefined> {
const location: any | undefined = await executeJavaLanguageServerCommand<any>(
JavaTestRunnerCommands.FIND_TEST_LOCATION, fullName);
if (location) {
return new Location(Uri.parse(location.uri), asRange(location.range)!);
}
return undefined;
}
export function setTestState(testRun: TestRun, item: TestItem, result: TestResultState, message?: TestMessage | TestMessage[], duration?: number): void {
switch (result) {
case TestResultState.Errored:
testRun.errored(item, message || [], duration);
break;
case TestResultState.Failed:
testRun.failed(item, message || [], duration);
break;
case TestResultState.Passed:
testRun.passed(item, duration);
break;
case TestResultState.Skipped:
testRun.skipped(item);
break;
case TestResultState.Running:
testRun.started(item);
default:
break;
}
}
// Copied from the proposed part of the API
export enum TestResultState {
// Test will be run, but is not currently running.
Queued = 1,
// Test is currently running
Running = 2,
// Test run has passed
Passed = 3,
// Test run has failed (on an assertion)
Failed = 4,
// Test run has been skipped
Skipped = 5,
// Test run failed for some other reason (compilation error, timeout, etc)
Errored = 6,
}