From 54e67889f10b39323fb729808b8cd22b4c832910 Mon Sep 17 00:00:00 2001 From: chick Date: Thu, 1 Aug 2019 09:21:52 -0700 Subject: Followup to PR #1142 Fixes a threading bug in where lazy reading of file caused a problem for multithreaded access to the that was read. Changes all uses of io.Source to use new API getText getLines getTextResource getLinesResouce Make style to only import FileUtils and not its methods So code is more explicit as e.g. FileUtils.getText() --- src/test/scala/firrtlTests/AnnotationTests.scala | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/test/scala/firrtlTests/AnnotationTests.scala') diff --git a/src/test/scala/firrtlTests/AnnotationTests.scala b/src/test/scala/firrtlTests/AnnotationTests.scala index 6b492148..7b944470 100644 --- a/src/test/scala/firrtlTests/AnnotationTests.scala +++ b/src/test/scala/firrtlTests/AnnotationTests.scala @@ -7,6 +7,7 @@ import java.io.{File, FileWriter, Writer} import firrtl.annotations.AnnotationYamlProtocol._ import firrtl.annotations._ import firrtl._ +import firrtl.FileUtils import firrtl.transforms.OptimizableExtModuleAnnotation import firrtl.passes.InlineAnnotation import firrtl.passes.memlib.PinAnnotation @@ -472,8 +473,7 @@ class LegacyAnnotationTests extends AnnotationTests { Annotation(ModuleName(mod, CircuitName("Top")), classOf[Transform], "some value") "LegacyAnnotations" should "be readable from file" in { - val annotationStream = getClass.getResourceAsStream("/annotations/SampleAnnotations.anno") - val annotationsYaml = scala.io.Source.fromInputStream(annotationStream).getLines().mkString("\n").parseYaml + 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") @@ -538,7 +538,7 @@ class JsonAnnotationTests extends AnnotationTests with BackendCompilationUtiliti writer.write(JsonProtocol.serialize(annos)) writer.close() - val text = io.Source.fromFile(annoFile).getLines().mkString("\n") + val text = FileUtils.getText(annoFile) annoFile.delete() val readAnnos = JsonProtocol.deserializeTry(text).get -- cgit v1.2.3