@@ -658,20 +658,48 @@ trait ParallelTesting extends RunnerOrchestration { self =>
658
658
if (errors > 0 )
659
659
errorMap.put(s " ${file.getPath}: ${lineNbr}" , errors)
660
660
661
+
661
662
val noposErrors = line.sliding(" // nopos-error" .length).count(_.mkString == " // nopos-error" )
662
663
if (noposErrors > 0 ) {
663
664
val nopos = errorMap.get(" nopos" )
664
665
val existing : Integer = if (nopos eq null ) 0 else nopos
665
666
errorMap.put(" nopos" , noposErrors + existing)
666
667
}
667
668
669
+ maybeWarning(line).foreach(warning => echo(s " Possible typo in file ${file.getCanonicalPath} at line number $lineNbr \n $warning" ))
670
+
668
671
expectedErrors += noposErrors + errors
669
672
}
670
673
}
671
674
672
675
(errorMap, expectedErrors)
673
676
}
674
677
678
+ /**
679
+ * We want to warn the developer about some of the possible typos when trying to point "error" and "nopos-error"
680
+ * For example - A warning could be emitted if the developer mistakenly types in "//error" instead of "// error"
681
+ * or "//nopos-error" instead of "// nopos-error"
682
+ *
683
+ * @param line the line which will be checked for possible typos
684
+ * @return Some(warningMessage) or None
685
+ */
686
+ def maybeWarning (line : String ) : Option [String ] = {
687
+
688
+ def hasTypo (line : String ) : Boolean = line.contains(" //error" ) || line.contains(" //nopos-error" )
689
+
690
+ def getWarning (line : String ): String = if (line.contains(" //error" )) {
691
+ s " Wrong : //error \n Correct : // error "
692
+ } else if (line.contains(" //nopos-error" )) {
693
+ s " Wrong : //nopos-error \n Correct : // nopos-error "
694
+ } else " "
695
+
696
+ if (hasTypo(line)){
697
+ Some (getWarning(line))
698
+ }else {
699
+ None
700
+ }
701
+ }
702
+
675
703
def getMissingExpectedErrors (errorMap : HashMap [String , Integer ], reporterErrors : Iterator [MessageContainer ]) = ! reporterErrors.forall { error =>
676
704
val key = if (error.pos.exists) {
677
705
def toRelative (path : String ): String = // For some reason, absolute paths leak from the compiler itself...
0 commit comments