diff --git a/approvaltests/src/main/java/org/approvaltests/reporters/DiffInfo.java b/approvaltests/src/main/java/org/approvaltests/reporters/DiffInfo.java index 73458675..0c74833d 100644 --- a/approvaltests/src/main/java/org/approvaltests/reporters/DiffInfo.java +++ b/approvaltests/src/main/java/org/approvaltests/reporters/DiffInfo.java @@ -64,6 +64,7 @@ public static String[] getProgramFilesPaths() paths.add(System.getenv("ProgramFiles(x86)")); paths.add(System.getenv("ProgramFiles")); paths.add(System.getenv("ProgramW6432")); + paths.add(System.getenv("LOCALAPPDATA") + "\\Programs"); return paths.stream().filter(Objects::nonNull).toArray(String[]::new); } public static class One diff --git a/approvaltests/src/main/java/org/approvaltests/reporters/IntelliJToolboxResolver.java b/approvaltests/src/main/java/org/approvaltests/reporters/IntelliJToolboxResolver.java index fab5d81f..869d3f45 100644 --- a/approvaltests/src/main/java/org/approvaltests/reporters/IntelliJToolboxResolver.java +++ b/approvaltests/src/main/java/org/approvaltests/reporters/IntelliJToolboxResolver.java @@ -23,6 +23,9 @@ public static DiffInfo findIt() if (!diffInfo.isEmpty()) { return diffInfo; } } + DiffInfo diffInfo = getDiffInfoWindows(DiffInfo.getProgramFilesPaths(), f -> new File(f).exists()); + if (!diffInfo.isEmpty()) + { return diffInfo; } return DiffInfo.getNull(); } public static DiffInfo getDiffInfoMac(String userHome, Function1 fileExists) @@ -31,28 +34,26 @@ public static DiffInfo getDiffInfoMac(String userHome, Function1 applications = as("/Applications", userHome + "/Applications"); String postfix = ".app/Contents/MacOS/idea"; - return getDiffInfo(fileExists, applications, locations, postfix); + return getDiffInfo(fileExists, applications, locations, postfix, "/"); } public static DiffInfo getDiffInfoLinux(String userHome, Function1 fileExists) { Queryable locations = as("intellij-idea-ultimate", "intellij-idea-community-edition"); Queryable applications = as(userHome + "/.local/share/JetBrains/Toolbox/apps"); String postfix = "/bin/idea.sh"; - return getDiffInfo(fileExists, applications, locations, postfix); - } - private static DiffInfo getDiffInfo(Function1 fileExists, Queryable locations, - Queryable applications, String postfix) - { - Queryable paths = locations.selectMany(a -> applications.select(l -> a + "/" + l + postfix)); - String matching = paths.first(fileExists); - return new DiffInfo(matching, "diff %s %s", GenericDiffReporter.TEXT_FILE_EXTENSIONS); + return getDiffInfo(fileExists, applications, locations, postfix, "/"); } public static DiffInfo getDiffInfoWindows(String[] programFiles, Function1 fileExists) { Queryable applications = as("IntelliJ IDEA Ultimate", "IntelliJ IDEA", "IntelliJ IDEA Community", "IntelliJ IDEA Community Edition"); Queryable locations = Queryable.as(programFiles); String postfix = "\\bin\\idea64.exe"; - Queryable paths = locations.selectMany(l -> applications.select(a -> l + "\\" + a + postfix)); + return getDiffInfo(fileExists, locations, applications, postfix, "\\"); + } + private static DiffInfo getDiffInfo(Function1 fileExists, Queryable locations, + Queryable applications, String postfix, String pathSeparator) + { + Queryable paths = locations.selectMany(l -> applications.select(a -> l + pathSeparator + a + postfix)); String matching = paths.first(fileExists); return new DiffInfo(matching, "diff %s %s", GenericDiffReporter.TEXT_FILE_EXTENSIONS); }