Fix locating files in GetCommonSourceFiles#125123
Conversation
|
@sbomer please take a look |
|
Tagging subscribers to this area: @agocke, @dotnet/illink |
There was a problem hiding this comment.
Pull request overview
This PR updates the ILLink test framework’s GetCommonSourceFiles path resolution so it doesn’t depend on the configurable _testCase.RootCasesDirectory, which can point at non-ILLink test case trees (e.g., Unity’s).
Changes:
- Switch
GetCommonSourceFilesto compute paths from a “known” test framework directory rather than_testCase.RootCasesDirectory. - Add
GetMonoLinkerTestsDirectoryhelper (viaCallerFilePath) to find theMono.Linker.Testsdirectory. - Make
GetCommonSourceFilesvirtual to allow downstream override.
src/tools/illink/test/Mono.Linker.Tests/TestCasesRunner/TestCaseCompilationMetadataProvider.cs
Outdated
Show resolved
Hide resolved
src/tools/illink/test/Mono.Linker.Tests/TestCasesRunner/TestCaseCompilationMetadataProvider.cs
Outdated
Show resolved
Hide resolved
|
I'm looking into the failures |
|
I haven't figured out the issue yet. Locally when I run tests from Rider they all pass. And when I run from the command line using They do fail when I run the way CI does using And I get errors such as |
`_testCase.RootCasesDirectory` is meant to be configurable. For example, Unity uses the same test framework to run tests that live in `Unity.Linker.Tests.Cases`. When we run tests, `_testCase.RootCasesDirectory` is going to be the path to our `Unity.Linker.Tests.Cases` directory. When that happens `GetCommonSourceFiles` cannot locate the files relative to `_testCase.RootCasesDirectory`. Since `GetCommonSourceFiles` is trying to explicitly locate files relative to the ILLink test case directory structure the code should be using a known directory to start from rather than a path that is configurable. I added the new `GetMonoLinkerTestsDirectory` directory to `TestCaseCompilationMetadataProvider.cs` instead of adding it to `PathUtilities` because it makes life a little easier. Unity has to provide it's own copy of `PathUtilities` in order to add the `bin` directory in the path returned by `GetTestAssemblyRoot`. Which means having this path location in `PathUtilities` leads to more wire up work for us. That said, if you'd prefer `GetMonoLinkerTestsDirectory` be in `PathUtilities` I can move it there and deal with the extra wiring on our end. While I was here I thought I'd make `GetCommonSourceFiles` virtual just in case Unity needs to override it in the future.
2716f6f to
cf83bba
Compare
|
@sbomer I changed the approach. I'm now using |
|
/ba-g "timeouts" |
_testCase.RootCasesDirectoryis meant to be configurable. For example, Unity uses the same test framework to run tests that live inUnity.Linker.Tests.Cases. When we run tests,_testCase.RootCasesDirectoryis going to be the path to ourUnity.Linker.Tests.Casesdirectory. When that happensGetCommonSourceFilescannot locate the files relative to_testCase.RootCasesDirectory.Since
GetCommonSourceFilesis trying to explicitly locate files relative to the ILLink test case directory structure the code should be using a known directory to start from rather than a path that is configurable.I added the new helper methods to
PathUtilitiesand followed theAppContext.GetDatapattern. I tried to use[CallerFilePath]but I couldn't get that to work on CI.While I was here I thought I'd make
GetCommonSourceFilesvirtual just in case Unity needs to override it in the future.