Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make tests resilient to exceptions thrown while reporting exceptions #19566

Conversation

nicolasstucki
Copy link
Contributor

@nicolasstucki nicolasstucki commented Jan 30, 2024

Part of #19542. We protect against the case where Exception.getMessage or Exception.getStackTrace throw an exception.

This change makes testCompilation tests/neg/i8984.scala fail as expected. tests/neg/i8984.scala is currently disabled (see #19561).

tests/neg/i8984.scala will not be fixed in this PR. Making the test framework more resilient is a priority. Fixing this is the last part of #19542.

Part of scala#19542. We protect against the case where `Exception.getMessage` or
`Exception.getStackTrace` throw an exception.
@nicolasstucki
Copy link
Contributor Author

This is what we get if we enable -Ydebug-cyclic to compute the stack trace of the CyclicReference

Exception thrown onComplete (probably by a reporter) in tests/neg/i8984.scala: class dotty.tools.dotc.core.CyclicReference
dotty.tools.dotc.core.CyclicReference message could not be printed due to an exception while computing the message.
dotty.tools.dotc.core.CyclicReference$.apply(TypeErrors.scala:192)              
dotty.tools.dotc.core.SymDenotations$SymDenotation.completeFrom(SymDenotations.scala:176)
dotty.tools.dotc.core.Denotations$Denotation.completeInfo$1(Denotations.scala:189)
dotty.tools.dotc.core.Denotations$Denotation.info(Denotations.scala:191)        
dotty.tools.dotc.reporting.Message$Seen.explanation(Message.scala:165)          
dotty.tools.dotc.reporting.Message$Seen.$anonfun$7(Message.scala:204)           
scala.collection.immutable.List.map(List.scala:250)                             
dotty.tools.dotc.reporting.Message$Seen.explanations(Message.scala:204)         
dotty.tools.dotc.reporting.Message.msgPostscript(Message.scala:327)             
dotty.tools.dotc.reporting.Message.message$$anonfun$1(Message.scala:372)        
dotty.tools.dotc.reporting.Message.inMessageContext(Message.scala:368)          
dotty.tools.dotc.reporting.Message.message(Message.scala:372)                   
dotty.tools.dotc.reporting.Diagnostic.message(Diagnostic.scala:102)             
dotty.tools.vulpix.ParallelTesting.showErrors$1$$anonfun$1$$anonfun$2(ParallelTesting.scala:902)
scala.collection.immutable.List.map(List.scala:250)                             
dotty.tools.vulpix.ParallelTesting.showErrors$1$$anonfun$1(ParallelTesting.scala:902)
scala.collection.immutable.List.flatMap(List.scala:293)                         
scala.collection.immutable.List.flatMap(List.scala:79)                          
dotty.tools.vulpix.ParallelTesting.dotty$tools$vulpix$ParallelTesting$NegTest$$_$showErrors$1(ParallelTesting.scala:902)
dotty.tools.vulpix.ParallelTesting$NegTest.maybeFailureMessage(ParallelTesting.scala:912)
dotty.tools.vulpix.ParallelTesting$CompilationLogic.dotty$tools$vulpix$ParallelTesting$CompilationLogic$$onComplete(ParallelTesting.scala:297)
dotty.tools.vulpix.ParallelTesting$$anon$4.checkTestSource$$anonfun$1(ParallelTesting.scala:286)
dotty.tools.vulpix.ParallelTesting$$anon$4.checkTestSource$$anonfun$adapted$1(ParallelTesting.scala:288)
scala.Function0.apply$mcV$sp(Function0.scala:42)                                
dotty.tools.vulpix.ParallelTesting$Test.tryCompile(ParallelTesting.scala:472)   
dotty.tools.vulpix.ParallelTesting$$anon$4.checkTestSource(ParallelTesting.scala:288)
dotty.tools.vulpix.ParallelTesting$Test$LoggedRunnable.run(ParallelTesting.scala:368)
dotty.tools.vulpix.ParallelTesting$Test$LoggedRunnable.run$(ParallelTesting.scala:350)
dotty.tools.vulpix.ParallelTesting$$anon$4.run(ParallelTesting.scala:283)       
java.base/java.util.concurrent.ForkJoinTask$AdaptedRunnableAction.exec(ForkJoinTask.java:1375)
java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:373)       
java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1182)
java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1655)        
java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1622)   
java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:165)

@odersky
Copy link
Contributor

odersky commented Jan 30, 2024

Good catch!

@nicolasstucki nicolasstucki merged commit 23efb89 into scala:main Jan 30, 2024
19 checks passed
@nicolasstucki nicolasstucki deleted the make-test-framework-reslilient-to-exceptions-thrown-while-reporting-exceptions branch January 30, 2024 10:03
This was referenced Jan 30, 2024
@Kordyjan Kordyjan added this to the 3.4.1 milestone Feb 14, 2024
WojciechMazur added a commit that referenced this pull request Jul 1, 2024
…xceptions" to LTS (#20864)

Backports #19566 to the LTS branch.

PR submitted by the release tooling.
[skip ci]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants