Skip to content

Commit cfc15f4

Browse files
committed
Properly close file
Otherwise, we encounter the following error on windows: java.nio.file.FileSystemException: out\rewrites\i8982\rewrites\i8982\i8982.scala: The process cannot access the file because it is being used by another process. at sun.nio.fs.WindowsException.translateToIOException(WindowsException.java:86) at sun.nio.fs.WindowsException.rethrowAsIOException(WindowsException.java:97) at sun.nio.fs.WindowsException.rethrowAsIOException(WindowsException.java:102) at sun.nio.fs.WindowsFileSystemProvider.implDelete(WindowsFileSystemProvider.java:269) at sun.nio.fs.AbstractFileSystemProvider.delete(AbstractFileSystemProvider.java:103) at java.nio.file.Files.delete(Files.java:1126) at dotty.tools.vulpix.ParallelTesting$CompilationTest.delete(ParallelTesting.scala:1061) at dotty.tools.vulpix.ParallelTesting$CompilationTest.delete$$anonfun$2(ParallelTesting.scala:1060) at dotty.runtime.function.JProcedure1.apply(JProcedure1.java:15) at dotty.runtime.function.JProcedure1.apply(JProcedure1.java:10) at scala.collection.ArrayOps$.foreach$extension(ArrayOps.scala:1323) at dotty.tools.vulpix.ParallelTesting$CompilationTest.delete(ParallelTesting.scala:1060) at dotty.tools.vulpix.ParallelTesting$CompilationTest.delete$$anonfun$1(ParallelTesting.scala:1057) at dotty.runtime.function.JProcedure1.apply(JProcedure1.java:15) at dotty.runtime.function.JProcedure1.apply(JProcedure1.java:10) at scala.collection.immutable.List.foreach(List.scala:333) at dotty.tools.vulpix.ParallelTesting$CompilationTest.delete(ParallelTesting.scala:1057) at dotty.tools.vulpix.ParallelTesting$CompilationTest.cleanup(ParallelTesting.scala:985) at dotty.tools.vulpix.ParallelTesting$CompilationTest.checkCompile(ParallelTesting.scala:892) at dotty.tools.vulpix.ParallelTesting$RewriteTest.verifyOutput(ParallelTesting.scala:614) at dotty.tools.vulpix.ParallelTesting$RewriteTest.onSuccess(ParallelTesting.scala:618) at dotty.tools.vulpix.ParallelTesting$CompilationLogic.dotty$tools$vulpix$ParallelTesting$CompilationLogic$$onComplete(ParallelTesting.scala:275) at dotty.tools.vulpix.ParallelTesting$$anon$2.checkTestSource$$anonfun$1(ParallelTesting.scala:264) at dotty.runtime.function.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.java:12) at dotty.tools.vulpix.ParallelTesting$Test.tryCompile(ParallelTesting.scala:431) at dotty.tools.vulpix.ParallelTesting$$anon$2.checkTestSource(ParallelTesting.scala:266) at dotty.tools.vulpix.ParallelTesting$Test$LoggedRunnable.run(ParallelTesting.scala:334) at dotty.tools.vulpix.ParallelTesting$Test$LoggedRunnable.run$(ParallelTesting.scala:316) at dotty.tools.vulpix.ParallelTesting$$anon$2.run(ParallelTesting.scala:261)
1 parent 4f9d7c0 commit cfc15f4

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

compiler/test/dotty/tools/vulpix/ParallelTesting.scala

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -606,7 +606,12 @@ trait ParallelTesting extends RunnerOrchestration { self =>
606606
testSource.sourceFiles.foreach { file =>
607607
if checkFiles.contains(file) then
608608
val checkFile = checkFiles(file)
609-
val actual = Source.fromFile(file, "UTF-8").getLines().toList
609+
val actual = {
610+
val source = Source.fromFile(file, "UTF-8")
611+
val lines = source.getLines().toList
612+
source.close()
613+
lines
614+
}
610615
diffTest(testSource, checkFile, actual, reporters, logger)
611616
}
612617

0 commit comments

Comments
 (0)