-
Notifications
You must be signed in to change notification settings - Fork 326
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Ensure new and wrapper nodes inherit UUID (#6067)
Instrumentation of calls involving warning values never really worked because: 1) newly created nodes didn't set the UUID of their children 2) the instrumentable wrappers always had an empty (i.e. null) UUID and they never referred `get`/`setId` calls to their delegates On the surface, everything worked fine. Except when one actually relied on the instrumentation of values with warnings for proper setup. Then no instrumentation (replacement of nodes) was performed due to empty UUID (as required by `hasTag` of `FunctionCallInstrumentationNode`). Closes #6045. Discovered in #5893.
- Loading branch information
Showing
10 changed files
with
225 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
92 changes: 92 additions & 0 deletions
92
...uments/src/test/java/org/enso/interpreter/test/instrument/WarningInstrumentationTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
package org.enso.interpreter.test.instrument; | ||
|
||
import com.oracle.truffle.api.instrumentation.SourceSectionFilter; | ||
import com.oracle.truffle.api.instrumentation.StandardTags; | ||
import org.enso.interpreter.runtime.tag.AvoidIdInstrumentationTag; | ||
import org.enso.interpreter.runtime.tag.IdentifiedTag; | ||
import org.enso.interpreter.test.Metadata; | ||
import org.enso.interpreter.test.NodeCountingTestInstrument; | ||
import org.enso.polyglot.RuntimeOptions; | ||
import org.graalvm.polyglot.Context; | ||
import org.graalvm.polyglot.Language; | ||
import org.graalvm.polyglot.Source; | ||
import static org.junit.Assert.assertEquals; | ||
import org.junit.After; | ||
import org.junit.Assert; | ||
import org.junit.Before; | ||
import org.junit.Test; | ||
|
||
import java.io.OutputStream; | ||
import java.nio.file.Paths; | ||
import java.util.Map; | ||
|
||
public class WarningInstrumentationTest { | ||
|
||
private Context context; | ||
private NodeCountingTestInstrument instrument; | ||
|
||
@Before | ||
public void initContext() { | ||
context = Context.newBuilder() | ||
.allowExperimentalOptions(true) | ||
.option( | ||
RuntimeOptions.LANGUAGE_HOME_OVERRIDE, | ||
Paths.get("../../distribution/component").toFile().getAbsolutePath() | ||
) | ||
.logHandler(OutputStream.nullOutputStream()) | ||
.allowExperimentalOptions(true) | ||
.allowIO(true) | ||
.allowAllAccess(true) | ||
.build(); | ||
|
||
var engine = context.getEngine(); | ||
Map<String, Language> langs = engine.getLanguages(); | ||
Assert.assertNotNull("Enso found: " + langs, langs.get("enso")); | ||
|
||
instrument = engine.getInstruments().get(NodeCountingTestInstrument.INSTRUMENT_ID).lookup(NodeCountingTestInstrument.class); | ||
SourceSectionFilter builder = SourceSectionFilter.newBuilder() | ||
.tagIs(StandardTags.ExpressionTag.class, StandardTags.CallTag.class) | ||
.tagIs(IdentifiedTag.class) | ||
.tagIsNot(AvoidIdInstrumentationTag.class) | ||
.build(); | ||
instrument.enable(builder); | ||
} | ||
|
||
@After | ||
public void disposeContext() { | ||
context.close(); | ||
} | ||
|
||
@Test | ||
public void instrumentValueWithWarnings() throws Exception { | ||
var metadata = new Metadata(); | ||
|
||
var idOp1 = metadata.addItem(151, 34, null); | ||
var idOp2 = metadata.addItem(202, 31, null); | ||
var idOp3 = metadata.addItem(250, 13, null); | ||
var rawCode = """ | ||
from Standard.Base import all | ||
from Standard.Base.Warning import Warning | ||
from Standard.Table.Data.Table import Table | ||
run column_name = | ||
operator1 = Table.new [[column_name, [1,2,3]]] | ||
operator2 = Warning.attach "Text" operator1 | ||
operator3 = operator2.get | ||
operator3 | ||
"""; | ||
var code = metadata.appendToCode(rawCode); | ||
var src = Source.newBuilder("enso", code, "TestWarning.enso").build(); | ||
var module = context.eval(src); | ||
var res = module.invokeMember("eval_expression", "run"); | ||
res.execute("A"); | ||
|
||
var calls = instrument.registeredCalls(); | ||
|
||
assertEquals(calls.keySet().size(), 3); | ||
assertEquals(calls.get(idOp1).getFunctionName(), "new"); | ||
assertEquals(calls.get(idOp2).getFunctionName(), "attach"); | ||
assertEquals(calls.get(idOp3).getTypeName().item(), "Table"); | ||
assertEquals(calls.get(idOp3).getFunctionName(), "get"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters