Path: blob/main/extensions/copilot/test/base/rubric.ts
13388 views
/*---------------------------------------------------------------------------------------------1* Copyright (c) Microsoft Corporation. All rights reserved.2* Licensed under the MIT License. See License.txt in the project root for license information.3*--------------------------------------------------------------------------------------------*/4import { ITestingServicesAccessor } from '../../src/platform/test/node/services';5import { ISimulationTestRuntime } from './stest';67export function rubric(accessor: ITestingServicesAccessor, ...assertions: (() => void)[]) {8const runtime = accessor.get(ISimulationTestRuntime);910let passed = 0;11for (const a of assertions) {12try {13a();14passed++;15} catch (e) {16runtime.log(String(e));17// ignored18}19}2021if (passed === 0) {22runtime.setOutcome({ kind: 'failed', hitContentFilter: false, error: 'no passed assertions', critical: false });23} else {24runtime.setExplicitScore(passed / assertions.length);25}26}272829