Skip to content

Commit 9efbd43

Browse files
committed
DO NOT MERGE. Jenkins test with better debugging output
1 parent bd9b011 commit 9efbd43

File tree

1 file changed

+24
-15
lines changed

1 file changed

+24
-15
lines changed

test/test/CompilerTest.scala

Lines changed: 24 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -255,28 +255,18 @@ abstract class CompilerTest extends DottyTest {
255255
processFileDir(sourceFile, { sf =>
256256
if (extensionsToCopy.contains(sf.extension)) {
257257
dest.parent.jfile.mkdirs
258-
println("copying " + sf.toString + " with UTF8 codec " + sf.creationCodec)
259-
val contents = try { sf.slurp(scala.io.Codec.UTF8) } catch {
260-
case e: Throwable => println("==================\n=======BOOM=======\n==================\nfailed slurping file " + sf.toString); ""
258+
val contents = try sf.slurp catch {
259+
case e: java.nio.charset.MalformedInputException =>
260+
println("ERROR: illegal character detected for file " + sf + " (charset " + sf.creationCodec + ")")
261+
checkEncoding(sf)
262+
throw e
261263
}
262264
dest.toFile.writeAll("/* ==========================================\n",
263265
" * ========= AUTOMATICALLY GENERATED ========\n",
264266
" * ========= DO NOT EDIT THIS FILE ==========\n",
265267
" * ==========================================\n",
266268
" * Original: " + sf.toString + " */\n\n",
267269
contents)
268-
269-
/* ==================
270-
=======BOOM=======
271-
==================
272-
failed slurping file ./src/dotty/tools/dotc/core/tasty/TastyFormat.scala
273-
failed slurping file ./src/dotty/tools/dotc/core/tasty/TastyFormat.scala
274-
failed slurping file ./src/dotty/tools/dotc/transform/PatternMatcher.scala
275-
failed slurping file ./src/dotty/tools/dotc/transform/PatternMatcher.scala
276-
277-
278-
*/
279-
280270
} else {
281271
log(s"WARNING: ignoring $sf")
282272
}
@@ -351,6 +341,25 @@ failed slurping file ./src/dotty/tools/dotc/transform/PatternMatcher.scala
351341

352342
/** Write either to console (JUnit) or log file (partest). */
353343
private def log(msg: String) = logFile.map(_.appendAll(msg + "\n")).getOrElse(println(msg))
344+
345+
/** Jenkins uses different Character encoding, check if this is the problem. */
346+
private def checkEncoding(sf: SFile) = {
347+
val reader1 = sf.reader(scala.io.Codec.UTF8) // local machine
348+
val reader2 = sf.reader(scala.io.Codec(java.nio.charset.Charset.forName("US-ASCII"))) // jenkins
349+
try {
350+
var read1, read2, count, diffcount = 0
351+
while ((read1 > -1 || read2 > -1) && diffcount < 30) {
352+
read1 = reader1.read(); read2 = reader2.read()
353+
count += 1
354+
if (read1 != read2) {
355+
println("difference at character " + count + ": UTF8: " + read1.toChar + ", US-ASCII (jenkins): " + read2.toChar)
356+
diffcount += 1
357+
}
358+
}
359+
} finally {
360+
reader1.close; reader2.close
361+
}
362+
}
354363
}
355364

356365
object CompilerTest extends App {

0 commit comments

Comments
 (0)