@@ -18,12 +18,30 @@ const NEXT_VERSION = process.env.NEXT_VERSION ?? 'latest'
1818const fixturesDir = fileURLToPath ( new URL ( `./fixtures` , import . meta. url ) )
1919const fixtureFilter = argv [ 2 ] ?? ''
2020
21+ // E2E tests run next builds, so we don't need to prepare those ahead of time for integration tests
22+ const e2eOnlyFixtures = new Set ( [
23+ 'after' ,
24+ 'cli-before-regional-blobs-support' ,
25+ 'dist-dir' ,
26+ // There is also a bug on Windows on Node.js 18.20.6, that cause build failures on this fixture
27+ // see https://github.com/opennextjs/opennextjs-netlify/actions/runs/13268839161/job/37043172448?pr=2749#step:12:78
28+ 'middleware-og' ,
29+ 'middleware-single-matcher' ,
30+ 'nx-integrated' ,
31+ 'turborepo' ,
32+ 'turborepo-npm' ,
33+ 'unstable-cache' ,
34+ ] )
35+
2136const limit = pLimit ( Math . max ( 2 , cpus ( ) . length / 2 ) )
2237const fixtures = readdirSync ( fixturesDir )
2338 // Ignoring things like `.DS_Store`.
2439 . filter ( ( fixture ) => ! fixture . startsWith ( '.' ) )
2540 // Applying the filter, if one is set.
2641 . filter ( ( fixture ) => ! fixtureFilter || fixture . startsWith ( fixtureFilter ) )
42+ // Filter out fixtures that are only needed for E2E tests
43+ . filter ( ( fixture ) => ! e2eOnlyFixtures . has ( fixture ) )
44+
2745console . log ( `🧪 Preparing fixtures: ${ fixtures . join ( ', ' ) } ` )
2846const fixtureList = new Set ( fixtures )
2947const fixtureCount = fixtures . length
@@ -62,7 +80,15 @@ const promises = fixtures.map((fixture) =>
6280 this . push ( chunk . toString ( ) . replace ( / \n / gm, `\n[${ fixture } ] ` ) )
6381 callback ( )
6482 } ,
83+ flush ( callback ) {
84+ // final transform might create non-terminated line with a prefix
85+ // so this is just to make sure we end with a newline so further writes
86+ // to same destination stream start on a new line for better readability
87+ this . push ( '\n' )
88+ callback ( )
89+ } ,
6590 } )
91+
6692 console . log ( `[${ fixture } ] Running \`${ cmd } \`...` )
6793 const output = execaCommand ( cmd , {
6894 cwd,
@@ -80,6 +106,11 @@ const promises = fixtures.map((fixture) =>
80106 operation : 'revert' ,
81107 } )
82108 }
109+ if ( output . exitCode !== 0 ) {
110+ const errorMessage = `[${ fixture } ] 🚨 Failed to install dependencies or build a fixture`
111+ console . error ( errorMessage )
112+ throw new Error ( errorMessage )
113+ }
83114 fixtureList . delete ( fixture )
84115 } )
85116 } ) . finally ( ( ) => {
@@ -91,5 +122,22 @@ const promises = fixtures.map((fixture) =>
91122 }
92123 } ) ,
93124)
94- await Promise . allSettled ( promises )
125+ const prepareFixturesResults = await Promise . allSettled ( promises )
126+ const failedFixturesErrors = prepareFixturesResults
127+ . map ( ( promise ) => {
128+ if ( promise . status === 'rejected' ) {
129+ return promise . reason
130+ }
131+ return null
132+ } )
133+ . filter ( Boolean )
134+
135+ if ( failedFixturesErrors . length > 0 ) {
136+ console . error ( 'Some fixtures failed to prepare:' )
137+ for ( const error of failedFixturesErrors ) {
138+ console . error ( error . message )
139+ }
140+ process . exit ( 1 )
141+ }
142+
95143console . log ( '🎉 All fixtures prepared' )
0 commit comments