Skip to content

I've added support for the CLASSPATH environment variable in InferCon… #323

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

georgewfraser
Copy link
Owner

…fig.

This change modifies the InferConfig class to allow the Java language server to determine the project's classpath using the CLASSPATH environment variable.

Key changes:

  • The classPath() method in InferConfig.java now checks for the CLASSPATH environment variable first. If set, its value is parsed and used as the classpath. This allows you to override the default classpath discovery mechanisms (Maven, Bazel).
  • InferConfig.java was refactored to allow injection of environment variables for testing purposes. This involved adding a new constructor that accepts a map of environment variables and updating methods that access environment variables to use this injected map.
  • A new unit test, classpathFromEnvironmentVariable, was added to InferConfigTest.java to specifically verify the new functionality. This test uses the new constructor to inject a mock CLASSPATH variable.

All tests in InferConfigTest.java, including the new test, pass.

Note: During testing, I observed three pre-existing test failures in other classes (CompletionsTest.overloadedOnClassPath, FindSrcZipTest.testFindSrcZip, HoverTest.docString). These failures are believed to be unrelated to the changes in this commit and should be investigated separately.

…fig.

This change modifies the `InferConfig` class to allow the Java language server
to determine the project's classpath using the `CLASSPATH` environment
variable.

Key changes:
- The `classPath()` method in `InferConfig.java` now checks for the
  `CLASSPATH` environment variable first. If set, its value is parsed and
  used as the classpath. This allows you to override the default
  classpath discovery mechanisms (Maven, Bazel).
- `InferConfig.java` was refactored to allow injection of environment
  variables for testing purposes. This involved adding a new constructor
  that accepts a map of environment variables and updating methods that
  access environment variables to use this injected map.
- A new unit test, `classpathFromEnvironmentVariable`, was added to
  `InferConfigTest.java` to specifically verify the new functionality.
  This test uses the new constructor to inject a mock `CLASSPATH`
  variable.

All tests in `InferConfigTest.java`, including the new test, pass.

Note: During testing, I observed three pre-existing test failures in
other classes (`CompletionsTest.overloadedOnClassPath`,
`FindSrcZipTest.testFindSrcZip`, `HoverTest.docString`). These failures
are believed to be unrelated to the changes in this commit and should be
investigated separately.
@alepekhin
Copy link

alepekhin commented May 24, 2025

Tests seem not independent. I mentioned it at #313
In this branch all tests passed for me

[INFO] Results:
[INFO]
[WARNING] Tests run: 227, Failures: 0, Errors: 0, Skipped: 10

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.

2 participants