Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix issue causing prepare tests to pass when it actually failed #69353

Merged
merged 2 commits into from
Aug 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 23 additions & 3 deletions src/Tools/PrepareTests/TestDiscovery.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
namespace PrepareTests;
internal class TestDiscovery
{
private static readonly object s_lock = new();

public static bool RunDiscovery(string repoRootDirectory, string dotnetPath, bool isUnix)
{
var binDirectory = Path.Combine(repoRootDirectory, "artifacts", "bin");
Expand All @@ -32,19 +34,31 @@ public static bool RunDiscovery(string repoRootDirectory, string dotnetPath, boo
? dotnetFrameworkWorker
: dotnetCoreWorker;

success &= RunWorker(dotnetPath, workerPath, assembly);
var result = RunWorker(dotnetPath, workerPath, assembly);
lock (s_lock)
{
success &= result;
}
});
stopwatch.Stop();

Console.WriteLine($"Discovered tests in {stopwatch.Elapsed}");
if (success)
{
Console.WriteLine($"Discovered tests in {stopwatch.Elapsed}");
}
else
{
Console.WriteLine($"Test discovery failed");
}

return success;
}

static (string dotnetCoreWorker, string dotnetFrameworkWorker) GetWorkers(string binDirectory)
{
var testDiscoveryWorkerFolder = Path.Combine(binDirectory, "TestDiscoveryWorker");
var configuration = Directory.Exists(Path.Combine(testDiscoveryWorkerFolder, "Debug")) ? "Debug" : "Release";
return (Path.Combine(testDiscoveryWorkerFolder, configuration, "net7.0", "TestDiscoveryWorker.dll"),
return (Path.Combine(testDiscoveryWorkerFolder, configuration, "net8.0", "TestDiscoveryWorker.dll"),
Path.Combine(testDiscoveryWorkerFolder, configuration, "net472", "TestDiscoveryWorker.exe"));
}

Expand Down Expand Up @@ -95,6 +109,12 @@ static bool RunWorker(string dotnetPath, string pathToWorker, string pathToAssem
pipeClient.WaitForExit();
success &= pipeClient.ExitCode == 0;
pipeClient.Close();

if (!success)
{
Console.WriteLine($"Failed to discover tests in {pathToAssembly}");
}

return success;
}

Expand Down
2 changes: 1 addition & 1 deletion src/Tools/TestDiscoveryWorker/TestDiscoveryWorker.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFrameworks>net7.0;net472</TargetFrameworks>
<TargetFrameworks>net8.0;net472</TargetFrameworks>
<Nullable>enable</Nullable>
</PropertyGroup>

Expand Down