File tree Expand file tree Collapse file tree 1 file changed +32
-1
lines changed
src/dotnet/Sentry.Cli.Tests Expand file tree Collapse file tree 1 file changed +32
-1
lines changed Original file line number Diff line number Diff line change 1+ using System . Diagnostics . CodeAnalysis ;
12using System . Runtime . CompilerServices ;
23
34namespace Sentry . Cli . Tests ;
@@ -24,13 +25,43 @@ private static DirectoryInfo GetTestProjectDirectory([CallerFilePath] string? so
2425
2526 if ( ! testProject . Exists )
2627 {
27- Assert . Fail ( $ "Test project not found: { testProject } ") ;
28+ if ( TryFindSolutionDirectory ( out var solution ) )
29+ {
30+ testProject = new FileInfo ( Path . Combine ( solution . FullName , "Sentry.Cli.Tests" , "Sentry.Cli.Tests.csproj" ) ) ;
31+ if ( ! testProject . Exists )
32+ {
33+ Assert . Fail ( $ "Test project not found: { testProject } ") ;
34+ }
35+ }
36+ else
37+ {
38+ Assert . Fail ( $ "Test project not found: { testProject } ") ;
39+ }
2840 }
2941
3042 Assert . NotNull ( testProject . Directory ) ;
3143 return testProject . Directory ;
3244 }
3345
46+ private static bool TryFindSolutionDirectory ( [ NotNullWhen ( true ) ] out DirectoryInfo ? solution )
47+ {
48+ var directory = new DirectoryInfo ( Directory . GetCurrentDirectory ( ) ) ;
49+
50+ while ( directory . Parent is { } parent )
51+ {
52+ directory = parent ;
53+
54+ if ( Directory . EnumerateFiles ( directory . FullName , "Sentry.Cli.slnx" , SearchOption . TopDirectoryOnly ) . Any ( ) )
55+ {
56+ solution = directory ;
57+ return true ;
58+ }
59+ }
60+
61+ solution = null ;
62+ return false ;
63+ }
64+
3465 private static DotnetProject GetLauncherProject ( )
3566 {
3667 var testProjectDirectory = s_testProjectDirectory . Value ;
You can’t perform that action at this time.
0 commit comments