forked from dotnet/sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGivenDotnetCleanInvocation.cs
66 lines (59 loc) · 3.3 KB
/
GivenDotnetCleanInvocation.cs
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
using CleanCommand = Microsoft.DotNet.Cli.Commands.Clean.CleanCommand;
namespace Microsoft.DotNet.Cli.MSBuild.Tests
{
[Collection(TestConstants.UsesStaticTelemetryState)]
public class GivenDotnetCleanInvocation : IClassFixture<NullCurrentSessionIdFixture>
{
private const string NugetInteractiveProperty = "-property:NuGetInteractive=false";
private static readonly string[] ExpectedPrefix = ["-maxcpucount", "-verbosity:m", "-tlp:default=auto", "-nologo", "-verbosity:normal", "-target:Clean", NugetInteractiveProperty];
private static readonly string WorkingDirectory =
TestPathUtilities.FormatAbsolutePath(nameof(GivenDotnetCleanInvocation));
[Fact]
public void ItAddsProjectToMsbuildInvocation()
{
var msbuildPath = "<msbuildpath>";
CleanCommand.FromArgs(new string[] { "<project>" }, msbuildPath)
.GetArgumentTokensToMSBuild()
.Should()
.BeEquivalentTo([.. ExpectedPrefix, "<project>"]);
}
[Theory]
[InlineData(new string[] { }, new string[] { })]
[InlineData(new string[] { "-o", "<output>" },
new string[] { "-property:OutputPath=<cwd><output>", "-property:_CommandLineDefinedOutputPath=true" })]
[InlineData(new string[] { "--output", "<output>" },
new string[] { "-property:OutputPath=<cwd><output>", "-property:_CommandLineDefinedOutputPath=true" })]
[InlineData(new string[] { "--artifacts-path", "foo" },
new string[] { "-property:ArtifactsPath=<cwd>foo" })]
[InlineData(new string[] { "-f", "<framework>" },
new string[] { "-property:TargetFramework=<framework>" })]
[InlineData(new string[] { "--framework", "<framework>" },
new string[] { "-property:TargetFramework=<framework>" })]
[InlineData(new string[] { "-c", "<configuration>" },
new string[] { "-property:Configuration=<configuration>" })]
[InlineData(new string[] { "--configuration", "<configuration>" },
new string[] { "-property:Configuration=<configuration>" })]
[InlineData(new string[] { "-v", "diag" },
new string[] { "-verbosity:diag" })]
[InlineData(new string[] { "--verbosity", "diag" },
new string[] { "-verbosity:diag" })]
[InlineData(new string[] { "--disable-build-servers" },
new string[] { "--property:UseRazorBuildServer=false", "--property:UseSharedCompilation=false", "/nodeReuse:false" })]
public void MsbuildInvocationIsCorrect(string[] args, string[] expectedAdditionalArgs)
{
CommandDirectoryContext.PerformActionWithBasePath(WorkingDirectory, () =>
{
expectedAdditionalArgs = expectedAdditionalArgs
.Select(arg => arg.Replace("<cwd>", WorkingDirectory))
.ToArray();
var msbuildPath = "<msbuildpath>";
CleanCommand.FromArgs(args, msbuildPath)
.GetArgumentTokensToMSBuild()
.Should()
.BeEquivalentTo([.. ExpectedPrefix, .. expectedAdditionalArgs]);
});
}
}
}