@@ -175,6 +175,8 @@ const makeWindowsPayloadFixture = Effect.fn("test.makeWindowsPayloadFixture")(fu
175175 readonly copyUnpackedNatives : boolean ;
176176 readonly serverEntrySource ?: string ;
177177 readonly wslRuntime ?: "valid" | "loose-server-tree" | "missing-pty" | "bad-digest" ;
178+ readonly targetArch ?: "x64" | "arm64" ;
179+ readonly ptyPrebuildArch ?: "x64" | "arm64" ;
178180} ) {
179181 const fs = yield * FileSystem . FileSystem ;
180182 const path = yield * Path . Path ;
@@ -212,7 +214,7 @@ const makeWindowsPayloadFixture = Effect.fn("test.makeWindowsPayloadFixture")(fu
212214 yield * fs . writeFileString ( path . join ( packagedAppDir , "chrome_crashpad_handler.exe" ) , "crashpad" ) ;
213215
214216 if ( input . wslRuntime !== undefined ) {
215- const stem = wslRuntimeArchiveStem ( WINDOWS_PAYLOAD_FIXTURE_VERSION , "x64" ) ;
217+ const stem = wslRuntimeArchiveStem ( WINDOWS_PAYLOAD_FIXTURE_VERSION , input . targetArch ?? "x64" ) ;
216218 const sourceArchivePath =
217219 input . wslRuntime === "loose-server-tree"
218220 ? // The old hand-rolled runtime: apps/server/dist + node_modules at the
@@ -226,9 +228,16 @@ const makeWindowsPayloadFixture = Effect.fn("test.makeWindowsPayloadFixture")(fu
226228 : yield * makeLinuxCliArchiveFixture ( {
227229 root : path . join ( tempDir , "wsl-runtime" ) ,
228230 stem,
229- ...( input . wslRuntime === "missing-pty"
231+ ...( input . wslRuntime === "missing-pty" || input . ptyPrebuildArch !== undefined
230232 ? { omitMembers : [ `${ stem } /node_modules/node-pty/build/Release/pty.node` ] }
231233 : { } ) ,
234+ ...( input . ptyPrebuildArch !== undefined
235+ ? {
236+ extraMembers : [
237+ `${ stem } /node_modules/node-pty/prebuilds/linux-${ input . ptyPrebuildArch } /pty.node` ,
238+ ] ,
239+ }
240+ : { } ) ,
232241 } ) ;
233242 const archivePath = path . join ( resourcesDir , WSL_RUNTIME_ARCHIVE_NAME ) ;
234243 const hashPath = path . join ( resourcesDir , WSL_RUNTIME_ARCHIVE_HASH_NAME ) ;
@@ -1206,6 +1215,55 @@ it.layer(NodeServices.layer)("build-desktop-artifact", (it) => {
12061215 ) . pipe ( Effect . provideService ( HostProcessPlatform , "linux" ) ) ,
12071216 ) ;
12081217
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+
12091267 it . effect ( "rejects an embedded archive built for a different release version" , ( ) =>
12101268 Effect . scoped (
12111269 Effect . gen ( function * ( ) {
@@ -1285,6 +1343,7 @@ it.layer(NodeServices.layer)("build-desktop-artifact", (it) => {
12851343 assert . equal ( error . reason , "wsl-runtime-invalid" ) ;
12861344 assert . deepStrictEqual ( error . missingFiles , [
12871345 `${ 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` ,
12881347 ] ) ;
12891348 } ) ,
12901349 ) ,
0 commit comments