Support running classes from specific Gradle source sets in Gradle actions#8897
Conversation
d05fc28 to
d632d1b
Compare
|
the LSP |
|
I tried running the same tests on the |
the LSP job does run when a PR is merged, it seems to work on master https://github.com/apache/netbeans/actions?query=branch%3Amaster, last success was 4h ago |
|
|
I will try to check then more on the tests. Thanks much for verifying it. |
|
I was looking at the test. The test is testing the DAP client, by running the The reason why the test fails is, I think, this: the test does not specify any There are multiple aspects to this:
|
|
@lahodaj, thank you so much for looking into it. I also believe that using |
| "file", FileUtil.toFile(testFile).getAbsolutePath(), | ||
| "classPaths", List.of("any"))) | ||
| "classPaths", List.of("any"), | ||
| "testRun", false)) |
There was a problem hiding this comment.
Does this change mean the behaviour of the service has changed in an incompatible way ?
There was a problem hiding this comment.
Earlier, the logic checked if a file wasn’t a test file by trying to find the source of the root file of that test file. If no source was found, it would assume the file was a mainSource: true. However, this approach was a bit hacky for determining whether a file is a mainClass. As a result, in some cases, files inside the test sources that were actually mainClass files were incorrectly classified as test files, causing tests to run instead of executing the mainClass.
The new approach uses sourceCP directly to check whether a file is a mainClass.
However, since indexing wasn’t run in the tests scenario , it fails to identify mainClass files correctly in the failing test scenarios.
If there are any changes required in the changed behaviour, please let me know.
There was a problem hiding this comment.
I suspect the current proposed state goes a little bit too far. Unless there's a proof the given class is a main class/has a main method, it will use the test actions to run the file. As I said, I don't know what is the state with Gradle, but for other project types, this is likely to fail, as they don't support test actions outside of the test roots.
I suspect a hybrid approach would work better: for stuff outside of test roots, use the non-test actions. For stuff in test roots, look at whether the given class has a main method.
There was a problem hiding this comment.
Sorry, I didn’t understand your comment at first, @lahodaj. I’ve now made the changes according to your suggestions.
7ef4048 to
653c8eb
Compare
…ebug action didn't work, fixed that
653c8eb to
7d33f32
Compare
lahodaj
left a comment
There was a problem hiding this comment.
NbLaunchDelegate seems good to me now. Thanks!
When a
mainClassis defined in a source set other thanmainin a Gradle project, the NetBeans Gradle action was unable to run or debug that class. This has been fixed by introducing a new project configuration parameter,runSourceSetName, similar torunSelectedClassName.Additionally, in the LSP launch configuration, specifying a
mainClassfrom a non-mainsource set inlaunch.jsonpreviously caused it to run as if it were part of the test source set. This behavior has been corrected so that the specifiedmainClassis now executed properly instead of running tests.Before fix:
After fix:
Related issue: oracle/javavscode#353