1
1
// Copyright (c) Microsoft Corporation. All rights reserved.
2
2
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
3
3
4
+ using Microsoft . Build . Logging . StructuredLogger ;
4
5
using Microsoft . Testing . Platform . Acceptance . IntegrationTests . Helpers ;
5
6
7
+ using SL = Microsoft . Build . Logging . StructuredLogger ;
8
+ using SystemTask = System . Threading . Tasks . Task ;
9
+
6
10
namespace Microsoft . Testing . Platform . Acceptance . IntegrationTests ;
7
11
8
12
[ TestGroup ]
@@ -19,7 +23,7 @@ public MSTestRunnerTests(ITestExecutionContext testExecutionContext, AcceptanceF
19
23
}
20
24
21
25
[ ArgumentsProvider ( nameof ( GetBuildMatrixTfmBuildVerbConfiguration ) ) ]
22
- public async Task EnableMSTestRunner_True_Will_Run_Standalone ( string tfm , BuildConfiguration buildConfiguration , Verb verb )
26
+ public async SystemTask EnableMSTestRunner_True_Will_Run_Standalone ( string tfm , BuildConfiguration buildConfiguration , Verb verb )
23
27
{
24
28
await Lock . WaitAsync ( ) ;
25
29
try
@@ -39,6 +43,12 @@ public async Task EnableMSTestRunner_True_Will_Run_Standalone(string tfm, BuildC
39
43
compilationResult = await DotnetCli . RunAsync (
40
44
$ "{ verb } -m:1 -nodeReuse:false { generator . TargetAssetPath } -c { buildConfiguration } -bl:{ binlogFile } -r { RID } ",
41
45
_acceptanceFixture . NuGetGlobalPackagesFolder . Path ) ;
46
+
47
+ SL . Build binLog = SL . Serialization . Read ( binlogFile ) ;
48
+ Assert . IsNotEmpty ( binLog . FindChildrenRecursive < AddItem > ( )
49
+ . Where ( x => x . Title . Contains ( "ProjectCapability" ) )
50
+ . Where ( x => x . Children . Any ( c => ( ( Item ) c ) . Name == "TestingPlatformServer" ) ) ) ;
51
+
42
52
var testHost = TestInfrastructure . TestHost . LocateFrom ( generator . TargetAssetPath , AssetName , tfm , buildConfiguration : buildConfiguration , verb : verb ) ;
43
53
var testHostResult = await testHost . ExecuteAsync ( ) ;
44
54
testHostResult . AssertOutputContains ( "Passed! - Failed: 0, Passed: 1, Skipped: 0, Total: 1" ) ;
@@ -50,7 +60,7 @@ public async Task EnableMSTestRunner_True_Will_Run_Standalone(string tfm, BuildC
50
60
}
51
61
52
62
[ ArgumentsProvider ( nameof ( GetBuildMatrixTfmBuildVerbConfiguration ) ) ]
53
- public async Task EnableMSTestRunner_True_WithCustomEntryPoint_Will_Run_Standalone ( string tfm , BuildConfiguration buildConfiguration , Verb verb )
63
+ public async SystemTask EnableMSTestRunner_True_WithCustomEntryPoint_Will_Run_Standalone ( string tfm , BuildConfiguration buildConfiguration , Verb verb )
54
64
{
55
65
await Lock . WaitAsync ( ) ;
56
66
try
@@ -94,21 +104,21 @@ public async Task EnableMSTestRunner_True_WithCustomEntryPoint_Will_Run_Standalo
94
104
}
95
105
96
106
[ ArgumentsProvider ( nameof ( GetBuildMatrixTfmBuildVerbConfiguration ) ) ]
97
- public async Task EnableMSTestRunner_False_Will_Run_Empty_Program_EntryPoint_From_Tpv2_SDK ( string tfm , BuildConfiguration buildConfiguration , Verb verb )
107
+ public async SystemTask EnableMSTestRunner_False_Will_Run_Empty_Program_EntryPoint_From_Tpv2_SDK ( string tfm , BuildConfiguration buildConfiguration , Verb verb )
98
108
{
99
109
await Lock . WaitAsync ( ) ;
100
110
try
101
111
{
102
112
using TestAsset generator = await TestAsset . GenerateAssetAsync (
103
- AssetName ,
104
- CurrentMSTestSourceCode
105
- . PatchCodeWithReplace ( "$TargetFramework$" , $ "<TargetFramework>{ tfm } </TargetFramework>")
106
- . PatchCodeWithReplace ( "$MicrosoftNETTestSdkVersion$" , MicrosoftNETTestSdkVersion )
107
- . PatchCodeWithReplace ( "$MSTestVersion$" , MSTestVersion )
108
- . PatchCodeWithReplace ( "$EnableMSTestRunner$" , "<EnableMSTestRunner>false</EnableMSTestRunner>" )
109
- . PatchCodeWithReplace ( "$OutputType$" , "<OutputType>Exe</OutputType>" )
110
- . PatchCodeWithReplace ( "$Extra$" , string . Empty ) ,
111
- addPublicFeeds : true ) ;
113
+ AssetName ,
114
+ CurrentMSTestSourceCode
115
+ . PatchCodeWithReplace ( "$TargetFramework$" , $ "<TargetFramework>{ tfm } </TargetFramework>")
116
+ . PatchCodeWithReplace ( "$MicrosoftNETTestSdkVersion$" , MicrosoftNETTestSdkVersion )
117
+ . PatchCodeWithReplace ( "$MSTestVersion$" , MSTestVersion )
118
+ . PatchCodeWithReplace ( "$EnableMSTestRunner$" , "<EnableMSTestRunner>false</EnableMSTestRunner>" )
119
+ . PatchCodeWithReplace ( "$OutputType$" , "<OutputType>Exe</OutputType>" )
120
+ . PatchCodeWithReplace ( "$Extra$" , string . Empty ) ,
121
+ addPublicFeeds : true ) ;
112
122
string binlogFile = Path . Combine ( generator . TargetAssetPath , "msbuild.binlog" ) ;
113
123
var compilationResult = await DotnetCli . RunAsync ( $ "restore -m:1 -nodeReuse:false { generator . TargetAssetPath } -r { RID } ", _acceptanceFixture . NuGetGlobalPackagesFolder . Path ) ;
114
124
try
@@ -134,4 +144,36 @@ public async Task EnableMSTestRunner_False_Will_Run_Empty_Program_EntryPoint_Fro
134
144
Lock . Release ( ) ;
135
145
}
136
146
}
147
+
148
+ [ ArgumentsProvider ( nameof ( GetBuildMatrixTfmBuildVerbConfiguration ) ) ]
149
+ public async SystemTask EnableMSTestRunner_False_Wont_Flow_TestingPlatformServer_Capability ( string tfm , BuildConfiguration buildConfiguration , Verb verb )
150
+ {
151
+ await Lock . WaitAsync ( ) ;
152
+ try
153
+ {
154
+ using TestAsset generator = await TestAsset . GenerateAssetAsync (
155
+ AssetName ,
156
+ CurrentMSTestSourceCode
157
+ . PatchCodeWithReplace ( "$TargetFramework$" , $ "<TargetFramework>{ tfm } </TargetFramework>")
158
+ . PatchCodeWithReplace ( "$MicrosoftNETTestSdkVersion$" , MicrosoftNETTestSdkVersion )
159
+ . PatchCodeWithReplace ( "$MSTestVersion$" , MSTestVersion )
160
+ . PatchCodeWithReplace ( "$EnableMSTestRunner$" , string . Empty )
161
+ . PatchCodeWithReplace ( "$OutputType$" , string . Empty )
162
+ . PatchCodeWithReplace ( "$Extra$" , string . Empty ) ,
163
+ addPublicFeeds : false ) ;
164
+
165
+ string binlogFile = Path . Combine ( generator . TargetAssetPath , "msbuild.binlog" ) ;
166
+ var compilationResult = await DotnetCli . RunAsync ( $ "restore -m:1 -nodeReuse:false { generator . TargetAssetPath } -r { RID } ", _acceptanceFixture . NuGetGlobalPackagesFolder . Path ) ;
167
+ compilationResult = await DotnetCli . RunAsync ( $ "{ verb } -bl:{ binlogFile } -m:1 -nodeReuse:false { generator . TargetAssetPath } -c { buildConfiguration } -r { RID } ", _acceptanceFixture . NuGetGlobalPackagesFolder . Path ) ;
168
+
169
+ SL . Build binLog = SL . Serialization . Read ( binlogFile ) ;
170
+ Assert . IsEmpty ( binLog . FindChildrenRecursive < AddItem > ( )
171
+ . Where ( x => x . Title . Contains ( "ProjectCapability" ) )
172
+ . Where ( x => x . Children . Any ( c => ( ( Item ) c ) . Name == "TestingPlatformServer" ) ) ) ;
173
+ }
174
+ finally
175
+ {
176
+ Lock . Release ( ) ;
177
+ }
178
+ }
137
179
}
0 commit comments