Skip to content

Commit c1ddcac

Browse files
committed
Include the tck features and test infrastructure.
1 parent 7d81270 commit c1ddcac

File tree

5 files changed

+180
-1
lines changed

5 files changed

+180
-1
lines changed

Makefile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,7 @@ test:
44
go test -v github.com/mburbidg/cypher/scanner
55
go test -v github.com/mburbidg/cypher/parser
66
.PHONY:test
7+
8+
tck-test:
9+
go test -v github.com/mburbidg/cypher/tck-test
10+
.PHONY:tck-test

go.mod

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,19 @@ require (
88
)
99

1010
require (
11+
github.com/cucumber/gherkin-go/v19 v19.0.3 // indirect
12+
github.com/cucumber/godog v0.12.6 // indirect
13+
github.com/cucumber/messages-go/v16 v16.0.1 // indirect
1114
github.com/davecgh/go-spew v1.1.1 // indirect
15+
github.com/gofrs/uuid v4.2.0+incompatible // indirect
16+
github.com/hashicorp/go-immutable-radix v1.3.1 // indirect
17+
github.com/hashicorp/go-memdb v1.3.2 // indirect
18+
github.com/hashicorp/golang-lru v0.5.4 // indirect
1219
github.com/kr/pretty v0.2.1 // indirect
1320
github.com/kr/text v0.2.0 // indirect
1421
github.com/pmezard/go-difflib v1.0.0 // indirect
22+
github.com/spf13/pflag v1.0.5 // indirect
1523
golang.org/x/text v0.3.6 // indirect
16-
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 // indirect
24+
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c // indirect
1725
gopkg.in/yaml.v3 v3.0.1 // indirect
1826
)

go.sum

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,31 @@
1+
github.com/cpuguy83/go-md2man/v2 v2.0.1/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o=
12
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
3+
github.com/cucumber/gherkin-go/v19 v19.0.3 h1:mMSKu1077ffLbTJULUfM5HPokgeBcIGboyeNUof1MdE=
4+
github.com/cucumber/gherkin-go/v19 v19.0.3/go.mod h1:jY/NP6jUtRSArQQJ5h1FXOUgk5fZK24qtE7vKi776Vw=
5+
github.com/cucumber/godog v0.12.6 h1:3IToXviU45G7FgijwTk/LdB4iojn8zUFDfQLj4MMiHc=
6+
github.com/cucumber/godog v0.12.6/go.mod h1:Y02TTpimPXDb70PnG6M3zpODXm1+bjCsuZzcW76xAww=
7+
github.com/cucumber/messages-go/v16 v16.0.0/go.mod h1:EJcyR5Mm5ZuDsKJnT2N9KRnBK30BGjtYotDKpwQ0v6g=
8+
github.com/cucumber/messages-go/v16 v16.0.1 h1:fvkpwsLgnIm0qugftrw2YwNlio+ABe2Iu94Ap8GMYIY=
9+
github.com/cucumber/messages-go/v16 v16.0.1/go.mod h1:EJcyR5Mm5ZuDsKJnT2N9KRnBK30BGjtYotDKpwQ0v6g=
210
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
311
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
412
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
13+
github.com/gofrs/uuid v4.0.0+incompatible/go.mod h1:b2aQJv3Z4Fp6yNu3cdSllBxTCLRxnplIgP/c0N/04lM=
14+
github.com/gofrs/uuid v4.2.0+incompatible h1:yyYWMnhkhrKwwr8gAOcOCYxOOscHgDS9yZgBrnJfGa0=
15+
github.com/gofrs/uuid v4.2.0+incompatible/go.mod h1:b2aQJv3Z4Fp6yNu3cdSllBxTCLRxnplIgP/c0N/04lM=
16+
github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY=
17+
github.com/hashicorp/go-immutable-radix v1.3.0/go.mod h1:0y9vanUI8NX6FsYoO3zeMjhV/C5i9g4Q3DwcSNZ4P60=
18+
github.com/hashicorp/go-immutable-radix v1.3.1 h1:DKHmCUm2hRBK510BaiZlwvpD40f8bJFeZnpfm2KLowc=
19+
github.com/hashicorp/go-immutable-radix v1.3.1/go.mod h1:0y9vanUI8NX6FsYoO3zeMjhV/C5i9g4Q3DwcSNZ4P60=
20+
github.com/hashicorp/go-memdb v1.3.2 h1:RBKHOsnSszpU6vxq80LzC2BaQjuuvoyaQbkLTf7V7g8=
21+
github.com/hashicorp/go-memdb v1.3.2/go.mod h1:Mluclgwib3R93Hk5fxEfiRhB+6Dar64wWh71LpNSe3g=
22+
github.com/hashicorp/go-uuid v1.0.0/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro=
23+
github.com/hashicorp/go-uuid v1.0.2/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro=
24+
github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8=
25+
github.com/hashicorp/golang-lru v0.5.4 h1:YDjusn29QI/Das2iO9M0BHnIbxPeyuCHsjMW+lJfyTc=
26+
github.com/hashicorp/golang-lru v0.5.4/go.mod h1:iADmTwqILo4mZ8BN3D2Q6+9jd8WM5uGBxy+E8yxSoD4=
27+
github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8=
28+
github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU=
529
github.com/kr/pretty v0.2.1 h1:Fmg33tUaq4/8ym9TJN1x7sLJnHVwhP33CNkpYV/7rwI=
630
github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI=
731
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
@@ -10,20 +34,34 @@ github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
1034
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
1135
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
1236
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
37+
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
38+
github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc=
39+
github.com/smartystreets/goconvey v1.6.4/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9QV7WQ/tjFTllLA=
1340
github.com/smasher164/xid v0.1.1 h1:b3k/MqqZNWgUmCxJY2E7dFd89DHL49+TPgVibFVYYhg=
1441
github.com/smasher164/xid v0.1.1/go.mod h1:tgivm8CQl19fH1c5y+8F4mA+qY6n2i6qDRBlY/6nm+I=
42+
github.com/spf13/cobra v1.4.0/go.mod h1:Wo4iy3BUC+X2Fybo0PDqwJIv3dNRiZLHQymsfxlB84g=
43+
github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA=
44+
github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
1545
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
1646
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
47+
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
1748
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
1849
github.com/stretchr/testify v1.8.0 h1:pSgiaMZlXftHpm5L7V1+rVB+AZJydKsMxsQBIJw4PKk=
1950
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
51+
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
52+
golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
53+
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
54+
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
2055
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
2156
golang.org/x/text v0.3.6 h1:aRYxNxv6iGQlyVaZmk6ZgYEDa+Jg18DxebPSrd6bg1M=
2257
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
2358
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
59+
golang.org/x/tools v0.0.0-20190328211700-ab21143f2384/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
2460
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
2561
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 h1:YR8cESwS4TdDjEe65xsg0ogRM/Nc3DYOhEAlW+xobZo=
2662
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
63+
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q=
64+
gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
2765
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
2866
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
2967
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=

tck_test/ast_eval_test.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
package tck_test
2+
3+
import "github.com/mburbidg/cypher/parser"
4+
5+
type astRuntime struct {
6+
}
7+
8+
func (runtime *astRuntime) eval(stmt parser.Statement) error {
9+
return nil
10+
}

