| ... | @@ -4,7 +4,7 @@ import { | ... | @@ -4,7 +4,7 @@ import { |
| 4 | HostProcessEnvironment, | 4 | HostProcessEnvironment, |
| 5 | HostProcessPlatform, | 5 | HostProcessPlatform, |
| 6 | } from "@t3tools/shared/hostProcess"; | 6 | } from "@t3tools/shared/hostProcess"; |
| 7 | import { assert, describe, it } from "@effect/vitest"; | 7 | import { afterEach, assert, describe, expect, it, vi } from "@effect/vitest"; |
| 8 | import * as Effect from "effect/Effect"; | 8 | import * as Effect from "effect/Effect"; |
| 9 | import * as FileSystem from "effect/FileSystem"; | 9 | import * as FileSystem from "effect/FileSystem"; |
| 10 | | 10 | |
| ... | @@ -12,6 +12,36 @@ import { ServerConfig } from "../config.ts"; | ... | @@ -12,6 +12,36 @@ import { ServerConfig } from "../config.ts"; |
| 12 | import * as ResourceMonitorBinary from "./ResourceMonitorBinary.ts"; | 12 | import * as ResourceMonitorBinary from "./ResourceMonitorBinary.ts"; |
| 13 | | 13 | |
| 14 | describe("ResourceMonitorBinary", () => { | 14 | describe("ResourceMonitorBinary", () => { |
| | 15 | afterEach(() => { |
| | 16 | vi.restoreAllMocks(); |
| | 17 | }); |
| | 18 | |
| | 19 | it.effect("skips Linux libc detection on Windows", () => |
| | 20 | Effect.gen(function* () { |
| | 21 | const getReport = vi.spyOn(process.report, "getReport").mockImplementation(() => { |
| | 22 | throw new Error("Linux libc detection must not run on Windows"); |
| | 23 | }); |
| | 24 | const fileSystem = yield* FileSystem.FileSystem; |
| | 25 | const baseDir = yield* fileSystem.makeTempDirectoryScoped({ |
| | 26 | prefix: "t3-resource-monitor-binary-", |
| | 27 | }); |
| | 28 | const binaryPath = `${baseDir}/t3-resource-monitor.exe`; |
| | 29 | yield* fileSystem.writeFileString(binaryPath, "binary"); |
| | 30 | |
| | 31 | const service = yield* ResourceMonitorBinary.make().pipe( |
| | 32 | Effect.provide(ServerConfig.layerTest(process.cwd(), baseDir)), |
| | 33 | Effect.provideService(HostProcessPlatform, "win32"), |
| | 34 | Effect.provideService(HostProcessArchitecture, "arm64"), |
| | 35 | Effect.provideService(HostProcessEnvironment, { |
| | 36 | T3CODE_RESOURCE_MONITOR_PATH: binaryPath, |
| | 37 | }), |
| | 38 | ); |
| | 39 | |
| | 40 | assert.equal(yield* service.resolve, binaryPath); |
| | 41 | expect(getReport).not.toHaveBeenCalled(); |
| | 42 | }).pipe(Effect.scoped, Effect.provide(NodeServices.layer)), |
| | 43 | ); |
| | 44 | |
| 15 | it.effect("resolves an executable override", () => | 45 | it.effect("resolves an executable override", () => |
| 16 | Effect.gen(function* () { | 46 | Effect.gen(function* () { |
| 17 | const fileSystem = yield* FileSystem.FileSystem; | 47 | const fileSystem = yield* FileSystem.FileSystem; |