@@ -2,6 +2,7 @@ import { writeFile } from "node:fs/promises";
22import type { DocumentLoader } from "@fedify/vocab-runtime" ;
33import process from "node:process" ;
44import { getContextLoader , getDocumentLoader } from "../docloader.ts" ;
5+ import { describeError } from "../utils.ts" ;
56import { buildFleet } from "./actor/fleet.ts" ;
67import type { BenchCommand } from "./command.ts" ;
78import {
@@ -24,7 +25,7 @@ import {
2425 type ResolvedScenario ,
2526 type ResolvedSuite ,
2627} from "./scenario/normalize.ts" ;
27- import type { LoadConfig , Suite } from "./scenario/types.ts" ;
28+ import type { LoadConfig , Suite , SuiteDefaults } from "./scenario/types.ts" ;
2829import { validateSuite } from "./scenario/validate.ts" ;
2930import {
3031 assertInboxDestinationAllowed ,
@@ -100,7 +101,7 @@ export default async function runBench(
100101 validated = validateSuite ( rendered , command . scenario ) ;
101102 suite = normalizeSuite ( validated , { target : command . target } ) ;
102103 } catch ( error ) {
103- log ( error instanceof Error ? error . message : String ( error ) ) ;
104+ log ( describeError ( error ) ) ;
104105 return void exit ( 2 ) ;
105106 }
106107
@@ -119,7 +120,7 @@ export default async function runBench(
119120 resolveAdvertiseHost ( command . advertiseHost ) ;
120121 }
121122 } catch ( error ) {
122- log ( error instanceof Error ? error . message : String ( error ) ) ;
123+ log ( describeError ( error ) ) ;
123124 return void exit ( 2 ) ;
124125 }
125126
@@ -190,7 +191,7 @@ export default async function runBench(
190191 allowUnsafe : command . allowUnsafeTarget ,
191192 explicitCliTarget : command . target != null ,
192193 destinationTier,
193- suite : validated ,
194+ defaults : validated . defaults ,
194195 } ) ;
195196 } ;
196197
@@ -207,7 +208,7 @@ export default async function runBench(
207208 ) ;
208209 return void exit ( 0 ) ;
209210 } catch ( error ) {
210- log ( error instanceof Error ? error . message : String ( error ) ) ;
211+ log ( describeError ( error ) ) ;
211212 return void exit ( 2 ) ;
212213 }
213214 }
@@ -431,10 +432,6 @@ async function describeInboxDiscoveryPlan(
431432 return lines ;
432433}
433434
434- function describeError ( error : unknown ) : string {
435- return error instanceof Error ? error . message : String ( error ) ;
436- }
437-
438435function describeWebFingerPlan (
439436 scenario : ResolvedScenario ,
440437 target : URL ,
@@ -472,7 +469,7 @@ interface PublicDestinationOverrideContext {
472469 readonly allowUnsafe : boolean ;
473470 readonly explicitCliTarget : boolean ;
474471 readonly destinationTier : TargetTier ;
475- readonly suite : Suite ;
472+ readonly defaults ?: SuiteDefaults ;
476473}
477474
478475function assertPublicDestinationOverrideAllowed (
@@ -493,24 +490,24 @@ function assertPublicDestinationOverrideAllowed(
493490 benchmarkMode : false ,
494491 allowUnsafe : true ,
495492 explicitCliTarget : context . explicitCliTarget ,
496- scenarios : [ unsafeOverrideScenario ( scenario , context . suite ) ] ,
493+ scenarios : [ unsafeOverrideScenario ( scenario , context . defaults ) ] ,
497494 } ) ;
498495}
499496
500497function unsafeOverrideScenarios (
501498 suite : Suite ,
502499) : Parameters < typeof assertUnsafeOverrideAllowed > [ 0 ] [ "scenarios" ] {
503500 return suite . scenarios . map ( ( scenario ) =>
504- unsafeOverrideScenario ( scenario , suite )
501+ unsafeOverrideScenario ( scenario , suite . defaults )
505502 ) ;
506503}
507504
508505function unsafeOverrideScenario (
509506 scenario : ResolvedScenario | Suite [ "scenarios" ] [ number ] ,
510- suite ?: Suite ,
507+ defaults ?: SuiteDefaults ,
511508) : Parameters < typeof assertUnsafeOverrideAllowed > [ 0 ] [ "scenarios" ] [ number ] {
512- const defaultDuration = suite ?. defaults ?. duration != null ;
513- const defaultLoad = hasExplicitLoad ( suite ?. defaults ?. load ) ;
509+ const defaultDuration = defaults ?. duration != null ;
510+ const defaultLoad = hasExplicitLoad ( defaults ?. load ) ;
514511 const raw = "raw" in scenario ? scenario . raw : scenario ;
515512 return {
516513 name : scenario . name ,
0 commit comments