@@ -146,34 +146,14 @@ function getAffectedTestApplications(
146
146
// If something in e2e tests themselves are changed, check if only test applications were changed
147
147
if ( affectedProjects . includes ( '@sentry-internal/e2e-tests' ) ) {
148
148
try {
149
- const changedFiles = execSync (
150
- `git diff --name-only ${ base } ${ head ? `..${ head } ` : '' } -- dev-packages/e2e-tests/` ,
151
- { encoding : 'utf-8' } ,
152
- )
153
- . toString ( )
154
- . split ( '\n' )
155
- . map ( line => line . trim ( ) )
156
- . filter ( Boolean ) ;
157
-
158
- // Check if only test application files were changed
159
- const changedTestApps = new Set < string > ( ) ;
160
- const hasSharedCodeChanges = changedFiles . some ( file => {
161
- // Check if the file is within a test application directory
162
- const testAppMatch = file . match ( / ^ d e v - p a c k a g e s \/ e 2 e - t e s t s \/ t e s t - a p p l i c a t i o n s \/ ( [ ^ / ] + ) \/ / ) ;
163
- if ( testAppMatch ?. [ 1 ] ) {
164
- changedTestApps . add ( testAppMatch [ 1 ] ) ;
165
- return false ;
166
- }
167
- // If it's not in test-applications/, we assume it's shared code
168
- return true ;
169
- } ) ;
149
+ const changedTestApps = getChangedTestApps ( base , head ) ;
170
150
171
151
// Shared code was changed, run all tests
172
- if ( hasSharedCodeChanges ) {
152
+ if ( changedTestApps === false ) {
173
153
return testApplications ;
174
154
}
175
155
176
- // Only test applications were changed, run selectively
156
+ // Only test applications that were changed, run selectively
177
157
if ( changedTestApps . size > 0 ) {
178
158
return testApplications . filter ( testApp => changedTestApps . has ( testApp ) ) ;
179
159
}
@@ -192,3 +172,32 @@ function getAffectedTestApplications(
192
172
return sentryDependencies . some ( dep => affectedProjects . includes ( dep ) ) ;
193
173
} ) ;
194
174
}
175
+
176
+ function getChangedTestApps ( base : string , head ?: string ) : false | Set < string > {
177
+ const changedFiles = execSync ( `git diff --name-only ${ base } ${ head ? `..${ head } ` : '' } -- dev-packages/e2e-tests/` , {
178
+ encoding : 'utf-8' ,
179
+ } )
180
+ . toString ( )
181
+ . split ( '\n' )
182
+ . map ( line => line . trim ( ) )
183
+ . filter ( Boolean ) ;
184
+
185
+ const changedTestApps : Set < string > = new Set ( ) ;
186
+ const testAppsPrefix = 'dev-packages/e2e-tests/test-applications/' ;
187
+
188
+ for ( const file of changedFiles ) {
189
+ if ( ! file . startsWith ( testAppsPrefix ) ) {
190
+ // Shared code change - need to run all tests
191
+ return false ;
192
+ }
193
+
194
+ const pathAfterPrefix = file . slice ( testAppsPrefix . length ) ;
195
+ const slashIndex = pathAfterPrefix . indexOf ( '/' ) ;
196
+
197
+ if ( slashIndex > 0 ) {
198
+ changedTestApps . add ( pathAfterPrefix . slice ( 0 , slashIndex ) ) ;
199
+ }
200
+ }
201
+
202
+ return changedTestApps ;
203
+ }
0 commit comments