aboutsummaryrefslogtreecommitdiff
path: root/src/test/scala/firrtlTests/options/phases/WriteOutputAnnotationsSpec.scala
diff options
context:
space:
mode:
authorchick2020-08-14 19:47:53 -0700
committerJack Koenig2020-08-14 19:47:53 -0700
commit6fc742bfaf5ee508a34189400a1a7dbffe3f1cac (patch)
tree2ed103ee80b0fba613c88a66af854ae9952610ce /src/test/scala/firrtlTests/options/phases/WriteOutputAnnotationsSpec.scala
parentb516293f703c4de86397862fee1897aded2ae140 (diff)
All of src/ formatted with scalafmt
Diffstat (limited to 'src/test/scala/firrtlTests/options/phases/WriteOutputAnnotationsSpec.scala')
-rw-r--r--src/test/scala/firrtlTests/options/phases/WriteOutputAnnotationsSpec.scala83
1 files changed, 48 insertions, 35 deletions
diff --git a/src/test/scala/firrtlTests/options/phases/WriteOutputAnnotationsSpec.scala b/src/test/scala/firrtlTests/options/phases/WriteOutputAnnotationsSpec.scala
index 0a3cce67..4fe16041 100644
--- a/src/test/scala/firrtlTests/options/phases/WriteOutputAnnotationsSpec.scala
+++ b/src/test/scala/firrtlTests/options/phases/WriteOutputAnnotationsSpec.scala
@@ -2,7 +2,6 @@
package firrtlTests.options.phases
-
import java.io.File
import firrtl.AnnotationSeq
@@ -15,7 +14,8 @@ import firrtl.options.{
PhaseException,
StageOptions,
TargetDirAnnotation,
- WriteDeletedAnnotation}
+ WriteDeletedAnnotation
+}
import firrtl.options.Viewer.view
import firrtl.options.phases.{GetIncludes, WriteOutputAnnotations}
import org.scalatest.flatspec.AnyFlatSpec
@@ -37,33 +37,38 @@ class WriteOutputAnnotationsSpec extends AnyFlatSpec with Matchers with firrtl.t
info(s"reading '$f' works")
val read = (new GetIncludes)
.transform(Seq(InputAnnotationFileAnnotation(f.toString)))
- .filterNot{
+ .filterNot {
case a @ DeletedAnnotation(_, _: InputAnnotationFileAnnotation) => true
- case _ => false }
+ case _ => false
+ }
info(s"annotations in file are expected size")
- read.size should be (a.size)
+ read.size should be(a.size)
read
.zip(a)
- .foreach{ case (read, expected) =>
- info(s"$read matches")
- read should be (expected) }
+ .foreach {
+ case (read, expected) =>
+ info(s"$read matches")
+ read should be(expected)
+ }
f.delete()
}
class Fixture { val phase: Phase = new WriteOutputAnnotations }
- behavior of classOf[WriteOutputAnnotations].toString
+ behavior.of(classOf[WriteOutputAnnotations].toString)
it should "write annotations to a file (excluding DeletedAnnotations)" in new Fixture {
val file = new File(dir + "/should-write-annotations-to-a-file.anno.json")
- val annotations = Seq( OutputAnnotationFileAnnotation(file.toString),
- WriteOutputAnnotationsSpec.FooAnnotation,
- WriteOutputAnnotationsSpec.BarAnnotation(0),
- WriteOutputAnnotationsSpec.BarAnnotation(1),
- DeletedAnnotation("foo", WriteOutputAnnotationsSpec.FooAnnotation) )
+ val annotations = Seq(
+ OutputAnnotationFileAnnotation(file.toString),
+ WriteOutputAnnotationsSpec.FooAnnotation,
+ WriteOutputAnnotationsSpec.BarAnnotation(0),
+ WriteOutputAnnotationsSpec.BarAnnotation(1),
+ DeletedAnnotation("foo", WriteOutputAnnotationsSpec.FooAnnotation)
+ )
val expected = annotations.filter {
case a: DeletedAnnotation => false
case a => true
@@ -71,31 +76,35 @@ class WriteOutputAnnotationsSpec extends AnyFlatSpec with Matchers with firrtl.t
val out = phase.transform(annotations)
info("annotations are unmodified")
- out.toSeq should be (annotations)
+ out.toSeq should be(annotations)
fileContainsAnnotations(file, expected)
}
it should "include DeletedAnnotations if a WriteDeletedAnnotation is present" in new Fixture {
val file = new File(dir + "should-include-deleted.anno.json")
- val annotations = Seq( OutputAnnotationFileAnnotation(file.toString),
- WriteOutputAnnotationsSpec.FooAnnotation,
- WriteOutputAnnotationsSpec.BarAnnotation(0),
- WriteOutputAnnotationsSpec.BarAnnotation(1),
- DeletedAnnotation("foo", WriteOutputAnnotationsSpec.FooAnnotation),
- WriteDeletedAnnotation )
+ val annotations = Seq(
+ OutputAnnotationFileAnnotation(file.toString),
+ WriteOutputAnnotationsSpec.FooAnnotation,
+ WriteOutputAnnotationsSpec.BarAnnotation(0),
+ WriteOutputAnnotationsSpec.BarAnnotation(1),
+ DeletedAnnotation("foo", WriteOutputAnnotationsSpec.FooAnnotation),
+ WriteDeletedAnnotation
+ )
val out = phase.transform(annotations)
info("annotations are unmodified")
- out.toSeq should be (annotations)
+ out.toSeq should be(annotations)
fileContainsAnnotations(file, annotations)
}
it should "do nothing if no output annotation file is specified" in new Fixture {
- val annotations = Seq( WriteOutputAnnotationsSpec.FooAnnotation,
- WriteOutputAnnotationsSpec.BarAnnotation(0),
- WriteOutputAnnotationsSpec.BarAnnotation(1) )
+ val annotations = Seq(
+ WriteOutputAnnotationsSpec.FooAnnotation,
+ WriteOutputAnnotationsSpec.BarAnnotation(0),
+ WriteOutputAnnotationsSpec.BarAnnotation(1)
+ )
val out = catchWrites { phase.transform(annotations) } match {
case Right(a) =>
@@ -106,14 +115,16 @@ class WriteOutputAnnotationsSpec extends AnyFlatSpec with Matchers with firrtl.t
}
info("annotations are unmodified")
- out.toSeq should be (annotations)
+ out.toSeq should be(annotations)
}
it should "write CustomFileEmission annotations" in new Fixture {
val file = new File("write-CustomFileEmission-annotations.anno.json")
- val annotations = Seq( TargetDirAnnotation(dir),
- OutputAnnotationFileAnnotation(file.toString),
- WriteOutputAnnotationsSpec.Custom("hello!") )
+ val annotations = Seq(
+ TargetDirAnnotation(dir),
+ OutputAnnotationFileAnnotation(file.toString),
+ WriteOutputAnnotationsSpec.Custom("hello!")
+ )
val serializedFileName = view[StageOptions](annotations).getBuildFileName("Custom", Some(".Emission"))
val expected = annotations.map {
case _: WriteOutputAnnotationsSpec.Custom => WriteOutputAnnotationsSpec.Replacement(serializedFileName)
@@ -123,7 +134,7 @@ class WriteOutputAnnotationsSpec extends AnyFlatSpec with Matchers with firrtl.t
val out = phase.transform(annotations)
info("annotations are unmodified")
- out.toSeq should be (annotations)
+ out.toSeq should be(annotations)
fileContainsAnnotations(new File(dir, file.toString), expected)
@@ -133,13 +144,15 @@ class WriteOutputAnnotationsSpec extends AnyFlatSpec with Matchers with firrtl.t
it should "error if multiple annotations try to write to the same file" in new Fixture {
val file = new File("write-CustomFileEmission-annotations-error.anno.json")
- val annotations = Seq( TargetDirAnnotation(dir),
- OutputAnnotationFileAnnotation(file.toString),
- WriteOutputAnnotationsSpec.Custom("foo"),
- WriteOutputAnnotationsSpec.Custom("bar") )
+ val annotations = Seq(
+ TargetDirAnnotation(dir),
+ OutputAnnotationFileAnnotation(file.toString),
+ WriteOutputAnnotationsSpec.Custom("foo"),
+ WriteOutputAnnotationsSpec.Custom("bar")
+ )
intercept[PhaseException] {
phase.transform(annotations)
- }.getMessage should startWith ("Multiple CustomFileEmission annotations")
+ }.getMessage should startWith("Multiple CustomFileEmission annotations")
}
}