elharo commented on code in PR #843:
URL: 
https://github.com/apache/maven-shade-plugin/pull/843#discussion_r3880446372


##########
src/test/java/org/apache/maven/plugins/shade/mojo/ShadeMojoParentPathTest.java:
##########
@@ -0,0 +1,56 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.maven.plugins.shade.mojo;
+
+import java.io.File;
+import java.nio.file.Files;
+
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.io.TempDir;
+
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+public class ShadeMojoParentPathTest {
+    @TempDir
+    File temporaryFolder;
+
+    @Test
+    public void matchingParentFilesKeepTheRelativePath() throws Exception {
+        File pom = new File(temporaryFolder, "pom.xml");
+        Files.write(pom.toPath(), "<project/>".getBytes("UTF-8"));
+        assertTrue(ShadeMojo.isSameFile(pom, pom));

Review Comment:
   This is a general issue in a lot of Maven projects. I should save this 
comment so I can copy and paste it in the future, or maybe make a blog post out 
of it because this comes up a lot. 
   
   Making the method non-private allows it to be easily reached for unit tests. 
However it doesn't guarantee that the code in question is actually reached by 
Maven, or that it's called in the way you expect. 
   
   An integration test should be able to test this without making anything 
non-private just for testing. If an integration test can't test this code, then 
it's very possible this code isn't needed at all.
   
   LLMs are usually pretty good at contributing integration tests for Maven, as 
long as you prompt them to do that. Otherwise they tend to default to bad 
habits and shortcuts they've learned from existing code like making methods 
non-private just for testing.



-- 
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]

Reply via email to