@@ -223,7 +223,7 @@ function classifySkip(path, title, expression) {
223223}
224224
225225export function excludesWindows ( expression ) {
226- const compact = expression . replaceAll ( / \s + / gu, ' ' ) ;
226+ const compact = stripBalancedOuterParentheses ( expression . replaceAll ( / \s + / gu, ' ' ) . trim ( ) ) ;
227227 // A Windows-only regression commonly uses `false` on Windows and a skip
228228 // reason elsewhere. Exempt only when that ternary is the complete skip
229229 // expression: a surrounding boolean expression may still skip on Windows.
@@ -240,6 +240,39 @@ export function excludesWindows(expression) {
240240 ) ;
241241}
242242
243+ function stripBalancedOuterParentheses ( expression ) {
244+ let compact = expression ;
245+ while ( hasCompleteOuterParentheses ( compact ) ) compact = compact . slice ( 1 , - 1 ) . trim ( ) ;
246+ return compact ;
247+ }
248+
249+ function hasCompleteOuterParentheses ( expression ) {
250+ if ( ! expression . startsWith ( '(' ) || ! expression . endsWith ( ')' ) ) return false ;
251+ let depth = 0 ;
252+ let quote ;
253+ let escaped = false ;
254+ for ( let index = 0 ; index < expression . length ; index += 1 ) {
255+ const char = expression [ index ] ;
256+ if ( quote ) {
257+ if ( escaped ) escaped = false ;
258+ else if ( char === '\\' ) escaped = true ;
259+ else if ( char === quote ) quote = undefined ;
260+ continue ;
261+ }
262+ if ( char === "'" || char === '"' || char === '`' ) {
263+ quote = char ;
264+ continue ;
265+ }
266+ if ( char === '(' ) depth += 1 ;
267+ else if ( char === ')' ) {
268+ depth -= 1 ;
269+ if ( depth === 0 ) return index === expression . length - 1 ;
270+ if ( depth < 0 ) return false ;
271+ }
272+ }
273+ return false ;
274+ }
275+
243276function nearbyTestTitle ( lines , skipIndex ) {
244277 const context = lines . slice ( Math . max ( 0 , skipIndex - 12 ) , skipIndex + 1 ) . join ( '\n' ) ;
245278 const matches = [ ...context . matchAll ( / \b (?: t e s t | i t | d e s c r i b e ) \s * \( \s * ( [ ' " ` ] ) ( [ \s \S ] + ?) \1/ gu) ] ;
0 commit comments