Merge in 'release/6.0.1xx' changes
This commit is contained in:
commit
76ce973431
5 changed files with 104 additions and 98 deletions
|
@ -5,7 +5,6 @@
|
|||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using Xunit;
|
||||
using Xunit.Abstractions;
|
||||
|
||||
namespace Microsoft.DotNet.SourceBuild.SmokeTests;
|
||||
|
@ -81,15 +80,6 @@ internal class DotNetHelper
|
|||
|
||||
public void ExecuteCmd(string args, string? workingDirectory = null, Action<Process>? additionalProcessConfigCallback = null, int expectedExitCode = 0, int millisecondTimeout = -1)
|
||||
{
|
||||
Action<Process, string?> configureProcess = (Process process, string? workingDirectory) => {
|
||||
ConfigureProcess(process, workingDirectory);
|
||||
|
||||
if (additionalProcessConfigCallback != null)
|
||||
{
|
||||
additionalProcessConfigCallback(process);
|
||||
}
|
||||
};
|
||||
|
||||
(Process Process, string StdOut, string StdErr) executeResult = ExecuteHelper.ExecuteProcess(
|
||||
DotNetPath,
|
||||
args,
|
||||
|
@ -98,6 +88,13 @@ internal class DotNetHelper
|
|||
millisecondTimeout: millisecondTimeout);
|
||||
|
||||
ExecuteHelper.ValidateExitCode(executeResult, expectedExitCode);
|
||||
|
||||
void configureProcess(Process process, string? workingDirectory)
|
||||
{
|
||||
ConfigureProcess(process, workingDirectory);
|
||||
|
||||
additionalProcessConfigCallback?.Invoke(process);
|
||||
}
|
||||
}
|
||||
|
||||
public static void ConfigureProcess(Process process, string? workingDirectory, bool setPath = false)
|
||||
|
|
|
@ -44,10 +44,24 @@ internal static class ExecuteHelper
|
|||
configure?.Invoke(process);
|
||||
|
||||
StringBuilder stdOutput = new();
|
||||
process.OutputDataReceived += new DataReceivedEventHandler((sender, e) => stdOutput.AppendLine(e.Data));
|
||||
process.OutputDataReceived += new DataReceivedEventHandler(
|
||||
(sender, e) =>
|
||||
{
|
||||
lock (stdOutput)
|
||||
{
|
||||
stdOutput.AppendLine(e.Data);
|
||||
}
|
||||
});
|
||||
|
||||
StringBuilder stdError = new();
|
||||
process.ErrorDataReceived += new DataReceivedEventHandler((sender, e) => stdError.AppendLine(e.Data));
|
||||
process.ErrorDataReceived += new DataReceivedEventHandler(
|
||||
(sender, e) =>
|
||||
{
|
||||
lock (stdError)
|
||||
{
|
||||
stdError.AppendLine(e.Data);
|
||||
}
|
||||
});
|
||||
|
||||
process.Start();
|
||||
process.BeginOutputReadLine();
|
||||
|
|
|
@ -5,35 +5,34 @@
|
|||
using System;
|
||||
using Xunit;
|
||||
|
||||
namespace Microsoft.DotNet.SourceBuild.SmokeTests
|
||||
namespace Microsoft.DotNet.SourceBuild.SmokeTests;
|
||||
|
||||
/// <summary>
|
||||
/// A Fact that will be skipped based on the specified environment variable's value.
|
||||
/// </summary>
|
||||
internal class SkippableFactAttribute : FactAttribute
|
||||
{
|
||||
/// <summary>
|
||||
/// A Fact that will be skipped based on the specified environment variable's value.
|
||||
/// </summary>
|
||||
internal class SkippableFactAttribute : FactAttribute
|
||||
public SkippableFactAttribute(string envName, bool skipOnNullOrWhiteSpace = false, bool skipOnTrue = false) =>
|
||||
CheckEnvs(skipOnNullOrWhiteSpace, skipOnTrue, (skip) => Skip = skip, envName);
|
||||
|
||||
public SkippableFactAttribute(string[] envNames, bool skipOnNullOrWhiteSpace = false, bool skipOnTrue = false) =>
|
||||
CheckEnvs(skipOnNullOrWhiteSpace, skipOnTrue, (skip) => Skip = skip, envNames);
|
||||
|
||||
public static void CheckEnvs(bool skipOnNullOrWhiteSpace, bool skipOnTrue, Action<string> setSkip, params string[] envNames)
|
||||
{
|
||||
public SkippableFactAttribute(string envName, bool skipOnNullOrWhiteSpace = false, bool skipOnTrue = false) =>
|
||||
CheckEnvs(skipOnNullOrWhiteSpace, skipOnTrue, (skip) => Skip = skip, envName);
|
||||
|
||||
public SkippableFactAttribute(string[] envNames, bool skipOnNullOrWhiteSpace = false, bool skipOnTrue = false) =>
|
||||
CheckEnvs(skipOnNullOrWhiteSpace, skipOnTrue, (skip) => Skip = skip, envNames);
|
||||
|
||||
public static void CheckEnvs(bool skipOnNullOrWhiteSpace, bool skipOnTrue, Action<string> setSkip, params string[] envNames)
|
||||
foreach (string envName in envNames)
|
||||
{
|
||||
foreach (string envName in envNames)
|
||||
{
|
||||
string? envValue = Environment.GetEnvironmentVariable(envName);
|
||||
string? envValue = Environment.GetEnvironmentVariable(envName);
|
||||
|
||||
if (skipOnNullOrWhiteSpace && string.IsNullOrWhiteSpace(envValue))
|
||||
{
|
||||
setSkip($"Skipping because `{envName}` is null or whitespace");
|
||||
break;
|
||||
}
|
||||
else if (skipOnTrue && bool.TryParse(envValue, out bool boolValue) && boolValue)
|
||||
{
|
||||
setSkip($"Skipping because `{envName}` is set to True");
|
||||
break;
|
||||
}
|
||||
if (skipOnNullOrWhiteSpace && string.IsNullOrWhiteSpace(envValue))
|
||||
{
|
||||
setSkip($"Skipping because `{envName}` is null or whitespace");
|
||||
break;
|
||||
}
|
||||
else if (skipOnTrue && bool.TryParse(envValue, out bool boolValue) && boolValue)
|
||||
{
|
||||
setSkip($"Skipping because `{envName}` is set to True");
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,17 +4,16 @@
|
|||
|
||||
using Xunit;
|
||||
|
||||
namespace Microsoft.DotNet.SourceBuild.SmokeTests
|
||||
{
|
||||
/// <summary>
|
||||
/// A Theory that will be skipped based on the specified environment variable's value.
|
||||
/// </summary>
|
||||
internal class SkippableTheoryAttribute : TheoryAttribute
|
||||
{
|
||||
public SkippableTheoryAttribute(string envName, bool skipOnNullOrWhiteSpace = false, bool skipOnTrue = false) =>
|
||||
SkippableFactAttribute.CheckEnvs(skipOnNullOrWhiteSpace, skipOnTrue, (skip) => Skip = skip, envName);
|
||||
namespace Microsoft.DotNet.SourceBuild.SmokeTests;
|
||||
|
||||
public SkippableTheoryAttribute(string[] envNames, bool skipOnNullOrWhiteSpace = false, bool skipOnTrue = false) =>
|
||||
SkippableFactAttribute.CheckEnvs(skipOnNullOrWhiteSpace, skipOnTrue, (skip) => Skip = skip, envNames);
|
||||
}
|
||||
/// <summary>
|
||||
/// A Theory that will be skipped based on the specified environment variable's value.
|
||||
/// </summary>
|
||||
internal class SkippableTheoryAttribute : TheoryAttribute
|
||||
{
|
||||
public SkippableTheoryAttribute(string envName, bool skipOnNullOrWhiteSpace = false, bool skipOnTrue = false) =>
|
||||
SkippableFactAttribute.CheckEnvs(skipOnNullOrWhiteSpace, skipOnTrue, (skip) => Skip = skip, envName);
|
||||
|
||||
public SkippableTheoryAttribute(string[] envNames, bool skipOnNullOrWhiteSpace = false, bool skipOnTrue = false) =>
|
||||
SkippableFactAttribute.CheckEnvs(skipOnNullOrWhiteSpace, skipOnTrue, (skip) => Skip = skip, envNames);
|
||||
}
|
||||
|
|
|
@ -2,66 +2,63 @@
|
|||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
using System;
|
||||
namespace Microsoft.DotNet.SourceBuild.SmokeTests;
|
||||
|
||||
namespace Microsoft.DotNet.SourceBuild.SmokeTests
|
||||
public class TestScenario
|
||||
{
|
||||
public class TestScenario
|
||||
public DotNetActions Commands { get; }
|
||||
public DotNetLanguage Language { get; }
|
||||
public bool NoHttps { get; set; } = Config.TargetRid.Contains("osx");
|
||||
public string ScenarioName { get; }
|
||||
public DotNetTemplate Template { get; }
|
||||
|
||||
public TestScenario(string scenarioName, DotNetLanguage language, DotNetTemplate template, DotNetActions commands = DotNetActions.None)
|
||||
{
|
||||
public DotNetActions Commands { get; }
|
||||
public DotNetLanguage Language { get; }
|
||||
public bool NoHttps { get; set; } = Config.TargetRid.Contains("osx");
|
||||
public string ScenarioName { get; }
|
||||
public DotNetTemplate Template { get; }
|
||||
ScenarioName = scenarioName;
|
||||
Template = template;
|
||||
Language = language;
|
||||
Commands = commands;
|
||||
}
|
||||
|
||||
public TestScenario(string scenarioName, DotNetLanguage language, DotNetTemplate template, DotNetActions commands = DotNetActions.None)
|
||||
internal void Execute(DotNetHelper dotNetHelper)
|
||||
{
|
||||
// Don't use the cli language name in the project name because it may contain '#': https://github.com/dotnet/roslyn/issues/51692
|
||||
string projectName = $"{ScenarioName}_{Template}_{Language}";
|
||||
string customNewArgs = Template.IsAspNetCore() && NoHttps ? "--no-https" : string.Empty;
|
||||
dotNetHelper.ExecuteNew(Template.GetName(), projectName, Language.ToCliName(), customArgs: customNewArgs);
|
||||
|
||||
if (Commands.HasFlag(DotNetActions.Build))
|
||||
{
|
||||
ScenarioName = scenarioName;
|
||||
Template = template;
|
||||
Language = language;
|
||||
Commands = commands;
|
||||
dotNetHelper.ExecuteBuild(projectName);
|
||||
}
|
||||
|
||||
internal void Execute(DotNetHelper dotNetHelper)
|
||||
if (Commands.HasFlag(DotNetActions.Run))
|
||||
{
|
||||
// Don't use the cli language name in the project name because it may contain '#': https://github.com/dotnet/roslyn/issues/51692
|
||||
string projectName = $"{ScenarioName}_{Template}_{Language}";
|
||||
string customNewArgs = Template.IsAspNetCore() && NoHttps ? "--no-https" : string.Empty;
|
||||
dotNetHelper.ExecuteNew(Template.GetName(), projectName, Language.ToCliName(), customArgs: customNewArgs);
|
||||
|
||||
if (Commands.HasFlag(DotNetActions.Build))
|
||||
if (Template.IsAspNetCore())
|
||||
{
|
||||
dotNetHelper.ExecuteBuild(projectName);
|
||||
dotNetHelper.ExecuteRunWeb(projectName);
|
||||
}
|
||||
if (Commands.HasFlag(DotNetActions.Run))
|
||||
else
|
||||
{
|
||||
if (Template.IsAspNetCore())
|
||||
{
|
||||
dotNetHelper.ExecuteRunWeb(projectName);
|
||||
}
|
||||
else
|
||||
{
|
||||
dotNetHelper.ExecuteRun(projectName);
|
||||
}
|
||||
}
|
||||
if (Commands.HasFlag(DotNetActions.Publish))
|
||||
{
|
||||
dotNetHelper.ExecutePublish(projectName);
|
||||
}
|
||||
if (Commands.HasFlag(DotNetActions.PublishComplex))
|
||||
{
|
||||
dotNetHelper.ExecutePublish(projectName, selfContained: false);
|
||||
dotNetHelper.ExecutePublish(projectName, selfContained: true, Config.TargetRid);
|
||||
dotNetHelper.ExecutePublish(projectName, selfContained: true, "linux-x64");
|
||||
}
|
||||
if (Commands.HasFlag(DotNetActions.PublishR2R))
|
||||
{
|
||||
dotNetHelper.ExecutePublish(projectName, selfContained: true, "linux-x64", trimmed: true, readyToRun: true);
|
||||
}
|
||||
if (Commands.HasFlag(DotNetActions.Test))
|
||||
{
|
||||
dotNetHelper.ExecuteTest(projectName);
|
||||
dotNetHelper.ExecuteRun(projectName);
|
||||
}
|
||||
}
|
||||
if (Commands.HasFlag(DotNetActions.Publish))
|
||||
{
|
||||
dotNetHelper.ExecutePublish(projectName);
|
||||
}
|
||||
if (Commands.HasFlag(DotNetActions.PublishComplex))
|
||||
{
|
||||
dotNetHelper.ExecutePublish(projectName, selfContained: false);
|
||||
dotNetHelper.ExecutePublish(projectName, selfContained: true, Config.TargetRid);
|
||||
dotNetHelper.ExecutePublish(projectName, selfContained: true, "linux-x64");
|
||||
}
|
||||
if (Commands.HasFlag(DotNetActions.PublishR2R))
|
||||
{
|
||||
dotNetHelper.ExecutePublish(projectName, selfContained: true, "linux-x64", trimmed: true, readyToRun: true);
|
||||
}
|
||||
if (Commands.HasFlag(DotNetActions.Test))
|
||||
{
|
||||
dotNetHelper.ExecuteTest(projectName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue