Skip to content

Commit 51d5fe2

Browse files
authored
Modify MRT Core UnpackagedTests clean-up, and reorganize test reporting (#870)
This change modifies the MRT Core UnpackagedTests to unblock running on my local PC. It also improves how the tests are reported in the Azure DevOps UI.
1 parent 7640276 commit 51d5fe2

2 files changed

Lines changed: 37 additions & 19 deletions

File tree

build/build-mrt.yml

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -124,33 +124,40 @@ steps:
124124
artifactName: binlogs
125125

126126
- task: VSTest@2
127-
displayName: 'test MRT (Managed)'
127+
displayName: 'test MRT: ManagedTests'
128128
condition: and(succeeded(), or(eq(variables['buildPlatform'], 'x86'), eq(variables['buildPlatform'], 'x64')))
129129
inputs:
130130
testSelector: 'testAssemblies'
131-
testAssemblyVer2: |
132-
**\ManagedTest.build.appxrecipe
133-
searchFolder: '${{ parameters.MRTBinariesDirectory }}\Release\$(buildPlatform)'
134-
testRunTitle: 'test MRT $(buildPlatform)'
131+
testAssemblyVer2: '**\ManagedTest.build.appxrecipe'
132+
searchFolder: '${{ parameters.MRTBinariesDirectory }}\$(buildConfiguration)\$(buildPlatform)\ManagedTest'
133+
testRunTitle: 'test MRT: ManagedTests - $(buildPlatform)'
135134
platform: '$(buildPlatform)'
136135
configuration: '$(buildConfiguration)'
137136

138137
- task: VSTest@2
139-
displayName: 'test MRT'
138+
displayName: 'test MRT: UnitTests'
140139
condition: and(succeeded(), or(eq(variables['buildPlatform'], 'x86'), eq(variables['buildPlatform'], 'x64')))
141140
inputs:
142141
testSelector: 'testAssemblies'
143-
testAssemblyVer2: |
144-
**\*test*.dll
145-
!**\*TestAdapter.dll
146-
!**\TE.*.dll
147-
!**\obj\**
148-
!**\MrtCoreUnpackagedTests.dll
149-
searchFolder: '${{ parameters.MRTBinariesDirectory }}\$(buildConfiguration)\$(buildPlatform)'
150-
testRunTitle: 'test MRT $(buildPlatform)'
142+
testAssemblyVer2: '**\UnitTest.dll'
143+
searchFolder: '${{ parameters.MRTBinariesDirectory }}\$(buildConfiguration)\$(buildPlatform)\UnitTest'
144+
testRunTitle: 'test MRT: UnitTests - $(buildPlatform)'
151145
platform: '$(buildPlatform)'
152146
configuration: '$(buildConfiguration)'
153147

148+
- task: VSTest@2
149+
displayName: 'test MRT: BaseUnitTests'
150+
condition: and(succeeded(), or(eq(variables['buildPlatform'], 'x86'), eq(variables['buildPlatform'], 'x64')))
151+
inputs:
152+
testSelector: 'testAssemblies'
153+
testAssemblyVer2: '**\BaseUnitTests.dll'
154+
searchFolder: '${{ parameters.MRTBinariesDirectory }}\$(buildConfiguration)\$(buildPlatform)\BaseUnitTests'
155+
testRunTitle: 'test MRT: BaseUnitTests - $(buildPlatform)'
156+
platform: '$(buildPlatform)'
157+
configuration: '$(buildConfiguration)'
158+
159+
# Note: The MRT Unpackaged tests currently do not work in the CI pipeline.
160+
154161
- task: ComponentGovernanceComponentDetection@0
155162
inputs:
156163
scanType: 'Register'

dev/MRTCore/mrt/Microsoft.ApplicationModel.Resources/UnpackagedTests/TestClass.cs

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -111,11 +111,26 @@ public class TestClass
111111
[AssemblyInitialize]
112112
public static void ModuleSetup(TestContext testContext)
113113
{
114-
// Cleanup just in case
114+
// Clean up any left over files just in case
115115
File.Delete(Path.Combine(m_assemblyFolder, "resources.pri"));
116116
File.Delete(Path.Combine(m_assemblyFolder, "te.processhost.pri"));
117117
}
118118

119+
[TestCleanup]
120+
public static void TestCleanup()
121+
{
122+
GC.Collect(); // Force any ResourceManager objects to be cleaned up.
123+
124+
if (File.Exists(Path.Combine(m_assemblyFolder, "resources.pri")))
125+
{
126+
File.Delete(Path.Combine(m_assemblyFolder, "resources.pri"));
127+
}
128+
if (File.Exists(Path.Combine(m_assemblyFolder, "te.processhost.pri")))
129+
{
130+
File.Delete(Path.Combine(m_assemblyFolder, "te.processhost.pri"));
131+
}
132+
}
133+
119134
[TestMethod]
120135
public void DefaultResourceManager()
121136
{
@@ -140,8 +155,6 @@ public void DefaultResourceManagerWithResourcePri()
140155
Verify.AreNotEqual(map.ResourceCount, 0u);
141156
var resource = map.GetValue("IDS_MANIFEST_MUSIC_APP_NAME").ValueAsString;
142157
Verify.AreEqual(resource, "Groove Music");
143-
144-
File.Delete(Path.Combine(m_assemblyFolder, "resources.pri"));
145158
}
146159

147160
[TestMethod]
@@ -155,8 +168,6 @@ public void DefaultResourceManagerWithExePri()
155168
Verify.AreNotEqual(map.ResourceCount, 0u);
156169
var resource = map.GetValue("IDS_MANIFEST_MUSIC_APP_NAME").ValueAsString;
157170
Verify.AreEqual(resource, "Groove Music");
158-
159-
File.Delete(Path.Combine(m_assemblyFolder, "te.processhost.pri"));
160171
}
161172

162173
[TestMethod]

0 commit comments

Comments
 (0)