Skip to content

Commit 145e08d

Browse files
committed
Allow buildscript functions without arguments.
1 parent ec5f51e commit 145e08d

File tree

3 files changed

+10
-9
lines changed

3 files changed

+10
-9
lines changed

pkg/buildscript/marshal.go

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -136,11 +136,13 @@ func funcCallString(f *funcCall) string {
136136
}
137137

138138
buf := bytes.Buffer{}
139-
buf.WriteString(fmt.Sprintf("%s(%s", f.Name, newline))
140-
141-
buf.WriteString(argsToString(f.Arguments, newline, comma, indent))
142-
143-
buf.WriteString(")")
139+
if len(f.Arguments) > 0 {
140+
buf.WriteString(fmt.Sprintf("%s(%s", f.Name, newline))
141+
buf.WriteString(argsToString(f.Arguments, newline, comma, indent))
142+
buf.WriteString(")")
143+
} else {
144+
buf.WriteString(fmt.Sprintf("%s()", f.Name))
145+
}
144146
return buf.String()
145147
}
146148

pkg/buildscript/raw.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,5 +71,5 @@ type null struct {
7171

7272
type funcCall struct {
7373
Name string `parser:"@Ident"`
74-
Arguments []*value `parser:"'(' @@ (',' @@)* ','? ')'"`
74+
Arguments []*value `parser:"'(' (@@ (',' @@)* ','?)? ')'"`
7575
}

test/integration/buildscript_int_test.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -168,9 +168,8 @@ func (suite *BuildScriptIntegrationTestSuite) TestBuildScriptRequirementVersionA
168168
cp := ts.Spawn("config", "set", constants.AsyncRuntimeConfig, "true")
169169
cp.ExpectExitCode(0)
170170

171-
// Enable as part of DX-3230.
172-
//cp = ts.Spawn("config", "set", constants.OptinBuildscriptsConfig, "true")
173-
//cp.ExpectExitCode(0)
171+
cp = ts.Spawn("config", "set", constants.OptinBuildscriptsConfig, "true")
172+
cp.ExpectExitCode(0)
174173

175174
// This project's build expression has a requirement whose version is the "Any()" function.
176175
// Make sure we can successfully checkout and modify this project.

0 commit comments

Comments
 (0)