dotnet-installer/test/dotnet.Tests/GivenThatDotNetRunsCommands.cs
Peter Huene 92507184bd
Log a verbose message when DOTNET_CLI_HOME is being used.
This commit logs a diagnostic message when the `DOTNET_CLI_HOME` variable is
used.  This enables users to determine where first-run-experience and global
tool files are being written to.

Fixes #9510.
2018-06-26 16:34:00 -07:00

71 lines
2.6 KiB
C#
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

// 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;
using FluentAssertions;
using Microsoft.DotNet.Cli.Utils;
using Microsoft.DotNet.Configurer;
using Microsoft.DotNet.Tools.Test.Utilities;
using Xunit;
using LocalizableStrings = Microsoft.DotNet.Cli.Utils.LocalizableStrings;
namespace Microsoft.DotNet.Tests
{
public class GivenThatDotNetRunsCommands : TestBase
{
[Fact]
public void UnresolvedPlatformReferencesFailAsExpected()
{
var testInstance = TestAssets.Get("NonRestoredTestProjects", "TestProjectWithUnresolvedPlatformDependency")
.CreateInstance()
.WithSourceFiles()
.Root.FullName;
new RestoreCommand()
.WithWorkingDirectory(testInstance)
.ExecuteWithCapturedOutput("/p:SkipInvalidConfigurations=true")
.Should()
.Fail();
new DotnetCommand()
.WithWorkingDirectory(testInstance)
.ExecuteWithCapturedOutput("crash")
.Should().Fail()
.And.HaveStdErrContaining(string.Format(LocalizableStrings.NoExecutableFoundMatchingCommand, "dotnet-crash"));
}
[Theory]
[InlineData("")]
[InlineData(null)]
public void GivenAMissingHomeVariableItPrintsErrorMessage(string value)
{
new TestCommand("dotnet")
.WithEnvironmentVariable(CliFolderPathCalculator.PlatformHomeVariableName, value)
.ExecuteWithCapturedOutput("--help")
.Should()
.Fail()
.And
.HaveStdErrContaining(CliFolderPathCalculator.DotnetHomeVariableName);
}
[Fact]
public void GivenASpecifiedDotnetCliHomeVariableItPrintsUsageMessage()
{
var home = Path.Combine(TempRoot.Root, Path.GetRandomFileName());
new TestCommand("dotnet")
.WithEnvironmentVariable(CliFolderPathCalculator.DotnetHomeVariableName, home)
.ExecuteWithCapturedOutput("-d help")
.Should()
.Pass()
.And
.HaveStdOutContaining(
string.Format(
LocalizableStrings.DotnetCliHomeUsed,
home,
CliFolderPathCalculator.DotnetHomeVariableName));
}
}
}