Skip to content

Commit eb4f246

Browse files
authored
Fix execution of ilverify tests in outerloop runs (#73132)
As JanK noticed in #73109, outerloop tests don't run the ilverify/ILVerificationTests.csproj test project. This is because the project is somewhat atypical in residing just one directory level beneath the test binary root folder; all other tests reside under at least two directory levels and the legacy XUnit wrapper generator reflects it so that each wrapper corresponds to a two-level directory subtree. The pre-existing logic for determining active two-level test directories was quite hacky and perf-costly; I probably accidentally removed the support for single-subfolder tests in one of my refactorings of the src/tests/build.proj script. This change fixes it and makes the construction of TestDirectories much more efficient as we no longer construct a Carthesian product of all tests and all two-level folder directories. Thanks Tomas
1 parent dae9edc commit eb4f246

3 files changed

Lines changed: 14 additions & 24 deletions

File tree

src/tests/Common/CLRTest.CrossGen.targets

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,8 @@ if [ ! -z ${RunCrossGen2+x} ]%3B then
6666
else
6767
cp *.dll IL-CG2/
6868
rm IL-CG2/composite-r2r.dll 2>/dev/null
69+
rm IL-CG2/Coreclr.TestWrapper.dll 2>/dev/null
70+
rm IL-CG2/*.XUnitWrapper.dll 2>/dev/null
6971
fi
7072
7173
ExtraCrossGen2Args+=" $(CrossGen2TestExtraArguments)"
@@ -186,6 +188,8 @@ if defined RunCrossGen2 (
186188
mkdir IL-CG2
187189
copy *.dll IL-CG2\
188190
del IL-CG2\composite-r2r.dll 2>nul
191+
del IL-CG2\Coreclr.TestWrapper.dll 2>nul
192+
del IL-CG2\*.XUnitWrapper.dll 2>nul
189193
190194
if defined CompositeBuildMode (
191195
set ExtraCrossGen2Args=!ExtraCrossGen2Args! --composite
@@ -196,9 +200,9 @@ if defined RunCrossGen2 (
196200
IF NOT !CrossGen2Status!==0 goto :DoneCrossgen2Operations
197201
) else (
198202
set ExtraCrossGen2Args=!ExtraCrossGen2Args! -r:!scriptPath!IL-CG2\*.dll
199-
for %%I in (!scriptPath!\*.dll) do (
200-
set __OutputFile=!scriptPath!\%%~nI.dll
201-
set __InputFile=!scriptPath!IL-CG2\%%~nI.dll
203+
for %%I in (!scriptPath!IL-CG2\*.dll) do (
204+
set __OutputFile=!scriptPath!%%~nI.dll
205+
set __InputFile=%%I
202206
call :CompileOneFileCrossgen2
203207
IF NOT !CrossGen2Status!==0 (
204208
IF NOT !CrossGen2Status!==2 goto :DoneCrossgen2Operations

src/tests/build.proj

Lines changed: 6 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
<DisabledTestDir Include="Common" />
1717
<DisabledTestDir Include="Tests" />
1818
<DisabledTestDir Include="TestWrappers" />
19-
<_SkipTestDir Include="@(DisabledTestDir)" />
2019
</ItemGroup>
2120

2221
<ItemGroup>
@@ -49,23 +48,11 @@
4948
<Error Condition="!Exists('$(XunitTestBinBase)')"
5049
Text="$(XunitTestBinBase) does not exist. Please run src\tests\build / src/tests/build.sh from the repo root at least once to get the tests built." />
5150

52-
<ItemGroup>
53-
<AllTestDirsNonCanonicalPaths Include="$([System.IO.Directory]::GetDirectories(`$(XunitTestBinBase)`))" />
54-
<AllTestDirsPaths Include="@(AllTestDirsNonCanonicalPaths)" />
55-
<AllTestDirsPaths Include="@(AllTestDirsNonCanonicalPaths)" >
56-
<Path>$([System.IO.Path]::GetFullPath(%(Identity)))</Path>
57-
</AllTestDirsPaths>
58-
<SkipTestDirsPaths Include="$([System.IO.Path]::GetFullPath('$(XunitTestBinBase)%(_SkipTestDir.Identity)'))" />
59-
<NonExcludedTestDirectories Include="@(AllTestDirsPaths -> '%(Path)')" Exclude="@(SkipTestDirsPaths)" />
60-
</ItemGroup>
61-
6251
<ItemGroup Condition="'@(LegacyRunnableTestPaths)' != ''">
63-
<TopLevelDirectories Include="@(NonExcludedTestDirectories)" />
64-
<SecondLevel Include="$([System.IO.Directory]::GetDirectories(%(TopLevelDirectories.Identity)))" />
65-
<SecondLevelDirectories Include="@(SecondLevel)">
66-
<Path>$([System.IO.Path]::GetFullPath(%(LegacyRunnableTestPaths.Identity)))</Path>
67-
</SecondLevelDirectories>
68-
<TestDirectoriesWithDup Include="@(SecondLevelDirectories -> '%(Identity)')" Condition="$([System.String]::new('%(Path)').StartsWith('%(Identity)'))" />
52+
<LegacyRunnableTestPaths Separator="$([System.String]::Copy('%(LegacyRunnableTestPaths.Identity)').IndexOfAny('\\/', $(XunitTestBinBase.Length)))" />
53+
<LegacyRunnableTestPaths SecondSeparator="$([System.String]::Copy('%(LegacyRunnableTestPaths.Identity)').IndexOfAny('\\/', $([MSBuild]::Add(%(LegacyRunnableTestPaths.Separator), 1))))" />
54+
<LegacyRunnableTestPaths Separator="%(LegacyRunnableTestPaths.SecondSeparator)" Condition="'%(LegacyRunnableTestPaths.SecondSeparator)' != '-1'" />
55+
<TestDirectoriesWithDup Include="$([System.String]::Copy('%(LegacyRunnableTestPaths.Identity)').Substring(0, %(LegacyRunnableTestPaths.Separator)))" />
6956
</ItemGroup>
7057

7158
<RemoveDuplicates Inputs="@(TestDirectoriesWithDup)">
@@ -390,8 +377,10 @@
390377

391378
<Target Name="GetListOfTestCmds">
392379
<ItemGroup>
380+
<SkipTestDirsPaths Include="$([System.IO.Path]::GetFullPath('$(XunitTestBinBase)%(DisabledTestDir.Identity)'))" />
393381
<AllRunnableTestPaths Include="$(XunitTestBinBase)\**\*.$(TestScriptExtension)"/>
394382
<AllRunnableTestPaths Remove="$(XunitTestBinBase)\**\run-v8.sh" Condition="'$(TargetArchitecture)' == 'wasm'" />
383+
<AllRunnableTestPaths Remove="%(SkipTestDirsPaths.Identity)\**\*.$(TestScriptExtension)" />
395384
<MergedAssemblyMarkerPaths Include="$(XunitTestBinBase)\**\*.MergedTestAssembly"/>
396385
<MergedAssemblyFolders Include="$([System.IO.Path]::GetDirectoryName('%(MergedAssemblyMarkerPaths.Identity)'))" />
397386
<MergedAssemblyParentFolders Include="$([System.IO.Path]::GetDirectoryName('%(MergedAssemblyFolders.Identity)'))" />

src/tests/xunit-wrappers.targets

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -99,10 +99,7 @@ $(_XunitEpilog)
9999
<!-- NOTE! semicolons must be escaped with %3B boooo -->
100100

101101
<PropertyGroup>
102-
<_CMDDIR_Parent>$([System.IO.Path]::GetDirectoryName($(_CMDDIR)))</_CMDDIR_Parent>
103-
<_CMDDIR_Grandparent>$([System.IO.Path]::GetDirectoryName($(_CMDDIR_Parent)))</_CMDDIR_Grandparent>
104-
<CategoryWithSlash Condition="'$(RunningOnUnix)' != 'true'" >$([System.String]::Copy('$(_CMDDIR)').Replace("$(_CMDDIR_Grandparent)\",""))</CategoryWithSlash>
105-
<CategoryWithSlash Condition="'$(RunningOnUnix)' == 'true'" >$([System.String]::Copy('$(_CMDDIR)').Replace("$(_CMDDIR_Grandparent)/",""))</CategoryWithSlash>
102+
<CategoryWithSlash>$([System.IO.Path]::GetRelativePath('$(XunitTestBinBase)', '$(_CMDDIR)'))</CategoryWithSlash>
106103
<Category Condition="'$(RunningOnUnix)' != 'true'" >$([System.String]::Copy('$(CategoryWithSlash)').Replace('\','.'))</Category>
107104
<Category Condition="'$(RunningOnUnix)' == 'true'" >$([System.String]::Copy('$(CategoryWithSlash)').Replace('/','.'))</Category>
108105
<XunitWrapper>$(Category).XUnitWrapper</XunitWrapper>

0 commit comments

Comments
 (0)