1
1
package dotty .tools .dotc .core .tasty
2
2
3
3
import java .io .{File => JFile , ByteArrayOutputStream , IOException }
4
- import java .nio .file .{Files , NoSuchFileException , Path , Paths }
4
+ import java .nio .file .{Files , NoSuchFileException , Paths }
5
5
6
6
import scala .sys .process ._
7
7
@@ -19,7 +19,7 @@ import dotty.tools.dotc.core.Mode
19
19
import dotty .tools .dotc .core .Names .Name
20
20
import dotty .tools .dotc .interfaces .Diagnostic .ERROR
21
21
import dotty .tools .dotc .reporting .TestReporter
22
- import dotty .tools .io .{Directory , File , Path }
22
+ import dotty .tools .io .{Directory , File , Path , JarArchive }
23
23
24
24
import dotty .tools .vulpix .TestConfiguration
25
25
@@ -42,28 +42,24 @@ class PathPicklingTest {
42
42
assertFalse(" Compilation failed." , rep.hasErrors)
43
43
}
44
44
45
- val decompiled =
46
- val outstream = new ByteArrayOutputStream ()
47
- val options = TestConfiguration .defaultOptions
48
- .and(" -print-tasty" )
49
- .and(" -color:never" )
50
- .and(s " $out/out.jar " )
51
- val reporter = TestReporter .reporter(System .out, logLevel = ERROR )
52
- val rep = Console .withOut(outstream) {
53
- decompiler.Main .process(options.all, reporter)
54
- }
55
- assertFalse(" Decompilation failed." , rep.hasErrors)
56
- new String (outstream.toByteArray(), " UTF-8" )
45
+ val printedTasty =
46
+ val sb = new StringBuffer
47
+ val jar = JarArchive .open(Path (s " $out/out.jar " ), create = false )
48
+ try
49
+ for file <- jar.iterator() if file.name.endsWith(" .tasty" ) do
50
+ sb.append(TastyPrinter .showContents(file.toByteArray, noColor = true ))
51
+ finally jar.close()
52
+ sb.toString()
57
53
58
- assertTrue(decompiled .contains(" : i10430/lib.scala" ))
59
- assertTrue(decompiled .contains(" : i10430/app .scala" ))
60
- assertTrue(decompiled .contains(" [ i10430/ lib.scala] " ))
61
- assertTrue(decompiled .contains(" [i10430/app .scala]" ))
54
+ assertTrue(printedTasty .contains(" : i10430/lib.scala" ))
55
+ assertTrue(printedTasty .contains(" [ i10430/lib .scala] " ))
56
+ assertFalse(printedTasty .contains(" : i10430\\ lib.scala" ))
57
+ assertFalse(printedTasty .contains(" [i10430\\ lib .scala]" ))
62
58
63
- assertFalse(decompiled .contains(" : i10430\\ lib .scala" ))
64
- assertFalse(decompiled .contains(" : i10430\\ app.scala" ))
65
- assertFalse(decompiled .contains(" [ i10430\\ lib .scala] " ))
66
- assertFalse(decompiled .contains(" [i10430\\ app.scala]" ))
59
+ assertTrue(printedTasty .contains(" : i10430/app .scala" ))
60
+ assertTrue(printedTasty .contains(" [ i10430/ app.scala] " ))
61
+ assertFalse(printedTasty .contains(" : i10430\\ app .scala" ))
62
+ assertFalse(printedTasty .contains(" [i10430\\ app.scala]" ))
67
63
}
68
64
69
65
private def delete (file : JFile ): Unit = {
0 commit comments