Skip to content

Commit 879fa12

Browse files
committed
More understandable failure when tools/tmp doesn't exist
1 parent 509dfab commit 879fa12

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

tools/ExampleTester/ExampleTests.cs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ namespace ExampleTester;
77

88
public static class ExampleTests
99
{
10-
private static TesterConfiguration TesterConfiguration { get; } = new(FindTmpDirectory());
10+
private static TesterConfiguration TesterConfiguration { get; } = new(Path.Join(FindSlnDirectory(), "tmp"));
1111

1212
public static IEnumerable<object[]> LoadExamples() =>
1313
from example in GeneratedExample.LoadAllExamples(TesterConfiguration.ExtractedOutputDirectory)
@@ -22,15 +22,14 @@ public static async Task ExamplePasses(GeneratedExample example)
2222
Assert.Fail("There were one or more failures. See the logged output for details.");
2323
}
2424

25-
private static string FindTmpDirectory()
25+
private static string FindSlnDirectory()
2626
{
2727
for (string? current = AppDomain.CurrentDomain.BaseDirectory; current != null; current = Path.GetDirectoryName(current))
2828
{
29-
string testPath = Path.Join(current, "tmp");
30-
if (Directory.Exists(testPath))
31-
return testPath;
29+
if (Directory.EnumerateFiles(current, "*.sln").Any())
30+
return current;
3231
}
3332

34-
throw new InvalidOperationException($"Can't find 'tmp' directory in {AppDomain.CurrentDomain.BaseDirectory} or any parent directories.");
33+
throw new InvalidOperationException($"Can't find a directory containing a .sln file in {AppDomain.CurrentDomain.BaseDirectory} or any parent directories.");
3534
}
3635
}

0 commit comments

Comments
 (0)