@@ -6,23 +6,30 @@ import * as NodeURL from "node:url";
66import { expect , it } from "vite-plus/test" ;
77import { cacheKey , seedPreparedCache } from "./server-compile-cache.ts" ;
88
9- it ( "skips prepared bytecode generation for unsupported platforms" , async ( ) => {
10- const { spawnSync } = await import ( "node:child_process" ) ;
11- const hook = NodeURL . fileURLToPath (
12- new URL ( "../prepare-server-compile-cache.cjs" , import . meta. url ) ,
13- ) ;
14- const result = spawnSync (
15- process . execPath ,
16- [
17- "-e" ,
18- `Object.defineProperty(process, "platform", { value: "freebsd" });
19- require(${ JSON . stringify ( hook ) } )({ electronPlatformName: "freebsd", arch: 1 }).catch(error => { console.error(error); process.exitCode = 1; });` ,
20- ] ,
21- { encoding : "utf8" } ,
22- ) ;
23- expect ( result . status , result . stderr ) . toBe ( 0 ) ;
24- expect ( result . stdout ) . toContain ( "Skipping unsupported target freebsd" ) ;
25- } ) ;
9+ it . each ( [
10+ { platform : "freebsd" , hostArch : "x64" , arch : 1 , reason : "unsupported target freebsd" } ,
11+ { platform : "linux" , hostArch : "arm64" , arch : 3 , reason : "unsupported Linux architecture arm64" } ,
12+ ] ) (
13+ "skips unsupported $platform/$hostArch cache generation" ,
14+ async ( { platform, hostArch, arch, reason } ) => {
15+ const { spawnSync } = await import ( "node:child_process" ) ;
16+ const hook = NodeURL . fileURLToPath (
17+ new URL ( "../prepare-server-compile-cache.cjs" , import . meta. url ) ,
18+ ) ;
19+ const result = spawnSync (
20+ process . execPath ,
21+ [
22+ "-e" ,
23+ `Object.defineProperty(process, "platform", { value: ${ JSON . stringify ( platform ) } });
24+ Object.defineProperty(process, "arch", { value: ${ JSON . stringify ( hostArch ) } });
25+ require(${ JSON . stringify ( hook ) } )({ electronPlatformName: ${ JSON . stringify ( platform ) } , arch: ${ arch } }).catch(error => { console.error(error); process.exitCode = 1; });` ,
26+ ] ,
27+ { encoding : "utf8" } ,
28+ ) ;
29+ expect ( result . status , result . stderr ) . toBe ( 0 ) ;
30+ expect ( result . stdout ) . toContain ( `Skipping ${ reason } ` ) ;
31+ } ,
32+ ) ;
2633
2734// macOS runs on an ARM64 host to exercise the Rosetta build-host check.
2835it . each ( [
0 commit comments