Split SelfContained test into two separate tests.
This commit is contained in:
parent
ab15200500
commit
7f389c9729
1 changed files with 43 additions and 39 deletions
|
@ -71,11 +71,7 @@ namespace Microsoft.DotNet.Cli.Publish.Tests
|
||||||
.GetDirectory("bin", configuration, "netcoreapp2.0", rid, "publish", $"{testAppName}{Constants.ExeSuffix}")
|
.GetDirectory("bin", configuration, "netcoreapp2.0", rid, "publish", $"{testAppName}{Constants.ExeSuffix}")
|
||||||
.FullName;
|
.FullName;
|
||||||
|
|
||||||
if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
|
EnsureProgramIsRunnable(outputProgram);
|
||||||
{
|
|
||||||
//Workaround for https://github.com/dotnet/corefx/issues/15516
|
|
||||||
Process.Start("chmod", $"u+x {outputProgram}").WaitForExit();
|
|
||||||
}
|
|
||||||
|
|
||||||
new TestCommand(outputProgram)
|
new TestCommand(outputProgram)
|
||||||
.ExecuteWithCapturedOutput()
|
.ExecuteWithCapturedOutput()
|
||||||
|
@ -83,13 +79,43 @@ namespace Microsoft.DotNet.Cli.Publish.Tests
|
||||||
.And.HaveStdOutContaining("Hello World");
|
.And.HaveStdOutContaining("Hello World");
|
||||||
}
|
}
|
||||||
|
|
||||||
[Theory]
|
[Fact]
|
||||||
[InlineData(true)]
|
public void ItPublishesARidSpecificAppSettingSelfContainedToTrue()
|
||||||
[InlineData(false)]
|
|
||||||
public void ItPublishesAnAppExplicitlySpecifyingSelfContained(bool selfContained)
|
|
||||||
{
|
{
|
||||||
var testAppName = "MSBuildTestApp";
|
var testAppName = "MSBuildTestApp";
|
||||||
|
var outputDirectory = PublishAppWithSelfContained(testAppName, true);
|
||||||
|
|
||||||
|
var outputProgram = Path.Combine(outputDirectory.FullName, $"{testAppName}{Constants.ExeSuffix}");
|
||||||
|
|
||||||
|
EnsureProgramIsRunnable(outputProgram);
|
||||||
|
|
||||||
|
new TestCommand(outputProgram)
|
||||||
|
.ExecuteWithCapturedOutput()
|
||||||
|
.Should().Pass()
|
||||||
|
.And.HaveStdOutContaining("Hello World");
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public void ItPublishesARidSpecificAppSettingSelfContainedToFalse()
|
||||||
|
{
|
||||||
|
var testAppName = "MSBuildTestApp";
|
||||||
|
var outputDirectory = PublishAppWithSelfContained(testAppName, false);
|
||||||
|
|
||||||
|
outputDirectory.Should().OnlyHaveFiles(new[] {
|
||||||
|
$"{testAppName}.dll",
|
||||||
|
$"{testAppName}.pdb",
|
||||||
|
$"{testAppName}.deps.json",
|
||||||
|
$"{testAppName}.runtimeconfig.json",
|
||||||
|
});
|
||||||
|
|
||||||
|
new DotnetCommand()
|
||||||
|
.ExecuteWithCapturedOutput(Path.Combine(outputDirectory.FullName, $"{testAppName}.dll"))
|
||||||
|
.Should().Pass()
|
||||||
|
.And.HaveStdOutContaining("Hello World");
|
||||||
|
}
|
||||||
|
|
||||||
|
private DirectoryInfo PublishAppWithSelfContained(string testAppName, bool selfContained)
|
||||||
|
{
|
||||||
var testInstance = TestAssets.Get(testAppName)
|
var testInstance = TestAssets.Get(testAppName)
|
||||||
.CreateInstance($"PublishesSelfContained{selfContained}")
|
.CreateInstance($"PublishesSelfContained{selfContained}")
|
||||||
.WithSourceFiles()
|
.WithSourceFiles()
|
||||||
|
@ -107,39 +133,17 @@ namespace Microsoft.DotNet.Cli.Publish.Tests
|
||||||
.Should().Pass();
|
.Should().Pass();
|
||||||
|
|
||||||
var configuration = Environment.GetEnvironmentVariable("CONFIGURATION") ?? "Debug";
|
var configuration = Environment.GetEnvironmentVariable("CONFIGURATION") ?? "Debug";
|
||||||
var outputPath = testProjectDirectory
|
return testProjectDirectory
|
||||||
.GetDirectory("bin", configuration, "netcoreapp2.0", rid, "publish")
|
.GetDirectory("bin", configuration, "netcoreapp2.0", rid, "publish");
|
||||||
.FullName;
|
}
|
||||||
var selfContainedProgram = Path.Combine(outputPath, $"{testAppName}{Constants.ExeSuffix}");
|
|
||||||
var selfContainedProgramFile = new FileInfo(selfContainedProgram);
|
|
||||||
|
|
||||||
TestCommand testCommand;
|
private static void EnsureProgramIsRunnable(string path)
|
||||||
string testArgs;
|
{
|
||||||
if (selfContained)
|
if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
|
||||||
{
|
{
|
||||||
selfContainedProgramFile.Should().Exist();
|
//Workaround for https://github.com/dotnet/corefx/issues/15516
|
||||||
|
Process.Start("chmod", $"u+x {path}").WaitForExit();
|
||||||
if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
|
|
||||||
{
|
|
||||||
//Workaround for https://github.com/dotnet/corefx/issues/15516
|
|
||||||
Process.Start("chmod", $"u+x {selfContainedProgram}").WaitForExit();
|
|
||||||
}
|
|
||||||
|
|
||||||
testCommand = new TestCommand(selfContainedProgram);
|
|
||||||
testArgs = null;
|
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
selfContainedProgramFile.Should().NotExist();
|
|
||||||
|
|
||||||
testCommand = new DotnetCommand();
|
|
||||||
testArgs = Path.Combine(outputPath, $"{testAppName}.dll");
|
|
||||||
}
|
|
||||||
|
|
||||||
testCommand
|
|
||||||
.ExecuteWithCapturedOutput(testArgs)
|
|
||||||
.Should().Pass()
|
|
||||||
.And.HaveStdOutContaining("Hello World");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
|
|
Loading…
Add table
Reference in a new issue