diff options
| author | Jack Koenig | 2020-08-12 21:17:14 -0700 |
|---|---|---|
| committer | GitHub | 2020-08-13 04:17:14 +0000 |
| commit | 39f510a9081d09d94d56eb89ceb97a678993fda1 (patch) | |
| tree | 02dcadb37c768d5763f6eae87b84b5aeeead6df1 /src/test | |
| parent | e1d3a0c64a48b4c9999ad59f15922db7c155c361 (diff) | |
Remove LegacyAnnotation and [most] MoultingYaml (#1833)
* Remove LegacyAnnotation and MoultingYaml
It has been deprecated since 1.1
* Remove all uses of ConvertLegacyAnnotations
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Diffstat (limited to 'src/test')
| -rw-r--r-- | src/test/resources/annotations/InvalidLegacyAnnotations.anno | 26 | ||||
| -rw-r--r-- | src/test/resources/annotations/LegacyAnnotations.anno | 50 | ||||
| -rw-r--r-- | src/test/resources/annotations/SampleAnnotations.anno | 30 | ||||
| -rw-r--r-- | src/test/scala/firrtlTests/AnnotationTests.scala | 46 | ||||
| -rw-r--r-- | src/test/scala/firrtlTests/DriverSpec.scala | 125 | ||||
| -rw-r--r-- | src/test/scala/firrtlTests/FileUtilsSpec.scala | 2 | ||||
| -rw-r--r-- | src/test/scala/firrtlTests/stage/FirrtlMainSpec.scala | 63 |
7 files changed, 1 insertions, 341 deletions
diff --git a/src/test/resources/annotations/InvalidLegacyAnnotations.anno b/src/test/resources/annotations/InvalidLegacyAnnotations.anno deleted file mode 100644 index 75bb3b96..00000000 --- a/src/test/resources/annotations/InvalidLegacyAnnotations.anno +++ /dev/null @@ -1,26 +0,0 @@ -- targetString: CircuitTop - transformClass: firrtl.VerilogEmitter - value: emitCircuit -- targetString: CircuitTop - transformClass: firrtl.VerilogEmitter - value: emitAllModules -- targetString: CircuitTop - transformClass: firrtl.Transform - value: emittedFirrtlCircuit:0 -- targetString: CircuitTop - transformClass: firrtl.Transform - value: emittedVerilogCircuit:0 -- targetString: CircuitTop - transformClass: firrtl.Transform - value: emittedFirrtlModule:0 -- targetString: CircuitTop - transformClass: firrtl.Transform - value: emittedVerilogModule:0 -- targetString: foo - transformClass: firrtl.Transform - value: | - DELETED by DeadCodeElimination - targetString: foo - transformClass: firrtl.passes.InlineInstances - value: '' - diff --git a/src/test/resources/annotations/LegacyAnnotations.anno b/src/test/resources/annotations/LegacyAnnotations.anno deleted file mode 100644 index 395fa56d..00000000 --- a/src/test/resources/annotations/LegacyAnnotations.anno +++ /dev/null @@ -1,50 +0,0 @@ -- targetString: foo - transformClass: firrtl.passes.InlineInstances - value: '' -- targetString: foo.bar - transformClass: firrtl.passes.clocklist.ClockListTransform - value: output -- targetString: foo - transformClass: firrtl.passes.memlib.InferReadWrite - value: '' -- targetString: foo - transformClass: firrtl.passes.memlib.ReplSeqMem - value: input output -- targetString: foo.bar.x - transformClass: firrtl.passes.memlib.ResolveMemoryReference - value: nodedupmem! -- targetString: foo.bar - transformClass: firrtl.transforms.DedupModules - value: nodedup! -- targetString: foo.bar.x - transformClass: firrtl.passes.wiring.WiringTransform - value: source pin -- targetString: foo.bar.x - transformClass: firrtl.passes.wiring.WiringTransform - value: sink pin -- targetString: foo.bar - transformClass: firrtl.transforms.BlackBoxSourceHelper - value: |- - resource - resource -- targetString: foo.bar - transformClass: firrtl.transforms.BlackBoxSourceHelper - value: |- - inline - name - text -- targetString: foo.bar - transformClass: firrtl.transforms.BlackBoxSourceHelper - value: |- - targetDir - targetdir -- targetString: CircuitTop - transformClass: firrtl.transforms.DeadCodeElimination - value: noDCE! -- targetString: foo.bar.x - transformClass: firrtl.Transform - value: DONTtouch! -- targetString: foo.bar - transformClass: firrtl.Transform - value: optimizableExtModule! - diff --git a/src/test/resources/annotations/SampleAnnotations.anno b/src/test/resources/annotations/SampleAnnotations.anno deleted file mode 100644 index 8fa9f44f..00000000 --- a/src/test/resources/annotations/SampleAnnotations.anno +++ /dev/null @@ -1,30 +0,0 @@ -- transformClass: firrtl.passes.InlineInstances - targetString: ModC - value: ModC.this params 16 32 -- transformClass: firrtl.passes.InlineInstances - targetString: ModC.io.out - value: ModuleC(16,32) width < 32 -- transformClass: firrtl.passes.InlineInstances - targetString: ModA - value: ModA.this -- transformClass: firrtl.passes.InlineInstances - targetString: ModA.io.out - value: inside ModA.io.out params 64,64 -- transformClass: firrtl.passes.InlineInstances - targetString: ModC_1 - value: ModC.this params 42 77 -- transformClass: firrtl.passes.InlineInstances - targetString: ModC_1.io.out - value: ModuleC(42,77) width < 77 -- transformClass: firrtl.passes.InlineInstances - targetString: ModB.io.out - value: inside ModB.io.out params 32,48 -- transformClass: firrtl.passes.InlineInstances - targetString: TopOfDiamond - value: |- - TopOfDiamond - With - Some new lines -- transformClass: firrtl.passes.InlineInstances - targetString: ModB.io.in - value: TopOfDiamond.moduleB.io.in diff --git a/src/test/scala/firrtlTests/AnnotationTests.scala b/src/test/scala/firrtlTests/AnnotationTests.scala index 2b347034..03131165 100644 --- a/src/test/scala/firrtlTests/AnnotationTests.scala +++ b/src/test/scala/firrtlTests/AnnotationTests.scala @@ -4,7 +4,6 @@ package firrtlTests import java.io.{File, FileWriter} -import firrtl.annotations.AnnotationYamlProtocol._ import firrtl.annotations._ import firrtl._ import firrtl.FileUtils @@ -13,7 +12,6 @@ import firrtl.passes.InlineAnnotation import firrtl.passes.memlib.PinAnnotation import firrtl.util.BackendCompilationUtilities import firrtl.testutils._ -import net.jcazevedo.moultingyaml._ import org.scalatest.matchers.should.Matchers /** @@ -472,50 +470,6 @@ abstract class AnnotationTests extends AnnotationSpec with Matchers { } } -class LegacyAnnotationTests extends AnnotationTests { - def anno(s: String, value: String ="this is a value", mod: String = "Top"): Annotation = - Annotation(ComponentName(s, ModuleName(mod, CircuitName("Top"))), classOf[Transform], value) - def manno(mod: String): Annotation = - Annotation(ModuleName(mod, CircuitName("Top")), classOf[Transform], "some value") - - "LegacyAnnotations" should "be readable from file" in { - val annotationsYaml = FileUtils.getTextResource("/annotations/SampleAnnotations.anno").parseYaml - val annotationArray = annotationsYaml.convertTo[Array[LegacyAnnotation]] - annotationArray.length should be (9) - annotationArray(0).targetString should be ("ModC") - annotationArray(7).transformClass should be ("firrtl.passes.InlineInstances") - val expectedValue = "TopOfDiamond\nWith\nSome new lines" - annotationArray(7).value should be (expectedValue) - } - - "Badly formatted LegacyAnnotation serializations" should "return reasonable error messages" in { - var badYaml = - """ - |- transformClass: firrtl.passes.InlineInstances - | targetString: circuit.module.. - | value: ModC.this params 16 32 - """.stripMargin.parseYaml - - var thrown = intercept[Exception] { - badYaml.convertTo[Array[LegacyAnnotation]] - } - thrown.getMessage should include ("Illegal component name") - - badYaml = - """ - |- transformClass: firrtl.passes.InlineInstances - | targetString: .circuit.module.component - | value: ModC.this params 16 32 - """.stripMargin.parseYaml - - thrown = intercept[Exception] { - badYaml.convertTo[Array[LegacyAnnotation]] - } - thrown.getMessage should include ("Illegal circuit name") - } - -} - class JsonAnnotationTests extends AnnotationTests with BackendCompilationUtilities { // Helper annotations case class SimpleAnno(target: ComponentName, value: String) extends diff --git a/src/test/scala/firrtlTests/DriverSpec.scala b/src/test/scala/firrtlTests/DriverSpec.scala index 92381e8c..400bf314 100644 --- a/src/test/scala/firrtlTests/DriverSpec.scala +++ b/src/test/scala/firrtlTests/DriverSpec.scala @@ -209,131 +209,6 @@ class DriverSpec extends AnyFreeSpec with Matchers with BackendCompilationUtilit } } - // Deprecated - "Annotations can be read implicitly from the name of the circuit" - { - val input = """|circuit foo : - | module foo : - | input x : UInt<8> - | output y : UInt<8> - | y <= x""".stripMargin - val top = "foo" - val optionsManager = new ExecutionOptionsManager("test") with HasFirrtlOptions { - commonOptions = commonOptions.copy(topName = top) - 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) - val annos = Driver.getAnnotations(optionsManager) - 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) - Driver.execute(optionsManager) match { - case r: FirrtlExecutionSuccess => - val annos = r.circuitState.annotations - annos.count(_.isInstanceOf[InlineAnnotation]) should be(9) - } - annoFile.delete() - vFile.delete() - } - } - - // Deprecated - "Annotations can be read using annotationFileNameOverride" in { - val optionsManager = new ExecutionOptionsManager("test") with HasFirrtlOptions { - commonOptions = commonOptions.copy(topName = "a.fir") - firrtlOptions = firrtlOptions.copy( - annotationFileNameOverride = "SampleAnnotations" - ) - } - val annotationsTestFile = new File(optionsManager.commonOptions.targetDirName, optionsManager.firrtlOptions.annotationFileNameOverride + ".anno") - copyResourceToFile("/annotations/SampleAnnotations.anno", annotationsTestFile) - optionsManager.firrtlOptions.annotations.length should be(0) - val annos = Driver.getAnnotations(optionsManager) - annos.length should be(12) // 9 from circuit plus 3 general purpose - annos.count(_.isInstanceOf[InlineAnnotation]) should be(9) - annotationsTestFile.delete() - } - - // Deprecated - "Supported LegacyAnnotations will be converted automagically" in { - val testDir = createTestDirectory("test") - val annoFilename = "LegacyAnnotations.anno" - val annotationsTestFile = new File(testDir, annoFilename) - val optionsManager = new ExecutionOptionsManager("test") with HasFirrtlOptions { - commonOptions = commonOptions.copy(topName = "test", targetDirName = testDir.toString) - firrtlOptions = firrtlOptions.copy( - annotationFileNames = List(annotationsTestFile.toString) - ) - } - copyResourceToFile(s"/annotations/$annoFilename", annotationsTestFile) - val annos = Driver.getAnnotations(optionsManager) - - val cname = CircuitName("foo") - val mname = ModuleName("bar", cname) - val compname = ComponentName("x", mname) - import firrtl.passes.clocklist._ - import firrtl.passes.memlib._ - import firrtl.passes.wiring._ - import firrtl.transforms._ - val expected = List( - InlineAnnotation(cname), - ClockListAnnotation(mname, "output"), - InferReadWriteAnnotation, - ReplSeqMemAnnotation("input", "output"), - NoDedupMemAnnotation(compname), - NoDedupAnnotation(mname), - SourceAnnotation(compname, "pin"), - SinkAnnotation(compname, "pin"), - BlackBoxResourceAnno(mname, "resource"), - BlackBoxInlineAnno(mname, "name", "text"), - BlackBoxTargetDirAnno("targetdir"), - NoDCEAnnotation, - DontTouchAnnotation(compname), - OptimizableExtModuleAnnotation(mname) - ) - for (e <- expected) { - annos should contain(e) - } - } - - // Deprecated - "UNsupported LegacyAnnotations should throw errors" in { - val testDir = createTestDirectory("test") - val annoFilename = "InvalidLegacyAnnotations.anno" - val annotationsTestFile = new File(testDir, annoFilename) - copyResourceToFile(s"/annotations/$annoFilename", annotationsTestFile) - - import net.jcazevedo.moultingyaml._ - val text = FileUtils.getText(annotationsTestFile) - val yamlAnnos = text.parseYaml match { - case YamlArray(xs) => xs - } - - // Since each one should error, emit each one to an anno file and try to read it - for ((anno, i) <- yamlAnnos.zipWithIndex) { - val annoFile = new File(testDir, s"anno_$i.anno") - val fw = new FileWriter(annoFile) - fw.write(YamlArray(anno).prettyPrint) - fw.close() - val optionsManager = new ExecutionOptionsManager("test") with HasFirrtlOptions { - commonOptions = commonOptions.copy(topName = "test", targetDirName = testDir.toString) - firrtlOptions = firrtlOptions.copy( - annotationFileNames = List(annoFile.toString) - ) - } - (the[Exception] thrownBy { - Driver.getAnnotations(optionsManager) - }).getMessage should include("Old-style annotations") - } - } - "Annotations can be read from multiple files" in { val filename = "SampleAnnotations.anno.json" val optionsManager = new ExecutionOptionsManager("test") with HasFirrtlOptions { diff --git a/src/test/scala/firrtlTests/FileUtilsSpec.scala b/src/test/scala/firrtlTests/FileUtilsSpec.scala index 7b643e84..43d35048 100644 --- a/src/test/scala/firrtlTests/FileUtilsSpec.scala +++ b/src/test/scala/firrtlTests/FileUtilsSpec.scala @@ -9,7 +9,7 @@ import org.scalatest.matchers.should.Matchers class FileUtilsSpec extends AnyFlatSpec with Matchers { - private val sampleAnnotations: String = "annotations/SampleAnnotations.anno" + private val sampleAnnotations: String = "annotations/SampleAnnotations.anno.json" private val sampleAnnotationsFileName: String = s"src/test/resources/$sampleAnnotations" behavior of "FileUtils.getLines" diff --git a/src/test/scala/firrtlTests/stage/FirrtlMainSpec.scala b/src/test/scala/firrtlTests/stage/FirrtlMainSpec.scala index 5c8f1129..1b4a1375 100644 --- a/src/test/scala/firrtlTests/stage/FirrtlMainSpec.scala +++ b/src/test/scala/firrtlTests/stage/FirrtlMainSpec.scala @@ -304,69 +304,6 @@ class FirrtlMainSpec extends AnyFeatureSpec with GivenWhenThen with Matchers wit * behavior. */ - Scenario("User tries to use an implicit annotation file") { - val f = new FirrtlMainFixture - val td = new TargetDirectoryFixture("implict-annotation-file") - val circuit = new SimpleFirrtlCircuitFixture - - And("implicit legacy and extant annotation files") - val annoFiles = Array( (new File(td.dir + "/Top.anno"), "/annotations/SampleAnnotations.anno"), - (new File(td.dir + "/Top.anno.json"), "/annotations/SampleAnnotations.anno.json") ) - annoFiles.foreach{ case (file, source) => copyResourceToFile(source, file) } - - When("the user implies an annotation file (an annotation file has the same base name as an input file)") - val in = new File(td.dir + "/Top.fir") - val pw = new PrintWriter(in) - pw.write(circuit.input) - pw.close() - val (out, _, result) = grabStdOutErr{ catchStatus { f.stage.main(Array("-td", td.dir.toString, - "-i", in.toString, - "-foaf", "Top.out", - "-X", "high", - "-E", "high")) } } - - Then("the implicit annotation file should NOT be read") - val annoFileOut = new File(td.dir + "/Top.out.anno.json") - val annotationJson = FileUtils.getText(annoFileOut) - annotationJson should not include ("InlineInstances") - - And("no warning should be printed") - out should not include ("Warning:") - - And("no error should be printed") - out should not include ("Error:") - - And("the exit code should be 0") - result shouldBe a [Right[_,_]] - } - - Scenario("User provides unsupported legacy annotations") { - val f = new FirrtlMainFixture - val td = new TargetDirectoryFixture("legacy-annotation-file") - val circuit = new SimpleFirrtlCircuitFixture - - And("a legacy annotation file") - val annoFile = new File(td.dir + "/legacy.anno") - copyResourceToFile("/annotations/SampleAnnotations.anno", annoFile) - - When("the user provides legacy annotations") - val in = new File(td.dir + "/Top.fir") - val pw = new PrintWriter(in) - pw.write(circuit.input) - pw.close() - val (out, _, result) = grabStdOutErr{ catchStatus { f.stage.main(Array("-td", td.dir.toString, - "-i", in.toString, - "-faf", annoFile.toString, - "-foaf", "Top", - "-X", "high")) } } - - Then("a warning should be printed") - out should include ("YAML Annotation files are deprecated") - - And("the exit code should be 0") - result shouldBe a [Right[_,_]] - } - Seq( /* Erroneous inputs */ FirrtlMainTest(args = Array("--thisIsNotASupportedOption"), |
