From 96432a0866df298d7feac269f468063d1f74bfdf Mon Sep 17 00:00:00 2001 From: Fabio Zadrozny Date: Sun, 6 Oct 2024 21:26:41 -0300 Subject: [PATCH] Add auto-resolution for TEST_PYDEV_BASE_LOC in TestDependent and add a basis for mac os. --- .../org/python/pydev/core/TestDependent.java | 16 +++++++++++++++- .../pydev/core/TestDependent.mac.properties | 3 +++ 2 files changed, 18 insertions(+), 1 deletion(-) create mode 100644 plugins/org.python.pydev.core/tests/org/python/pydev/core/TestDependent.mac.properties diff --git a/plugins/org.python.pydev.core/tests/org/python/pydev/core/TestDependent.java b/plugins/org.python.pydev.core/tests/org/python/pydev/core/TestDependent.java index 3e4c948374..6a6d9e47f4 100644 --- a/plugins/org.python.pydev.core/tests/org/python/pydev/core/TestDependent.java +++ b/plugins/org.python.pydev.core/tests/org/python/pydev/core/TestDependent.java @@ -177,7 +177,21 @@ public static boolean isUnix() { } if (TEST_PYDEV_BASE_LOC == null) { - System.err.println("TEST_PYDEV_BASE_LOC variable MUST be set in " + propertiesFile + " to run tests."); + File file = new File(TestDependent.class.getProtectionDomain().getCodeSource().getLocation().getPath()); + + // File is something as Pydev/plugins/org.python.pydev.core + // We want something as: Pydev/plugins/ + file = file.getParentFile(); + if (new File(file, "org.python.pydev.core").exists()) { + TEST_PYDEV_BASE_LOC = file.toString().replace("\\", "/"); + if (!TEST_PYDEV_BASE_LOC.endsWith("/")) { + TEST_PYDEV_BASE_LOC += '/'; + } + } else { + System.err.println( + "TEST_PYDEV_BASE_LOC variable MUST be set in " + propertiesFile + " to run tests."); + } + } else if (!new File(TEST_PYDEV_BASE_LOC).exists()) { System.err.println("TEST_PYDEV_BASE_LOC variable points to path that does NOT exist: " + TEST_PYDEV_BASE_LOC); diff --git a/plugins/org.python.pydev.core/tests/org/python/pydev/core/TestDependent.mac.properties b/plugins/org.python.pydev.core/tests/org/python/pydev/core/TestDependent.mac.properties new file mode 100644 index 0000000000..80dc2f21a0 --- /dev/null +++ b/plugins/org.python.pydev.core/tests/org/python/pydev/core/TestDependent.mac.properties @@ -0,0 +1,3 @@ + +PYTHON_INSTALL = /Users/fabioz/Desktop/conda/miniconda3/envs/py311/ +PYTHON_EXE = /Users/fabioz/Desktop/conda/miniconda3/envs/py311/bin/python