Changes for debugging on OSX (fhir-tools-settings.conf)
This commit is contained in:
parent
0fa757b426
commit
76ed4abba7
|
@ -21,6 +21,7 @@ import org.hl7.fhir.r5.context.TerminologyCache;
|
|||
import org.hl7.fhir.r5.model.Parameters;
|
||||
import org.hl7.fhir.utilities.CSFile;
|
||||
import org.hl7.fhir.utilities.TextFile;
|
||||
import org.hl7.fhir.utilities.ToolGlobalSettings;
|
||||
import org.hl7.fhir.utilities.Utilities;
|
||||
import org.hl7.fhir.utilities.VersionUtilities;
|
||||
import org.hl7.fhir.utilities.npm.FilesystemPackageCacheManager;
|
||||
|
@ -164,14 +165,10 @@ public class TestingUtilities extends BaseTestingUtilities {
|
|||
public static String checkXMLIsSame(String f1, String f2) throws Exception {
|
||||
String result = compareXml(f1, f2);
|
||||
if (result != null && SHOW_DIFF) {
|
||||
String diff = Utilities.path(System.getenv("ProgramFiles"), "WinMerge", "WinMergeU.exe");
|
||||
if (new File(diff).exists()) {
|
||||
String diff = ToolGlobalSettings.hasComparePath() ? ToolGlobalSettings.getComparePath() : Utilities.path(System.getenv("ProgramFiles"), "WinMerge", "WinMergeU.exe");
|
||||
if (new File(diff).exists() || Utilities.isToken(diff)) {
|
||||
List<String> command = new ArrayList<String>();
|
||||
command.add("\"" + diff + "\" \"" + f1 + "\" \"" + f2 + "\"");
|
||||
|
||||
ProcessBuilder builder = new ProcessBuilder(command);
|
||||
builder.directory(new CSFile("c:\\temp"));
|
||||
builder.start();
|
||||
Process p = Runtime.getRuntime().exec(new String[]{diff, f1, f2});
|
||||
}
|
||||
}
|
||||
return result;
|
||||
|
@ -490,6 +487,8 @@ public class TestingUtilities extends BaseTestingUtilities {
|
|||
String path = Utilities.path("C:\\temp", name);
|
||||
Utilities.createDirectory(path);
|
||||
return path;
|
||||
} else if (ToolGlobalSettings.hasTempPath()) {
|
||||
return ToolGlobalSettings.getTempPath();
|
||||
} else if (new File("/tmp").exists()) {
|
||||
String path = Utilities.path("/tmp", name);
|
||||
Utilities.createDirectory(path);
|
||||
|
|
|
@ -0,0 +1,70 @@
|
|||
package org.hl7.fhir.utilities;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
public class ToolGlobalSettings {
|
||||
|
||||
private static boolean inited = false;
|
||||
|
||||
private static String npmPath;
|
||||
private static String rubyPath;
|
||||
private static String testsPath;
|
||||
private static String comparePath;
|
||||
private static String tempPath;
|
||||
|
||||
public static String getNpmPath() {
|
||||
init();
|
||||
return npmPath;
|
||||
}
|
||||
public static String getRubyPath() {
|
||||
init();
|
||||
return rubyPath;
|
||||
}
|
||||
public static String getTestsPath() {
|
||||
init();
|
||||
return testsPath;
|
||||
}
|
||||
|
||||
public static boolean hasNpmPath() {
|
||||
init();
|
||||
return npmPath != null;
|
||||
}
|
||||
public static boolean hasRubyPath() {
|
||||
init();
|
||||
return rubyPath != null;
|
||||
}
|
||||
public static boolean hasTestsPath() {
|
||||
init();
|
||||
return testsPath != null;
|
||||
}
|
||||
|
||||
public static String getComparePath() {
|
||||
return comparePath;
|
||||
}
|
||||
public static boolean hasComparePath() {
|
||||
return comparePath != null;
|
||||
}
|
||||
public static String getTempPath() {
|
||||
return tempPath;
|
||||
}
|
||||
public static boolean hasTempPath() {
|
||||
return tempPath != null;
|
||||
}
|
||||
private static void init() {
|
||||
if (!inited) {
|
||||
inited = true;
|
||||
IniFile ini;
|
||||
try {
|
||||
ini = new IniFile(Utilities.path(Utilities.path(System.getProperty("user.home"), ".fhir", "fhir-tool-settings.conf")));
|
||||
if (ini.hasSection("paths")) {
|
||||
npmPath = ini.getStringProperty("paths", "npm");
|
||||
rubyPath = ini.getStringProperty("paths", "ruby");
|
||||
testsPath = ini.getStringProperty("paths", "tests");
|
||||
comparePath = ini.getStringProperty("paths", "compare");
|
||||
tempPath = ini.getStringProperty("paths", "temp");
|
||||
}
|
||||
} catch (IOException e) {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -596,6 +596,8 @@ public class Utilities {
|
|||
if ("[tmp]".equals(a)) {
|
||||
if (hasCTempDir()) {
|
||||
a = "c:\\temp";
|
||||
} else if (ToolGlobalSettings.hasTempPath()) {
|
||||
a = ToolGlobalSettings.getTempPath();
|
||||
} else {
|
||||
a = System.getProperty("java.io.tmpdir");
|
||||
}
|
||||
|
|
|
@ -626,12 +626,12 @@ public class FilesystemPackageCacheManager extends BasePackageCacheManager imple
|
|||
JsonObject json = JsonTrackingParser.fetchJson(Utilities.pathURL(url, "package.manifest.json"));
|
||||
String currDate = JSONUtil.str(json, "date");
|
||||
String packDate = p.date();
|
||||
if (!currDate.equals(packDate))
|
||||
if (!currDate.equals(packDate)) {
|
||||
return null; // nup, we need a new copy
|
||||
return p;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
return p;
|
||||
}
|
||||
return p;
|
||||
}
|
||||
|
||||
private boolean checkBuildLoaded() {
|
||||
|
|
|
@ -3,6 +3,7 @@ package org.hl7.fhir.utilities.tests;
|
|||
import org.apache.commons.io.IOUtils;
|
||||
import org.hl7.fhir.utilities.CSFile;
|
||||
import org.hl7.fhir.utilities.TextFile;
|
||||
import org.hl7.fhir.utilities.ToolGlobalSettings;
|
||||
import org.hl7.fhir.utilities.Utilities;
|
||||
|
||||
import java.io.*;
|
||||
|
@ -22,7 +23,11 @@ public class BaseTestingUtilities {
|
|||
* the name of the project directory to something other than 'fhir-test-cases', or move it to another location, not
|
||||
* at the same directory level as the core project.
|
||||
*/
|
||||
|
||||
String dir = System.getenv("FHIR-TEST-CASES");
|
||||
if (dir == null && ToolGlobalSettings.hasTestsPath()) {
|
||||
dir = ToolGlobalSettings.getTestsPath();
|
||||
}
|
||||
if (dir != null && new CSFile(dir).exists()) {
|
||||
String n = Utilities.path(dir, Utilities.path(paths));
|
||||
// ok, we'll resolve this locally
|
||||
|
@ -44,6 +49,9 @@ public class BaseTestingUtilities {
|
|||
|
||||
public static InputStream loadTestResourceStream(String... paths) throws IOException {
|
||||
String dir = System.getenv("FHIR-TEST-CASES");
|
||||
if (dir == null && ToolGlobalSettings.hasTestsPath()) {
|
||||
dir = ToolGlobalSettings.getTestsPath();
|
||||
}
|
||||
if (dir != null && new File(dir).exists()) {
|
||||
String n = Utilities.path(dir, Utilities.path(paths));
|
||||
return new FileInputStream(n);
|
||||
|
@ -59,6 +67,9 @@ public class BaseTestingUtilities {
|
|||
|
||||
public static byte[] loadTestResourceBytes(String... paths) throws IOException {
|
||||
String dir = System.getenv("FHIR-TEST-CASES");
|
||||
if (dir == null && ToolGlobalSettings.hasTestsPath()) {
|
||||
dir = ToolGlobalSettings.getTestsPath();
|
||||
}
|
||||
if (dir != null && new File(dir).exists()) {
|
||||
String n = Utilities.path(dir, Utilities.path(paths));
|
||||
return TextFile.fileToBytes(n);
|
||||
|
@ -74,6 +85,9 @@ public class BaseTestingUtilities {
|
|||
|
||||
public static boolean findTestResource(String... paths) throws IOException {
|
||||
String dir = System.getenv("FHIR-TEST-CASES");
|
||||
if (dir == null && ToolGlobalSettings.hasTestsPath()) {
|
||||
dir = ToolGlobalSettings.getTestsPath();
|
||||
}
|
||||
if (dir != null && new File(dir).exists()) {
|
||||
String n = Utilities.path(dir, Utilities.path(paths));
|
||||
return new File(n).exists();
|
||||
|
|
Loading…
Reference in New Issue