dotnet-installer/src/SourceBuild/tarball/content/test/Microsoft.DotNet.SourceBuild.SmokeTests/ExecuteHelper.cs

81 lines
2.8 KiB
C#
Raw Normal View History

// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
Update 6.0.2xx with the current state of 1xx (#13244) * Update .vsts-ci.yml * Update dependencies from https://github.com/dotnet/source-build-reference-packages build 20220205.1 (#13179) [release/6.0.1xx] Update dependencies from dotnet/source-build-reference-packages * Override Microsoft.Net.Sdk.WindowsDesktop references during source-build in Roslyn (#13093) * override SDK for Microsoft.Net.Sdk.WindowsDesktop references in roslyn * add new EmptySdk in the source build tarball * remove roslyn solution filter patch * Update dependencies from https://github.com/dotnet/arcade build 20220207.2 (#13186) Microsoft.DotNet.CMake.Sdk , Microsoft.DotNet.Build.Tasks.Installers , Microsoft.DotNet.Arcade.Sdk From Version 6.0.0-beta.22102.3 -> To Version 6.0.0-beta.22107.2 Co-authored-by: dotnet-maestro[bot] <dotnet-maestro[bot]@users.noreply.github.com> * [release/6.0.1xx] Windows SDK projection update * Update asp.net templates (#13193) * Update dependencies from https://github.com/dotnet/source-build-reference-packages build 20220210.1 (#13215) [release/6.0.1xx] Update dependencies from dotnet/source-build-reference-packages * Add test to compare msft and sb sdk contents (#13153) * Update to SDK and previously-source-built 6.0.102. (#13221) * Add CentOS Stream 9 container to CI matrix (#12955) * Update dependencies from https://github.com/dotnet/source-build-reference-packages build 20220215.1 (#13229) [release/6.0.1xx] Update dependencies from dotnet/source-build-reference-packages * Gather additional smoke test prereqs (#13233) * Remove bootstrapping for CI builds now that we use CentOS7 previously-source-built (#13232) * Update Version.Details.xml * Update dependencies from https://github.com/dotnet/source-build-reference-packages build 20220303.2 Microsoft.SourceBuild.Intermediate.source-build-reference-packages From Version 6.0.0-servicing.22151.1 -> To Version 6.0.0-servicing.22153.2 Co-authored-by: dotnet-maestro[bot] <42748379+dotnet-maestro[bot]@users.noreply.github.com> Co-authored-by: Logan Bussell <loganbussell@microsoft.com> Co-authored-by: dotnet-maestro[bot] <dotnet-maestro[bot]@users.noreply.github.com> Co-authored-by: Sean Reeser <v-seanreeser@microsoft.com> Co-authored-by: Manodasan Wignarajah <mawign@microsoft.com> Co-authored-by: William Godbe <wigodbe@microsoft.com> Co-authored-by: vseanreesermsft <78103370+vseanreesermsft@users.noreply.github.com> Co-authored-by: Michael Simons <msimons@microsoft.com> Co-authored-by: Chris Rummel <crummel@microsoft.com> Co-authored-by: Omair Majid <omajid@redhat.com>
2022-03-04 18:43:03 -08:00
using System;
using System.Diagnostics;
using System.Linq;
using System.Text;
using Xunit.Abstractions;
namespace Microsoft.DotNet.SourceBuild.SmokeTests;
internal static class ExecuteHelper
{
public static (Process Process, string StdOut, string StdErr) ExecuteProcess(
Update 6.0.2xx with the current state of 1xx (#13244) * Update .vsts-ci.yml * Update dependencies from https://github.com/dotnet/source-build-reference-packages build 20220205.1 (#13179) [release/6.0.1xx] Update dependencies from dotnet/source-build-reference-packages * Override Microsoft.Net.Sdk.WindowsDesktop references during source-build in Roslyn (#13093) * override SDK for Microsoft.Net.Sdk.WindowsDesktop references in roslyn * add new EmptySdk in the source build tarball * remove roslyn solution filter patch * Update dependencies from https://github.com/dotnet/arcade build 20220207.2 (#13186) Microsoft.DotNet.CMake.Sdk , Microsoft.DotNet.Build.Tasks.Installers , Microsoft.DotNet.Arcade.Sdk From Version 6.0.0-beta.22102.3 -> To Version 6.0.0-beta.22107.2 Co-authored-by: dotnet-maestro[bot] <dotnet-maestro[bot]@users.noreply.github.com> * [release/6.0.1xx] Windows SDK projection update * Update asp.net templates (#13193) * Update dependencies from https://github.com/dotnet/source-build-reference-packages build 20220210.1 (#13215) [release/6.0.1xx] Update dependencies from dotnet/source-build-reference-packages * Add test to compare msft and sb sdk contents (#13153) * Update to SDK and previously-source-built 6.0.102. (#13221) * Add CentOS Stream 9 container to CI matrix (#12955) * Update dependencies from https://github.com/dotnet/source-build-reference-packages build 20220215.1 (#13229) [release/6.0.1xx] Update dependencies from dotnet/source-build-reference-packages * Gather additional smoke test prereqs (#13233) * Remove bootstrapping for CI builds now that we use CentOS7 previously-source-built (#13232) * Update Version.Details.xml * Update dependencies from https://github.com/dotnet/source-build-reference-packages build 20220303.2 Microsoft.SourceBuild.Intermediate.source-build-reference-packages From Version 6.0.0-servicing.22151.1 -> To Version 6.0.0-servicing.22153.2 Co-authored-by: dotnet-maestro[bot] <42748379+dotnet-maestro[bot]@users.noreply.github.com> Co-authored-by: Logan Bussell <loganbussell@microsoft.com> Co-authored-by: dotnet-maestro[bot] <dotnet-maestro[bot]@users.noreply.github.com> Co-authored-by: Sean Reeser <v-seanreeser@microsoft.com> Co-authored-by: Manodasan Wignarajah <mawign@microsoft.com> Co-authored-by: William Godbe <wigodbe@microsoft.com> Co-authored-by: vseanreesermsft <78103370+vseanreesermsft@users.noreply.github.com> Co-authored-by: Michael Simons <msimons@microsoft.com> Co-authored-by: Chris Rummel <crummel@microsoft.com> Co-authored-by: Omair Majid <omajid@redhat.com>
2022-03-04 18:43:03 -08:00
string fileName, string args, ITestOutputHelper outputHelper, bool logOutput = false)
{
outputHelper.WriteLine($"Executing: {fileName} {args}");
Process process = new()
{
EnableRaisingEvents = true,
StartInfo =
{
FileName = fileName,
Arguments = args,
RedirectStandardOutput = true,
RedirectStandardError = true,
}
};
// The `dotnet test` execution context sets a number of dotnet related ENVs that cause issues when executing
// dotnet commands. Clear these to avoid side effects.
foreach (string key in process.StartInfo.Environment.Keys.Where(key => key != "HOME").ToList())
{
process.StartInfo.Environment.Remove(key);
}
StringBuilder stdOutput = new();
process.OutputDataReceived += new DataReceivedEventHandler((sender, e) => stdOutput.AppendLine(e.Data));
StringBuilder stdError = new();
process.ErrorDataReceived += new DataReceivedEventHandler((sender, e) => stdError.AppendLine(e.Data));
process.Start();
process.BeginOutputReadLine();
process.BeginErrorReadLine();
process.WaitForExit();
string output = stdOutput.ToString().Trim();
Update 6.0.2xx with the current state of 1xx (#13244) * Update .vsts-ci.yml * Update dependencies from https://github.com/dotnet/source-build-reference-packages build 20220205.1 (#13179) [release/6.0.1xx] Update dependencies from dotnet/source-build-reference-packages * Override Microsoft.Net.Sdk.WindowsDesktop references during source-build in Roslyn (#13093) * override SDK for Microsoft.Net.Sdk.WindowsDesktop references in roslyn * add new EmptySdk in the source build tarball * remove roslyn solution filter patch * Update dependencies from https://github.com/dotnet/arcade build 20220207.2 (#13186) Microsoft.DotNet.CMake.Sdk , Microsoft.DotNet.Build.Tasks.Installers , Microsoft.DotNet.Arcade.Sdk From Version 6.0.0-beta.22102.3 -> To Version 6.0.0-beta.22107.2 Co-authored-by: dotnet-maestro[bot] <dotnet-maestro[bot]@users.noreply.github.com> * [release/6.0.1xx] Windows SDK projection update * Update asp.net templates (#13193) * Update dependencies from https://github.com/dotnet/source-build-reference-packages build 20220210.1 (#13215) [release/6.0.1xx] Update dependencies from dotnet/source-build-reference-packages * Add test to compare msft and sb sdk contents (#13153) * Update to SDK and previously-source-built 6.0.102. (#13221) * Add CentOS Stream 9 container to CI matrix (#12955) * Update dependencies from https://github.com/dotnet/source-build-reference-packages build 20220215.1 (#13229) [release/6.0.1xx] Update dependencies from dotnet/source-build-reference-packages * Gather additional smoke test prereqs (#13233) * Remove bootstrapping for CI builds now that we use CentOS7 previously-source-built (#13232) * Update Version.Details.xml * Update dependencies from https://github.com/dotnet/source-build-reference-packages build 20220303.2 Microsoft.SourceBuild.Intermediate.source-build-reference-packages From Version 6.0.0-servicing.22151.1 -> To Version 6.0.0-servicing.22153.2 Co-authored-by: dotnet-maestro[bot] <42748379+dotnet-maestro[bot]@users.noreply.github.com> Co-authored-by: Logan Bussell <loganbussell@microsoft.com> Co-authored-by: dotnet-maestro[bot] <dotnet-maestro[bot]@users.noreply.github.com> Co-authored-by: Sean Reeser <v-seanreeser@microsoft.com> Co-authored-by: Manodasan Wignarajah <mawign@microsoft.com> Co-authored-by: William Godbe <wigodbe@microsoft.com> Co-authored-by: vseanreesermsft <78103370+vseanreesermsft@users.noreply.github.com> Co-authored-by: Michael Simons <msimons@microsoft.com> Co-authored-by: Chris Rummel <crummel@microsoft.com> Co-authored-by: Omair Majid <omajid@redhat.com>
2022-03-04 18:43:03 -08:00
if (logOutput && !string.IsNullOrWhiteSpace(output))
{
outputHelper.WriteLine(output);
}
string error = stdError.ToString().Trim();
Update 6.0.2xx with the current state of 1xx (#13244) * Update .vsts-ci.yml * Update dependencies from https://github.com/dotnet/source-build-reference-packages build 20220205.1 (#13179) [release/6.0.1xx] Update dependencies from dotnet/source-build-reference-packages * Override Microsoft.Net.Sdk.WindowsDesktop references during source-build in Roslyn (#13093) * override SDK for Microsoft.Net.Sdk.WindowsDesktop references in roslyn * add new EmptySdk in the source build tarball * remove roslyn solution filter patch * Update dependencies from https://github.com/dotnet/arcade build 20220207.2 (#13186) Microsoft.DotNet.CMake.Sdk , Microsoft.DotNet.Build.Tasks.Installers , Microsoft.DotNet.Arcade.Sdk From Version 6.0.0-beta.22102.3 -> To Version 6.0.0-beta.22107.2 Co-authored-by: dotnet-maestro[bot] <dotnet-maestro[bot]@users.noreply.github.com> * [release/6.0.1xx] Windows SDK projection update * Update asp.net templates (#13193) * Update dependencies from https://github.com/dotnet/source-build-reference-packages build 20220210.1 (#13215) [release/6.0.1xx] Update dependencies from dotnet/source-build-reference-packages * Add test to compare msft and sb sdk contents (#13153) * Update to SDK and previously-source-built 6.0.102. (#13221) * Add CentOS Stream 9 container to CI matrix (#12955) * Update dependencies from https://github.com/dotnet/source-build-reference-packages build 20220215.1 (#13229) [release/6.0.1xx] Update dependencies from dotnet/source-build-reference-packages * Gather additional smoke test prereqs (#13233) * Remove bootstrapping for CI builds now that we use CentOS7 previously-source-built (#13232) * Update Version.Details.xml * Update dependencies from https://github.com/dotnet/source-build-reference-packages build 20220303.2 Microsoft.SourceBuild.Intermediate.source-build-reference-packages From Version 6.0.0-servicing.22151.1 -> To Version 6.0.0-servicing.22153.2 Co-authored-by: dotnet-maestro[bot] <42748379+dotnet-maestro[bot]@users.noreply.github.com> Co-authored-by: Logan Bussell <loganbussell@microsoft.com> Co-authored-by: dotnet-maestro[bot] <dotnet-maestro[bot]@users.noreply.github.com> Co-authored-by: Sean Reeser <v-seanreeser@microsoft.com> Co-authored-by: Manodasan Wignarajah <mawign@microsoft.com> Co-authored-by: William Godbe <wigodbe@microsoft.com> Co-authored-by: vseanreesermsft <78103370+vseanreesermsft@users.noreply.github.com> Co-authored-by: Michael Simons <msimons@microsoft.com> Co-authored-by: Chris Rummel <crummel@microsoft.com> Co-authored-by: Omair Majid <omajid@redhat.com>
2022-03-04 18:43:03 -08:00
if (logOutput && !string.IsNullOrWhiteSpace(error))
{
outputHelper.WriteLine(error);
}
return (process, output, error);
}
Update 6.0.2xx with the current state of 1xx (#13244) * Update .vsts-ci.yml * Update dependencies from https://github.com/dotnet/source-build-reference-packages build 20220205.1 (#13179) [release/6.0.1xx] Update dependencies from dotnet/source-build-reference-packages * Override Microsoft.Net.Sdk.WindowsDesktop references during source-build in Roslyn (#13093) * override SDK for Microsoft.Net.Sdk.WindowsDesktop references in roslyn * add new EmptySdk in the source build tarball * remove roslyn solution filter patch * Update dependencies from https://github.com/dotnet/arcade build 20220207.2 (#13186) Microsoft.DotNet.CMake.Sdk , Microsoft.DotNet.Build.Tasks.Installers , Microsoft.DotNet.Arcade.Sdk From Version 6.0.0-beta.22102.3 -> To Version 6.0.0-beta.22107.2 Co-authored-by: dotnet-maestro[bot] <dotnet-maestro[bot]@users.noreply.github.com> * [release/6.0.1xx] Windows SDK projection update * Update asp.net templates (#13193) * Update dependencies from https://github.com/dotnet/source-build-reference-packages build 20220210.1 (#13215) [release/6.0.1xx] Update dependencies from dotnet/source-build-reference-packages * Add test to compare msft and sb sdk contents (#13153) * Update to SDK and previously-source-built 6.0.102. (#13221) * Add CentOS Stream 9 container to CI matrix (#12955) * Update dependencies from https://github.com/dotnet/source-build-reference-packages build 20220215.1 (#13229) [release/6.0.1xx] Update dependencies from dotnet/source-build-reference-packages * Gather additional smoke test prereqs (#13233) * Remove bootstrapping for CI builds now that we use CentOS7 previously-source-built (#13232) * Update Version.Details.xml * Update dependencies from https://github.com/dotnet/source-build-reference-packages build 20220303.2 Microsoft.SourceBuild.Intermediate.source-build-reference-packages From Version 6.0.0-servicing.22151.1 -> To Version 6.0.0-servicing.22153.2 Co-authored-by: dotnet-maestro[bot] <42748379+dotnet-maestro[bot]@users.noreply.github.com> Co-authored-by: Logan Bussell <loganbussell@microsoft.com> Co-authored-by: dotnet-maestro[bot] <dotnet-maestro[bot]@users.noreply.github.com> Co-authored-by: Sean Reeser <v-seanreeser@microsoft.com> Co-authored-by: Manodasan Wignarajah <mawign@microsoft.com> Co-authored-by: William Godbe <wigodbe@microsoft.com> Co-authored-by: vseanreesermsft <78103370+vseanreesermsft@users.noreply.github.com> Co-authored-by: Michael Simons <msimons@microsoft.com> Co-authored-by: Chris Rummel <crummel@microsoft.com> Co-authored-by: Omair Majid <omajid@redhat.com>
2022-03-04 18:43:03 -08:00
public static string ExecuteProcessValidateExitCode(string fileName, string args, ITestOutputHelper outputHelper)
{
(Process Process, string StdOut, string StdErr) result = ExecuteHelper.ExecuteProcess(fileName, args, outputHelper);
if (result.Process.ExitCode != 0)
{
ProcessStartInfo startInfo = result.Process.StartInfo;
string msg = $"Failed to execute {startInfo.FileName} {startInfo.Arguments}" +
$"{Environment.NewLine}Exit code: {result.Process.ExitCode}" +
$"{Environment.NewLine}Standard Error: {result.StdErr}";
throw new InvalidOperationException(msg);
}
return result.StdOut;
}
}