summaryrefslogtreecommitdiffstats
path: root/jack-tests/tests/com
diff options
context:
space:
mode:
authorBenoit Lamarche <benoitlamarche@google.com>2015-03-27 18:37:40 +0100
committerBenoit Lamarche <benoitlamarche@google.com>2015-03-27 19:08:23 +0100
commit4ba4b36dad979d3e43b6cee7dffb90bd035acd0f (patch)
treec27095b3eded81e09942ad3bc803a2ab0d828ed9 /jack-tests/tests/com
parentb60deac3d08ace3cd053d1cc51c68aba18c57294 (diff)
downloadtoolchain_jack-4ba4b36dad979d3e43b6cee7dffb90bd035acd0f.tar.gz
toolchain_jack-4ba4b36dad979d3e43b6cee7dffb90bd035acd0f.tar.bz2
toolchain_jack-4ba4b36dad979d3e43b6cee7dffb90bd035acd0f.zip
Small changes around Jayce-related exceptions
Bug: 19787495 Change-Id: I40f9c10404544ee1455d4996a91d64f72089570c
Diffstat (limited to 'jack-tests/tests/com')
-rw-r--r--jack-tests/tests/com/android/jack/error/ErrorHandlingAllTests.java2
-rw-r--r--jack-tests/tests/com/android/jack/error/FileAccessErrorTest.java5
-rw-r--r--jack-tests/tests/com/android/jack/error/JayceFormatErrorTest.java (renamed from jack-tests/tests/com/android/jack/error/JackFormatErrorTest.java)41
3 files changed, 22 insertions, 26 deletions
diff --git a/jack-tests/tests/com/android/jack/error/ErrorHandlingAllTests.java b/jack-tests/tests/com/android/jack/error/ErrorHandlingAllTests.java
index f459d7a4..d58ca334 100644
--- a/jack-tests/tests/com/android/jack/error/ErrorHandlingAllTests.java
+++ b/jack-tests/tests/com/android/jack/error/ErrorHandlingAllTests.java
@@ -27,7 +27,7 @@ value = {
ConfigErrorTest.class,
ErrorTest.class,
FileAccessErrorTest.class,
- JackFormatErrorTest.class,
+ JayceFormatErrorTest.class,
SourceErrorTest.class
})
public class ErrorHandlingAllTests {
diff --git a/jack-tests/tests/com/android/jack/error/FileAccessErrorTest.java b/jack-tests/tests/com/android/jack/error/FileAccessErrorTest.java
index 259bf6a0..2268a95e 100644
--- a/jack-tests/tests/com/android/jack/error/FileAccessErrorTest.java
+++ b/jack-tests/tests/com/android/jack/error/FileAccessErrorTest.java
@@ -203,8 +203,9 @@ public class FileAccessErrorTest {
Assert.assertTrue(e.getCause().getCause() instanceof LibraryIOException);
} finally {
String errOutput = errOut.toString();
- Assert.assertTrue(errOutput.contains("is an invalid library"));
- Assert.assertTrue(errOutput.contains("is not readable"));
+ Assert.assertTrue(errOutput.contains(
+ "Error during the library reading phase: I/O error when accessing ")); // user reporting
+ Assert.assertTrue(errOutput.contains("is not readable")); // user reporting too
for (File jackFile : AbstractTestTools.getFiles(te.getJackFolder(), JayceFileImporter.JAYCE_FILE_EXTENSION)) {
if (!jackFile.setReadable(true)) {
Assert.fail("Fails to change file permissions of " + jackFile.getAbsolutePath());
diff --git a/jack-tests/tests/com/android/jack/error/JackFormatErrorTest.java b/jack-tests/tests/com/android/jack/error/JayceFormatErrorTest.java
index 9af3c449..f670a0b7 100644
--- a/jack-tests/tests/com/android/jack/error/JackFormatErrorTest.java
+++ b/jack-tests/tests/com/android/jack/error/JayceFormatErrorTest.java
@@ -38,9 +38,9 @@ import java.io.ByteArrayOutputStream;
import java.io.File;
/**
- * JUnit test checking Jack behavior on exceptions.
+ * Test checking the behavior of Jack with an invalid Jayce format.
*/
-public class JackFormatErrorTest {
+public class JayceFormatErrorTest {
@BeforeClass
public static void setUpClass() {
@@ -48,10 +48,10 @@ public class JackFormatErrorTest {
}
/**
- * Checks that compilation fails correctly when jayce file is corrupted.
+ * Checks that compilation fails correctly when a jayce file is corrupted.
*/
@Test
- public void testJackFormatError001() throws Exception {
+ public void testJayceFormatError() throws Exception {
ErrorTestHelper helper = new ErrorTestHelper();
AbstractTestTools.createFile(new File(helper.getJackFolder(), FileType.JAYCE.getPrefix()), "jack.incremental",
@@ -73,8 +73,6 @@ public class JackFormatErrorTest {
JackApiToolchainBase toolchain =
AbstractTestTools.getCandidateToolchain(JackApiToolchainBase.class);
- toolchain.setVerbose(true);
-
ByteArrayOutputStream errOut = new ByteArrayOutputStream();
toolchain.setErrorStream(errOut);
@@ -84,21 +82,21 @@ public class JackFormatErrorTest {
.srcToExe(helper.getOutputDexFolder(), /* zipFile= */ false, helper.getSourceFolder());
Assert.fail();
} catch (JackAbortException e) {
- // Failure is ok since jack file is corrupted.
+ // Failure is OK since a jayce file is corrupted.
Assert.assertTrue(e.getCause() instanceof LibraryReadingException);
Assert.assertTrue(e.getCause().getCause() instanceof LibraryFormatException);
} finally {
- Assert.assertTrue(errOut.toString().contains("is an invalid library"));
+ Assert.assertTrue(errOut.toString().contains("is an invalid library")); // user reporting
Assert.assertTrue(errOut.toString().contains(
- "Unexpected node NForStatement, NDeclaredType was expected"));
+ "Unexpected node NForStatement, NDeclaredType was expected")); // system log
}
}
/**
- * Checks that compilation fails correctly when jack file header is corrupted.
+ * Checks that compilation fails correctly when a Jayce file header is corrupted.
*/
@Test
- public void testJackFormatError002() throws Exception {
+ public void testJayceHeaderError() throws Exception {
ErrorTestHelper helper = new ErrorTestHelper();
AbstractTestTools.createFile(new File(helper.getJackFolder(), FileType.JAYCE.getPrefix()), "jack.incremental",
@@ -120,8 +118,6 @@ public class JackFormatErrorTest {
JackApiToolchainBase toolchain =
AbstractTestTools.getCandidateToolchain(JackApiToolchainBase.class);
- toolchain.setVerbose(true);
-
ByteArrayOutputStream errOut = new ByteArrayOutputStream();
toolchain.setErrorStream(errOut);
@@ -131,20 +127,21 @@ public class JackFormatErrorTest {
.srcToExe(helper.getOutputDexFolder(), /* zipFile= */ false, helper.getSourceFolder());
Assert.fail();
} catch (JackAbortException e) {
- // Failure is ok since jack file header is corrupted.
+ // Failure is OK since a jayce file header is corrupted.
Assert.assertTrue(e.getCause() instanceof LibraryReadingException);
Assert.assertTrue(e.getCause().getCause() instanceof LibraryFormatException);
} finally {
- Assert.assertTrue(errOut.toString().contains("is an invalid library"));
- Assert.assertTrue(errOut.toString().contains("Invalid Jayce header"));
+ Assert.assertTrue(errOut.toString().contains("is an invalid library")); // user reporting
+ Assert.assertTrue(errOut.toString().contains("Invalid Jayce header")); // system log
}
}
/**
- * Checks that compilation fails correctly when jack file is not longer supported.
+ * Checks that compilation fails correctly with a Jack library containing an invalid Jayce format
+ * version on classpath.
*/
@Test
- public void testJackFormatError003() throws Exception {
+ public void testJayceVersionError() throws Exception {
ErrorTestHelper helper = new ErrorTestHelper();
AbstractTestTools.createFile(new File(helper.getJackFolder(), FileType.JAYCE.getPrefix()),
@@ -166,8 +163,6 @@ public class JackFormatErrorTest {
JackApiToolchainBase toolchain =
AbstractTestTools.getCandidateToolchain(JackApiToolchainBase.class);
- toolchain.setVerbose(true);
-
ByteArrayOutputStream errOut = new ByteArrayOutputStream();
toolchain.setErrorStream(errOut);
@@ -177,12 +172,12 @@ public class JackFormatErrorTest {
.srcToExe(helper.getOutputDexFolder(), /* zipFile= */ false, helper.getSourceFolder());
Assert.fail();
} catch (JackAbortException e) {
- // Failure is ok since jack file header is corrupted.
+ // Failure is OK since Jayce format version 0 is not supported.
Assert.assertTrue(e.getCause() instanceof LibraryReadingException);
Assert.assertTrue(e.getCause().getCause() instanceof LibraryFormatException);
} finally {
- Assert.assertTrue(errOut.toString().contains("is an invalid library"));
- Assert.assertTrue(errOut.toString().contains("Jayce version 0 not supported"));
+ Assert.assertTrue(errOut.toString().contains("is an invalid library")); // user reporting
+ Assert.assertTrue(errOut.toString().contains("Jayce version 0 not supported")); // system log
}
}
}