aboutsummaryrefslogtreecommitdiff
path: root/src/test
diff options
context:
space:
mode:
authorSchuyler Eldridge2018-10-24 14:36:05 -0400
committerSchuyler Eldridge2018-10-24 18:58:02 -0400
commit3d3bc2fb9cf602f289852267db1f2193893bf1e7 (patch)
treebf9efdcd7e1c8fb50175686810531be07747e8a9 /src/test
parent69f9060f1439dae88146e850208148caf12bb059 (diff)
Better error message on missing BlackBox resource
This wraps interactions with a BlackBox resource file such that a FileNotFoundException are wrapped in a BlackBoxNotFoundException and rethrown. This provides a better, verbose error message to the user and avoids a FileNotFoundException showing up as an internal FIRRTL error. This adds tests that the expected exception is thrown for both BlackBoxResourceAnno and BlackBoxResourceAnno. Signed-off-by: Schuyler Eldridge <schuyler.eldridge@ibm.com>
Diffstat (limited to 'src/test')
-rw-r--r--src/test/scala/firrtlTests/transforms/BlacklBoxSourceHelperSpec.scala21
1 files changed, 20 insertions, 1 deletions
diff --git a/src/test/scala/firrtlTests/transforms/BlacklBoxSourceHelperSpec.scala b/src/test/scala/firrtlTests/transforms/BlacklBoxSourceHelperSpec.scala
index 7daebf21..c6918624 100644
--- a/src/test/scala/firrtlTests/transforms/BlacklBoxSourceHelperSpec.scala
+++ b/src/test/scala/firrtlTests/transforms/BlacklBoxSourceHelperSpec.scala
@@ -105,5 +105,24 @@ class BlacklBoxSourceHelperTransformSpec extends LowTransformSpec {
val verilogCompiler = new VerilogEmitter
verilogCompiler.transforms.map { x => x.getClass } should contain (classOf[BlackBoxSourceHelper])
}
-}
+ behavior of "BlackBox resources that do not exist"
+
+ it should "provide a useful error message for BlackBoxResourceAnno" in {
+ val annos = Seq( BlackBoxTargetDirAnno("test_run_dir"),
+ BlackBoxResourceAnno(moduleName, "/blackboxes/IDontExist.v") )
+
+ (the [BlackBoxNotFoundException] thrownBy { execute(input, "", annos) })
+ .getMessage should include ("Did you misspell it?")
+ }
+
+ it should "provide a useful error message for BlackBoxPathAnno" in {
+ val absPath = new java.io.File("src/test/resources/blackboxes/IDontExist.v").getCanonicalPath
+ val annos = Seq( BlackBoxTargetDirAnno("test_run_dir"),
+ BlackBoxPathAnno(moduleName, absPath) )
+
+ (the [BlackBoxNotFoundException] thrownBy { execute(input, "", annos) })
+ .getMessage should include ("Did you misspell it?")
+ }
+
+}