-
Notifications
You must be signed in to change notification settings - Fork 85
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
Retain Extra fields over Uses,Augments #244
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1461,6 +1461,12 @@ func (e *Entry) dup() *Entry { | |
ne.Dir[k] = de | ||
} | ||
} | ||
|
||
ne.Extra = make(map[string][]interface{}) | ||
for k, v := range e.Extra { | ||
ne.Extra[k] = v | ||
} | ||
|
||
return &ne | ||
} | ||
|
||
|
@@ -1485,11 +1491,7 @@ func (e *Entry) merge(prefix *Value, namespace *Value, oe *Entry) { | |
} else { | ||
v.Parent = e | ||
v.Exts = append(v.Exts, oe.Exts...) | ||
for lk, lv := range oe.Extra { | ||
if v.Extra[lk] == nil { | ||
v.Extra[lk] = lv | ||
continue | ||
} | ||
for lk := range oe.Extra { | ||
v.Extra[lk] = append(v.Extra[lk], oe.Extra[lk]...) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. (optional) Note that currently only augments in There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you please give an example where this would occur? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For what I see, There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Actually my comment here was misled by my naive thought that if-features should be applied to the target node where they should only be applied to the nodes within the |
||
} | ||
e.Dir[k] = v | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2058,6 +2058,7 @@ var testIfFeatureModules = []struct { | |
feature ft-identity; | ||
feature ft-uses; | ||
feature ft-refine; | ||
feature ft-augment-uses; | ||
|
||
container cont { | ||
if-feature ft-container; | ||
|
@@ -2118,6 +2119,9 @@ var testIfFeatureModules = []struct { | |
|
||
augment "/cont" { | ||
if-feature ft-augment; | ||
uses g { | ||
if-feature ft-augment-uses; | ||
} | ||
} | ||
|
||
identity id { | ||
|
@@ -2130,7 +2134,10 @@ var testIfFeatureModules = []struct { | |
if-feature ft-refine; | ||
} | ||
} | ||
grouping g {} | ||
|
||
grouping g { | ||
container gc {} | ||
} | ||
} | ||
`, | ||
}, | ||
|
@@ -2269,6 +2276,15 @@ func TestIfFeature(t *testing.T) { | |
inIfFeatures: ms.Modules["if-feature"].Uses[0].IfFeature, | ||
wantIfFeatures: []string{"ft-uses"}, | ||
}, | ||
{ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If you can add a comment above this test block, something like "// Testing that if-features are merged correctly" I think that would help make this more readable. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done |
||
name: "uses", | ||
inIfFeatures: entryIfFeatures(mod.Dir["gc"]), | ||
wantIfFeatures: []string{"ft-uses"}, | ||
}, { | ||
name: "augment-uses", | ||
inIfFeatures: entryIfFeatures(mod.Dir["cont"].Dir["gc"]), | ||
wantIfFeatures: []string{"ft-augment-uses", "ft-augment"}, | ||
}, | ||
} | ||
|
||
for _, tc := range testcases { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you add a test in
TestIfFeature
in entry_test.go?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done