-
Notifications
You must be signed in to change notification settings - Fork 1.1k
/
Copy pathEvaluatorFastPathTests.cs
63 lines (55 loc) · 2.76 KB
/
EvaluatorFastPathTests.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
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
namespace Microsoft.NET.Build.Tests
{
public class EvaluatorFastPathTests : SdkTest
{
public EvaluatorFastPathTests(ITestOutputHelper log) : base(log)
{
}
[Fact]
public void FastPathDoesNotNeedReflection()
{
var testAsset = _testAssetsManager
.CopyTestAsset("MSBuildBareBonesProject")
.WithSource();
var command = new MSBuildCommand(testAsset, string.Empty);
command
.WithEnvironmentVariable("MSBuildLogPropertyFunctionsRequiringReflection", "true")
.WithWorkingDirectory(testAsset.Path);
command
.ExecuteWithoutRestore()
.Should()
.Pass();
var logPath = Path.Combine(testAsset.Path, "PropertyFunctionsRequiringReflection");
File.Exists(logPath).Should().BeFalse();
}
[Theory]
[InlineData("console")]
[InlineData("webapp")]
public void EnsureDotnetCommonProjectPropertyFunctionsOnFastPath(string alias)
{
var testDir = _testAssetsManager.CreateTestDirectory().Path;
new DotnetNewCommand(Log, alias)
.WithoutCustomHive()
.WithWorkingDirectory(testDir)
.Execute()
.Should()
.Pass();
new DotnetBuildCommand(Log)
.WithWorkingDirectory(testDir)
.WithEnvironmentVariable("MSBuildLogPropertyFunctionsRequiringReflection", "true")
.Execute()
.Should()
.Pass();
var logPath = Path.Combine(testDir, "PropertyFunctionsRequiringReflection");
// Functions from Microsoft.Build.Utilities.ToolLocationHelper are pending to add fast path, tracked by https://github.com/dotnet/msbuild/issues/10411.
// This verification should be changed to no log file created once it is done.
var toolLocationHelper_GetPlatformSDKLocation = "ReceiverType=Microsoft.Build.Utilities.ToolLocationHelper; ObjectInstanceType=; MethodName=GetPlatformSDKLocation(String, String)";
var toolLocationHelper_GetPlatformSDKDisplayName = "ReceiverType=Microsoft.Build.Utilities.ToolLocationHelper; ObjectInstanceType=; MethodName=GetPlatformSDKDisplayName(String, String)";
var lines = File.ReadAllLines(logPath);
var allOnFastPathWithExceptions = lines.All(l => (toolLocationHelper_GetPlatformSDKLocation.Equals(l) || toolLocationHelper_GetPlatformSDKDisplayName.Equals(l)));
allOnFastPathWithExceptions.Should().BeTrue();
}
}
}