2016-02-19 23:12:04 +00:00
|
|
|
|
// Copyright (c) .NET Foundation and contributors. All rights reserved.
|
|
|
|
|
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
|
|
|
|
|
|
|
|
|
using System;
|
|
|
|
|
using System.IO;
|
2016-02-23 19:09:43 +00:00
|
|
|
|
using Microsoft.DotNet.TestFramework;
|
2016-02-19 23:12:04 +00:00
|
|
|
|
using Microsoft.DotNet.Tools.Test.Utilities;
|
|
|
|
|
using Xunit;
|
|
|
|
|
|
2016-02-23 19:09:43 +00:00
|
|
|
|
namespace Microsoft.DotNet.Tools.Run.Tests
|
2016-02-19 23:12:04 +00:00
|
|
|
|
{
|
2016-02-23 19:09:43 +00:00
|
|
|
|
public class RunTests : TestBase
|
2016-02-19 23:12:04 +00:00
|
|
|
|
{
|
2016-03-18 01:02:48 +00:00
|
|
|
|
private const string PortableAppsTestBase = "PortableTests";
|
2016-02-23 19:09:43 +00:00
|
|
|
|
private const string RunTestsBase = "RunTestsApps";
|
2016-02-19 23:12:04 +00:00
|
|
|
|
|
|
|
|
|
[WindowsOnlyFact]
|
|
|
|
|
public void RunsSingleTarget()
|
|
|
|
|
{
|
2016-02-23 19:09:43 +00:00
|
|
|
|
TestInstance instance = TestAssetsManager.CreateTestInstance(Path.Combine(RunTestsBase, "TestAppFullClr"))
|
2016-02-19 23:12:04 +00:00
|
|
|
|
.WithLockFiles()
|
|
|
|
|
.WithBuildArtifacts();
|
2016-03-31 16:00:25 +00:00
|
|
|
|
new RunCommand(instance.TestRoot).ExecuteWithCapturedOutput().Should().Pass().And.HaveStdOutContaining("NET451, ARGS: 0");
|
2016-02-19 23:12:04 +00:00
|
|
|
|
}
|
|
|
|
|
|
2016-02-23 19:09:43 +00:00
|
|
|
|
[Fact]
|
2016-02-19 23:12:04 +00:00
|
|
|
|
public void RunsDefaultWhenPresent()
|
|
|
|
|
{
|
|
|
|
|
TestInstance instance = TestAssetsManager.CreateTestInstance(Path.Combine(RunTestsBase, "TestAppMultiTarget"))
|
|
|
|
|
.WithLockFiles()
|
|
|
|
|
.WithBuildArtifacts();
|
2016-02-23 19:09:43 +00:00
|
|
|
|
new RunCommand(instance.TestRoot).Execute().Should().Pass();
|
2016-02-19 23:12:04 +00:00
|
|
|
|
}
|
|
|
|
|
|
2016-02-23 19:09:43 +00:00
|
|
|
|
[Fact]
|
2016-02-19 23:12:04 +00:00
|
|
|
|
public void FailsWithMultipleTargetAndNoDefault()
|
|
|
|
|
{
|
2016-02-23 19:09:43 +00:00
|
|
|
|
TestInstance instance = TestAssetsManager.CreateTestInstance(Path.Combine(RunTestsBase, "TestAppMultiTargetNoCoreClr"))
|
2016-02-19 23:12:04 +00:00
|
|
|
|
.WithLockFiles()
|
|
|
|
|
.WithBuildArtifacts();
|
2016-02-23 19:09:43 +00:00
|
|
|
|
new RunCommand(instance.TestRoot).Execute().Should().Fail();
|
2016-02-19 23:12:04 +00:00
|
|
|
|
}
|
|
|
|
|
|
2016-03-18 01:02:48 +00:00
|
|
|
|
[Fact]
|
|
|
|
|
public void ItRunsPortableApps()
|
|
|
|
|
{
|
|
|
|
|
TestInstance instance = TestAssetsManager.CreateTestInstance(Path.Combine(PortableAppsTestBase, "PortableApp"))
|
|
|
|
|
.WithLockFiles()
|
|
|
|
|
.WithBuildArtifacts();
|
|
|
|
|
new RunCommand(instance.TestRoot).Execute().Should().Pass();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Fact(Skip = "https://github.com/dotnet/cli/issues/1940")]
|
|
|
|
|
public void ItRunsPortableAppsWithNative()
|
|
|
|
|
{
|
|
|
|
|
TestInstance instance = TestAssetsManager.CreateTestInstance(Path.Combine(PortableAppsTestBase, "PortableAppWithNative"))
|
|
|
|
|
.WithLockFiles()
|
|
|
|
|
.WithBuildArtifacts();
|
|
|
|
|
new RunCommand(instance.TestRoot).Execute().Should().Pass();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Fact]
|
|
|
|
|
public void ItRunsStandaloneApps()
|
|
|
|
|
{
|
|
|
|
|
TestInstance instance = TestAssetsManager.CreateTestInstance(Path.Combine(PortableAppsTestBase, "StandaloneApp"))
|
|
|
|
|
.WithLockFiles()
|
|
|
|
|
.WithBuildArtifacts();
|
|
|
|
|
new RunCommand(instance.TestRoot).Execute().Should().Pass();
|
|
|
|
|
}
|
|
|
|
|
|
2016-04-26 22:22:09 +00:00
|
|
|
|
[Fact]
|
|
|
|
|
public void ItRunsWithLocalProjectJsonArg()
|
|
|
|
|
{
|
|
|
|
|
TestInstance instance = TestAssetsManager.CreateTestInstance("TestAppSimple")
|
|
|
|
|
.WithLockFiles()
|
|
|
|
|
.WithBuildArtifacts();
|
|
|
|
|
new RunCommand("project.json")
|
|
|
|
|
.WithWorkingDirectory(instance.TestRoot)
|
|
|
|
|
.ExecuteWithCapturedOutput()
|
|
|
|
|
.Should()
|
|
|
|
|
.Pass()
|
|
|
|
|
.And
|
|
|
|
|
.HaveStdOutContaining("Hello World!");
|
|
|
|
|
}
|
|
|
|
|
|
2016-04-25 16:04:23 +00:00
|
|
|
|
[Fact]
|
|
|
|
|
public void ItRunsAppsThatOutputUnicodeCharacters()
|
|
|
|
|
{
|
|
|
|
|
TestInstance instance = TestAssetsManager.CreateTestInstance("TestAppWithUnicodéPath")
|
|
|
|
|
.WithLockFiles()
|
|
|
|
|
.WithBuildArtifacts();
|
|
|
|
|
new RunCommand(instance.TestRoot)
|
|
|
|
|
.ExecuteWithCapturedOutput()
|
|
|
|
|
.Should()
|
|
|
|
|
.Pass()
|
|
|
|
|
.And
|
|
|
|
|
.HaveStdOutContaining("Hélló Wórld!");
|
|
|
|
|
}
|
2016-03-18 01:02:48 +00:00
|
|
|
|
|
2016-04-23 04:40:39 +00:00
|
|
|
|
[Fact]
|
|
|
|
|
public void ItPassesArgumentsToTheApp()
|
|
|
|
|
{
|
|
|
|
|
TestInstance instance = TestAssetsManager.CreateTestInstance("TestAppWithArgs")
|
|
|
|
|
.WithLockFiles()
|
|
|
|
|
.WithBuildArtifacts();
|
|
|
|
|
new RunCommand(instance.TestRoot)
|
|
|
|
|
.ExecuteWithCapturedOutput("one --two -three")
|
|
|
|
|
.Should()
|
|
|
|
|
.Pass()
|
|
|
|
|
.And
|
|
|
|
|
.HaveStdOutContaining(
|
|
|
|
|
JoinWithNewlines(
|
|
|
|
|
"Hello World!",
|
|
|
|
|
"I was passed 3 args:",
|
|
|
|
|
"arg: [one]",
|
|
|
|
|
"arg: [--two]",
|
|
|
|
|
"arg: [-three]"));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Fact]
|
|
|
|
|
public void ItPassesAllArgsAfterUnexpectedArg()
|
2016-02-19 23:12:04 +00:00
|
|
|
|
{
|
2016-04-23 04:40:39 +00:00
|
|
|
|
TestInstance instance = TestAssetsManager.CreateTestInstance("TestAppWithArgs")
|
|
|
|
|
.WithLockFiles()
|
|
|
|
|
.WithBuildArtifacts();
|
|
|
|
|
new RunCommand(instance.TestRoot)
|
|
|
|
|
.ExecuteWithCapturedOutput("Hello -f")
|
|
|
|
|
.Should()
|
|
|
|
|
.Pass()
|
|
|
|
|
.And
|
|
|
|
|
.HaveStdOutContaining(
|
|
|
|
|
JoinWithNewlines(
|
|
|
|
|
"Hello World!",
|
|
|
|
|
"I was passed 2 args:",
|
|
|
|
|
"arg: [Hello]",
|
|
|
|
|
"arg: [-f]"));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Fact]
|
|
|
|
|
public void ItHandlesArgSeparatorCorrectly()
|
|
|
|
|
{
|
|
|
|
|
TestInstance instance = TestAssetsManager.CreateTestInstance("TestAppWithArgs")
|
|
|
|
|
.WithLockFiles()
|
|
|
|
|
.WithBuildArtifacts();
|
|
|
|
|
new RunCommand(instance.TestRoot)
|
|
|
|
|
.ExecuteWithCapturedOutput("-- one two")
|
|
|
|
|
.Should()
|
|
|
|
|
.Pass()
|
|
|
|
|
.And
|
|
|
|
|
.HaveStdOutContaining(
|
|
|
|
|
JoinWithNewlines(
|
|
|
|
|
"Hello World!",
|
|
|
|
|
"I was passed 2 args:",
|
|
|
|
|
"arg: [one]",
|
|
|
|
|
"arg: [two]"));
|
2016-02-19 23:12:04 +00:00
|
|
|
|
}
|
|
|
|
|
|
2016-04-23 04:40:39 +00:00
|
|
|
|
private static string JoinWithNewlines(params string[] values)
|
2016-02-19 23:12:04 +00:00
|
|
|
|
{
|
2016-04-23 04:40:39 +00:00
|
|
|
|
return string.Join(Environment.NewLine, values);
|
2016-02-19 23:12:04 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|