forked from dotnet/sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDotnetCliSnapshotTests.cs
More file actions
41 lines (35 loc) · 1.96 KB
/
DotnetCliSnapshotTests.cs
File metadata and controls
41 lines (35 loc) · 1.96 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
using System.CommandLine.StaticCompletions;
using System.CommandLine.StaticCompletions.Shells;
namespace Microsoft.DotNet.Cli.Completions.Tests;
public class DotnetCliSnapshotTests : SdkTest
{
public DotnetCliSnapshotTests(ITestOutputHelper log) : base(log) { }
[MemberData(nameof(ShellNames))]
[Theory(Skip = "https://github.com/dotnet/sdk/issues/48817")]
public async Task VerifyCompletions(string shellName)
{
if (!shellName.Equals("zsh") || !TestContext.Current.ToolsetUnderTest.ShouldUseFullFrameworkMSBuild)
{
// This has been unstable lately; skipping
return;
}
var provider = CompletionsCommand.DefaultShells.Single(x => x.ArgumentName == shellName);
var completions = provider.GenerateCompletions(Parser.RootCommand);
var settings = new VerifySettings();
if (Environment.GetEnvironmentVariable("USER") is string user && user.Contains("helix", StringComparison.OrdinalIgnoreCase)
|| string.IsNullOrEmpty(Environment.GetEnvironmentVariable("USER")))
{
Log.WriteLine($"CI environment detected, using snapshots directory in the current working directory {Environment.CurrentDirectory}");
settings.UseDirectory(Path.Combine(Environment.CurrentDirectory, "snapshots", provider.ArgumentName));
}
else
{
Log.WriteLine($"Using snapshots from local repository because $USER {Environment.GetEnvironmentVariable("USER")} is not helix-related");
settings.UseDirectory(Path.Combine("snapshots", provider.ArgumentName));
}
await Verify(target: completions, extension: provider.Extension, settings: settings);
}
public static IEnumerable<object[]> ShellNames = CompletionsCommand.DefaultShells.Select<IShellProvider, object[]>(x => [x.ArgumentName]);
}