Merge in 'release/6.0.1xx' changes
This commit is contained in:
commit
1c5d7bae9f
15 changed files with 116 additions and 31 deletions
|
@ -21,10 +21,6 @@
|
|||
<MSBuild Projects="repos\$(RootRepoTests).proj" Targets="Build" Properties="RunTests=true;SkipEnsurePackagesCreated=true" BuildInParallel="$(BuildInParallel)" StopOnFirstFailure="true" />
|
||||
</Target>
|
||||
|
||||
<Target Name="CreateRootRepoFile" AfterTargets="PrepareOutput">
|
||||
<WriteLinesToFile Lines="$(RootRepo)" File="$(BaseIntermediatePath)rootrepo.txt" Overwrite="True" />
|
||||
</Target>
|
||||
|
||||
<Target Name="PrepareOutput">
|
||||
<MakeDir Directories="$(OutputPath)" />
|
||||
<MakeDir Directories="$(LoggingDir)" />
|
||||
|
@ -128,7 +124,7 @@
|
|||
</PropertyGroup>
|
||||
|
||||
<Exec Command="tar --numeric-owner -czf $(SmokeTestPrereqsTarballName) ."
|
||||
WorkingDirectory="./test/Microsoft.DotNet.SourceBuild.SmokeTests/bin/$(Configuration)/net6.0/smoke-tests/prereq-packages/"/>
|
||||
WorkingDirectory="./test/Microsoft.DotNet.SourceBuild.SmokeTests/bin/$(Configuration)/net6.0/assets/smoke-tests/prereq-packages/"/>
|
||||
|
||||
<Message Importance="High" Text="Packaged smoke-test prereqs in '$(SmokeTestPrereqsTarballName)'" />
|
||||
</Target>
|
||||
|
|
|
@ -14,7 +14,7 @@ namespace Microsoft.DotNet.SourceBuild.SmokeTests
|
|||
{
|
||||
internal class BaselineHelper
|
||||
{
|
||||
public static void Compare(string baselineFileName, IOrderedEnumerable<string> actualEntries)
|
||||
public static void CompareEntries(string baselineFileName, IOrderedEnumerable<string> actualEntries)
|
||||
{
|
||||
IEnumerable<string> baseline = File.ReadAllLines(GetBaselineFilePath(baselineFileName));
|
||||
string[] missingEntries = actualEntries.Except(baseline).ToArray();
|
||||
|
@ -34,20 +34,28 @@ namespace Microsoft.DotNet.SourceBuild.SmokeTests
|
|||
Assert.Null(message);
|
||||
}
|
||||
|
||||
public static void Compare(string baselineFileName, string actual, ITestOutputHelper outputHelper)
|
||||
public static void CompareContents(string baselineFileName, string actualContents, ITestOutputHelper outputHelper)
|
||||
{
|
||||
string baselineFilePath = GetBaselineFilePath(baselineFileName);
|
||||
string baseline = File.ReadAllText(baselineFilePath);
|
||||
|
||||
string actualFilePath = Path.Combine(Environment.CurrentDirectory, $"{baselineFileName}");
|
||||
File.WriteAllText(actualFilePath, actualContents);
|
||||
|
||||
CompareFiles(baselineFilePath, actualFilePath, outputHelper);
|
||||
}
|
||||
|
||||
public static void CompareFiles(string baselineFilePath, string actualFilePath, ITestOutputHelper outputHelper)
|
||||
{
|
||||
string baselineFileText = File.ReadAllText(baselineFilePath);
|
||||
string actualFileText = File.ReadAllText(actualFilePath);
|
||||
|
||||
string? message = null;
|
||||
if (baseline != actual)
|
||||
{
|
||||
string actualBaselineFilePath = Path.Combine(Environment.CurrentDirectory, $"{baselineFileName}");
|
||||
File.WriteAllText(actualBaselineFilePath, actual);
|
||||
|
||||
if (baselineFileText != actualFileText)
|
||||
{
|
||||
// Retrieve a diff in order to provide a UX which calls out the diffs.
|
||||
string diff = DiffFiles(baselineFilePath, actualBaselineFilePath, outputHelper);
|
||||
message = $"{Environment.NewLine}Baseline '{baselineFilePath}' does not match actual '{actualBaselineFilePath}`. {Environment.NewLine}"
|
||||
string diff = DiffFiles(baselineFilePath, actualFilePath, outputHelper);
|
||||
message = $"{Environment.NewLine}Baseline '{baselineFilePath}' does not match actual '{actualFilePath}`. {Environment.NewLine}"
|
||||
+ $"{diff}{Environment.NewLine}";
|
||||
}
|
||||
|
||||
|
@ -63,6 +71,8 @@ namespace Microsoft.DotNet.SourceBuild.SmokeTests
|
|||
return diffResult.StdOut;
|
||||
}
|
||||
|
||||
private static string GetBaselineFilePath(string baselineFileName) => Path.Combine(Directory.GetCurrentDirectory(), "baselines", baselineFileName);
|
||||
public static string GetAssetsDirectory() => Path.Combine(Directory.GetCurrentDirectory(), "assets");
|
||||
|
||||
private static string GetBaselineFilePath(string baselineFileName) => Path.Combine(GetAssetsDirectory(), "baselines", baselineFileName);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,47 @@
|
|||
// 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.
|
||||
|
||||
using System.IO;
|
||||
using Xunit;
|
||||
using Xunit.Abstractions;
|
||||
|
||||
namespace Microsoft.DotNet.SourceBuild.SmokeTests;
|
||||
|
||||
public class DotNetFormatTests
|
||||
{
|
||||
private const string UnformattedFileName = "FormatTestUnformatted.cs";
|
||||
private const string ExpectedFormattedFileName = "FormatTestExpectedFormatted.cs";
|
||||
|
||||
private ITestOutputHelper OutputHelper { get; }
|
||||
private DotNetHelper DotNetHelper { get; }
|
||||
|
||||
public DotNetFormatTests(ITestOutputHelper outputHelper)
|
||||
{
|
||||
OutputHelper = outputHelper;
|
||||
DotNetHelper = new DotNetHelper(outputHelper);
|
||||
}
|
||||
|
||||
/// <Summary>
|
||||
/// Format an unformatted project and verify that the output matches the pre-computed solution.
|
||||
/// </Summary>
|
||||
[Fact]
|
||||
public void FormatProject()
|
||||
{
|
||||
string assetsDirectory = BaselineHelper.GetAssetsDirectory();
|
||||
|
||||
string unformattedCsFilePath = Path.Combine(assetsDirectory, UnformattedFileName);
|
||||
string expectedFormattedCsFilePath = Path.Combine(assetsDirectory, ExpectedFormattedFileName);
|
||||
|
||||
string projectDirectory = DotNetHelper.ExecuteNew("console", "C#", nameof(FormatProject), OutputHelper);
|
||||
|
||||
string projectFilePath = Path.Combine(projectDirectory, nameof(FormatProject) + ".csproj");
|
||||
string formattedCsFilePath = Path.Combine(projectDirectory, UnformattedFileName);
|
||||
|
||||
File.Copy(unformattedCsFilePath, formattedCsFilePath);
|
||||
|
||||
DotNetHelper.ExecuteCmd($"format {projectFilePath}", OutputHelper);
|
||||
|
||||
BaselineHelper.CompareFiles(expectedFormattedCsFilePath, formattedCsFilePath, OutputHelper);
|
||||
}
|
||||
}
|
|
@ -13,6 +13,7 @@ namespace Microsoft.DotNet.SourceBuild.SmokeTests;
|
|||
internal class DotNetHelper
|
||||
{
|
||||
private static readonly object s_lockObj = new object();
|
||||
private static readonly string s_timestamp = DateTime.Now.ToString("yyyyMMddHHmmssffff");
|
||||
|
||||
public string DotNetPath { get; }
|
||||
|
||||
|
@ -35,10 +36,22 @@ internal class DotNetHelper
|
|||
DotNetPath = Path.Combine(Config.DotNetDirectory, "dotnet");
|
||||
}
|
||||
|
||||
public void ExecuteDotNetCmd(string args, ITestOutputHelper outputHelper)
|
||||
public void ExecuteCmd(string args, ITestOutputHelper outputHelper)
|
||||
{
|
||||
(Process Process, string StdOut, string StdErr) executeResult = ExecuteHelper.ExecuteProcess(DotNetPath, args, outputHelper);
|
||||
|
||||
Assert.Equal(0, executeResult.Process.ExitCode);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Create a new .NET project and return the path to the created project folder.
|
||||
/// </summary>
|
||||
public string ExecuteNew(string projectType, string language, string name, ITestOutputHelper outputHelper)
|
||||
{
|
||||
string outputDirectory = Path.Combine(Directory.GetCurrentDirectory(), $"projects-{s_timestamp}", name);
|
||||
|
||||
ExecuteCmd($"new {projectType} --language \"{language}\" --name {name} --output {outputDirectory}", outputHelper);
|
||||
|
||||
return outputDirectory;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,19 +18,22 @@
|
|||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Content Include="baselines/*">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Include="smoke-tests/*">
|
||||
<Content Include="assets/**">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</Content>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Compile Remove="assets/**" />
|
||||
<EmbeddedResource Remove="assets/**" />
|
||||
<None Remove="assets/**" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<SmokeTestPrereqs Include="..\..\packages\smoke-test-prereqs\*" />
|
||||
</ItemGroup>
|
||||
|
||||
<Target Name="CopySmokeTestPrereqs" BeforeTargets="Build">
|
||||
<Copy SourceFiles="@(SmokeTestPrereqs)" DestinationFolder="$(OutputPath)\smoke-tests\prereq-packages" />
|
||||
<Copy SourceFiles="@(SmokeTestPrereqs)" DestinationFolder="$(OutputPath)\assets\smoke-tests\prereq-packages" />
|
||||
</Target>
|
||||
</Project>
|
||||
|
|
|
@ -53,7 +53,7 @@ public class SdkContentTests
|
|||
diff = RemoveVersionedPaths(diff);
|
||||
diff = RemoveDiffMarkers(diff);
|
||||
diff = RemoveRids(diff);
|
||||
BaselineHelper.Compare("MsftToSbSdk.diff", diff, OutputHelper);
|
||||
BaselineHelper.CompareContents("MsftToSbSdk.diff", diff, OutputHelper);
|
||||
}
|
||||
|
||||
private void WriteTarballFileList(string tarballPath, string outputFileName)
|
||||
|
|
|
@ -38,7 +38,7 @@ public class SmokeTests
|
|||
smokeTestArgs += " --excludeOnlineTests";
|
||||
}
|
||||
|
||||
(Process Process, string StdOut, string StdErr) executeResult = ExecuteHelper.ExecuteProcess("./smoke-tests/smoke-test.sh", smokeTestArgs, OutputHelper);
|
||||
(Process Process, string StdOut, string StdErr) executeResult = ExecuteHelper.ExecuteProcess("./assets/smoke-tests/smoke-test.sh", smokeTestArgs, OutputHelper);
|
||||
|
||||
Assert.Equal(0, executeResult.Process.ExitCode);
|
||||
}
|
||||
|
|
|
@ -48,6 +48,6 @@ public class XmlDocTests
|
|||
}
|
||||
}
|
||||
|
||||
BaselineHelper.Compare("MissingXmlDoc.txt", missingXmlDoc.OrderBy(entry => entry));
|
||||
BaselineHelper.CompareEntries("MissingXmlDoc.txt", missingXmlDoc.OrderBy(entry => entry));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,11 @@
|
|||
namespace FormatTest
|
||||
{
|
||||
internal class Test
|
||||
{
|
||||
public void Run()
|
||||
{
|
||||
string test = "Hello World";
|
||||
Console.WriteLine(test);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
namespace FormatTest
|
||||
{
|
||||
internal class Test
|
||||
{
|
||||
public void Run()
|
||||
{
|
||||
string test = "Hello World" ;
|
||||
Console .WriteLine( test );
|
||||
}
|
||||
}
|
||||
}
|
|
@ -7,8 +7,7 @@ VERSION_PREFIX=6.0
|
|||
# See https://github.com/dotnet/source-build/issues/579, this version
|
||||
# needs to be compatible with the runtime produced from source-build
|
||||
DEV_CERTS_VERSION_DEFAULT=6.0.0-preview.6.21355.2
|
||||
ARTIFACTS_DIR="$SCRIPT_ROOT/../../../../../../artifacts/"
|
||||
__ROOT_REPO=$(sed 's/\r$//' "${ARTIFACTS_DIR}obj/rootrepo.txt") # remove CR if mounted repo on Windows drive
|
||||
ARTIFACTS_DIR="$SCRIPT_ROOT/../../../../../../../artifacts/"
|
||||
executingUserHome=${HOME:-}
|
||||
|
||||
export DOTNET_CLI_TELEMETRY_OPTOUT=1
|
||||
|
@ -456,11 +455,6 @@ function copyRestoredPackages() {
|
|||
|
||||
echo "RID to test: ${targetRid?not specified. Use ./build.sh --run-smoke-test to detect RID, or specify manually.}"
|
||||
|
||||
if [ "$__ROOT_REPO" != "known-good" ]; then
|
||||
echo "Skipping smoke-tests since cli was not built";
|
||||
exit
|
||||
fi
|
||||
|
||||
# Clean up and create directory
|
||||
if [ -e "$testingDir" ]; then
|
||||
rm -rf "$testingDir"
|
Loading…
Reference in a new issue