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

tests: ExecuteRunWeb: update expected SIGTERM exit code on mono. #15341

Merged
merged 2 commits into from
Feb 22, 2023
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ internal class DotNetHelper
{
private static readonly object s_lockObj = new();

private static bool IsMonoRuntime { get; } = DetermineIsMonoRuntime();
public static string DotNetPath { get; } = Path.Combine(Config.DotNetDirectory, "dotnet");
public static string LogsDirectory { get; } = Path.Combine(Directory.GetCurrentDirectory(), "logs");
public static string PackagesDirectory { get; } = Path.Combine(Directory.GetCurrentDirectory(), "packages");
Expand Down Expand Up @@ -198,10 +199,13 @@ public void ExecuteRun(string projectName) =>

public void ExecuteRunWeb(string projectName)
{
// 'dotnet run' exit code differs between CoreCLR and Mono (https://github.com/dotnet/sdk/issues/30095).
int expectedExitCode = IsMonoRuntime ? 143 : 0;
ExecuteCmd(
$"run {GetBinLogOption(projectName, "run")}",
GetProjectDirectory(projectName),
additionalProcessConfigCallback: processConfigCallback,
expectedExitCode,
millisecondTimeout: 30000);

void processConfigCallback(Process process)
Expand Down Expand Up @@ -230,5 +234,27 @@ private static string GetBinLogOption(string projectName, string command, string
return $"/bl:{Path.Combine(LogsDirectory, $"{fileName}.binlog")}";
}

private static bool DetermineIsMonoRuntime()
{
string dotnetRoot = Config.DotNetDirectory;

string sharedFrameworkRoot = Path.Combine(dotnetRoot, "shared", "Microsoft.NETCore.App");
if (!Directory.Exists(sharedFrameworkRoot))
{
return false;
}

string? version = Directory.GetDirectories(sharedFrameworkRoot).FirstOrDefault();
if (version is null)
{
return false;
}

string sharedFramework = Path.Combine(sharedFrameworkRoot, version);

// Check the presence of one of the mono header files.
return File.Exists(Path.Combine(sharedFramework, "mono-gc.h"));
}

private static string GetProjectDirectory(string projectName) => Path.Combine(ProjectsDirectory, projectName);
}