@@ -18,12 +18,30 @@ const NEXT_VERSION = process.env.NEXT_VERSION ?? 'latest'
18
18
const fixturesDir = fileURLToPath ( new URL ( `./fixtures` , import . meta. url ) )
19
19
const fixtureFilter = argv [ 2 ] ?? ''
20
20
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
+
21
36
const limit = pLimit ( Math . max ( 2 , cpus ( ) . length / 2 ) )
22
37
const fixtures = readdirSync ( fixturesDir )
23
38
// Ignoring things like `.DS_Store`.
24
39
. filter ( ( fixture ) => ! fixture . startsWith ( '.' ) )
25
40
// Applying the filter, if one is set.
26
41
. filter ( ( fixture ) => ! fixtureFilter || fixture . startsWith ( fixtureFilter ) )
42
+ // Filter out fixtures that are only needed for E2E tests
43
+ . filter ( ( fixture ) => ! e2eOnlyFixtures . has ( fixture ) )
44
+
27
45
console . log ( `🧪 Preparing fixtures: ${ fixtures . join ( ', ' ) } ` )
28
46
const fixtureList = new Set ( fixtures )
29
47
const fixtureCount = fixtures . length
@@ -62,7 +80,15 @@ const promises = fixtures.map((fixture) =>
62
80
this . push ( chunk . toString ( ) . replace ( / \n / gm, `\n[${ fixture } ] ` ) )
63
81
callback ( )
64
82
} ,
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
+ } ,
65
90
} )
91
+
66
92
console . log ( `[${ fixture } ] Running \`${ cmd } \`...` )
67
93
const output = execaCommand ( cmd , {
68
94
cwd,
@@ -80,6 +106,11 @@ const promises = fixtures.map((fixture) =>
80
106
operation : 'revert' ,
81
107
} )
82
108
}
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
+ }
83
114
fixtureList . delete ( fixture )
84
115
} )
85
116
} ) . finally ( ( ) => {
@@ -91,5 +122,22 @@ const promises = fixtures.map((fixture) =>
91
122
}
92
123
} ) ,
93
124
)
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
+
95
143
console . log ( '🎉 All fixtures prepared' )
0 commit comments