@@ -3,6 +3,7 @@ import * as HostProcess from "@t3tools/shared/HostProcess";
33import { afterEach , assert , describe , it , vi } from "@effect/vitest" ;
44import * as Effect from "effect/Effect" ;
55import * as FileSystem from "effect/FileSystem" ;
6+ import * as Path from "effect/Path" ;
67
78import * as ServerConfig from "../config.ts" ;
89import * as ResourceMonitorBinary from "./ResourceMonitorBinary.ts" ;
@@ -88,6 +89,39 @@ describe("ResourceMonitorBinary", () => {
8889 } ) . pipe ( Effect . scoped , Effect . provide ( NodeServices . layer ) ) ,
8990 ) ;
9091
92+ it . effect ( "looks for cargo build output from both the source and the bundled server layout" , ( ) =>
93+ Effect . gen ( function * ( ) {
94+ const fileSystem = yield * FileSystem . FileSystem ;
95+ const path = yield * Path . Path ;
96+ const baseDir = yield * fileSystem . makeTempDirectoryScoped ( {
97+ prefix : "t3-resource-monitor-binary-" ,
98+ } ) ;
99+ const service = yield * ResourceMonitorBinary . make ( ) . pipe (
100+ Effect . provide ( ServerConfig . layerTest ( process . cwd ( ) , baseDir ) ) ,
101+ Effect . provideService ( HostProcess . Platform , "darwin" ) ,
102+ Effect . provideService ( HostProcess . Architecture , "arm64" ) ,
103+ Effect . provideService ( HostProcess . Environment , { } ) ,
104+ ) ;
105+ const error = yield * Effect . flip ( service . resolve ) ;
106+
107+ assert . instanceOf ( error , ResourceMonitorBinary . ResourceMonitorBinaryNotFound ) ;
108+ const candidates = ( error as ResourceMonitorBinary . ResourceMonitorBinaryNotFound ) . candidates ;
109+ for ( const crateRelative of [
110+ "../../../../native/resource-monitor" ,
111+ "../../../native/resource-monitor" ,
112+ ] ) {
113+ const crateDirectory = path . resolve ( import . meta. dirname , crateRelative ) ;
114+ for ( const output of [
115+ path . join ( "target" , "aarch64-apple-darwin" , "release" ) ,
116+ path . join ( "target" , "release" ) ,
117+ path . join ( "target" , "debug" ) ,
118+ ] ) {
119+ assert . include ( candidates , path . join ( crateDirectory , output , "t3-resource-monitor" ) ) ;
120+ }
121+ }
122+ } ) . pipe ( Effect . scoped , Effect . provide ( NodeServices . layer ) ) ,
123+ ) ;
124+
91125 it . effect ( "rejects bundled glibc binaries on musl Linux hosts" , ( ) =>
92126 Effect . gen ( function * ( ) {
93127 const fileSystem = yield * FileSystem . FileSystem ;
0 commit comments