55f62d9d64
* compose all the parts * Fix on obtain and shim maker for better end to end experience * Fix error when there is space in the middle of path of nuget config * Fix path in profile.d is the tmp home path during install * better handle of ~home * remove profile.d file in uninstall script * Fix test since it looks up current directory * folder structure inside nupkg to tools/TFM/RID/mytool.dll * Add check for config file existence * Rename name space to Microsoft.DotNet.ShellShim * Rename name space to Microsoft.DotNet.ToolPackage
85 lines
3.4 KiB
C#
85 lines
3.4 KiB
C#
// 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.Collections.Generic;
|
|
using System.Diagnostics;
|
|
using System.Runtime.InteropServices;
|
|
using FluentAssertions;
|
|
using Microsoft.DotNet.Configurer;
|
|
using Microsoft.DotNet.Tools.Test.Utilities;
|
|
using Microsoft.Extensions.DependencyModel.Tests;
|
|
using Xunit;
|
|
|
|
namespace Microsoft.DotNet.ShellShim.Tests
|
|
{
|
|
public class LinuxEnvironmentPathTests
|
|
{
|
|
[Fact]
|
|
public void GivenEnvironmentAndReporterItCanPrintOutInstructionToAddPath()
|
|
{
|
|
var fakeReporter = new FakeReporter();
|
|
var linuxEnvironmentPath = new LinuxEnvironmentPath(
|
|
new BashPathUnderHomeDirectory("/myhome", "executable/path"),
|
|
fakeReporter,
|
|
new FakeEnvironmentProvider(
|
|
new Dictionary<string, string>
|
|
{
|
|
{"PATH", ""}
|
|
}),
|
|
FakeFile.Empty);
|
|
|
|
linuxEnvironmentPath.PrintAddPathInstructionIfPathDoesNotExist();
|
|
|
|
// similar to https://code.visualstudio.com/docs/setup/mac
|
|
fakeReporter.Message.Should().Be(
|
|
$"Cannot find the tools executable path. Please ensure /myhome/executable/path is added to your PATH.{Environment.NewLine}" +
|
|
$"If you are using bash. You can do this by running the following command:{Environment.NewLine}{Environment.NewLine}" +
|
|
$"cat << EOF >> ~/.bash_profile{Environment.NewLine}" +
|
|
$"# Add .NET Core SDK tools{Environment.NewLine}" +
|
|
$"export PATH=\"$PATH:/myhome/executable/path\"{Environment.NewLine}" +
|
|
$"EOF");
|
|
}
|
|
|
|
[Fact]
|
|
public void GivenEnvironmentAndReporterItPrintsNothingWhenenvironmentExists()
|
|
{
|
|
var fakeReporter = new FakeReporter();
|
|
var linuxEnvironmentPath = new LinuxEnvironmentPath(
|
|
new BashPathUnderHomeDirectory("/myhome", "executable/path"),
|
|
fakeReporter,
|
|
new FakeEnvironmentProvider(
|
|
new Dictionary<string, string>
|
|
{
|
|
{"PATH", @"/myhome/executable/path"}
|
|
}),
|
|
FakeFile.Empty);
|
|
|
|
linuxEnvironmentPath.PrintAddPathInstructionIfPathDoesNotExist();
|
|
|
|
fakeReporter.Message.Should().BeEmpty();
|
|
}
|
|
|
|
[Fact]
|
|
public void GivenAddPackageExecutablePathToUserPathJustRunItPrintsInstructionToLogout()
|
|
{
|
|
var fakeReporter = new FakeReporter();
|
|
var linuxEnvironmentPath = new LinuxEnvironmentPath(
|
|
new BashPathUnderHomeDirectory("/myhome", "executable/path"),
|
|
fakeReporter,
|
|
new FakeEnvironmentProvider(
|
|
new Dictionary<string, string>
|
|
{
|
|
{"PATH", @""}
|
|
}),
|
|
FakeFile.Empty);
|
|
linuxEnvironmentPath.AddPackageExecutablePathToUserPath();
|
|
|
|
linuxEnvironmentPath.PrintAddPathInstructionIfPathDoesNotExist();
|
|
|
|
fakeReporter.Message.Should()
|
|
.Be(
|
|
"Since you just installed the .NET Core SDK, you will need to logout or restart your session before running the tool you installed.");
|
|
}
|
|
}
|
|
}
|