Copilot commented on code in PR #268:
URL:
https://github.com/apache/maven-source-plugin/pull/268#discussion_r3413477145
##########
src/test/java/org/apache/maven/plugins/source/TestSourceJarMojoTest.java:
##########
@@ -138,18 +140,17 @@ InternalSession createSession() {
InternalSession session =
SessionMock.getMockSession("target/local-repo");
ProjectManager projectManager = mock(ProjectManager.class);
when(session.getService(ProjectManager.class)).thenReturn(projectManager);
- when(projectManager.getCompileSourceRoots(any(),
eq(ProjectScope.TEST))).thenAnswer(iom -> {
- Project p = iom.getArgument(0, Project.class);
- return Collections.singletonList(
-
Paths.get(getBasedir()).resolve(p.getModel().getBuild().getTestSourceDirectory()));
- });
- when(projectManager.getResources(any(),
eq(ProjectScope.TEST))).thenAnswer(iom -> {
- Project p = iom.getArgument(0, Project.class);
- return p.getBuild().getTestResources().stream()
- .map(r -> r.withDirectory(
-
Paths.get(getBasedir()).resolve(r.getDirectory()).toString()))
- .toList();
- });
+ when(projectManager.getEnabledSourceRoots(any(),
eq(ProjectScope.TEST), any()))
+ .thenAnswer(iom -> {
+ Project p = iom.getArgument(0, Project.class);
+ DefaultSourceRoot sourceRoot = new DefaultSourceRoot(
+ ProjectScope.MAIN,
+ Language.JAVA_FAMILY,
+ Paths.get(getBasedir())
+
.resolve(p.getModel().getBuild().getTestSourceDirectory()));
Review Comment:
In this test-session stub for `ProjectScope.TEST`, the `DefaultSourceRoot`
is created with `ProjectScope.MAIN`. That makes the stub internally
inconsistent and can hide bugs if code starts relying on the `SourceRoot`'s
scope metadata (e.g., filtering).
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]