Skip to content

Commit 5b408f6

Browse files
authored
3.x: Fix source locator code to support GitHub Actions folder layout (#7113)
1 parent 78b29f7 commit 5b408f6

File tree

1 file changed

+18
-10
lines changed

1 file changed

+18
-10
lines changed

src/test/java/io/reactivex/rxjava3/testsupport/TestHelper.java

+18-10
Original file line numberDiff line numberDiff line change
@@ -3503,18 +3503,26 @@ public static File findSource(String baseClassName, String parentPackage) throws
35033503
parentPackage = parentPackage.replace(".", "/");
35043504
// System.out.println(path);
35053505

3506-
int i = path.toLowerCase().indexOf("/rxjava");
3507-
if (i < 0) {
3508-
System.out.println("Can't find the base RxJava directory");
3509-
return null;
3510-
}
3511-
3512-
// find end of any potential postfix to /RxJava
3513-
int j = path.indexOf("/", i + 6);
3506+
// Locate the src/main/java directory
3507+
String p = null;
3508+
while (true) {
3509+
int idx = path.lastIndexOf("/");
3510+
if (idx < 0) {
3511+
break;
3512+
}
3513+
path = path.substring(0, idx);
3514+
String check = path + "/src/main/java";
35143515

3515-
String basePackage = path.substring(0, j + 1) + "src/main/java";
3516+
if (new File(check).exists()) {
3517+
p = check + "/" + parentPackage + "/" + baseClassName + ".java";
3518+
break;
3519+
}
3520+
}
35163521

3517-
String p = basePackage + "/" + parentPackage + "/" + baseClassName + ".java";
3522+
if (p == null) {
3523+
System.err.println("Unable to locate the RxJava sources");
3524+
return null;
3525+
}
35183526

35193527
File f = new File(p);
35203528

0 commit comments

Comments
 (0)