Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ sha256>/` on the server through the existing preparation protocol. The server ve
- Helper module: the manifest parses, has both CPUs for both helpers, and every entry has a 64-hex SHA-256. The laptop
path and remote path come from the same function. A cached helper archive with a wrong checksum is rejected.
- Remote helper installation: run the preparation protocol's Python source locally against a disposable HOME, as the
existing `runtime.test.js` does. A first run installs the helper, and a second run reuses it without reading bytes.
existing `runtime.test.ts` does. A first run installs the helper, and a second run reuses it without reading bytes.
An abandoned stage is repaired. A checksum mismatch leaves no installed file.
- Supervisor `PATH`: a test starts the supervisor entry with a disposable HOME that contains the private helpers. It
fails unless the started view's environment has them first on `PATH`, and unless a missing helper stops startup with
Expand Down
2 changes: 1 addition & 1 deletion scripts/bun-test-files.json
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,7 @@
"src/shared/remote/remote-runtime-workflows-records-reads.test.ts",
"src/shared/remote/remote-runtime-workflows-records.test.ts",
"src/shared/remote/remote-runtime-workflows-rollover.test.ts",
"src/shared/remote/runtime.test.js",
"src/shared/remote/runtime.test.ts",
"src/shared/remote/see-image-usage.test.ts",
"src/shared/remote/session-attachment-read.test.ts",
"src/shared/remote/session-control.test.ts",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,25 +24,25 @@ import { linuxTarget } from "./runtime.js";
const BUILD_ID = "a".repeat(64);
const PROTOCOL = 1;

/**
* @typedef {Object} RuntimeFixture
* @property {string} root
* @property {string} ssh
* @property {string} artifact
* @property {typeof import('./runtime.js')} module
* @property {FixtureMetadata} metadata
*/
/**
* @typedef {Object} FixtureMetadata
* @property {number} schema
* @property {number} protocol
* @property {string} buildId
* @property {string} target
* @property {string} version
* @property {string} sha256
*/
/** @param {(fixture: RuntimeFixture) => Promise<void>} fn */
async function fixture(fn) {
import type { ArtifactMetadata } from "../../../scripts/build-metadata.ts";

type RuntimeModule = typeof import("./runtime.js");
interface RuntimeFixture {
root: string;
ssh: string;
artifact: string;
module: RuntimeModule;
metadata: ArtifactMetadata;
}
interface RuntimeTransferHeader extends ArtifactMetadata {
size: number;
}
interface SshRequestLog {
args: string[];
header: RuntimeTransferHeader;
}

async function fixture(fn: (fixture: RuntimeFixture) => Promise<void>) {
const root = await fsRealpath(await fsMkdtemp(join(tmpdir(), "portable-fixture-")));
try {
const shared = join(root, "src/shared");
Expand Down Expand Up @@ -70,7 +70,7 @@ async function fixture(fn) {
`export const BUILD_ID = '${BUILD_ID}'; export const REMOTE_PROTOCOL_VERSION = ${PROTOCOL};`,
);
await fsWriteFile(join(shared, "version.js"), 'export const VERSION = "test-build";');
const module = await import(toFileUrl(join(remote, "runtime.js")).href);
const module: RuntimeModule = await import(toFileUrl(join(remote, "runtime.js")).href);
const ssh = join(root, "ssh");
await fsWriteFile(
ssh,
Expand All @@ -83,7 +83,7 @@ async function fixture(fn) {
const content = `#!/bin/sh\n[ "$1" = --remote-preflight ] || exit 2\necho '{"buildId":"${BUILD_ID}","protocol":${PROTOCOL},"version":"test-build"}'\n`;
await fsWriteFile(artifact, content);
const checksum = await sha256Bytes(new TextEncoder().encode(content));
const metadata = {
const metadata: ArtifactMetadata = {
schema: 1,
protocol: PROTOCOL,
buildId: BUILD_ID,
Expand Down Expand Up @@ -371,7 +371,7 @@ if (config.mode !== "reuse") console.log(JSON.stringify({ ok: true, path: "/remo
path: "/remote/cache/wld",
reused: mode === "reuse",
});
const request = JSON.parse(await fsReadFile(log, "utf8"));
const request: SshRequestLog = JSON.parse(await fsReadFile(log, "utf8"));
assertEquals(request.args, ["-T", "--", "example", module.REMOTE_PREPARE_COMMAND]);
assertEquals(request.header, { ...metadata, sha256, size: bytes.length });
assertEquals(new Uint8Array(await fsReadFile(transfer)), mode === "reuse" ? new Uint8Array() : bytes);
Expand Down
Loading