-
Notifications
You must be signed in to change notification settings - Fork 64
Add SBRPTests #689
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
Merged
Merged
Add SBRPTests #689
Changes from all commits
Commits
Show all changes
58 commits
Select commit
Hold shift + click to select a range
9cc191b
Add SBRPTests
341b5c0
Update
v-chayan a44a595
Generate package to sandbox instead of repo src
3317b3e
Optimize according to review comments
1d35990
Update
c059ae8
Merge branch 'main' into AddSBRPTests
v-chayan a02a301
Integrate tests into pipline
v-chayan 71b62ef
Fix running tests on Windows
v-chayan 53e47a4
Test in Pipeline attemption
v-chayan 58b7d1f
update
v-chayan 538c64e
update
v-chayan cea8a98
Fix job name
v-chayan 2a1f106
update
v-chayan 40fc1ef
update
v-chayan a3872d2
update
v-chayan 1adf0df
update
v-chayan aa62bdf
Fix issue
v-chayan 4bcddb2
update
v-chayan 3a6fba1
update
v-chayan 0d872fc
update
v-chayan 02d53cf
update
v-chayan 33602f9
update
v-chayan e34b359
update
v-chayan c432dd9
update
v-chayan 0912d12
update
v-chayan 0f2ed6d
update
v-chayan f04f238
update
v-chayan 73b6e40
fix test issue in pipeline
v-chayan f69df98
update
v-chayan d3e1b9e
update
v-chayan e743a20
update
v-chayan 754dbf9
update
v-chayan dc6648d
update
v-chayan b46422c
update
v-chayan 27d9b9e
update
v-chayan 977d4cc
update
v-chayan e40b86b
update
v-chayan 549cd50
update
v-chayan 9c88d76
update
v-chayan 9737cc4
update
v-chayan 3d3398c
update
v-chayan 3f89c4d
update
v-chayan 79ac625
update
v-chayan 6b0169c
update
v-chayan 87aaf62
Merge branch 'main' into AddSBRPTests
v-chayan eaaf94a
Use git diff for comparison
638f270
Merge branch 'main' into AddSBRPTests
v-chayan 33c0c0d
update
v-chayan 17f7633
update
e93b6ef
undo incorrect change
v-chayan d1dfd1c
Merge branch 'main' into AddSBRPTests
v-chayan 9af641e
Update
Winniexu01 4515e0f
Update
Winniexu01 3fb54d4
Update
Winniexu01 3695786
Generate latest text package
Winniexu01 86c602f
Delete icon file
Winniexu01 e88cc70
Revert "Delete icon file"
Winniexu01 78d36af
Merge branch 'main' into AddSBRPTests
Winniexu01 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
parameters: | ||
- name: buildConfiguration | ||
type: string | ||
values: | ||
- Debug | ||
- Release | ||
|
||
jobs: | ||
- job: | ||
strategy: | ||
matrix: | ||
Windows_NT: | ||
agentOs: Windows_NT | ||
imageName: "windows-latest" | ||
Linux: | ||
agentOs: Linux | ||
imageName: "ubuntu-latest" | ||
pool: | ||
vmImage: $(imageName) | ||
|
||
steps: | ||
- checkout: self | ||
clean: true | ||
- script: $(Build.SourcesDirectory)/test.cmd | ||
displayName: Windows NT GenerateScript Tests | ||
condition: eq(variables.agentOs, 'Windows_NT') | ||
- script: $(Build.SourcesDirectory)/test.sh | ||
displayName: Linux GenerateScript Tests | ||
condition: eq(variables.agentOs, 'Linux') | ||
- task: PublishTestResults@2 | ||
displayName: Publish Test Results | ||
inputs: | ||
testRunner: xUnit | ||
testResultsFiles: 'artifacts/TestResults/${{ parameters.buildConfiguration }}/*.xml' | ||
testRunTitle: '$(agentOs)_GenerateScript_tests' | ||
configuration: '${{ parameters.buildConfiguration }}' | ||
condition: always() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 9 additions & 0 deletions
9
...xtOnlyPackages/src/microsoft.build.notargets/3.7.0/Microsoft.Build.NoTargets.3.7.0.csproj
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFrameworks>netstandard2.0</TargetFrameworks> | ||
<AssemblyName>Microsoft.Build.NoTargets</AssemblyName> | ||
<ProjectTemplateVersion>2</ProjectTemplateVersion> | ||
</PropertyGroup> | ||
|
||
</Project> |
1 change: 0 additions & 1 deletion
1
...xtOnlyPackages/src/microsoft.build.notargets/3.7.0/microsoft.build.notargets.3.7.0.csproj
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
@echo off | ||
powershell -ExecutionPolicy ByPass -NoProfile -command "& """%~dp0eng\common\Build.ps1""" -restore -build -test %*" | ||
ViktorHofer marked this conversation as resolved.
Show resolved
Hide resolved
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
#!/usr/bin/env bash | ||
|
||
source="${BASH_SOURCE[0]}" | ||
|
||
# resolve $SOURCE until the file is no longer a symlink | ||
while [[ -h $source ]]; do | ||
scriptroot="$( cd -P "$( dirname "$source" )" && pwd )" | ||
source="$(readlink "$source")" | ||
|
||
# if $source was a relative symlink, we need to resolve it relative to the path where the | ||
# symlink file was located | ||
[[ $source != /* ]] && source="$scriptroot/$source" | ||
done | ||
|
||
scriptroot="$( cd -P "$( dirname "$source" )" && pwd )" | ||
|
||
export DOTNET_CLI_TELEMETRY_OPTOUT=1 | ||
export DOTNET_SKIP_FIRST_TIME_EXPERIENCE=1 | ||
export DOTNET_MULTILEVEL_LOOKUP=0 | ||
|
||
"$scriptroot/eng/common/build.sh" --restore --build --test "$@" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,119 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
|
||
using System; | ||
using System.Diagnostics; | ||
using System.Linq; | ||
using System.Text; | ||
using Xunit.Abstractions; | ||
|
||
namespace GenerateScriptTests; | ||
|
||
internal static class ExecuteHelper | ||
{ | ||
public static (Process Process, string StdOut, string StdErr) ExecuteProcess( | ||
string fileName, | ||
string args, | ||
ITestOutputHelper outputHelper, | ||
bool logOutput = false, | ||
Action<Process>? configure = null, | ||
int millisecondTimeout = -1) | ||
{ | ||
outputHelper.WriteLine($"Executing: {fileName} {args}"); | ||
|
||
Process process = new() | ||
{ | ||
EnableRaisingEvents = true, | ||
StartInfo = | ||
{ | ||
FileName = fileName, | ||
Arguments = args, | ||
RedirectStandardOutput = true, | ||
RedirectStandardError = true, | ||
} | ||
}; | ||
|
||
configure?.Invoke(process); | ||
|
||
StringBuilder stdOutput = new(); | ||
process.OutputDataReceived += new DataReceivedEventHandler( | ||
(sender, e) => | ||
{ | ||
lock (stdOutput) | ||
{ | ||
stdOutput.AppendLine(e.Data); | ||
} | ||
}); | ||
|
||
StringBuilder stdError = new(); | ||
process.ErrorDataReceived += new DataReceivedEventHandler( | ||
(sender, e) => | ||
{ | ||
lock (stdError) | ||
{ | ||
stdError.AppendLine(e.Data); | ||
} | ||
}); | ||
|
||
process.Start(); | ||
process.BeginOutputReadLine(); | ||
process.BeginErrorReadLine(); | ||
process.WaitForExit(millisecondTimeout); | ||
|
||
if (!process.HasExited) | ||
{ | ||
outputHelper.WriteLine($"Process did not exit. Killing {fileName} {args} after waiting {millisecondTimeout} milliseconds."); | ||
process.Kill(true); | ||
process.WaitForExit(); | ||
} | ||
|
||
string output; | ||
string error; | ||
|
||
lock (stdOutput) | ||
{ | ||
output = stdOutput.ToString().Trim(); | ||
} | ||
|
||
lock (stdError) | ||
{ | ||
error = stdError.ToString().Trim(); | ||
} | ||
|
||
if (logOutput) | ||
{ | ||
if (!string.IsNullOrWhiteSpace(output)) | ||
{ | ||
outputHelper.WriteLine(output); | ||
} | ||
|
||
if (string.IsNullOrWhiteSpace(error)) | ||
{ | ||
outputHelper.WriteLine(error); | ||
} | ||
} | ||
|
||
return (process, output, error); | ||
} | ||
|
||
public static string ExecuteProcessValidateExitCode(string fileName, string args, ITestOutputHelper outputHelper) | ||
{ | ||
(Process Process, string StdOut, string StdErr) result = ExecuteHelper.ExecuteProcess(fileName, args, outputHelper); | ||
ValidateExitCode(result); | ||
|
||
return result.StdOut; | ||
} | ||
|
||
public static void ValidateExitCode((Process Process, string StdOut, string StdErr) result, int expectedExitCode = 0) | ||
{ | ||
if (result.Process.ExitCode != expectedExitCode) | ||
{ | ||
ProcessStartInfo startInfo = result.Process.StartInfo; | ||
string msg = $"Failed to execute {startInfo.FileName} {startInfo.Arguments}" + | ||
$"{Environment.NewLine}Exit code: {result.Process.ExitCode}" + | ||
$"{Environment.NewLine}{result.StdOut}" + | ||
$"{Environment.NewLine}{result.StdErr}"; | ||
throw new InvalidOperationException(msg); | ||
} | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>$(NetCurrent)</TargetFramework> | ||
<Nullable>enable</Nullable> | ||
</PropertyGroup> | ||
|
||
</Project> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||||||
---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,65 @@ | ||||||||
// Licensed to the .NET Foundation under one or more agreements. | ||||||||
// The .NET Foundation licenses this file to you under the MIT license. | ||||||||
|
||||||||
using System; | ||||||||
using System.Collections.Generic; | ||||||||
using System.IO; | ||||||||
using System.Runtime.InteropServices; | ||||||||
using Xunit; | ||||||||
using Xunit.Abstractions; | ||||||||
|
||||||||
namespace GenerateScriptTests; | ||||||||
|
||||||||
public class GenerateScriptTests | ||||||||
{ | ||||||||
public enum PackageType | ||||||||
{ | ||||||||
Reference, | ||||||||
Text | ||||||||
} | ||||||||
|
||||||||
public static IEnumerable<object[]> Data => new List<object[]> | ||||||||
v-chayan marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||
{ | ||||||||
new object[] { "System.Xml.ReaderWriter", "4.0.11", PackageType.Reference }, | ||||||||
new object[] { "Microsoft.Extensions.Logging.Abstractions", "7.0.1", PackageType.Reference }, | ||||||||
new object[] { "Microsoft.CodeAnalysis.CSharp", "3.11.0", PackageType.Reference }, | ||||||||
new object[] { "System.Security.Cryptography.Pkcs", "7.0.2", PackageType.Reference }, | ||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We should be validating text only packages as well. All the test infrastructure was defined but no test data for them were added.
Suggested change
|
||||||||
new object[] { "Microsoft.Build.NoTargets", "3.7.0", PackageType.Text }, | ||||||||
}; | ||||||||
|
||||||||
public string SandboxDirectory { get; set; } | ||||||||
public string RepoRoot { get; set; } | ||||||||
public ITestOutputHelper output { get; set; } | ||||||||
|
||||||||
public GenerateScriptTests(ITestOutputHelper output) | ||||||||
{ | ||||||||
this.output = output; | ||||||||
RepoRoot = Environment.CurrentDirectory.Substring(0, Environment.CurrentDirectory.IndexOf("artifacts")); | ||||||||
SandboxDirectory = Path.Combine(Environment.CurrentDirectory, $"GenerateTests-{DateTimeOffset.UtcNow.ToUnixTimeSeconds().ToString()}"); | ||||||||
Directory.CreateDirectory(SandboxDirectory); | ||||||||
} | ||||||||
|
||||||||
[Theory] | ||||||||
[MemberData(nameof(GenerateScriptTests.Data), MemberType = typeof(GenerateScriptTests))] | ||||||||
public void VerifyGenerateScript(string package, string version, PackageType type) | ||||||||
{ | ||||||||
string command = Path.Combine(RepoRoot, RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? "generate.cmd" : "generate.sh"); | ||||||||
string arguments = $"-p {package},{version} -x -d {SandboxDirectory}"; | ||||||||
string packageSrcDirectory = string.Empty; | ||||||||
string sandboxPackageGeneratedDirecotry = Path.Combine(SandboxDirectory, package.ToLower(), version); | ||||||||
|
||||||||
switch (type) | ||||||||
v-chayan marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||
{ | ||||||||
case PackageType.Reference: | ||||||||
packageSrcDirectory = Path.Combine(RepoRoot, "src", "referencePackages", "src", package.ToLower(), version); | ||||||||
break; | ||||||||
case PackageType.Text: | ||||||||
arguments += " -t text"; | ||||||||
packageSrcDirectory = Path.Combine(RepoRoot, "src", "textOnlyPackages", "src", package.ToLower(), version); | ||||||||
break; | ||||||||
} | ||||||||
|
||||||||
ExecuteHelper.ExecuteProcess(command, arguments, output); | ||||||||
Assert.Empty(ExecuteHelper.ExecuteProcess("git", $"diff --no-index {packageSrcDirectory} {sandboxPackageGeneratedDirecotry}", output, true).StdOut); | ||||||||
} | ||||||||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This icon file should be deleted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried deleting the icon file, but the test failed. Because the icon file is still generated by the latest tooling. So I reverted the change and kept the icon file.