Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
microsoft
GitHub Repository: microsoft/vscode
Path: blob/main/extensions/copilot/test/base/rubric.ts
13388 views
1
/*---------------------------------------------------------------------------------------------
2
* Copyright (c) Microsoft Corporation. All rights reserved.
3
* Licensed under the MIT License. See License.txt in the project root for license information.
4
*--------------------------------------------------------------------------------------------*/
5
import { ITestingServicesAccessor } from '../../src/platform/test/node/services';
6
import { ISimulationTestRuntime } from './stest';
7
8
export function rubric(accessor: ITestingServicesAccessor, ...assertions: (() => void)[]) {
9
const runtime = accessor.get(ISimulationTestRuntime);
10
11
let passed = 0;
12
for (const a of assertions) {
13
try {
14
a();
15
passed++;
16
} catch (e) {
17
runtime.log(String(e));
18
// ignored
19
}
20
}
21
22
if (passed === 0) {
23
runtime.setOutcome({ kind: 'failed', hitContentFilter: false, error: 'no passed assertions', critical: false });
24
} else {
25
runtime.setExplicitScore(passed / assertions.length);
26
}
27
}
28
29