@@ -57,11 +57,12 @@ async function testCompatibility(testCase: CompatibilityCase): Promise<void> {
5757 `Astro ${ testCase . astro } , ${ adapterName } ${ testCase . adapter } , ${ testCase . runtime } ` ;
5858 console . log ( `Testing ${ label } ...` ) ;
5959 const tempDir = await Deno . makeTempDir ( { prefix : "fedify-astro-compat-" } ) ;
60+ const port = reservePort ( ) ;
6061 try {
6162 const tarballs = await packFedifyPackages ( tempDir ) ;
6263 await Deno . writeTextFile (
6364 join ( tempDir , "astro.config.mjs" ) ,
64- await getAstroConfig ( testCase ) ,
65+ await getAstroConfig ( testCase , port ) ,
6566 ) ;
6667 await copy ( join ( compatDir , "src" ) , join ( tempDir , "src" ) ) ;
6768 await Deno . writeTextFile (
@@ -89,7 +90,7 @@ async function testCompatibility(testCase: CompatibilityCase): Promise<void> {
8990
9091 await run ( [ "pnpm" , "install" , "--strict-peer-dependencies" ] , tempDir ) ;
9192 await run ( [ "pnpm" , "exec" , "astro" , "build" ] , tempDir ) ;
92- await exerciseServer ( tempDir , testCase . runtime ) ;
93+ await exerciseServer ( tempDir , testCase . runtime , port ) ;
9394 console . log ( `Passed ${ label } .` ) ;
9495 } finally {
9596 if ( Deno . env . get ( "KEEP_ASTRO_COMPAT" ) == null ) {
@@ -100,7 +101,10 @@ async function testCompatibility(testCase: CompatibilityCase): Promise<void> {
100101 }
101102}
102103
103- async function getAstroConfig ( testCase : CompatibilityCase ) : Promise < string > {
104+ async function getAstroConfig (
105+ testCase : CompatibilityCase ,
106+ port : number ,
107+ ) : Promise < string > {
104108 if ( ! testCase . astro . startsWith ( "^7." ) ) {
105109 return await Deno . readTextFile ( join ( compatDir , "astro.config.mjs.tpl" ) ) ;
106110 }
@@ -122,6 +126,16 @@ async function getAstroConfig(testCase: CompatibilityCase): Promise<string> {
122126 } ) ;
123127 const config = initializer . files ?. [ "astro.config.ts" ] ;
124128 if ( config == null ) throw new Error ( "Astro initializer produced no config" ) ;
129+ if ( testCase . runtime === "deno" ) {
130+ const configured = config . replace (
131+ "adapter: deno()," ,
132+ `adapter: deno({ port: ${ port } }),` ,
133+ ) ;
134+ if ( configured === config ) {
135+ throw new Error ( "Could not configure the Deno compatibility test port" ) ;
136+ }
137+ return configured ;
138+ }
125139 return config ;
126140}
127141
@@ -167,8 +181,8 @@ async function packFedifyPackages(
167181async function exerciseServer (
168182 dir : string ,
169183 runtime : "node" | "deno" | "bun" ,
184+ port : number ,
170185) : Promise < void > {
171- const port = runtime === "deno" ? 8085 : reservePort ( ) ;
172186 const command = new Deno . Command ( runtime , {
173187 args : runtime === "deno"
174188 ? [ "run" , "-A" , "dist/server/entry.mjs" ]
0 commit comments