diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/main/scala/chisel3/stage/ChiselAnnotations.scala | 2 | ||||
| -rw-r--r-- | src/test/scala/chiselTests/ChiselSpec.scala | 5 | ||||
| -rw-r--r-- | src/test/scala/chiselTests/OneHotMuxSpec.scala | 16 | ||||
| -rw-r--r-- | src/test/scala/chiselTests/stage/ChiselMainSpec.scala | 22 |
4 files changed, 36 insertions, 9 deletions
diff --git a/src/main/scala/chisel3/stage/ChiselAnnotations.scala b/src/main/scala/chisel3/stage/ChiselAnnotations.scala index bfce0e8d..11697d7d 100644 --- a/src/main/scala/chisel3/stage/ChiselAnnotations.scala +++ b/src/main/scala/chisel3/stage/ChiselAnnotations.scala @@ -52,7 +52,7 @@ case class ChiselGeneratorAnnotation(gen: () => RawModule) extends NoTargetAnnot } catch { case e @ (_: OptionsException | _: ChiselException) => throw e case e: Throwable => - throw new OptionsException(s"Exception thrown when elaborating ChiselGeneratorAnnotation", e) + throw new ChiselException(s"Exception thrown when elaborating ChiselGeneratorAnnotation", e) } } diff --git a/src/test/scala/chiselTests/ChiselSpec.scala b/src/test/scala/chiselTests/ChiselSpec.scala index 9af7e88f..be1b2d60 100644 --- a/src/test/scala/chiselTests/ChiselSpec.scala +++ b/src/test/scala/chiselTests/ChiselSpec.scala @@ -7,7 +7,6 @@ import org.scalatest.prop._ import org.scalacheck._ import chisel3._ import chisel3.testers._ -import firrtl.options.OptionsException import firrtl.{AnnotationSeq, CommonOptions, ExecutionOptionsManager, FirrtlExecutionFailure, FirrtlExecutionSuccess, HasFirrtlOptions} import firrtl.util.BackendCompilationUtilities import java.io.ByteArrayOutputStream @@ -100,7 +99,7 @@ class ChiselTestUtilitiesSpec extends ChiselFlatSpec { import org.scalatest.exceptions.TestFailedException // Who tests the testers? "assertKnownWidth" should "error when the expected width is wrong" in { - val caught = intercept[OptionsException] { + val caught = intercept[ChiselException] { assertKnownWidth(7) { Wire(UInt(8.W)) } @@ -123,7 +122,7 @@ class ChiselTestUtilitiesSpec extends ChiselFlatSpec { } "assertInferredWidth" should "error if the width is known" in { - val caught = intercept[OptionsException] { + val caught = intercept[ChiselException] { assertInferredWidth(8) { Wire(UInt(8.W)) } diff --git a/src/test/scala/chiselTests/OneHotMuxSpec.scala b/src/test/scala/chiselTests/OneHotMuxSpec.scala index 7476ebe2..e6c9add4 100644 --- a/src/test/scala/chiselTests/OneHotMuxSpec.scala +++ b/src/test/scala/chiselTests/OneHotMuxSpec.scala @@ -4,6 +4,7 @@ package chiselTests import chisel3._ import chisel3.experimental.FixedPoint +import chisel3.internal.ChiselException import chisel3.testers.BasicTester import chisel3.util.{Mux1H, UIntToOH} import org.scalatest._ @@ -31,23 +32,31 @@ class OneHotMuxSpec extends FreeSpec with Matchers with ChiselRunners { assertTesterPasses(new ParameterizedAggregateOneHotTester) } "simple one hot mux with all aggregates containing inferred width fixed values should NOT work" in { - intercept[ChiselException] { + intercept [ChiselException] { assertTesterPasses(new InferredWidthAggregateOneHotTester) } } "simple one hot mux with all fixed width bundles but with different bundles should Not work" in { - intercept[IllegalArgumentException] { + try { assertTesterPasses(new DifferentBundleOneHotTester) + } catch { + case a: ChiselException => a.getCause match { + case _: IllegalArgumentException => + } } } "UIntToOH with output width greater than 2^(input width)" in { assertTesterPasses(new UIntToOHTester) } "UIntToOH should not accept width of zero (until zero-width wires are fixed" in { - intercept[java.lang.IllegalArgumentException] { + try { assertTesterPasses(new BasicTester { val out = UIntToOH(0.U, 0) }) + } catch { + case a: ChiselException => a.getCause match { + case _: IllegalArgumentException => + } } } @@ -305,4 +314,3 @@ class UIntToOHTester extends BasicTester { stop() } - diff --git a/src/test/scala/chiselTests/stage/ChiselMainSpec.scala b/src/test/scala/chiselTests/stage/ChiselMainSpec.scala index 2b3b9c2c..f5b47982 100644 --- a/src/test/scala/chiselTests/stage/ChiselMainSpec.scala +++ b/src/test/scala/chiselTests/stage/ChiselMainSpec.scala @@ -25,6 +25,11 @@ object ChiselMainSpec { out := in } + /** A module that fails a requirement */ + class FailingRequirementModule extends RawModule { + require(false) + } + } case class TestClassAspect() extends InspectorAspect[RawModule] ({ @@ -128,7 +133,22 @@ class ChiselMainSpec extends FeatureSpec with GivenWhenThen with Matchers with c result = 1) ).foreach(runStageExpectFiles) } - feature("Aspect library") { + feature("Report properly trimmed stack traces") { + Seq( + ChiselMainTest(args = Array("-X", "low"), + generator = Some(classOf[FailingRequirementModule]), + stdout = Some("requirement failed"), + result = 1), + ChiselMainTest(args = Array("-X", "low", "--full-stacktrace"), + generator = Some(classOf[FailingRequirementModule]), + stdout = Some("chisel3.internal.ChiselException"), + result = 1) + ).foreach(runStageExpectFiles) + } + + info("As an aspect writer") + info("I write an aspect") + feature("Running aspects via the command line") { Seq( ChiselMainTest(args = Array( "-X", "high", "--with-aspect", "chiselTests.stage.TestClassAspect" ), generator = Some(classOf[SameTypesModule]), |
