From 0ace0218d3151df2d102463dd682128a88ae7be6 Mon Sep 17 00:00:00 2001 From: Jack Koenig Date: Fri, 22 Feb 2019 13:59:33 -0800 Subject: Stop reporting exceptions in custom transformations as internal errors (#867) Instead, just forward the exception--- .../scala/firrtlTests/CustomTransformSpec.scala | 25 ++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'src/test/scala/firrtlTests/CustomTransformSpec.scala') diff --git a/src/test/scala/firrtlTests/CustomTransformSpec.scala b/src/test/scala/firrtlTests/CustomTransformSpec.scala index d1ff6fd1..1b0e8190 100644 --- a/src/test/scala/firrtlTests/CustomTransformSpec.scala +++ b/src/test/scala/firrtlTests/CustomTransformSpec.scala @@ -46,5 +46,30 @@ class CustomTransformSpec extends FirrtlFlatSpec { runFirrtlTest("CustomTransform", "/features", customTransforms = List(new ReplaceExtModuleTransform)) } + + they should "not cause \"Internal Errors\"" in { + val input = """ + |circuit test : + | module test : + | output out : UInt + | out <= UInt(123)""".stripMargin + val errorString = "My Custom Transform failed!" + class ErroringTransform extends Transform { + def inputForm = HighForm + def outputForm = HighForm + def execute(state: CircuitState): CircuitState = { + require(false, errorString) + state + } + } + val optionsManager = new ExecutionOptionsManager("test") with HasFirrtlOptions { + firrtlOptions = FirrtlExecutionOptions( + firrtlSource = Some(input), + customTransforms = List(new ErroringTransform)) + } + (the [java.lang.IllegalArgumentException] thrownBy { + Driver.execute(optionsManager) + }).getMessage should include (errorString) + } } -- cgit v1.2.3