| ... | ... | @@ -175,6 +175,8 @@ const makeWindowsPayloadFixture = Effect.fn("test.makeWindowsPayloadFixture")(fu |
| 175 | 175 | readonly copyUnpackedNatives: boolean; |
| 176 | 176 | readonly serverEntrySource?: string; |
| 177 | 177 | readonly wslRuntime?: "valid" | "loose-server-tree" | "missing-pty" | "bad-digest"; |
| 178 | readonly targetArch?: "x64" | "arm64"; |
| 179 | readonly ptyPrebuildArch?: "x64" | "arm64"; |
| 178 | 180 | }) { |
| 179 | 181 | const fs = yield* FileSystem.FileSystem; |
| 180 | 182 | const path = yield* Path.Path; |
| ... | ... | @@ -212,7 +214,7 @@ const makeWindowsPayloadFixture = Effect.fn("test.makeWindowsPayloadFixture")(fu |
| 212 | 214 | yield* fs.writeFileString(path.join(packagedAppDir, "chrome_crashpad_handler.exe"), "crashpad"); |
| 213 | 215 | |
| 214 | 216 | if (input.wslRuntime !== undefined) { |
| 215 | | const stem = wslRuntimeArchiveStem(WINDOWS_PAYLOAD_FIXTURE_VERSION, "x64"); |
| 217 | const stem = wslRuntimeArchiveStem(WINDOWS_PAYLOAD_FIXTURE_VERSION, input.targetArch ?? "x64"); |
| 216 | 218 | const sourceArchivePath = |
| 217 | 219 | input.wslRuntime === "loose-server-tree" |
| 218 | 220 | ? // The old hand-rolled runtime: apps/server/dist + node_modules at the |
| ... | ... | @@ -226,9 +228,16 @@ const makeWindowsPayloadFixture = Effect.fn("test.makeWindowsPayloadFixture")(fu |
| 226 | 228 | : yield* makeLinuxCliArchiveFixture({ |
| 227 | 229 | root: path.join(tempDir, "wsl-runtime"), |
| 228 | 230 | stem, |
| 229 | | ...(input.wslRuntime === "missing-pty" |
| 231 | ...(input.wslRuntime === "missing-pty" || input.ptyPrebuildArch !== undefined |
| 230 | 232 | ? { omitMembers: [`${stem}/node_modules/node-pty/build/Release/pty.node`] } |
| 231 | 233 | : {}), |
| 234 | ...(input.ptyPrebuildArch !== undefined |
| 235 | ? { |
| 236 | extraMembers: [ |
| 237 | `${stem}/node_modules/node-pty/prebuilds/linux-${input.ptyPrebuildArch}/pty.node`, |
| 238 | ], |
| 239 | } |
| 240 | : {}), |
| 232 | 241 | }); |
| 233 | 242 | const archivePath = path.join(resourcesDir, WSL_RUNTIME_ARCHIVE_NAME); |
| 234 | 243 | const hashPath = path.join(resourcesDir, WSL_RUNTIME_ARCHIVE_HASH_NAME); |
| ... | ... | @@ -1206,6 +1215,55 @@ it.layer(NodeServices.layer)("build-desktop-artifact", (it) => { |
| 1206 | 1215 | ).pipe(Effect.provideService(HostProcessPlatform, "linux")), |
| 1207 | 1216 | ); |
| 1208 | 1217 | |
| 1218 | for (const targetArch of ["x64", "arm64"] as const) { |
| 1219 | it.effect(`accepts an embedded archive with the Linux ${targetArch} node-pty prebuild`, () => |
| 1220 | Effect.scoped( |
| 1221 | Effect.gen(function* () { |
| 1222 | const fixture = yield* makeWindowsPayloadFixture({ |
| 1223 | copyUnpackedNatives: true, |
| 1224 | wslRuntime: "valid", |
| 1225 | targetArch, |
| 1226 | ptyPrebuildArch: targetArch, |
| 1227 | }); |
| 1228 | const result = yield* validateWindowsPackagedPayload({ |
| 1229 | stageDistDir: fixture.stageDistDir, |
| 1230 | appExecutableName: fixture.appExecutableName, |
| 1231 | targetArch, |
| 1232 | appVersion: WINDOWS_PAYLOAD_FIXTURE_VERSION, |
| 1233 | expectWslRuntime: true, |
| 1234 | }); |
| 1235 | |
| 1236 | assert.equal(result.packagedAppDir, fixture.packagedAppDir); |
| 1237 | }), |
| 1238 | ).pipe(Effect.provideService(HostProcessPlatform, "linux")), |
| 1239 | ); |
| 1240 | |
| 1241 | it.effect( |
| 1242 | `rejects a node-pty prebuild for the wrong architecture in a Linux ${targetArch} archive`, |
| 1243 | () => |
| 1244 | Effect.scoped( |
| 1245 | Effect.gen(function* () { |
| 1246 | const fixture = yield* makeWindowsPayloadFixture({ |
| 1247 | copyUnpackedNatives: true, |
| 1248 | wslRuntime: "valid", |
| 1249 | targetArch, |
| 1250 | ptyPrebuildArch: targetArch === "x64" ? "arm64" : "x64", |
| 1251 | }); |
| 1252 | const error = yield* validateWindowsPackagedPayload({ |
| 1253 | stageDistDir: fixture.stageDistDir, |
| 1254 | appExecutableName: fixture.appExecutableName, |
| 1255 | targetArch, |
| 1256 | appVersion: WINDOWS_PAYLOAD_FIXTURE_VERSION, |
| 1257 | expectWslRuntime: true, |
| 1258 | }).pipe(Effect.flip); |
| 1259 | |
| 1260 | assert.instanceOf(error, WindowsPackagedPayloadValidationError); |
| 1261 | assert.equal(error.reason, "wsl-runtime-invalid"); |
| 1262 | }), |
| 1263 | ), |
| 1264 | ); |
| 1265 | } |
| 1266 | |
| 1209 | 1267 | it.effect("rejects an embedded archive built for a different release version", () => |
| 1210 | 1268 | Effect.scoped( |
| 1211 | 1269 | Effect.gen(function* () { |
| ... | ... | @@ -1285,6 +1343,7 @@ it.layer(NodeServices.layer)("build-desktop-artifact", (it) => { |
| 1285 | 1343 | assert.equal(error.reason, "wsl-runtime-invalid"); |
| 1286 | 1344 | assert.deepStrictEqual(error.missingFiles, [ |
| 1287 | 1345 | `${wslRuntimeArchiveStem(WINDOWS_PAYLOAD_FIXTURE_VERSION, "x64")}/node_modules/node-pty/build/Release/pty.node`, |
| 1346 | `${wslRuntimeArchiveStem(WINDOWS_PAYLOAD_FIXTURE_VERSION, "x64")}/node_modules/node-pty/prebuilds/linux-x64/pty.node`, |
| 1288 | 1347 | ]); |
| 1289 | 1348 | }), |
| 1290 | 1349 | ), |