diff options
| author | Schuyler Eldridge | 2018-12-04 01:35:48 -0500 |
|---|---|---|
| committer | Schuyler Eldridge | 2019-04-25 16:24:15 -0400 |
| commit | 254e7909f6c9d155f514664584f142566f0a6799 (patch) | |
| tree | fb2cdc32f8a37f8fc74cbf92ef79ee33240cc96c /src/test/scala/firrtlTests/DriverSpec.scala | |
| parent | b2dd0eb845081609d0aec4a873587ab3f22fe3f7 (diff) | |
Add tests for Annotations/Options refactor
- Add tests for DriverCompatibility.AddImplicitEmitter
- Add tests for DriverCompatibility.AddImplicitOutputFile
- Use a different top name in DriverSpec emit circuit tests for better
coverage
- Add tests for DriverCompatibility.WriteEmitted
- Add catchWrites firrtlTests utility to intercept file writes
- Add tests for WriteOutputAnnotations
- Add tests for --custom-transforms reversing
Signed-off-by: Schuyler Eldridge <schuyler.eldridge@ibm.com>
Diffstat (limited to 'src/test/scala/firrtlTests/DriverSpec.scala')
| -rw-r--r-- | src/test/scala/firrtlTests/DriverSpec.scala | 38 |
1 files changed, 25 insertions, 13 deletions
diff --git a/src/test/scala/firrtlTests/DriverSpec.scala b/src/test/scala/firrtlTests/DriverSpec.scala index d26aadf2..1cb991c8 100644 --- a/src/test/scala/firrtlTests/DriverSpec.scala +++ b/src/test/scala/firrtlTests/DriverSpec.scala @@ -218,6 +218,7 @@ class DriverSpec extends FreeSpec with Matchers with BackendCompilationUtilities firrtlOptions = firrtlOptions.copy(firrtlSource = Some(input)) } val annoFile = new File(optionsManager.commonOptions.targetDirName, top + ".anno") + val vFile = new File(optionsManager.commonOptions.targetDirName, top + ".v") "Using Driver.getAnnotations" in { copyResourceToFile("/annotations/SampleAnnotations.anno", annoFile) optionsManager.firrtlOptions.annotations.length should be(0) @@ -225,6 +226,7 @@ class DriverSpec extends FreeSpec with Matchers with BackendCompilationUtilities annos.length should be(12) // 9 from circuit plus 3 general purpose annos.count(_.isInstanceOf[InlineAnnotation]) should be(9) annoFile.delete() + vFile.delete() } "Using Driver.execute" in { copyResourceToFile("/annotations/SampleAnnotations.anno", annoFile) @@ -234,6 +236,7 @@ class DriverSpec extends FreeSpec with Matchers with BackendCompilationUtilities annos.count(_.isInstanceOf[InlineAnnotation]) should be(9) } annoFile.delete() + vFile.delete() } } @@ -384,20 +387,29 @@ class DriverSpec extends FreeSpec with Matchers with BackendCompilationUtilities "To a single file with file extension depending on the compiler by default" in { Seq( - "none" -> "./Top.fir", - "low" -> "./Top.lo.fir", - "high" -> "./Top.hi.fir", - "middle" -> "./Top.mid.fir", - "verilog" -> "./Top.v", - "mverilog" -> "./Top.v", - "sverilog" -> "./Top.sv" + "none" -> "./Foo.fir", + "low" -> "./Foo.lo.fir", + "high" -> "./Foo.hi.fir", + "middle" -> "./Foo.mid.fir", + "verilog" -> "./Foo.v", + "mverilog" -> "./Foo.v", + "sverilog" -> "./Foo.sv" ).foreach { case (compilerName, expectedOutputFileName) => + info(s"$compilerName -> $expectedOutputFileName") val manager = new ExecutionOptionsManager("test") with HasFirrtlOptions { - commonOptions = CommonOptions(topName = "Top") + commonOptions = CommonOptions(topName = "Foo") firrtlOptions = FirrtlExecutionOptions(firrtlSource = Some(input), compilerName = compilerName) } - firrtl.Driver.execute(manager) + firrtl.Driver.execute(manager) match { + case success: FirrtlExecutionSuccess => + success.emitted.size should not be (0) + success.circuitState.annotations.length should be > (0) + case a: FirrtlExecutionFailure => + fail(s"Got a FirrtlExecutionFailure! Expected FirrtlExecutionSuccess. Full message:\n${a.message}") + } + + val file = new File(expectedOutputFileName) file.exists() should be(true) @@ -414,9 +426,8 @@ class DriverSpec extends FreeSpec with Matchers with BackendCompilationUtilities "mverilog" -> Seq("./Top.v", "./Child.v"), "sverilog" -> Seq("./Top.sv", "./Child.sv") ).foreach { case (compilerName, expectedOutputFileNames) => - println(s"$compilerName -> $expectedOutputFileNames") + info(s"$compilerName -> $expectedOutputFileNames") val manager = new ExecutionOptionsManager("test") with HasFirrtlOptions { - commonOptions = CommonOptions(topName = "Top") firrtlOptions = FirrtlExecutionOptions(firrtlSource = Some(input), compilerName = compilerName, emitOneFilePerModule = true) @@ -424,9 +435,10 @@ class DriverSpec extends FreeSpec with Matchers with BackendCompilationUtilities firrtl.Driver.execute(manager) match { case success: FirrtlExecutionSuccess => + success.emitted.size should not be (0) success.circuitState.annotations.length should be > (0) - case _ => - + case failure: FirrtlExecutionFailure => + fail(s"Got a FirrtlExecutionFailure! Expected FirrtlExecutionSuccess. Full message:\n${failure.message}") } for (name <- expectedOutputFileNames) { |
