Skip to content

Commit

Permalink
Fix: globbing--read extra storage from owner instead of receiver (app…
Browse files Browse the repository at this point in the history
…le#607)

This fixes an issue where a PklBugException is thrown when a globbed
read/import is amended.
  • Loading branch information
bioball authored Aug 5, 2024
1 parent 604b042 commit d5e86ed
Show file tree
Hide file tree
Showing 6 changed files with 59 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public ImportGlobMemberBodyNode(

@Override
public Object executeGeneric(VirtualFrame frame) {
var mapping = VmUtils.getObjectReceiver(frame);
var mapping = VmUtils.getOwner(frame);
var path = (String) VmUtils.getMemberKey(frame);
return importModule(mapping, path);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public ReadGlobMemberBodyNode(SourceSection sourceSection) {

@Override
public Object executeGeneric(VirtualFrame frame) {
var mapping = VmUtils.getObjectReceiver(frame);
var mapping = VmUtils.getOwner(frame);
var path = (String) VmUtils.getMemberKey(frame);
return readResource(mapping, path);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,16 @@ examples {
import*("../../input-helper/globtest/**.pkl").keys.toListing()
}

["amended"] {
(import*("../../input-helper/globtest/**.pkl")) {
[[true]] {
output {
renderer = new YamlRenderer {}
}
}
}.toMap().values.map((it) -> it.output.text).join("\n---\n")
}

["globstar then up one level"] {
import*("../../input-helper/globtest/**/../*.pkl").keys.toListing()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,14 @@ examples {
read*("globtest/*.txt")
}

["amended"] {
(read*("../../input-helper/globtest/**.pkl")) {
[[true]] {
text = "hi"
}
}
}

["env:"] {
// doesn't match names that include slashes
read*("env:*")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,21 @@ examples {
"../../input-helper/globtest/child/moduleC.pkl"
}
}
["amended"] {
"""
{}
---
name: moduleA
---
name: moduleB
---
name: child/moduleC
"""
}
["globstar then up one level"] {
new {
"../../input-helper/globtest/child/../module with [weird] ~!characters.pkl"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,30 @@ examples {
}
}
}
["amended"] {
new {
["../../input-helper/globtest/module with [weird] ~!characters.pkl"] {
uri = "file:///$snippetsDir/input-helper/globtest/module%20with%20%5Bweird%5D%20~!characters.pkl"
text = "hi"
base64 = ""
}
["../../input-helper/globtest/moduleA.pkl"] {
uri = "file:///$snippetsDir/input-helper/globtest/moduleA.pkl"
text = "hi"
base64 = "bmFtZSA9ICJtb2R1bGVBIgo="
}
["../../input-helper/globtest/moduleB.pkl"] {
uri = "file:///$snippetsDir/input-helper/globtest/moduleB.pkl"
text = "hi"
base64 = "bmFtZSA9ICJtb2R1bGVCIgo="
}
["../../input-helper/globtest/child/moduleC.pkl"] {
uri = "file:///$snippetsDir/input-helper/globtest/child/moduleC.pkl"
text = "hi"
base64 = "bmFtZSA9ICJjaGlsZC9tb2R1bGVDIgo="
}
}
}
["env:"] {
new {
["env:NAME1"] = "value1"
Expand Down

0 comments on commit d5e86ed

Please sign in to comment.