make GivenDotnetUsesDotnetTools test optional based on AspNetCore availability (#207)

This commit is contained in:
Tomas Weinfurt 2018-12-14 20:08:38 -08:00 committed by Nick Guerrera
parent 4538e052e4
commit e1e6c25c1b
3 changed files with 29 additions and 1 deletions

View file

@ -6,7 +6,7 @@ namespace EndToEnd
{
public class GivenDotnetUsesDotnetTools : TestBase
{
[Fact]
[RequiresAspNetCore]
public void ThenOneDotnetToolsCanBeCalled()
{
new DotnetCommand()

View file

@ -19,6 +19,7 @@ namespace Microsoft.DotNet.Tools.Test.Utilities
private string _builtDotnet;
private string _nugetPackages;
private string _stage2Sdk;
private string _stage2AspNetCore;
private string _stage2WithBackwardsCompatibleRuntimesDirectory;
private string _testPackages;
private string _testWorkingFolder;
@ -90,6 +91,7 @@ namespace Microsoft.DotNet.Tools.Test.Utilities
public string DotnetRoot => _dotnetRoot;
public string NugetPackages => _nugetPackages;
public string Stage2Sdk => _stage2Sdk;
public string Stage2AspNetCore => _stage2AspNetCore;
public string Stage2WithBackwardsCompatibleRuntimesDirectory => _stage2WithBackwardsCompatibleRuntimesDirectory;
public string TestPackages => _testPackages;
public string TestWorkingFolder => _testWorkingFolder;
@ -116,6 +118,12 @@ namespace Microsoft.DotNet.Tools.Test.Utilities
.EnumerateDirectories(Path.Combine(_artifacts, "dotnet", "sdk"))
.First(d => !d.Contains("NuGetFallbackFolder"));
string AspNetCoreDir = Path.Combine(_dotnetRoot, "shared", "Microsoft.AspNetCore.App");
if (Directory.Exists(AspNetCoreDir))
{
_stage2AspNetCore = Directory.EnumerateDirectories(AspNetCoreDir).First();
}
_stage2WithBackwardsCompatibleRuntimesDirectory =
Path.Combine(_artifacts, "dotnetWithBackwardsCompatibleRuntimes");

View file

@ -0,0 +1,20 @@
// 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 Xunit;
namespace Microsoft.DotNet.Tools.Test.Utilities
{
public class RequiresAspNetCore : FactAttribute
{
public RequiresAspNetCore()
{
var repoDirectoriesProvider = new RepoDirectoriesProvider();
if (repoDirectoriesProvider.Stage2AspNetCore == null)
{
this.Skip = $"This test requires a AspNetCore but it isn't present.";
}
}
}
}