@@ -10,12 +10,10 @@ import dotty.tools.dotc.core.Mode
10
10
import dotty .tools .dotc .core .Names .Name
11
11
import dotty .tools .dotc .interfaces .Diagnostic .ERROR
12
12
import dotty .tools .dotc .reporting .TestReporter
13
- import dotty .tools .IOUtils
13
+ import dotty .tools .io .{ Directory , File , Path }
14
14
15
15
import dotty .tools .vulpix .TestConfiguration
16
16
17
- import java .nio .file .{Files , Path }
18
-
19
17
import org .junit .Test
20
18
import org .junit .Assert .{assertEquals , assertFalse , fail }
21
19
@@ -81,25 +79,25 @@ class CommentPicklingTest {
81
79
}
82
80
83
81
private def compileAndUnpickle [T ](sources : List [String ])(fn : (List [tpd.Tree ], Context ) => T ) = {
84
- IOUtils .inTempDirectory { tmp =>
82
+ Directory .inTempDirectory { tmp =>
85
83
val sourceFiles = sources.zipWithIndex.map {
86
84
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 )
89
87
path.toString
90
88
}
91
89
92
- val out = tmp.resolve (" out" )
93
- Files .createDirectories(out )
90
+ val out = tmp./ (" out" )
91
+ out.createDirectory( )
94
92
95
- val options = compileOptions.and(" -d" , out.toAbsolutePath .toString).and(sourceFiles : _* )
93
+ val options = compileOptions.and(" -d" , out.toAbsolute .toString).and(sourceFiles : _* )
96
94
val reporter = TestReporter .reporter(System .out, logLevel = ERROR )
97
95
Main .process(options.all, reporter)
98
96
assertFalse(" Compilation failed." , reporter.hasErrors)
99
97
100
- val tastyFiles = IOUtils .getAll(tmp, " glob:**. tasty" )
98
+ val tastyFiles = Path .onlyFiles(out.walkFilter(_.extension == " tasty" )).toList
101
99
val unpicklingOptions = unpickleOptions
102
- .withClasspath(out.toAbsolutePath .toString)
100
+ .withClasspath(out.toAbsolute .toString)
103
101
.and(" dummy" ) // Need to pass a dummy source file name
104
102
val unpicklingDriver = new UnpicklingDriver
105
103
unpicklingDriver.unpickle(unpicklingOptions.all, tastyFiles)(fn)
@@ -108,12 +106,11 @@ class CommentPicklingTest {
108
106
109
107
private class UnpicklingDriver extends Driver {
110
108
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 = {
112
110
implicit val (_, ctx : Context ) = setup(args, initCtx)
113
111
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)
117
114
unpickler.enter(roots = Set .empty)
118
115
unpickler.trees(ctx)
119
116
}
0 commit comments