@@ -4,14 +4,44 @@ import {
44 HostProcessEnvironment ,
55 HostProcessPlatform ,
66} from "@t3tools/shared/hostProcess" ;
7- import { assert , describe , it } from "@effect/vitest" ;
7+ import { afterEach , assert , describe , expect , it , vi } from "@effect/vitest" ;
88import * as Effect from "effect/Effect" ;
99import * as FileSystem from "effect/FileSystem" ;
1010
1111import { ServerConfig } from "../config.ts" ;
1212import * as ResourceMonitorBinary from "./ResourceMonitorBinary.ts" ;
1313
1414describe ( "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+
1545 it . effect ( "resolves an executable override" , ( ) =>
1646 Effect . gen ( function * ( ) {
1747 const fileSystem = yield * FileSystem . FileSystem ;
0 commit comments