8077168: CodeStoreAndPathTest.java fails in jtreg mode on Mac
authormhaupt
Tue, 18 Aug 2015 09:13:46 -0700
changeset 32244 956c3ae61be6
parent 32243 422ccb5d8437
child 32245 80164edf8a10
8077168: CodeStoreAndPathTest.java fails in jtreg mode on Mac Summary: use correct path on JRT file system Reviewed-by: attila, sundar
nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/codegen/OptimisticTypesPersistence.java
nashorn/test/src/jdk/nashorn/internal/runtime/test/CodeStoreAndPathTest.java
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/codegen/OptimisticTypesPersistence.java	Tue Aug 18 18:53:13 2015 +0530
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/codegen/OptimisticTypesPersistence.java	Tue Aug 18 09:13:46 2015 -0700
@@ -398,7 +398,7 @@
         } else if(protocol.equals("jrt")) {
             return getJrtVersionDirName();
         } else {
-            throw new AssertionError();
+            throw new AssertionError("unknown protocol");
         }
     }
 
@@ -556,13 +556,15 @@
         return Math.max(0, Integer.parseInt(str));
     }
 
+    private static final String JRT_NASHORN_DIR = "/modules/jdk.scripting.nashorn";
+
     // version directory name if nashorn is loaded from jrt:/ URL
     private static String getJrtVersionDirName() throws Exception {
         final FileSystem fs = getJrtFileSystem();
         // consider all .class resources under nashorn module to compute checksum
-        final Path nashorn = fs.getPath("/jdk.scripting.nashorn");
+        final Path nashorn = fs.getPath(JRT_NASHORN_DIR);
         if (! Files.isDirectory(nashorn)) {
-            throw new FileNotFoundException("missing /jdk.scripting.nashorn dir in jrt fs");
+            throw new FileNotFoundException("missing " + JRT_NASHORN_DIR + " dir in jrt fs");
         }
         final MessageDigest digest = MessageDigest.getInstance("SHA-1");
         Files.walk(nashorn).forEach(new Consumer<Path>() {
--- a/nashorn/test/src/jdk/nashorn/internal/runtime/test/CodeStoreAndPathTest.java	Tue Aug 18 18:53:13 2015 +0530
+++ b/nashorn/test/src/jdk/nashorn/internal/runtime/test/CodeStoreAndPathTest.java	Tue Aug 18 09:13:46 2015 -0700
@@ -26,6 +26,7 @@
 
 import static org.testng.Assert.assertEquals;
 import static org.testng.Assert.assertFalse;
+import static org.testng.Assert.assertTrue;
 import java.io.File;
 import java.io.IOException;
 import java.nio.file.DirectoryStream;
@@ -38,7 +39,6 @@
 import org.testng.annotations.Test;
 
 /**
- * @ignore Fails with jtreg, but passes with ant test run. Ignore for now.
  * @test
  * @bug 8039185 8039403
  * @summary  Test for persistent code cache and path handling
@@ -113,7 +113,8 @@
         assertEquals(actualCodeCachePath, expectedCodeCachePath);
         // Check that code cache dir exists and it's not empty
         final File file = new File(actualCodeCachePath.toUri());
-        assertFalse(!file.isDirectory(), "No code cache directory was created!");
+        assertTrue(file.exists(), "No code cache directory was created!");
+        assertTrue(file.isDirectory(), "Code cache location is not a directory!");
         assertFalse(file.list().length == 0, "Code cache directory is empty!");
     }
 
@@ -174,7 +175,7 @@
                 return codeCachePath.resolve(file);
             }
         }
-        throw new AssertionError("Code cache path not found");
+        throw new AssertionError("Code cache path not found: " + codeCachePath.toString());
     }
 
     private static void checkCompiledScripts(final DirectoryStream<Path> stream, final int numberOfScripts) throws IOException {