-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create tests that verifies the Dockerfiles and templates are in sync
- Loading branch information
1 parent
63d1a3a
commit 3c4653d
Showing
14 changed files
with
182 additions
and
84 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
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
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
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
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
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 |
---|---|---|
@@ -1,20 +1,22 @@ | ||
#!/usr/bin/env pwsh | ||
param( | ||
# Paths to the Dockerfiles to generate. | ||
[string[]]$Paths | ||
[switch]$Validate | ||
) | ||
|
||
if ($Paths) { | ||
$pathArgs = " --path " + ($Paths -join " --path ") | ||
if ($Validate) { | ||
$customImageBuilderArgs = " --validate" | ||
} | ||
|
||
$repoRoot = (Get-Item "$PSScriptRoot").Parent.Parent.FullName | ||
|
||
$onDockerfilesGenerated = { | ||
param($ContainerName) | ||
Exec "docker cp ${ContainerName}:/repo/src $repoRoot" | ||
|
||
if (-Not $Validate) { | ||
Exec "docker cp ${ContainerName}:/repo/src $repoRoot" | ||
} | ||
} | ||
|
||
& $PSScriptRoot/../common/Invoke-ImageBuilder.ps1 ` | ||
-ImageBuilderArgs "generateDockerfiles --architecture * --os-type *$pathArgs" ` | ||
-ImageBuilderArgs "generateDockerfiles --architecture '*' --os-type '*'$customImageBuilderArgs" ` | ||
-OnCommandExecuted $onDockerfilesGenerated |
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
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
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
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,54 @@ | ||
// 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.Diagnostics; | ||
using System.Text; | ||
using Xunit.Abstractions; | ||
|
||
namespace Microsoft.DotNet.Docker.Tests | ||
{ | ||
public static class ExecuteHelper | ||
{ | ||
public static (Process Process, string StdOut, string StdErr) ExecuteProcess( | ||
string fileName, string args, ITestOutputHelper outputHelper) | ||
{ | ||
Process process = new Process | ||
{ | ||
EnableRaisingEvents = true, | ||
StartInfo = | ||
{ | ||
FileName = fileName, | ||
Arguments = args, | ||
RedirectStandardOutput = true, | ||
RedirectStandardError = true, | ||
} | ||
}; | ||
|
||
StringBuilder stdOutput = new StringBuilder(); | ||
process.OutputDataReceived += new DataReceivedEventHandler((sender, e) => stdOutput.AppendLine(e.Data)); | ||
|
||
StringBuilder stdError = new StringBuilder(); | ||
process.ErrorDataReceived += new DataReceivedEventHandler((sender, e) => stdError.AppendLine(e.Data)); | ||
|
||
process.Start(); | ||
process.BeginOutputReadLine(); | ||
process.BeginErrorReadLine(); | ||
process.WaitForExit(); | ||
|
||
string output = stdOutput.ToString().Trim(); | ||
if (outputHelper != null && !string.IsNullOrWhiteSpace(output)) | ||
{ | ||
outputHelper.WriteLine(output); | ||
} | ||
|
||
string error = stdError.ToString().Trim(); | ||
if (outputHelper != null && !string.IsNullOrWhiteSpace(error)) | ||
{ | ||
outputHelper.WriteLine(error); | ||
} | ||
|
||
return (process, output, error); | ||
} | ||
} | ||
} |
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
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
Oops, something went wrong.