收敛树命令与投影切换
This commit is contained in:
@@ -7,6 +7,7 @@ import {
|
||||
readRustTreeDomainEventPlan,
|
||||
readRustTreeDomainEventPlans,
|
||||
readRustTreeDomainEventType,
|
||||
resolveRustRuntimeProcessEnv,
|
||||
type RustBridgeCommandPlan,
|
||||
} from "./rust-runtime";
|
||||
|
||||
@@ -82,6 +83,26 @@ describe("shouldUseBuiltBridgeRuntimeBinary", () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe("resolveRustRuntimeProcessEnv", () => {
|
||||
it("未设置默认 toolchain 时应注入仓库声明的 Rust toolchain", () => {
|
||||
expect(resolveRustRuntimeProcessEnv({} as NodeJS.ProcessEnv)).toMatchObject({
|
||||
CARGO_TERM_COLOR: "never",
|
||||
RUSTUP_TOOLCHAIN: "1.89.0",
|
||||
});
|
||||
});
|
||||
|
||||
it("应保留调用方显式设置的 Rust toolchain", () => {
|
||||
expect(
|
||||
resolveRustRuntimeProcessEnv({
|
||||
RUSTUP_TOOLCHAIN: "nightly",
|
||||
} as NodeJS.ProcessEnv),
|
||||
).toMatchObject({
|
||||
CARGO_TERM_COLOR: "never",
|
||||
RUSTUP_TOOLCHAIN: "nightly",
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe("executeRustBridgeMutationTransport", () => {
|
||||
it("documents.move 应把 Rust treeWriteOperation 透传给 Convex 写执行器", async () => {
|
||||
const movePlan = {
|
||||
|
||||
@@ -217,6 +217,17 @@ type RuntimeInvocation = {
|
||||
};
|
||||
|
||||
const RUST_RUNTIME_TIMEOUT_MS = 30_000;
|
||||
const RUST_RUNTIME_FALLBACK_TOOLCHAIN = "1.89.0";
|
||||
|
||||
export function resolveRustRuntimeProcessEnv(env: NodeJS.ProcessEnv = process.env): NodeJS.ProcessEnv {
|
||||
const explicitToolchain = env.RUSTUP_TOOLCHAIN?.trim() || env.MNOTE_RUST_BRIDGE_TOOLCHAIN?.trim();
|
||||
|
||||
return {
|
||||
...env,
|
||||
CARGO_TERM_COLOR: "never",
|
||||
RUSTUP_TOOLCHAIN: explicitToolchain || RUST_RUNTIME_FALLBACK_TOOLCHAIN,
|
||||
};
|
||||
}
|
||||
|
||||
async function pathExists(targetPath: string) {
|
||||
try {
|
||||
@@ -348,10 +359,7 @@ async function runRustRuntime(input: Record<string, unknown>): Promise<RustRunti
|
||||
const result = await new Promise<RuntimeProcessResult>((resolve, reject) => {
|
||||
const child = spawn(invocation.command, invocation.args, {
|
||||
stdio: ["pipe", "pipe", "pipe"],
|
||||
env: {
|
||||
...process.env,
|
||||
CARGO_TERM_COLOR: "never",
|
||||
},
|
||||
env: resolveRustRuntimeProcessEnv(),
|
||||
});
|
||||
|
||||
let stdout = "";
|
||||
|
||||
Reference in New Issue
Block a user