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

Executor: Don't use Process.ExitCode, unless the process has exited #1947

Merged
merged 4 commits into from
Mar 18, 2022
Merged
Show file tree
Hide file tree
Changes from 3 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
10 changes: 10 additions & 0 deletions src/BenchmarkDotNet/Toolchains/DotNetCli/DotNetCliCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,12 @@ public BuildResult RestoreThenBuild()

var buildResult = BuildNoRestore();
if (!buildResult.IsSuccess) // if we fail to do the full build, we try with --no-dependencies
{
Logger.WriteLineInfo(buildResult.StandardOutput);
Logger.WriteLineInfo(buildResult.StandardError);
Logger.WriteLineInfo("Build failed. Trying with --no-dependencies");
buildResult = BuildNoRestoreNoDependencies();
}
adamsitnik marked this conversation as resolved.
Show resolved Hide resolved

return buildResult.ToBuildResult(GenerateResult);
}
Expand All @@ -86,7 +91,12 @@ public BuildResult RestoreThenBuildThenPublish()

var buildResult = BuildNoRestore();
if (!buildResult.IsSuccess) // if we fail to do the full build, we try with --no-dependencies
{
Logger.WriteLineInfo(buildResult.StandardOutput);
Logger.WriteLineInfo(buildResult.StandardError);
Logger.WriteLineInfo("Build failed. Trying with --no-dependencies");
buildResult = BuildNoRestoreNoDependencies();
}
adamsitnik marked this conversation as resolved.
Show resolved Hide resolved

if (!buildResult.IsSuccess)
return BuildResult.Failure(GenerateResult, buildResult.AllInformation);
Expand Down
7 changes: 6 additions & 1 deletion src/BenchmarkDotNet/Toolchains/Executor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,12 @@ private ExecuteResult Execute(Process process, BenchmarkCase benchmarkCase, Sync
if (loggerWithDiagnoser.LinesWithResults.Any(line => line.Contains("BadImageFormatException")))
logger.WriteLineError("You are probably missing <PlatformTarget>AnyCPU</PlatformTarget> in your .csproj file.");

return new ExecuteResult(true, process.ExitCode, process.Id, loggerWithDiagnoser.LinesWithResults, loggerWithDiagnoser.LinesWithExtraOutput, launchIndex);
return new ExecuteResult(true,
process.HasExited ? process.ExitCode : null,
process.Id,
loggerWithDiagnoser.LinesWithResults,
loggerWithDiagnoser.LinesWithExtraOutput,
launchIndex);
}

private ProcessStartInfo CreateStartInfo(BenchmarkCase benchmarkCase, ArtifactsPaths artifactsPaths, string args, IResolver resolver)
Expand Down