From a9b079ac24ef96dce4d08a3860b03ca7f5730c32 Mon Sep 17 00:00:00 2001 From: Seth Tisue Date: Thu, 24 Sep 2015 21:59:27 -0400 Subject: fix bug in partest-extras causing test failures on Windows includes comment with full details --- src/partest-extras/scala/tools/partest/IcodeComparison.scala | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/partest-extras/scala/tools/partest/IcodeComparison.scala b/src/partest-extras/scala/tools/partest/IcodeComparison.scala index 7122703918..1430db886e 100644 --- a/src/partest-extras/scala/tools/partest/IcodeComparison.scala +++ b/src/partest-extras/scala/tools/partest/IcodeComparison.scala @@ -48,8 +48,13 @@ abstract class IcodeComparison extends DirectTest { compile("-d" :: testOutput.path :: arg0 :: args.toList : _*) val icodeFiles = testOutput.files.toList filter (_ hasExtension "icode") - try icodeFiles sortBy (_.name) flatMap (f => f.lines.toList) - finally icodeFiles foreach (f => f.delete()) + // Some methods in scala.reflect.io.File leak an InputStream, leaving the underlying file open. + // Windows won't delete an open file, but we must ensure the files get deleted, since the logic + // here depends on it (collectIcode will be called multiple times, and we can't allow crosstalk + // between calls). So we are careful to use `slurp` which does call `close`, and careful to + // check that `delete` returns true indicating successful deletion. + try icodeFiles sortBy (_.name) flatMap (f => f.slurp().lines.toList) + finally icodeFiles foreach (f => require(f.delete())) } /** Collect icode at the default phase, `printIcodeAfterPhase`. */ -- cgit v1.2.3