Skip to content

Commit

Permalink
Fix tests on Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
fmeum committed Oct 15, 2022
1 parent 8d96a87 commit 41a8cd5
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 4 deletions.
5 changes: 4 additions & 1 deletion src/test/java/com/github/johnynek/jarjar/integration/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,8 @@ java_test(
srcs = ["DuplicateClassTest.java"],
data = ["duplicate_class.jar"],
test_class = "com.github.johnynek.jarjar.integration.DuplicateClassTest",
deps = [":base"],
deps = [
":base",
"@bazel_tools//tools/java/runfiles",
],
)
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.github.johnynek.jarjar.integration;


import com.google.devtools.build.runfiles.Runfiles;
import org.junit.Test;
import java.util.Map;
import java.util.List;
Expand All @@ -16,9 +17,13 @@

public class DuplicateClassTest extends IntegrationTestBase {

private static final String DUPLICATE_CLASSES_JAR =
"com_github_johnynek_bazel_jar_jar/src/test/java/com/github/johnynek/jarjar/integration/duplicate_class.jar";

@Test
public void testErrorOnDuplicateClasses() throws Exception {
File duplicateClassJar = new File("src/test/java/com/github/johnynek/jarjar/integration/duplicate_class.jar");
Runfiles runfiles = Runfiles.create();
File duplicateClassJar = new File(runfiles.rlocation(DUPLICATE_CLASSES_JAR));
assertTrue("Test is misconfigured if we can't find this", duplicateClassJar.exists());

try {
Expand All @@ -34,7 +39,8 @@ public void testErrorOnDuplicateClasses() throws Exception {

@Test
public void ignoreDuplicateClasses() throws Exception {
File duplicateClassJar = new File("src/test/java/com/github/johnynek/jarjar/integration/duplicate_class.jar");
Runfiles runfiles = Runfiles.create();
File duplicateClassJar = new File(runfiles.rlocation(DUPLICATE_CLASSES_JAR));
assertTrue("Test is misconfigured if we can't find this", duplicateClassJar.exists());

File shaded = shadeJar(duplicateClassJar, new HashMap<String, String>() {{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ protected File shadeJar(File jarFile, Map<String, String> jarjarArgs, String[] r
* @param fullyQualifiedName The fully qualified classname of the java class should use.
*/
protected String basicJavaFile(String fullyQualifiedName) {
fullyQualifiedName = fullyQualifiedName.replaceAll("[.]", File.separator);
fullyQualifiedName = fullyQualifiedName.replace('.', File.separatorChar);

String packageName = null;
String className = null;
Expand Down

0 comments on commit 41a8cd5

Please # to comment.