SPT unescape expectation breaks
I upgraded Spoofax (API) from 2.4.1 to 2.5.1 and bumped into a bug. I use SPT’s API to extract test cases:
SpoofaxTestCaseExtractor testCaseExtractor = spoofax.injector.getInstance(SpoofaxTestCaseExtractor.class); FileObject testFile = spoofax.resourceService.resolve(path.toFile()); String text = getText(testFile); ISpoofaxInputUnit inputUnit = spoofax.unitService.inputUnit(testFile, text, spt, null); ISpoofaxTestCaseExtractionResult extractionResult = testCaseExtractor.extract(inputUnit, project);
and get an AssertionError:
java.lang.AssertionError: Attachments only supported for mutable, non-shared terms; failed for None at org.spoofax.terms.AbstractSimpleTerm.putAttachment(AbstractSimpleTerm.java:28) at org.metaborg.spt.core.extract.SpoofaxTestCaseBuilder.unescapeExpectation(SpoofaxTestCaseBuilder.java:140) at org.metaborg.spt.core.extract.SpoofaxTestCaseBuilder.unescapeExpectationKids(SpoofaxTestCaseBuilder.java:150) at org.metaborg.spt.core.extract.SpoofaxTestCaseBuilder.unescapeExpectation(SpoofaxTestCaseBuilder.java:124) at org.metaborg.spt.core.extract.SpoofaxTestCaseBuilder.withTest(SpoofaxTestCaseBuilder.java:95) at org.metaborg.spt.core.extract.SpoofaxTestCaseBuilder.withTest(SpoofaxTestCaseBuilder.java:1) at org.metaborg.spt.core.extract.SpoofaxTestCaseExtractor$1.preVisit(SpoofaxTestCaseExtractor.java:167) at org.spoofax.terms.TermVisitor.visit(TermVisitor.java:17) at org.spoofax.terms.TermVisitor.visit(TermVisitor.java:21) at org.spoofax.terms.TermVisitor.visit(TermVisitor.java:21) at org.metaborg.spt.core.extract.SpoofaxTestCaseExtractor.extract(SpoofaxTestCaseExtractor.java:190) at org.metaborg.spt.core.extract.SpoofaxTestCaseExtractor.extract(SpoofaxTestCaseExtractor.java:88) at oracle.pgx.algorithm.AlgorithmCompilerTest.getTestCases(AlgorithmCompilerTest.java:118) at java.util.stream.ReferencePipeline$7$1.accept(ReferencePipeline.java:267) at java.util.Spliterators$IteratorSpliterator.tryAdvance(Spliterators.java:1812) at java.util.stream.StreamSpliterators$WrappingSpliterator.lambda$initPartialTraversalState$0(StreamSpliterators.java:294) at java.util.stream.StreamSpliterators$AbstractWrappingSpliterator.fillBuffer(StreamSpliterators.java:206) at java.util.stream.StreamSpliterators$AbstractWrappingSpliterator.doAdvance(StreamSpliterators.java:161) at java.util.stream.StreamSpliterators$WrappingSpliterator.tryAdvance(StreamSpliterators.java:300) at java.util.Spliterators$1Adapter.hasNext(Spliterators.java:681) at org.junit.jupiter.engine.descriptor.TestFactoryTestDescriptor.lambda$invokeTestMethod$1(TestFactoryTestDescriptor.java:93) at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:72) at org.junit.jupiter.engine.descriptor.TestFactoryTestDescriptor.invokeTestMethod(TestFactoryTestDescriptor.java:84) at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.execute(TestMethodTestDescriptor.java:114) at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.execute(TestMethodTestDescriptor.java:59) at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$5(NodeTestTask.java:105) at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:72) at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:95) at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:71) at java.util.ArrayList.forEach(ArrayList.java:1249) at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.invokeAll(SameThreadHierarchicalTestExecutorService.java:38) at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$5(NodeTestTask.java:110) at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:72) at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:95) at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:71) at java.util.ArrayList.forEach(ArrayList.java:1249) at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.invokeAll(SameThreadHierarchicalTestExecutorService.java:38) at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$5(NodeTestTask.java:110) at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:72) at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:95) at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:71) at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.submit(SameThreadHierarchicalTestExecutorService.java:32) at org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor.execute(HierarchicalTestExecutor.java:57) at org.junit.platform.engine.support.hierarchical.HierarchicalTestEngine.execute(HierarchicalTestEngine.java:51) at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:220) at org.junit.platform.launcher.core.DefaultLauncher.lambda$execute$6(DefaultLauncher.java:188) at org.junit.platform.launcher.core.DefaultLauncher.withInterceptedStreams(DefaultLauncher.java:202) at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:181) at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:128) at com.intellij.junit5.JUnit5IdeaTestRunner.startRunnerWithArgs(JUnit5IdeaTestRunner.java:74) at com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:47) at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:242) at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70)
The problem is that the SpoofaxTestCaseBuilder creates its own TermFactory that produces immutable terms. It then copies over attachments (e.g. ImploderAttachments resulting from the parse) by calling putAttachment. This method asserts that the term is mutable. Since the term is immutable, the assertion fails.
Submitted by Martijn on 4 December 2018 at 14:05
Log in to post comments