@@ -255,28 +255,18 @@ abstract class CompilerTest extends DottyTest {
255
255
processFileDir(sourceFile, { sf =>
256
256
if (extensionsToCopy.contains(sf.extension)) {
257
257
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 ==================\n failed 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
261
263
}
262
264
dest.toFile.writeAll(" /* ==========================================\n " ,
263
265
" * ========= AUTOMATICALLY GENERATED ========\n " ,
264
266
" * ========= DO NOT EDIT THIS FILE ==========\n " ,
265
267
" * ==========================================\n " ,
266
268
" * Original: " + sf.toString + " */\n\n " ,
267
269
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
-
280
270
} else {
281
271
log(s " WARNING: ignoring $sf" )
282
272
}
@@ -351,6 +341,25 @@ failed slurping file ./src/dotty/tools/dotc/transform/PatternMatcher.scala
351
341
352
342
/** Write either to console (JUnit) or log file (partest). */
353
343
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
+ }
354
363
}
355
364
356
365
object CompilerTest extends App {
0 commit comments