Skip to content

Conversation

@DaveTryon
Copy link
Contributor

@DaveTryon DaveTryon commented Mar 4, 2025

As called out in #930, we have recently begun to have local E2E test failures. Upon investigation, the problem was determined that the test logs are being written to the folder we are using as the BuildDropPath, and that causes the SBOM validation to fail. This seems to be a recent change (bug?) in Visual Studio--we have been able to specify the --results-directory parameter when running from the command line, but attempts to change it when running from inside Visual Studio have proven unsuccessful.

This PR works around the problem by copying the existing folder to a temporary folder before running the tests, then cleaning up the temporary folder after the tests complete. Since the Microsoft.Sbom.Targets.Tests project has both net472 and net80 targets, we need to ensure that each target has its own directory.

With these changes in place, I can successfully run all tests from inside Visual Studio, or by the command prompt via dotnet test, without needing to specify the --results-directory parameter.

The AbstractGenerateSbomTaskInputTests.cs and AbstractGenerateSbomTaskTests.cs tests were refactored to allow the names of the concrete classes to be passed into the abstract base classes. The old code used CurrentDirectory, which no longer seemed correct, so I renamed it to TestBuildDropPath. The SPDX 3.0 E2E tests will probably use these same abstract classes.

I'm not thrilled with having 3 copies of the Xcopy function. At one point I had it down to 2 copies (one per project), but once it was written, the extra overhead was worse than having the extra copy. Happy to entertain options here if people have strong feelings.

@DaveTryon DaveTryon requested a review from a team as a code owner March 4, 2025 06:39
@DaveTryon
Copy link
Contributor Author

/azp run

@DaveTryon
Copy link
Contributor Author

/azp run

@DaveTryon
Copy link
Contributor Author

/azp run

@DaveTryon
Copy link
Contributor Author

/azp run

@DaveTryon DaveTryon merged commit f44fbf5 into main Mar 19, 2025
4 checks passed
@DaveTryon DaveTryon deleted the DaveTryon/fix-local-unit-tests branch March 19, 2025 04:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants