Skip to content

Commit 8227ac4

Browse files
authored
Merge pull request #131 from goplus/revert-126-runner
Revert "feat(modfile): add run directive support for custom project runners"
2 parents 25c02e4 + 493aeb4 commit 8227ac4

File tree

2 files changed

+2
-60
lines changed

2 files changed

+2
-60
lines changed

modfile/gop_test.go

Lines changed: 2 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,6 @@ xgo 1.1
171171
172172
project github.com/goplus/spx math
173173
class .spx Sprite
174-
runner github.com/goplus/spx/v2/cmd/spxrun v2.0.1
175174
176175
require (
177176
github.com/ajstarks/svgo v0.0.0-20210927141636-6d70534b1098
@@ -183,7 +182,7 @@ func TestGoModCompat2(t *testing.T) {
183182
gopmod = goxmodSpx2
184183
)
185184
f, err := modfile.ParseLax("go.mod", []byte(gopmod), nil)
186-
if err != nil || len(f.Syntax.Stmt) != 7 {
185+
if err != nil || len(f.Syntax.Stmt) != 6 {
187186
t.Fatal("modfile.ParseLax failed:", f, err)
188187
}
189188

@@ -192,7 +191,7 @@ func TestGoModCompat2(t *testing.T) {
192191
t.Fatal("modfile.ParseLax xgo:", xgo)
193192
}
194193

195-
require := f.Syntax.Stmt[6].(*modfile.LineBlock)
194+
require := f.Syntax.Stmt[5].(*modfile.LineBlock)
196195
if len(require.Token) != 1 || require.Token[0] != "require" {
197196
t.Fatal("modfile.ParseLax require:", require)
198197
}
@@ -346,26 +345,6 @@ import "\?" math
346345
`)
347346
doTestParseErr(t, `gop.mod:2: import must declare after a project definition`, `
348347
import math
349-
`)
350-
doTestParseErr(t, `gop.mod:2: runner must declare after a project definition`, `
351-
runner github.com/goplus/spx/v2/cmd/spxrun
352-
`)
353-
doTestParseErr(t, `gop.mod:3: usage: runner runnerPkgPath [version]`, `
354-
project github.com/goplus/spx math
355-
runner
356-
`)
357-
doTestParseErr(t, `gop.mod:3: invalid quoted string: invalid syntax`, `
358-
project github.com/goplus/spx math
359-
runner "\?"
360-
`)
361-
doTestParseErr(t, `gop.mod:3: invalid syntax`, `
362-
project github.com/goplus/spx math
363-
runner github.com/goplus/spx/v2/cmd/spxrun "\?"
364-
`)
365-
doTestParseErr(t, `gop.mod:4: repeated runner statement`, `
366-
project github.com/goplus/spx math
367-
runner github.com/goplus/spx/v2/cmd/spxrun
368-
runner github.com/goplus/spx/v2/cmd/spxrun
369348
`)
370349
doTestParseErr(t, `gop.mod:2: unknown directive: unknown`, `
371350
unknown .spx

modfile/rule.go

Lines changed: 0 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,6 @@ type Compiler struct {
3232
Version string
3333
}
3434

35-
// A Runner is the runner statement that specifies a custom runner for the project.
36-
// Example: runner github.com/goplus/spx/v2/cmd/spxrun
37-
type Runner struct {
38-
Path string // package path of the runner
39-
Version string // optional version of the runner
40-
Syntax *Line
41-
}
42-
4335
// A File is the parsed, interpreted form of a gox.mod file.
4436
type File struct {
4537
XGo *XGo
@@ -91,7 +83,6 @@ type Project struct {
9183
Works []*Class // work class of classfile
9284
PkgPaths []string // package paths of classfile and optional inline-imported packages.
9385
Import []*Import // auto-imported packages
94-
Runner *Runner // custom runner
9586
Syntax *Line
9687
}
9788

@@ -328,34 +319,6 @@ usage: class [-embed -prefix=Prefix] *.workExt WorkClass [WorkPrototype]`, sw)
328319
errorf("usage: import [name] pkgPath")
329320
return
330321
}
331-
case "runner":
332-
proj := f.proj()
333-
if proj == nil {
334-
errorf("runner must declare after a project definition")
335-
return
336-
}
337-
if proj.Runner != nil {
338-
errorf("repeated runner statement")
339-
return
340-
}
341-
if len(args) < 1 {
342-
errorf("usage: runner runnerPkgPath [version]")
343-
return
344-
}
345-
runnerPath, err := parsePkgPath(&args[0])
346-
if err != nil {
347-
wrapError(err)
348-
return
349-
}
350-
runnerVer := ""
351-
if len(args) > 1 {
352-
runnerVer, err = parseString(&args[1])
353-
if err != nil {
354-
wrapError(err)
355-
return
356-
}
357-
}
358-
proj.Runner = &Runner{Path: runnerPath, Version: runnerVer, Syntax: line}
359322
default:
360323
if strict {
361324
errorf("unknown directive: %s", verb)

0 commit comments

Comments
 (0)