JAL-629 Fixed ~ based test for build server
authorBen Soares <b.soares@dundee.ac.uk>
Wed, 12 Apr 2023 13:41:23 +0000 (14:41 +0100)
committerBen Soares <b.soares@dundee.ac.uk>
Wed, 12 Apr 2023 13:41:23 +0000 (14:41 +0100)
test/jalview/util/FileUtilsTest.java

index d49fd4c..79c703f 100644 (file)
@@ -21,6 +21,7 @@
 package jalview.util;
 
 import java.io.File;
+import java.io.IOException;
 import java.util.List;
 
 import org.testng.Assert;
@@ -67,7 +68,7 @@ public class FileUtilsTest
     else if (where < 0)
       Assert.assertTrue(d.startsWith(dirname),
               "getDirname(" + file.getPath() + ")=" + d
-                      + " didn't start with '" + d + "'");
+                      + " didn't start with '" + dirname + "'");
     else if (where > 0)
       Assert.assertTrue(d.endsWith(dirname), "getDirname(" + file.getPath()
               + ")=" + d + " didn't end with '" + d + "'");
@@ -100,9 +101,18 @@ public class FileUtilsTest
   @DataProvider(name = "dirnamesAndBasenames")
   public Object[][] dirnamesAndBasenames()
   {
+    String homeDir = null;
+    try
+    {
+      homeDir = new File(System.getProperty("user.home"))
+              .getCanonicalPath();
+    } catch (IOException e)
+    {
+      System.err.println("Problem getting canonical home dir");
+      e.printStackTrace();
+    }
     return new Object[][] { // -1=startsWith, 0=equals, 1=endsWith
-        { "~/hello/sailor", -1, System.getProperty("user.home"), "sailor",
-            "~" }, //
+        { "~/hello/sailor", -1, homeDir, "sailor", "~" }, //
         { "~/hello/sailor", 1, "/hello", "sailor", "~" }, //
         { "./examples/uniref50.fa", -1, "/", "uniref50", null }, //
         { "./examples/uniref50.fa", 1, "/examples", "uniref50", null }, //