@systemfsoftware/effect-spec-runtime 1.3.2 → 1.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +2 -6
- package/README.md +7 -1
- package/dist/index.d.ts +26 -11
- package/dist/index.mjs +57 -23
- package/package.json +6 -6
package/CHANGELOG.md
CHANGED
|
@@ -1,9 +1,5 @@
|
|
|
1
1
|
# @systemfsoftware/effect-spec-runtime
|
|
2
2
|
|
|
3
|
-
# @systemfsoftware/effect-spec-runtime@1.
|
|
3
|
+
# @systemfsoftware/effect-spec-runtime@1.4.0
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
No consumer-visible package changes.
|
|
8
|
-
|
|
9
|
-
Rebuilt with tsdown 0.23.7 against the updated dev dependencies: the bundled `dist/` files carry a different hashed runtime chunk name and comment markers, and the declared devDependency ranges move. The public API and runtime behaviour are unchanged.
|
|
5
|
+
Adds `sharedLayer(layer)`, exported from the package entry and from `Suite`. Called at module top level, it returns a layer the whole test file shares: built once before the file's first case and released once when the file ends, both with no time limit. A suite's shared layer (`Suite.openShared`, `Suite.openSharedCase`) now runs on the same mechanism: it is built in the suite's setup before its first case starts, with no time limit, rather than by the first case inside that case's timeout, and released with no time limit. A failed shared build fails the setup hook with the build's error, so the cases that use it fail without running, and a shared layer read before its build ran dies with `SharedLayerNotBuilt`, exported from `Suite`. Adds the `TestFile` reference and its `TestFileInfo` type. While a shared layer builds, `TestFile` holds `Option.some` of the running file as Vitest identifies it: `name`, the path from the Vitest root with `/` separators; `rootName`, the root directory's name; and `projectName`, the Vitest project name or `undefined`. Otherwise it holds `Option.none()`.
|
package/README.md
CHANGED
|
@@ -19,7 +19,7 @@ A registered explored case runs `explore` first and `exploreOnce` as the fork's
|
|
|
19
19
|
|
|
20
20
|
## Suite
|
|
21
21
|
|
|
22
|
-
`Suite.open` registers a suite with no layer, `Suite.openShared` adds a layer shared by the whole suite, `Suite.openCase` adds a layer acquired fresh around every case, and `Suite.openSharedCase` does both. The shared layer is built once,
|
|
22
|
+
`Suite.open` registers a suite with no layer, `Suite.openShared` adds a layer shared by the whole suite, `Suite.openCase` adds a layer acquired fresh around every case, and `Suite.openSharedCase` does both. The shared layer is built once, in the suite's setup before its first case starts, with no time limit; every case of the suite sees those same services, and they are released, again with no time limit, when the suite ends. A failed build fails the suite's setup with the build's error, so its cases fail without running, and a shared layer read before its build ran dies with `SharedLayerNotBuilt`. State a case must not share belongs in the case layer:
|
|
23
23
|
|
|
24
24
|
```ts
|
|
25
25
|
Suite.openShared(bindings, config, { layer: DatabaseFixture }, (register) => {
|
|
@@ -45,6 +45,12 @@ Suite.openShared(bindings, config, { layer: DatabaseFixture }, (register) => {
|
|
|
45
45
|
|
|
46
46
|
An explored case's kernel run re-provides the test's binding onto the program (so the checks the kernel runs count for this test), scopes the run, and reports a failure with its seed and decision path. Its second run takes the same path through `KernelCase.exploreOnce`.
|
|
47
47
|
|
|
48
|
+
## sharedLayer
|
|
49
|
+
|
|
50
|
+
`sharedLayer(layer)`, called at module top level, returns a layer that the whole test file shares: it is built once before the file's first case, in setup with no time limit, and released once when the file ends. It takes and returns a plain `Layer`, so it goes wherever a layer goes, and it runs on the same mechanism as a suite's shared layer.
|
|
51
|
+
|
|
52
|
+
While a shared layer builds, the `TestFile` reference holds `Option.some` of the running test file as Vitest identifies it: `name`, its path from the Vitest root with `/` separators; `rootName`, the root directory's name; and `projectName`, the Vitest project name or `undefined`. A layer can name what it creates after the file that created it. Outside a shared build it holds `Option.none()`.
|
|
53
|
+
|
|
48
54
|
## TaskRef
|
|
49
55
|
|
|
50
56
|
`TaskRef.provideTaskRef(effect, ctx)` makes the running Vitest task context available to a case body:
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
import { Context, Effect, Layer, Scope as Scope$1, Tracer } from "effect";
|
|
1
|
+
import { Context as Context$1, Effect, Layer, Schema, Scope as Scope$1, Tracer } from "effect";
|
|
2
2
|
import { Expect, Vitest } from "@systemfsoftware/vitest";
|
|
3
3
|
import { Asserted } from "@systemfsoftware/vitest/integration";
|
|
4
4
|
import { TestOptions } from "vitest";
|
|
5
|
+
import * as Context from "effect/Context";
|
|
6
|
+
import * as Option from "effect/Option";
|
|
5
7
|
import * as Scope from "effect/Scope";
|
|
6
8
|
declare namespace KernelCase_d_exports {
|
|
7
9
|
export { LiveCase, announceLive, caseProgram, explore, exploreOnce, liveCase };
|
|
@@ -52,8 +54,14 @@ interface SpanRecorder {
|
|
|
52
54
|
declare const make: () => SpanRecorder;
|
|
53
55
|
type RegisterMode = 'run' | 'skip' | 'only';
|
|
54
56
|
type DescribeMode = 'describe' | 'skip' | 'only';
|
|
57
|
+
declare const SharedLayerNotBuilt_base: Schema.Class<SharedLayerNotBuilt, Schema.TaggedStruct<"SharedLayerNotBuilt", {}>, import("effect/Cause").YieldableError & {
|
|
58
|
+
readonly brand: unique symbol;
|
|
59
|
+
}>;
|
|
60
|
+
declare class SharedLayerNotBuilt extends SharedLayerNotBuilt_base {
|
|
61
|
+
get message(): string;
|
|
62
|
+
}
|
|
55
63
|
declare namespace Suite_d_exports {
|
|
56
|
-
export { Bindings, CaseLive, Config, DescribeMode, LiveCase, Options, RegisterFn, RegisterMode, Scenario, Shared, open, openCase, openShared, openSharedCase };
|
|
64
|
+
export { Bindings, CaseLive, Config, DescribeMode, LiveCase, Options, RegisterFn, RegisterMode, Scenario, Shared, SharedLayerNotBuilt, open, openCase, openShared, openSharedCase, sharedLayer };
|
|
57
65
|
}
|
|
58
66
|
type Options = Pick<TestOptions, 'tags'> & Partial<TestOptions>;
|
|
59
67
|
interface Bindings {
|
|
@@ -65,8 +73,8 @@ interface Config {
|
|
|
65
73
|
readonly options: Options | undefined;
|
|
66
74
|
readonly live?: LiveCase;
|
|
67
75
|
}
|
|
68
|
-
interface Shared<R> {
|
|
69
|
-
readonly layer: Layer.Layer<R>;
|
|
76
|
+
interface Shared<R, E = never> {
|
|
77
|
+
readonly layer: Layer.Layer<R, E>;
|
|
70
78
|
}
|
|
71
79
|
/**
|
|
72
80
|
* A registered case: the runner's own `expect` arrives as the argument, so a case's assertion
|
|
@@ -89,17 +97,18 @@ declare const open: {
|
|
|
89
97
|
<B, E, C>(config: Config, use: (register: RegisterFn<B, E, Scope$1.Scope>, propIt: Vitest.MethodsNonLive<never>) => C): (bindings: Bindings) => void;
|
|
90
98
|
<B, E, C>(bindings: Bindings, config: Config, use: (register: RegisterFn<B, E, Scope$1.Scope>, propIt: Vitest.MethodsNonLive<never>) => C): void;
|
|
91
99
|
};
|
|
100
|
+
export declare const sharedLayer: <RShared, EShared>(layer: Layer.Layer<RShared, EShared>) => Layer.Layer<RShared>;
|
|
92
101
|
declare const openShared: {
|
|
93
|
-
<B, E, RShared, C>(config: Config, shared: Shared<RShared>, use: (register: RegisterFn<B, E, RShared | Scope$1.Scope>, propIt: Vitest.MethodsNonLive<never>) => C): (bindings: Bindings) => void;
|
|
94
|
-
<B, E, RShared, C>(bindings: Bindings, config: Config, shared: Shared<RShared>, use: (register: RegisterFn<B, E, RShared | Scope$1.Scope>, propIt: Vitest.MethodsNonLive<never>) => C): void;
|
|
102
|
+
<B, E, RShared, EShared, C>(config: Config, shared: Shared<RShared, EShared>, use: (register: RegisterFn<B, E, RShared | Scope$1.Scope>, propIt: Vitest.MethodsNonLive<never>) => C): (bindings: Bindings) => void;
|
|
103
|
+
<B, E, RShared, EShared, C>(bindings: Bindings, config: Config, shared: Shared<RShared, EShared>, use: (register: RegisterFn<B, E, RShared | Scope$1.Scope>, propIt: Vitest.MethodsNonLive<never>) => C): void;
|
|
95
104
|
};
|
|
96
105
|
declare const openCase: {
|
|
97
106
|
<B, E, RFresh, RFreshReq extends Scope$1.Scope, C>(config: Config, caseLayer: Layer.Layer<RFresh, never, RFreshReq>, use: (register: RegisterFn<B, E, RFresh | RFreshReq | Scope$1.Scope>, propIt: Vitest.MethodsNonLive<never>) => C): (bindings: Bindings) => void;
|
|
98
107
|
<B, E, RFresh, RFreshReq extends Scope$1.Scope, C>(bindings: Bindings, config: Config, caseLayer: Layer.Layer<RFresh, never, RFreshReq>, use: (register: RegisterFn<B, E, RFresh | RFreshReq | Scope$1.Scope>, propIt: Vitest.MethodsNonLive<never>) => C): void;
|
|
99
108
|
};
|
|
100
109
|
declare const openSharedCase: {
|
|
101
|
-
<B, E, RShared, RFresh, RFreshReq extends RShared, C>(config: Config, shared: Shared<RShared>, caseLayer: Layer.Layer<RFresh, never, RFreshReq>, use: (register: RegisterFn<B, E, RShared | RFresh | Scope$1.Scope>, propIt: Vitest.MethodsNonLive<never>) => C): (bindings: Bindings) => void;
|
|
102
|
-
<B, E, RShared, RFresh, RFreshReq extends RShared, C>(bindings: Bindings, config: Config, shared: Shared<RShared>, caseLayer: Layer.Layer<RFresh, never, RFreshReq>, use: (register: RegisterFn<B, E, RShared | RFresh | Scope$1.Scope>, propIt: Vitest.MethodsNonLive<never>) => C): void;
|
|
110
|
+
<B, E, RShared, EShared, RFresh, RFreshReq extends RShared, C>(config: Config, shared: Shared<RShared, EShared>, caseLayer: Layer.Layer<RFresh, never, RFreshReq>, use: (register: RegisterFn<B, E, RShared | RFresh | Scope$1.Scope>, propIt: Vitest.MethodsNonLive<never>) => C): (bindings: Bindings) => void;
|
|
111
|
+
<B, E, RShared, EShared, RFresh, RFreshReq extends RShared, C>(bindings: Bindings, config: Config, shared: Shared<RShared, EShared>, caseLayer: Layer.Layer<RFresh, never, RFreshReq>, use: (register: RegisterFn<B, E, RShared | RFresh | Scope$1.Scope>, propIt: Vitest.MethodsNonLive<never>) => C): void;
|
|
103
112
|
};
|
|
104
113
|
declare namespace TaskRef_service_d_exports {
|
|
105
114
|
export { RawVitestTaskRef, VitestTaskContext, VitestTaskRef, provideTaskRef };
|
|
@@ -110,14 +119,20 @@ interface VitestTaskContext<Ann = unknown> {
|
|
|
110
119
|
readonly annotations?: readonly Ann[] | undefined;
|
|
111
120
|
} | undefined;
|
|
112
121
|
}
|
|
113
|
-
declare const VitestTaskRef: Context.Reference<VitestTaskContext | null>;
|
|
122
|
+
declare const VitestTaskRef: Context$1.Reference<VitestTaskContext | null>;
|
|
114
123
|
/**
|
|
115
124
|
* The task context as the fork's run provides it: built on the fork's own key, so a case lane that goes
|
|
116
125
|
* through `provideTaskRef` and a property lane the fork runs itself read the same context.
|
|
117
126
|
*/
|
|
118
|
-
declare const RawVitestTaskRef: Context.Reference<VitestTaskContext | null>;
|
|
127
|
+
declare const RawVitestTaskRef: Context$1.Reference<VitestTaskContext | null>;
|
|
119
128
|
declare const provideTaskRef: {
|
|
120
129
|
<Ctx>(ctx: Ctx): <A, E, R>(effect: Effect.Effect<A, E, R>) => Effect.Effect<A, E, R>;
|
|
121
130
|
<A, E, R, Ctx>(effect: Effect.Effect<A, E, R>, ctx: Ctx): Effect.Effect<A, E, R>;
|
|
122
131
|
};
|
|
123
|
-
|
|
132
|
+
interface TestFileInfo {
|
|
133
|
+
readonly name: string;
|
|
134
|
+
readonly projectName: string | undefined;
|
|
135
|
+
readonly rootName: string;
|
|
136
|
+
}
|
|
137
|
+
export declare const TestFile: Context.Reference<Option.Option<TestFileInfo>>;
|
|
138
|
+
export { KernelCase_d_exports as KernelCase, SpanRecorder_d_exports as SpanRecorder, Suite_d_exports as Suite, TaskRef_service_d_exports as TaskRef, type TestFileInfo };
|
package/dist/index.mjs
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import { t as __exportAll } from "./rolldown-runtime-D3KUYPsf.mjs";
|
|
2
2
|
import { Kernel } from "@systemfsoftware/effect-sim-kernel";
|
|
3
3
|
import { createSpanRecorder, providedWorkspaceRoot, replayOfText, testIdentityOf, throwFailureRecord } from "@systemfsoftware/vitest/failure";
|
|
4
|
-
import { Cause, Config, Context, Effect, Exit, Layer, Match, Option, Schema, Scope, Tracer } from "effect";
|
|
4
|
+
import { Cause, Config, Context as Context$1, Effect, Exit, Layer, Match, Option as Option$1, Result, Schema, Scope, Tracer } from "effect";
|
|
5
5
|
import { dual } from "effect/Function";
|
|
6
6
|
import { VitestTestContext, vitestTestContextKey } from "@systemfsoftware/vitest";
|
|
7
7
|
import { captureRunBinding } from "@systemfsoftware/vitest/integration";
|
|
8
|
-
import { afterAll, describe } from "vitest";
|
|
8
|
+
import { TestRunner, afterAll, beforeAll, describe } from "vitest";
|
|
9
|
+
import * as Context from "effect/Context";
|
|
10
|
+
import * as Option from "effect/Option";
|
|
9
11
|
// src/KernelFailure.schema.ts
|
|
10
12
|
/**
|
|
11
13
|
* The kernel's own failure — a deadlock, an escape, a wait it cannot observe, or a runaway run — as a failure
|
|
@@ -23,16 +25,16 @@ var TaskRef_service_exports = /* @__PURE__ */ __exportAll({
|
|
|
23
25
|
VitestTaskRef: () => VitestTaskRef,
|
|
24
26
|
provideTaskRef: () => provideTaskRef
|
|
25
27
|
});
|
|
26
|
-
const VitestTaskRef = Context.Reference("@systemfsoftware/effect-spec-runtime/VitestTask", { defaultValue: () => null });
|
|
28
|
+
const VitestTaskRef = Context$1.Reference("@systemfsoftware/effect-spec-runtime/VitestTask", { defaultValue: () => null });
|
|
27
29
|
/**
|
|
28
30
|
* The task context as the fork's run provides it: built on the fork's own key, so a case lane that goes
|
|
29
31
|
* through `provideTaskRef` and a property lane the fork runs itself read the same context.
|
|
30
32
|
*/
|
|
31
|
-
const RawVitestTaskRef = Context.Reference(vitestTestContextKey, { defaultValue: () => null });
|
|
33
|
+
const RawVitestTaskRef = Context$1.Reference(vitestTestContextKey, { defaultValue: () => null });
|
|
32
34
|
const isPlainTaskContext = (ctx) => typeof ctx === "object" && ctx !== null;
|
|
33
35
|
const isTaskContext = (ctx) => typeof ctx === "object" ? ctx !== null : typeof ctx === "function";
|
|
34
|
-
const readTaskContext = (ctx) => Option.getOrNull(Option.liftPredicate(ctx, isPlainTaskContext));
|
|
35
|
-
const readRawTaskContext = (ctx) => Option.getOrNull(Option.liftPredicate(ctx, isTaskContext));
|
|
36
|
+
const readTaskContext = (ctx) => Option$1.getOrNull(Option$1.liftPredicate(ctx, isPlainTaskContext));
|
|
37
|
+
const readRawTaskContext = (ctx) => Option$1.getOrNull(Option$1.liftPredicate(ctx, isTaskContext));
|
|
36
38
|
const provideTaskRefImpl = (effect, ctx) => effect.pipe(Effect.provideService(VitestTaskRef, readTaskContext(ctx)), Effect.provideService(RawVitestTaskRef, readRawTaskContext(ctx)));
|
|
37
39
|
const provideTaskRef = dual(2, provideTaskRefImpl);
|
|
38
40
|
// src/KernelCase.ts
|
|
@@ -43,6 +45,10 @@ var KernelCase_exports = /* @__PURE__ */ __exportAll({
|
|
|
43
45
|
exploreOnce: () => exploreOnce,
|
|
44
46
|
liveCase: () => liveCase
|
|
45
47
|
});
|
|
48
|
+
const jsonTextOf = (value) => Result.match(Schema.encodeUnknownResult(Schema.fromJsonString(Schema.Unknown))(value), {
|
|
49
|
+
onFailure: () => String(value),
|
|
50
|
+
onSuccess: (text) => text
|
|
51
|
+
});
|
|
46
52
|
/**
|
|
47
53
|
* One run's program: the case's layers build under the zero-preemption
|
|
48
54
|
* schedule, exploration is marked, and the scenario body runs under the
|
|
@@ -70,11 +76,11 @@ const announceLive = (reason) => Effect.gen(function* () {
|
|
|
70
76
|
const task = yield* RawVitestTaskRef;
|
|
71
77
|
return yield* announce(task, reason);
|
|
72
78
|
});
|
|
73
|
-
const dispatchAnnotate = (annotate, message) => Option.match(Option.fromNullishOr(annotate), {
|
|
79
|
+
const dispatchAnnotate = (annotate, message) => Option$1.match(Option$1.fromNullishOr(annotate), {
|
|
74
80
|
onNone: () => Effect.void,
|
|
75
81
|
onSome: (record) => Effect.promise(() => Promise.resolve(record(message)))
|
|
76
82
|
});
|
|
77
|
-
const announce = (task, reason) => Option.match(Option.fromNullishOr(task), {
|
|
83
|
+
const announce = (task, reason) => Option$1.match(Option$1.fromNullishOr(task), {
|
|
78
84
|
onNone: () => Effect.void,
|
|
79
85
|
onSome: (context) => dispatchAnnotate(context.annotate, `live case: ${reason}`)
|
|
80
86
|
});
|
|
@@ -99,7 +105,7 @@ const describeSuspended = (fiber) => {
|
|
|
99
105
|
if (first === void 0) return `fiber ${fiber.id}`;
|
|
100
106
|
return `fiber ${fiber.id} at ${first}`;
|
|
101
107
|
};
|
|
102
|
-
const describeKernelFailure = (failure) => Match.value(failure).pipe(Match.when({ _tag: "Escape" }, (escape) => `escaped the controlled schedule through the ${escape.timer} timer at ${escape.site}`), Match.when({ _tag: "Blocked" }, (blocked) => `waited on a resource the kernel cannot observe: ${blocked.resources.join(", ")}`), Match.when({ _tag: "Deadlock" }, (deadlock) => `deadlocked with ${deadlock.suspended.length} suspended fibers: ${deadlock.suspended.map(describeSuspended).join("; ")}`), Match.when({ _tag: "Runaway" }, (runaway) => `ran past ${runaway.steps} steps with ${runaway.pending} fibers pending`), Match.when({ _tag: "ReplayTraceDiverged" }, (diverged) => `the replayed trace diverged at step ${diverged.atStep}: expected ${
|
|
108
|
+
const describeKernelFailure = (failure) => Match.value(failure).pipe(Match.when({ _tag: "Escape" }, (escape) => `escaped the controlled schedule through the ${escape.timer} timer at ${escape.site}`), Match.when({ _tag: "Blocked" }, (blocked) => `waited on a resource the kernel cannot observe: ${blocked.resources.join(", ")}`), Match.when({ _tag: "Deadlock" }, (deadlock) => `deadlocked with ${deadlock.suspended.length} suspended fibers: ${deadlock.suspended.map(describeSuspended).join("; ")}`), Match.when({ _tag: "Runaway" }, (runaway) => `ran past ${runaway.steps} steps with ${runaway.pending} fibers pending`), Match.when({ _tag: "ReplayTraceDiverged" }, (diverged) => `the replayed trace diverged at step ${diverged.atStep}: expected ${jsonTextOf(diverged.expected)}, got ${jsonTextOf(diverged.actual)}`), Match.exhaustive);
|
|
103
109
|
/** One run with its own recorder: the record is rendered from exactly the spans this run opened (KTD2). */
|
|
104
110
|
const recorded = (program) => {
|
|
105
111
|
const recorder = createSpanRecorder();
|
|
@@ -135,7 +141,7 @@ const seedsToRun = (seed, budget) => {
|
|
|
135
141
|
if (seed === void 0) return seedList(budget);
|
|
136
142
|
return [seed];
|
|
137
143
|
};
|
|
138
|
-
const readReplayValue = () => Effect.runPromise(Effect.map(Config.option(Config.String("CONFORMANCE_REPLAY")), Option.getOrUndefined));
|
|
144
|
+
const readReplayValue = () => Effect.runPromise(Effect.map(Config.option(Config.String("CONFORMANCE_REPLAY")), Option$1.getOrUndefined));
|
|
139
145
|
const replayRun = (program, replay, path) => {
|
|
140
146
|
const run = recorded(program);
|
|
141
147
|
return Kernel.run(run.program, {
|
|
@@ -209,7 +215,7 @@ const selectDescribe = (mode) => ({
|
|
|
209
215
|
only: describe.only,
|
|
210
216
|
describe
|
|
211
217
|
})[mode];
|
|
212
|
-
const invokeDescribeImpl = (mode, suiteName, suiteOpts, fn) => Option.match(Option.fromUndefinedOr(suiteOpts), {
|
|
218
|
+
const invokeDescribeImpl = (mode, suiteName, suiteOpts, fn) => Option$1.match(Option$1.fromUndefinedOr(suiteOpts), {
|
|
213
219
|
onNone: () => {
|
|
214
220
|
selectDescribe(mode)(suiteName, fn);
|
|
215
221
|
},
|
|
@@ -269,12 +275,35 @@ const exploredOnceProgram = (program) => exploredWith(exploreOnce, program);
|
|
|
269
275
|
*/
|
|
270
276
|
const selectCaseRunnerImpl = (methodsIt, mode, live) => pickLane(caseLanes(methodsIt, live), mode);
|
|
271
277
|
const selectCaseRunner = dual(3, selectCaseRunnerImpl);
|
|
278
|
+
// src/SharedLayer.schema.ts
|
|
279
|
+
var SharedLayerNotBuilt = class extends Schema.TaggedError()("SharedLayerNotBuilt", {}) {
|
|
280
|
+
get message() {
|
|
281
|
+
return "A shared layer was read before its build ran";
|
|
282
|
+
}
|
|
283
|
+
};
|
|
284
|
+
// src/TestFile.ts
|
|
285
|
+
const TestFile = Context.Reference("@systemfsoftware/effect-spec-runtime/TestFile", { defaultValue: Option.none });
|
|
286
|
+
const rootNameOf = (filepath, name) => {
|
|
287
|
+
const root = filepath.slice(0, filepath.length - name.length - 1);
|
|
288
|
+
return root.slice(root.lastIndexOf("/") + 1);
|
|
289
|
+
};
|
|
290
|
+
const projectNameOf = (projectName) => projectName === "" ? void 0 : projectName;
|
|
291
|
+
const testFileInfo = (file) => {
|
|
292
|
+
const name = file.name.replaceAll("\\", "/");
|
|
293
|
+
return {
|
|
294
|
+
name,
|
|
295
|
+
projectName: projectNameOf(file.projectName),
|
|
296
|
+
rootName: rootNameOf(file.filepath, name)
|
|
297
|
+
};
|
|
298
|
+
};
|
|
272
299
|
// src/Suite.ts
|
|
273
300
|
var Suite_exports = /* @__PURE__ */ __exportAll({
|
|
301
|
+
SharedLayerNotBuilt: () => SharedLayerNotBuilt,
|
|
274
302
|
open: () => open,
|
|
275
303
|
openCase: () => openCase,
|
|
276
304
|
openShared: () => openShared,
|
|
277
|
-
openSharedCase: () => openSharedCase
|
|
305
|
+
openSharedCase: () => openSharedCase,
|
|
306
|
+
sharedLayer: () => sharedLayer
|
|
278
307
|
});
|
|
279
308
|
const caseEffectOf = (body, env, live) => {
|
|
280
309
|
if (live !== void 0) return liveCase(body, env, live.reason);
|
|
@@ -332,20 +361,25 @@ const openImpl = (bindings, config, use) => {
|
|
|
332
361
|
});
|
|
333
362
|
};
|
|
334
363
|
const open = dual(3, openImpl);
|
|
335
|
-
|
|
336
|
-
* The suite's layer, built once by the first case that needs it and released when the suite
|
|
337
|
-
* ends, so every case of the suite sees the same services. The build runs on its own root
|
|
338
|
-
* fiber: the first case's fiber ends with that case, and the suite's resources must not.
|
|
339
|
-
*/
|
|
340
|
-
const suiteLayerOf = (shared) => {
|
|
364
|
+
const sharedLayerOf = (shared) => {
|
|
341
365
|
const scope = Scope.makeUnsafe();
|
|
342
|
-
const
|
|
366
|
+
const testFile = Option$1.some(testFileInfo(TestRunner.getCurrentSuite().file));
|
|
367
|
+
let built;
|
|
368
|
+
beforeAll(async () => {
|
|
369
|
+
const exit = await Effect.runPromiseExit(Layer.buildWithScope(shared.layer, scope).pipe(Effect.provideService(TestFile, testFile)));
|
|
370
|
+
if (Exit.isFailure(exit)) {
|
|
371
|
+
await Effect.runPromise(Scope.close(scope, Exit.void).pipe(Effect.ignore));
|
|
372
|
+
throw Cause.squash(exit.cause);
|
|
373
|
+
}
|
|
374
|
+
built = exit.value;
|
|
375
|
+
}, UNTIMED.timeout);
|
|
343
376
|
afterAll(() => Effect.runPromise(Scope.close(scope, Exit.void)), UNTIMED.timeout);
|
|
344
|
-
return Layer.unwrap(Effect.
|
|
377
|
+
return Layer.unwrap(Effect.suspend(() => built === void 0 ? Effect.die(new SharedLayerNotBuilt()) : Effect.succeed(Layer.succeedContext(built))));
|
|
345
378
|
};
|
|
379
|
+
const sharedLayer = (layer) => sharedLayerOf({ layer });
|
|
346
380
|
const openSharedImpl = (bindings, config, shared, use) => {
|
|
347
381
|
invokeDescribe(config.describe, config.name, config.options, () => {
|
|
348
|
-
use(registrarFor(bindings.it, config,
|
|
382
|
+
use(registrarFor(bindings.it, config, sharedLayerOf(shared)), bindings.it);
|
|
349
383
|
});
|
|
350
384
|
};
|
|
351
385
|
const openShared = dual(4, openSharedImpl);
|
|
@@ -357,8 +391,8 @@ const openCaseImpl = (bindings, config, caseLayer, use) => {
|
|
|
357
391
|
const openCase = dual(4, openCaseImpl);
|
|
358
392
|
const openSharedCaseImpl = (bindings, config, shared, caseLayer, use) => {
|
|
359
393
|
invokeDescribe(config.describe, config.name, config.options, () => {
|
|
360
|
-
use(registrarFor(bindings.it, config, Layer.fresh(caseLayer).pipe(Layer.provideMerge(
|
|
394
|
+
use(registrarFor(bindings.it, config, Layer.fresh(caseLayer).pipe(Layer.provideMerge(sharedLayerOf(shared)))), bindings.it);
|
|
361
395
|
});
|
|
362
396
|
};
|
|
363
397
|
const openSharedCase = dual(5, openSharedCaseImpl);
|
|
364
|
-
export { KernelCase_exports as KernelCase, SpanRecorder_exports as SpanRecorder, Suite_exports as Suite, TaskRef_service_exports as TaskRef };
|
|
398
|
+
export { KernelCase_exports as KernelCase, SpanRecorder_exports as SpanRecorder, Suite_exports as Suite, TaskRef_service_exports as TaskRef, TestFile, sharedLayer };
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@systemfsoftware/effect-spec-runtime",
|
|
3
3
|
"license": "Apache-2.0",
|
|
4
|
-
"version": "1.
|
|
4
|
+
"version": "1.4.0",
|
|
5
5
|
"author": "Ryan Lee <drdgvhbh@gmail.com>",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
@@ -37,10 +37,10 @@
|
|
|
37
37
|
"devDependencies": {
|
|
38
38
|
"@microsoft/api-extractor": "^7.60.1",
|
|
39
39
|
"@systemfsoftware/arethetypeswrong-cli": "^4.2.0",
|
|
40
|
-
"@systemfsoftware/oxlint-config-recommended": "^
|
|
40
|
+
"@systemfsoftware/oxlint-config-recommended": "^9.0.2",
|
|
41
41
|
"@systemfsoftware/tsconfig": "^2.1.0",
|
|
42
|
-
"@systemfsoftware/tsdown-config": "^0.
|
|
43
|
-
"@systemfsoftware/vitest": "^4.2.
|
|
42
|
+
"@systemfsoftware/tsdown-config": "^0.2.0",
|
|
43
|
+
"@systemfsoftware/vitest": "^4.2.1",
|
|
44
44
|
"@systemfsoftware/vitest-config": "^0.1.4",
|
|
45
45
|
"@types/node": "^26.6.6",
|
|
46
46
|
"effect": "^4.1.4",
|
|
@@ -52,7 +52,7 @@
|
|
|
52
52
|
"vitest": "^5.1.0"
|
|
53
53
|
},
|
|
54
54
|
"peerDependencies": {
|
|
55
|
-
"@systemfsoftware/vitest": "^4.2.
|
|
55
|
+
"@systemfsoftware/vitest": "^4.2.1",
|
|
56
56
|
"effect": "^4.1.4",
|
|
57
57
|
"vitest": "^5.1.0"
|
|
58
58
|
},
|
|
@@ -66,7 +66,7 @@
|
|
|
66
66
|
"typecheck": "tsc -b",
|
|
67
67
|
"test": "vitest run",
|
|
68
68
|
"test:types": "TSTYCHE_TYPESCRIPT_MODULE=tstyche-typescript tstyche",
|
|
69
|
-
"lint": "f=${OXLINT_FORMAT:-${AGENT:+agent}}; oxlint . --format=${f:-default}",
|
|
69
|
+
"lint": "f=${OXLINT_FORMAT:-${AGENT:+agent}}; effect-tsgo oxlint . --format=${f:-default}",
|
|
70
70
|
"attw": "attw --pack .",
|
|
71
71
|
"api:check": "api-extractor-quiet run",
|
|
72
72
|
"api:update": "api-extractor run --local"
|