From 3d3bc2fb9cf602f289852267db1f2193893bf1e7 Mon Sep 17 00:00:00 2001 From: Schuyler Eldridge Date: Wed, 24 Oct 2018 14:36:05 -0400 Subject: 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 --- .../transforms/BlacklBoxSourceHelperSpec.scala | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) (limited to 'src/test') 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?") + } + +} -- cgit v1.2.3