aboutsummaryrefslogtreecommitdiff
path: root/src/test/scala/firrtlTests/options/phases
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
parentb516293f703c4de86397862fee1897aded2ae140 (diff)
All of src/ formatted with scalafmt
Diffstat (limited to 'src/test/scala/firrtlTests/options/phases')
-rw-r--r--src/test/scala/firrtlTests/options/phases/AddDefaultsSpec.scala7
-rw-r--r--src/test/scala/firrtlTests/options/phases/ChecksSpec.scala5
-rw-r--r--src/test/scala/firrtlTests/options/phases/GetIncludesSpec.scala30
-rw-r--r--src/test/scala/firrtlTests/options/phases/WriteOutputAnnotationsSpec.scala83
4 files changed, 68 insertions, 57 deletions
diff --git a/src/test/scala/firrtlTests/options/phases/AddDefaultsSpec.scala b/src/test/scala/firrtlTests/options/phases/AddDefaultsSpec.scala
index 3401a408..f625f991 100644
--- a/src/test/scala/firrtlTests/options/phases/AddDefaultsSpec.scala
+++ b/src/test/scala/firrtlTests/options/phases/AddDefaultsSpec.scala
@@ -2,7 +2,6 @@
package firrtlTests.options.phases
-
import firrtl.options.{Phase, TargetDirAnnotation}
import firrtl.options.phases.AddDefaults
import org.scalatest.flatspec.AnyFlatSpec
@@ -16,13 +15,13 @@ class AddDefaultsSpec extends AnyFlatSpec with Matchers {
val defaultDir = TargetDirAnnotation(".")
}
- behavior of classOf[AddDefaults].toString
+ behavior.of(classOf[AddDefaults].toString)
it should "add a TargetDirAnnotation if it does not exist" in new Fixture {
- phase.transform(Seq.empty).toSeq should be (Seq(defaultDir))
+ phase.transform(Seq.empty).toSeq should be(Seq(defaultDir))
}
it should "don't add a TargetDirAnnotation if it exists" in new Fixture {
- phase.transform(Seq(targetDir)).toSeq should be (Seq(targetDir))
+ phase.transform(Seq(targetDir)).toSeq should be(Seq(targetDir))
}
}
diff --git a/src/test/scala/firrtlTests/options/phases/ChecksSpec.scala b/src/test/scala/firrtlTests/options/phases/ChecksSpec.scala
index 96d6569d..62afed94 100644
--- a/src/test/scala/firrtlTests/options/phases/ChecksSpec.scala
+++ b/src/test/scala/firrtlTests/options/phases/ChecksSpec.scala
@@ -2,7 +2,6 @@
package firrtlTests.options.phases
-
import firrtl.AnnotationSeq
import firrtl.options.{OptionsException, OutputAnnotationFileAnnotation, Phase, TargetDirAnnotation}
import firrtl.options.phases.Checks
@@ -20,9 +19,9 @@ class ChecksSpec extends AnyFlatSpec with Matchers {
val min = Seq(targetDir)
def checkExceptionMessage(phase: Phase, annotations: AnnotationSeq, messageStart: String): Unit =
- intercept[OptionsException]{ phase.transform(annotations) }.getMessage should startWith(messageStart)
+ intercept[OptionsException] { phase.transform(annotations) }.getMessage should startWith(messageStart)
- behavior of classOf[Checks].toString
+ behavior.of(classOf[Checks].toString)
it should "enforce exactly one TargetDirAnnotation" in new Fixture {
info("0 target directories throws an exception")
diff --git a/src/test/scala/firrtlTests/options/phases/GetIncludesSpec.scala b/src/test/scala/firrtlTests/options/phases/GetIncludesSpec.scala
index 7d20ac89..95c2a435 100644
--- a/src/test/scala/firrtlTests/options/phases/GetIncludesSpec.scala
+++ b/src/test/scala/firrtlTests/options/phases/GetIncludesSpec.scala
@@ -2,12 +2,10 @@
package firrtlTests.options.phases
-
import java.io.{File, PrintWriter}
import firrtl.AnnotationSeq
-import firrtl.annotations.{AnnotationFileNotFoundException, JsonProtocol,
- NoTargetAnnotation}
+import firrtl.annotations.{AnnotationFileNotFoundException, JsonProtocol, NoTargetAnnotation}
import firrtl.options.phases.GetIncludes
import firrtl.options.{InputAnnotationFileAnnotation, Phase}
import firrtl.util.BackendCompilationUtilities
@@ -29,10 +27,10 @@ class GetIncludesSpec extends AnyFlatSpec with Matchers with BackendCompilationU
def checkAnnos(a: AnnotationSeq, b: AnnotationSeq): Unit = {
info("read the expected number of annotations")
- a.size should be (b.size)
+ a.size should be(b.size)
info("annotations match exact order")
- a.zip(b).foreach{ case (ax, bx) => ax should be (bx) }
+ a.zip(b).foreach { case (ax, bx) => ax should be(bx) }
}
val files = Seq(
@@ -43,19 +41,21 @@ class GetIncludesSpec extends AnyFlatSpec with Matchers with BackendCompilationU
new File(dir + "/e.anno.json") -> Seq(E)
)
- files.foreach{ case (file, annotations) =>
- val pw = new PrintWriter(file)
- pw.write(JsonProtocol.serialize(annotations))
- pw.close()
+ files.foreach {
+ case (file, annotations) =>
+ val pw = new PrintWriter(file)
+ pw.write(JsonProtocol.serialize(annotations))
+ pw.close()
}
class Fixture { val phase: Phase = new GetIncludes }
- behavior of classOf[GetIncludes].toString
+ behavior.of(classOf[GetIncludes].toString)
it should "throw an exception if the annotation file doesn't exit" in new Fixture {
- intercept[AnnotationFileNotFoundException]{ phase.transform(Seq(ref("f"))) }
- .getMessage should startWith("Annotation file")
+ intercept[AnnotationFileNotFoundException] { phase.transform(Seq(ref("f"))) }.getMessage should startWith(
+ "Annotation file"
+ )
}
it should "read annotations from a file" in new Fixture {
@@ -75,9 +75,9 @@ class GetIncludesSpec extends AnyFlatSpec with Matchers with BackendCompilationU
checkAnnos(out, expect)
- Seq("d", "e").foreach{ x =>
+ Seq("d", "e").foreach { x =>
info(s"a warning about '$x.anno.json' was printed")
- stdout should include (s"Warning: Annotation file ($dir/$x.anno.json) already included!")
+ stdout should include(s"Warning: Annotation file ($dir/$x.anno.json) already included!")
}
}
@@ -90,7 +90,7 @@ class GetIncludesSpec extends AnyFlatSpec with Matchers with BackendCompilationU
checkAnnos(out, expect)
info("a warning about 'a.anno.json' was printed")
- stdout should include (s"Warning: Annotation file ($dir/a.anno.json)")
+ stdout should include(s"Warning: Annotation file ($dir/a.anno.json)")
}
}
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")
}
}