Skip to content

Utilize ShellName and Add Test to Enable Completions W/out Shell on Unix #48918

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,8 @@ static IShellProvider LookupShellFromEnvironment(Dictionary<string, IShellProvid
{
throw new InvalidOperationException(Strings.ShellDiscovery_ShellEnvironmentNotSet);
}
var shellName = Path.GetFileName(shellPath);
if (shellMap.TryGetValue(shellPath, out var shellProvider))
var shellName = Path.GetFileName(shellPath).ToLower();
if (shellMap.TryGetValue(shellName, out var shellProvider))
{
return shellProvider;
}
Expand Down
24 changes: 24 additions & 0 deletions test/dotnet.Tests/CompletionTests/ShellDiscoveryTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

#nullable disable


using System.CommandLine.StaticCompletions.Shells;
using Microsoft.DotNet.Cli.Commands.BuildServer.Shutdown;
using Xunit;
using Xunit.Abstractions;
using Parser = Microsoft.DotNet.Cli.Parser;

namespace System.CommandLine.StaticCompletions.Tests;

public class ShellDiscoveryTests
{
[Fact]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe parameterize this test with the shell names and set the SHELL env var before each run so we can easily test all of our shell experiences??

public void StaticCompletionsCanParseWithoutAShell()
{
var result = Parser.Instance.Parse(@"dotnet completions script");
result.Errors.Should().BeEmpty();
result.GetValue<IShellProvider>("@CompletionsCommand_ShellArgument_Description").Should().NotBeNull();
}
}
Loading