@@ -172,6 +172,13 @@ public static async Task<int> MainAsync(string[] args)
172172 continue ;
173173 }
174174
175+ if ( TryGetExampleTests ( filePath , projectPaths , nodeToTests , out var exampleName , out var impactedExampleTests ) )
176+ {
177+ selected . UnionWith ( impactedExampleTests ) ;
178+ reasons . Add ( $ "Selected { impactedExampleTests . Count } tests because { filePath } belongs to example { exampleName } .") ;
179+ continue ;
180+ }
181+
175182 if ( filePath . StartsWith ( "src/" , StringComparison . Ordinal ) ||
176183 filePath . StartsWith ( "tests/" , StringComparison . Ordinal ) ||
177184 filePath . StartsWith ( "examples/" , StringComparison . Ordinal ) ||
@@ -571,6 +578,42 @@ private static bool TryGetTypeScriptAppHostTests(
571578 return false ;
572579 }
573580
581+ private static bool TryGetExampleTests (
582+ string filePath ,
583+ List < string > projectPaths ,
584+ Dictionary < string , HashSet < string > > nodeToTests ,
585+ out string exampleName ,
586+ out HashSet < string > tests )
587+ {
588+ tests = [ ] ;
589+ exampleName = string . Empty ;
590+
591+ if ( ! filePath . StartsWith ( "examples/" , StringComparison . Ordinal ) )
592+ {
593+ return false ;
594+ }
595+
596+ var segments = filePath . Split ( '/' , StringSplitOptions . RemoveEmptyEntries ) ;
597+ if ( segments . Length < 2 )
598+ {
599+ return false ;
600+ }
601+
602+ exampleName = segments [ 1 ] ;
603+ var examplePrefix = $ "examples/{ exampleName } /";
604+ var exampleProjects = projectPaths . Where ( projectPath => projectPath . StartsWith ( examplePrefix , StringComparison . Ordinal ) ) ;
605+
606+ foreach ( var projectPath in exampleProjects )
607+ {
608+ if ( nodeToTests . TryGetValue ( projectPath , out var impacted ) )
609+ {
610+ tests . UnionWith ( impacted ) ;
611+ }
612+ }
613+
614+ return tests . Count > 0 ;
615+ }
616+
574617 private static Dictionary < string , string > ParseStringConstants ( string contents )
575618 {
576619 var constants = new Dictionary < string , string > ( StringComparer . Ordinal ) ;
0 commit comments