fix(server): skip Linux libc detection on Windows/macOS (#5354)
This commit is contained in:
1 parent
f9730979c1
commit
1fa315ea93
2 files changed
+33
-3
No files matched your search
@@ -4,7 +4,7 @@ import {
|
||||
HostProcessEnvironment,
|
||||
HostProcessPlatform,
|
||||
} from "@t3tools/shared/hostProcess";
|
||||
import { assert, describe, it } from "@effect/vitest";
|
||||
import { afterEach, assert, describe, expect, it, vi } from "@effect/vitest";
|
||||
import * as Effect from "effect/Effect";
|
||||
import * as FileSystem from "effect/FileSystem";
|
||||
|
||||
@@ -12,6 +12,36 @@ import { ServerConfig } from "../config.ts";
|
||||
import * as ResourceMonitorBinary from "./ResourceMonitorBinary.ts";
|
||||
|
||||
describe("ResourceMonitorBinary", () => {
|
||||
afterEach(() => {
|
||||
vi.restoreAllMocks();
|
||||
});
|
||||
|
||||
it.effect("skips Linux libc detection on Windows", () =>
|
||||
Effect.gen(function* () {
|
||||
const getReport = vi.spyOn(process.report, "getReport").mockImplementation(() => {
|
||||
throw new Error("Linux libc detection must not run on Windows");
|
||||
});
|
||||
const fileSystem = yield* FileSystem.FileSystem;
|
||||
const baseDir = yield* fileSystem.makeTempDirectoryScoped({
|
||||
prefix: "t3-resource-monitor-binary-",
|
||||
});
|
||||
const binaryPath = `${baseDir}/t3-resource-monitor.exe`;
|
||||
yield* fileSystem.writeFileString(binaryPath, "binary");
|
||||
|
||||
const service = yield* ResourceMonitorBinary.make().pipe(
|
||||
Effect.provide(ServerConfig.layerTest(process.cwd(), baseDir)),
|
||||
Effect.provideService(HostProcessPlatform, "win32"),
|
||||
Effect.provideService(HostProcessArchitecture, "arm64"),
|
||||
Effect.provideService(HostProcessEnvironment, {
|
||||
T3CODE_RESOURCE_MONITOR_PATH: binaryPath,
|
||||
}),
|
||||
);
|
||||
|
||||
assert.equal(yield* service.resolve, binaryPath);
|
||||
expect(getReport).not.toHaveBeenCalled();
|
||||
}).pipe(Effect.scoped, Effect.provide(NodeServices.layer)),
|
||||
);
|
||||
|
||||
it.effect("resolves an executable override", () =>
|
||||
Effect.gen(function* () {
|
||||
const fileSystem = yield* FileSystem.FileSystem;
|
||||
|
||||
@@ -106,7 +106,7 @@ export function resourceMonitorPlatformKey(
|
||||
export function resourceMonitorRustTarget(
|
||||
platform: NodeJS.Platform,
|
||||
architecture: NodeJS.Architecture,
|
||||
linuxLibc: ResourceMonitorLinuxLibc,
|
||||
linuxLibc?: ResourceMonitorLinuxLibc,
|
||||
): string | undefined {
|
||||
if (platform === "darwin") {
|
||||
return architecture === "arm64"
|
||||
@@ -142,7 +142,7 @@ export const make = Effect.fn("resourceTelemetry.resourceMonitorBinary.make")(fu
|
||||
const platform = yield* HostProcessPlatform;
|
||||
const architecture = yield* HostProcessArchitecture;
|
||||
const environment = yield* HostProcessEnvironment;
|
||||
const linuxLibc = yield* ResourceMonitorHostLinuxLibc;
|
||||
const linuxLibc = platform === "linux" ? yield* ResourceMonitorHostLinuxLibc : undefined;
|
||||
const executableName = binaryName(platform);
|
||||
const platformKey = resourceMonitorPlatformKey(platform, architecture);
|
||||
const rustTarget = resourceMonitorRustTarget(platform, architecture, linuxLibc);
|
||||
|
||||
Reference in new issue
Block a user