@@ -10,12 +10,10 @@ import dotty.tools.dotc.core.Mode
1010import dotty .tools .dotc .core .Names .Name
1111import dotty .tools .dotc .interfaces .Diagnostic .ERROR
1212import dotty .tools .dotc .reporting .TestReporter
13- import dotty .tools .IOUtils
13+ import dotty .tools .io .{ Directory , File , Path }
1414
1515import dotty .tools .vulpix .TestConfiguration
1616
17- import java .nio .file .{Files , Path }
18-
1917import org .junit .Test
2018import org .junit .Assert .{assertEquals , assertFalse , fail }
2119
@@ -81,25 +79,25 @@ class CommentPicklingTest {
8179 }
8280
8381 private def compileAndUnpickle [T ](sources : List [String ])(fn : (List [tpd.Tree ], Context ) => T ) = {
84- IOUtils .inTempDirectory { tmp =>
82+ Directory .inTempDirectory { tmp =>
8583 val sourceFiles = sources.zipWithIndex.map {
8684 case (src, id) =>
87- val path = tmp.resolve( s " Src $id.scala " ).toAbsolutePath
88- Files .write( path, src.getBytes( " UTF-8 " ) )
85+ val path = tmp./ ( File ( " Src$id.scala" )).toAbsolute
86+ path.writeAll(src )
8987 path.toString
9088 }
9189
92- val out = tmp.resolve (" out" )
93- Files .createDirectories(out )
90+ val out = tmp./ (" out" )
91+ out.createDirectory( )
9492
95- val options = compileOptions.and(" -d" , out.toAbsolutePath .toString).and(sourceFiles : _* )
93+ val options = compileOptions.and(" -d" , out.toAbsolute .toString).and(sourceFiles : _* )
9694 val reporter = TestReporter .reporter(System .out, logLevel = ERROR )
9795 Main .process(options.all, reporter)
9896 assertFalse(" Compilation failed." , reporter.hasErrors)
9997
100- val tastyFiles = IOUtils .getAll(tmp, " glob:**. tasty" )
98+ val tastyFiles = Path .onlyFiles(out.walkFilter(_.extension == " tasty" )).toList
10199 val unpicklingOptions = unpickleOptions
102- .withClasspath(out.toAbsolutePath .toString)
100+ .withClasspath(out.toAbsolute .toString)
103101 .and(" dummy" ) // Need to pass a dummy source file name
104102 val unpicklingDriver = new UnpicklingDriver
105103 unpicklingDriver.unpickle(unpicklingOptions.all, tastyFiles)(fn)
@@ -108,12 +106,11 @@ class CommentPicklingTest {
108106
109107 private class UnpicklingDriver extends Driver {
110108 override def initCtx = super .initCtx.addMode(Mode .ReadComments )
111- def unpickle [T ](args : Array [String ], paths : List [Path ])(fn : (List [tpd.Tree ], Context ) => T ): T = {
109+ def unpickle [T ](args : Array [String ], files : List [File ])(fn : (List [tpd.Tree ], Context ) => T ): T = {
112110 implicit val (_, ctx : Context ) = setup(args, initCtx)
113111 ctx.initialize()
114- val trees = paths.flatMap { p =>
115- val bytes = Files .readAllBytes(p)
116- val unpickler = new DottyUnpickler (bytes)
112+ val trees = files.flatMap { f =>
113+ val unpickler = new DottyUnpickler (f.bytes.toArray)
117114 unpickler.enter(roots = Set .empty)
118115 unpickler.trees(ctx)
119116 }
0 commit comments