fix path problem

This commit is contained in:
Grahame Grieve 2023-04-21 12:25:10 +08:00
parent 4d94a064a7
commit 81b3295f3c
1 changed files with 11 additions and 1 deletions

View File

@ -44,7 +44,7 @@ public class CompareUtilities extends BaseTestingUtilities {
public static String checkXMLIsSame(String expected, String actual) throws Exception {
String result = compareXml(expected, actual);
if (result != null && SHOW_DIFF) {
String diff = FhirSettings.hasDiffToolPath() ? FhirSettings.getDiffToolPath() : Utilities.path(System.getenv("ProgramFiles"), "WinMerge", "WinMergeU.exe");
String diff = getDiffTool();
if (new File(diff).exists() || Utilities.isToken(diff)) {
Runtime.getRuntime().exec(new String[]{diff, expected, actual});
}
@ -52,6 +52,16 @@ public class CompareUtilities extends BaseTestingUtilities {
return result;
}
private static String getDiffTool() throws IOException {
if (FhirSettings.hasDiffToolPath()) {
return FhirSettings.getDiffToolPath();
} else if (System.getenv("ProgramFiles") != null) {
return Utilities.path(System.getenv("ProgramFiles"), "WinMerge", "WinMergeU.exe");
} else {
return null;
}
}
private static String compareXml(InputStream expected, InputStream actual) throws Exception {
return compareElements("", loadXml(expected).getDocumentElement(), loadXml(actual).getDocumentElement());
}