tck_test/cypher_test.go

Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
1+
package tck_test
2+
3+
import (
4+
"context"
5+
"fmt"
6+
"github.com/cucumber/godog"
7+
"github.com/mburbidg/cypher/parser"
8+
"github.com/mburbidg/cypher/scanner"
9+
"os"
10+
"testing"
11+
)
12+
13+
type graphFeature struct{}
14+
15+
type syntaxErrKey struct{}
16+
17+
type reporter struct{}
18+
19+
func (r reporter) Error(line int, msg string) error {
20+
return fmt.Errorf("Error: %s (line %d)", msg, line)
21+
}
22+
23+
func (g *graphFeature) anyGraph(ctx context.Context) (context.Context, error) {
24+
return ctx, nil
25+
}
26+
27+
func (g *graphFeature) beforeScenario(ctx context.Context, sc *godog.Scenario) (context.Context, error) {
28+
return ctx, nil
29+
}
30+
31+
func (g *graphFeature) afterScenario(ctx context.Context, sc *godog.Scenario, err error) (context.Context, error) {
32+
return ctx, nil
33+
}
34+
35+
func (g *graphFeature) anEmptyGraph(ctx context.Context) (context.Context, error) {
36+
return ctx, nil
37+
}
38+
39+
func (g *graphFeature) executingQuery(ctx context.Context, query *godog.DocString) (context.Context, error) {
40+
//session := ctx.Value(sessionCtxKey{}).(neo4j.SessionWithContext)
41+
//result, err := session.Run(ctx, query.Content, map[string]any{})
42+
//if err != nil {
43+
// if err, ok := err.(*db.Neo4jError); ok {
44+
// if err.Code == "Neo.ClientError.Statement.SyntaxError" {
45+
// ctx = context.WithValue(ctx, syntaxErrorMsgKey{}, err.Msg)
46+
// } else {
47+
// return ctx, err
48+
// }
49+
// } else {
50+
// return ctx, err
51+
// }
52+
//}
53+
//return context.WithValue(ctx, resultCtxKey{}, result), nil
54+
55+
reporter := &reporter{}
56+
s := scanner.New([]byte(query.Content), reporter)
57+
p := parser.New(s, reporter)
58+
r := &astRuntime{}
59+
stmt, err := p.Parse()
60+
if err != nil {
61+
return context.WithValue(ctx, syntaxErrKey{}, err), nil
62+
}
63+
err = r.eval(stmt)
64+
if err != nil {
65+
return context.WithValue(ctx, syntaxErrKey{}, err), nil
66+
}
67+
return ctx, nil
68+
}
69+
70+
func (g *graphFeature) theResultShouldBeEmpty(ctx context.Context) (context.Context, error) {
71+
return ctx, nil
72+
}
73+
74+
func (g *graphFeature) theResultShouldBeInAnyOrder(ctx context.Context, table *godog.Table) (context.Context, error) {
75+
return ctx, nil
76+
}
77+
78+
func (g *graphFeature) theSideEffectsShouldBe(ctx context.Context, values *godog.Table) (context.Context, error) {
79+
return ctx, nil
80+
}
81+
82+
func (g *graphFeature) syntaxErrorRaised(ctx context.Context, errStr string) (context.Context, error) {
83+
if _, ok := ctx.Value(syntaxErrKey{}).(string); ok {
84+
return ctx, nil
85+
}
86+
return ctx, fmt.Errorf("expecting syntax error: %s", errStr)
87+
}
88+
89+
func TestCypherFeatures(t *testing.T) {
90+
suite := godog.TestSuite{
91+
ScenarioInitializer: InitializeCypherScenario,
92+
Options: &godog.Options{
93+
Format: "pretty",
94+
Paths: []string{"tck/features/clauses/create/Create1.feature"},
95+
TestingT: t,
96+
},
97+
}
98+
99+
if suite.Run() != 0 {
100+
t.Fatal("non-zero status returned, failed to run feature tests")
101+
}
102+
}
103+
104+
func InitializeCypherScenario(sc *godog.ScenarioContext) {
105+
g := &graphFeature{}
106+
sc.Before(g.beforeScenario)
107+
sc.After(g.afterScenario)
108+
sc.Step(`^any graph$`, g.anyGraph)
109+
sc.Step(`^an empty graph$`, g.anEmptyGraph)
110+
sc.Step(`^executing query:$`, g.executingQuery)
111+
sc.Step(`^the result should be empty$`, g.theResultShouldBeEmpty)
112+
sc.Step(`^the result should be, in any order:$`, g.theResultShouldBeInAnyOrder)
113+
sc.Step(`^the side effects should be:$`, g.theSideEffectsShouldBe)
114+
sc.Step(`^a SyntaxError should be raised at compile time: ([a-zA-Z]+)$`, g.syntaxErrorRaised)
115+
}
116+
117+
func TestMain(m *testing.M) {
118+
os.Exit(m.Run())
119+
}

0 commit comments

Comments
 (0)