forked from dotnet/sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathOutputPathOptionTests.cs
More file actions
88 lines (76 loc) · 2.92 KB
/
OutputPathOptionTests.cs
File metadata and controls
88 lines (76 loc) · 2.92 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
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
// 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.Runtime.CompilerServices;
namespace dotnet.Tests
{
public class OutputPathOptionTests : SdkTest
{
public OutputPathOptionTests(ITestOutputHelper log) : base(log)
{
}
[Theory]
[InlineData("build", true)]
[InlineData("clean", true)]
[InlineData("pack", false)]
[InlineData("publish", true)]
[InlineData("test", true)]
public void OutputOptionGeneratesWarningsWithSolutionFiles(string command, bool shouldWarn)
{
TestOutputWithSolution(command, useOption: true, shouldWarn: shouldWarn);
}
[Theory]
[InlineData("build")]
[InlineData("clean")]
[InlineData("pack")]
[InlineData("publish")]
[InlineData("test")]
public void OutputPathPropertyDoesNotGenerateWarningsWithSolutionFiles(string command)
{
TestOutputWithSolution(command, useOption: false, shouldWarn: false);
}
void TestOutputWithSolution(string command, bool useOption, bool shouldWarn, [CallerMemberName] string callingMethod = "")
{
var testProject = new TestProject()
{
IsExe = true,
TargetFrameworks = ToolsetInfo.CurrentTargetFramework
};
var testAsset = _testAssetsManager.CreateTestProject(testProject, callingMethod, identifier: command);
var slnDirectory = testAsset.TestRoot;
Log.WriteLine($"Test root: {slnDirectory}");
new DotnetNewCommand(Log)
.WithVirtualHive()
.WithWorkingDirectory(slnDirectory)
.Execute("sln")
.Should().Pass();
new DotnetCommand(Log)
.WithWorkingDirectory(slnDirectory)
.Execute("sln", "add", testProject.Name)
.Should().Pass();
string outputDirectory = Path.Combine(slnDirectory, "bin");
Microsoft.DotNet.Cli.Utils.CommandResult commandResult;
if (useOption)
{
commandResult = new DotnetCommand(Log)
.WithWorkingDirectory(slnDirectory)
.Execute(command, "--output", outputDirectory);
}
else
{
commandResult = new DotnetCommand(Log)
.WithWorkingDirectory(slnDirectory)
.Execute(command, $"--property:OutputPath={outputDirectory}");
}
commandResult.Should().Pass();
if (shouldWarn)
{
commandResult.Should().HaveStdOutContaining("NETSDK1194");
}
else
{
commandResult.Should().NotHaveStdOutContaining("NETSDK1194");
}
}
}
}