-
Notifications
You must be signed in to change notification settings - Fork 479
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix test Generate all runtime support dlls in content folder
- Loading branch information
1 parent
f8577af
commit 13a74ae
Showing
3 changed files
with
200 additions
and
7 deletions.
There are no files selected for viewing
This file contains 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
24 changes: 24 additions & 0 deletions
24
Tools/LambdaTestTool-v2/src/Amazon.Lambda.TestTool/Amazon.Lambda.TestTool.sln
This file contains 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,24 @@ | ||
Microsoft Visual Studio Solution File, Format Version 12.00 | ||
# Visual Studio Version 17 | ||
VisualStudioVersion = 17.5.2.0 | ||
MinimumVisualStudioVersion = 10.0.40219.1 | ||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Amazon.Lambda.TestTool", "Amazon.Lambda.TestTool.csproj", "{129F6132-C0B3-6F05-B947-6FC288B0E9D9}" | ||
EndProject | ||
Global | ||
GlobalSection(SolutionConfigurationPlatforms) = preSolution | ||
Debug|Any CPU = Debug|Any CPU | ||
Release|Any CPU = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(ProjectConfigurationPlatforms) = postSolution | ||
{129F6132-C0B3-6F05-B947-6FC288B0E9D9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{129F6132-C0B3-6F05-B947-6FC288B0E9D9}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{129F6132-C0B3-6F05-B947-6FC288B0E9D9}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{129F6132-C0B3-6F05-B947-6FC288B0E9D9}.Release|Any CPU.Build.0 = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(SolutionProperties) = preSolution | ||
HideSolutionNode = FALSE | ||
EndGlobalSection | ||
GlobalSection(ExtensibilityGlobals) = postSolution | ||
SolutionGuid = {DFCCF963-C635-4341-B013-7CCA0D77559C} | ||
EndGlobalSection | ||
EndGlobal |
154 changes: 154 additions & 0 deletions
154
Tools/LambdaTestTool-v2/tests/Amazon.Lambda.TestTool.UnitTests/PackagingTests.cs
This file contains 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,154 @@ | ||
using System; | ||
using System.Diagnostics; | ||
using System.IO; | ||
using System.IO.Compression; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using Xunit; | ||
using Xunit.Abstractions; | ||
|
||
namespace Amazon.Lambda.TestTool.UnitTests; | ||
|
||
public class PackagingTests | ||
{ | ||
private readonly ITestOutputHelper _output; | ||
private static readonly string[] ExpectedFrameworks = new[] | ||
{ | ||
"net5.0", | ||
"net6.0", | ||
"net8.0", | ||
"netstandard2.0" | ||
}; | ||
|
||
public PackagingTests(ITestOutputHelper output) | ||
{ | ||
_output = output; | ||
} | ||
|
||
[Fact] | ||
public void VerifyPackageContentsHasRuntimeSupport() | ||
{ | ||
string solutionRoot = FindSolutionRoot(); | ||
string runtimeSupportPath = Path.Combine(solutionRoot, "Libraries", "src", "Amazon.Lambda.RuntimeSupport", "Amazon.Lambda.RuntimeSupport.csproj"); | ||
string projectPath = Path.Combine(solutionRoot, "Tools", "LambdaTestTool-v2", "src", "Amazon.Lambda.TestTool", "Amazon.Lambda.TestTool.csproj"); | ||
|
||
// Build RuntimeSupport first | ||
_output.WriteLine("Building RuntimeSupport..."); | ||
var buildProcess = new Process | ||
{ | ||
StartInfo = new ProcessStartInfo | ||
{ | ||
FileName = "dotnet", | ||
Arguments = $"build {runtimeSupportPath} -c Release", | ||
RedirectStandardOutput = true, | ||
RedirectStandardError = true, | ||
UseShellExecute = false, | ||
CreateNoWindow = true, | ||
} | ||
}; | ||
|
||
buildProcess.Start(); | ||
string buildOutput = buildProcess.StandardOutput.ReadToEnd(); | ||
string buildError = buildProcess.StandardError.ReadToEnd(); | ||
buildProcess.WaitForExit(); | ||
|
||
_output.WriteLine("Build Output:"); | ||
_output.WriteLine(buildOutput); | ||
if (!string.IsNullOrEmpty(buildError)) | ||
{ | ||
_output.WriteLine("Build Errors:"); | ||
_output.WriteLine(buildError); | ||
} | ||
|
||
Assert.Equal(0, buildProcess.ExitCode); | ||
|
||
// Now pack the test tool | ||
_output.WriteLine("\nPacking TestTool..."); | ||
var packProcess = new Process | ||
{ | ||
StartInfo = new ProcessStartInfo | ||
{ | ||
FileName = "dotnet", | ||
Arguments = $"pack {projectPath} -c Release", | ||
RedirectStandardOutput = true, | ||
RedirectStandardError = true, | ||
UseShellExecute = false, | ||
CreateNoWindow = true, | ||
} | ||
}; | ||
|
||
packProcess.Start(); | ||
string packOutput = packProcess.StandardOutput.ReadToEnd(); | ||
string packError = packProcess.StandardError.ReadToEnd(); | ||
packProcess.WaitForExit(); | ||
|
||
_output.WriteLine("Pack Output:"); | ||
_output.WriteLine(packOutput); | ||
if (!string.IsNullOrEmpty(packError)) | ||
{ | ||
_output.WriteLine("Pack Errors:"); | ||
_output.WriteLine(packError); | ||
} | ||
|
||
Assert.Equal(0, packProcess.ExitCode); | ||
|
||
string packageDir = Path.Combine(Path.GetDirectoryName(projectPath), "bin", "Release"); | ||
_output.WriteLine($"Looking for package in: {packageDir}"); | ||
|
||
var packageFiles = Directory.GetFiles(packageDir, "*.nupkg", SearchOption.AllDirectories); | ||
Assert.True(packageFiles.Length > 0, $"No .nupkg files found in {packageDir}"); | ||
|
||
// Rest of the verification code remains the same... | ||
string packagePath = packageFiles[0]; | ||
_output.WriteLine($"Found package: {packagePath}"); | ||
|
||
using (var archive = ZipFile.OpenRead(packagePath)) | ||
{ | ||
var missingFiles = new List<string>(); | ||
|
||
foreach (var framework in ExpectedFrameworks) | ||
{ | ||
var expectedPath = $"content/{framework}/Amazon.Lambda.RuntimeSupport.dll"; | ||
var entry = archive.GetEntry(expectedPath); | ||
|
||
if (entry == null) | ||
{ | ||
missingFiles.Add(expectedPath); | ||
} | ||
} | ||
|
||
if (missingFiles.Any()) | ||
{ | ||
Assert.Fail($"The following RuntimeSupport DLLs are missing from the package:\n" + | ||
string.Join("\n", missingFiles)); | ||
} | ||
|
||
var actualFrameworkDlls = archive.Entries | ||
.Where(e => e.FullName.Contains("Amazon.Lambda.RuntimeSupport.dll")) | ||
.Select(e => e.FullName) | ||
.ToList(); | ||
|
||
_output.WriteLine("\nFound DLLs in package:"); | ||
foreach (var dll in actualFrameworkDlls) | ||
{ | ||
_output.WriteLine(dll); | ||
} | ||
} | ||
} | ||
|
||
|
||
private string FindSolutionRoot() | ||
{ | ||
string currentDirectory = Directory.GetCurrentDirectory(); | ||
while (currentDirectory != null) | ||
{ | ||
// Look for the aws-lambda-dotnet directory specifically | ||
if (Path.GetFileName(currentDirectory) == "aws-lambda-dotnet") | ||
{ | ||
return currentDirectory; | ||
} | ||
currentDirectory = Directory.GetParent(currentDirectory)?.FullName; | ||
} | ||
throw new Exception("Could not find the aws-lambda-dotnet root directory."); | ||
} | ||
} |