[dotnet] toggle starting test server with Java if Runfiles are not available
User description
Description
This allows users to run .NET tests with bazel (both pinned and unpinned browsers), as well as locally with Java using dotnet on Mac. @nvborisenko can you verify this works on Windows? I can spin up a VM if I need to.
This might be more of a hack than the right solution, but it's the best I know how to do. Feedback appreciated.
Motivation and Context
Current code does not work on Mac to run tests locally
PR Type
Enhancement, Bug fix
Description
- Improved
Runfileshandling inEnvironmentManagerby adding null checks and adjusting logic forFileNotFoundException. - Enhanced
TestWebServerstartup logic:- Added fallback to
JAVA_HOMEenvironment variable. - Refactored platform-specific executable path handling.
- Improved error handling for missing Java executable.
- Simplified process start logic and environment variable setup.
- Added fallback to
Changes walkthrough 📝
| Relevant files | |||||
|---|---|---|---|---|---|
| Enhancement |
|
💡 PR-Agent usage: Comment
/helpon the PR to get a list of all available PR-Agent tools and their descriptions
PR Review 🔍
| ⏱️ Estimated effort to review [1-5] |
3, because the PR involves multiple changes across different files with modifications in logic, error handling, and environment variable management. The changes are not overly complex but require a good understanding of the existing system and the impact of these changes. |
| 🧪 Relevant tests |
No |
| ⚡ Possible issues |
Possible Bug: The fallback to |
|
Error Handling: The changes in error handling and file path adjustments need thorough testing to ensure they do not introduce new edge cases, especially in different operating system environments. | |
| 🔒 Security concerns |
No |
PR Code Suggestions ✨
| Category | Suggestion | Score |
| Possible issue |
Add a check to ensure
| 7 |
| Maintainability |
Extract the process start configuration into a separate method to improve readability and maintainabilityTo improve readability and maintainability, consider extracting the process start dotnet/test/common/Environment/TestWebServer.cs [68-75]
Suggestion importance[1-10]: 7Why: Extracting the process start configuration into a separate method is a good practice for improving the modularity and readability of the code, making it easier to manage and understand. | 7 |
| Enhancement |
Initialize the
| 6 |
| Best practice |
Use
| 4 |
It doesn't work on my side.
Message:
OneTimeSetUp: System.ArgumentNullException : Value cannot be null. (Parameter 'path1')
Stack Trace:
ArgumentNullException.Throw(String paramName)
Path.Combine(String path1, String path2, String path3)
TestWebServer.Start() line 80
AssemblyFixture.RunBeforeAnyTest() line 19
This is because this.javaHomeDirectory = System.Environment.GetEnvironmentVariable("JAVA_HOME"); - I don't have java installed on my machine, and honestly I don't want to install it.
The code in trunk works for me perfectly.
Good point, I thought it wasn't getting used if it wasn't needed, I'll recheck the flow.
My windows dev environment seems to have broken again. I'm still trying to debug locally.
After doing way too much work, apparently all that was needed was 6785daca6a92358b92635c5a221dfe9c7d937481