Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions cmd/mobyextgen/generation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,8 +131,8 @@ type Runtime interface{ Do(ctx interface{}, req *Req) (*Resp, error) }
wire, err := emitWire(pt)
assert.NilError(t, err)
src := string(wire)
assert.Check(t, strings.Contains(src, "func RegisterServer(r grpc.ServiceRegistrar, impl p.Runtime)"), src)
assert.Check(t, strings.Contains(src, "func NewClient(conn grpc.ClientConnInterface) p.Runtime"), src)
assert.Check(t, strings.Contains(src, "func RegisterServer(r grpc.ServiceRegistrar, impl mobyextcontract.Runtime)"), src)
assert.Check(t, strings.Contains(src, "func NewClient(conn grpc.ClientConnInterface) mobyextcontract.Runtime"), src)
assert.Check(t, !strings.Contains(src, "ServerPoint"), "a non-point contract must not emit point registrations:\n%s", src)
assert.Check(t, !strings.Contains(src, "clientpoint"), "a non-point contract must not import the point packages:\n%s", src)
assert.Check(t, !strings.Contains(src, "servicev0"), "an unpublished contract must not emit typed publication APIs:\n%s", src)
Expand Down Expand Up @@ -163,7 +163,7 @@ var Point = extensions.DefinePoint[Runtime]("my.proto.pkg.v1")
assert.Check(t, strings.Contains(src, "var ClientPoint = clientpoint.Registration{"), src)
assert.Check(t, strings.Contains(src, "func NewRuntimeClient(cc grpc.ClientConnInterface) RuntimeClient"),
"ordinary point must retain its raw gRPC client:\n%s", src)
assert.Check(t, strings.Contains(src, "func NewClient(conn grpc.ClientConnInterface) p.Runtime"),
assert.Check(t, strings.Contains(src, "func NewClient(conn grpc.ClientConnInterface) mobyextcontract.Runtime"),
"ordinary point must expose its handwritten client:\n%s", src)
assert.Check(t, !strings.Contains(src, "servicev0") && !strings.Contains(src, "func Bind("),
"ordinary Point transport must not contain extension-side publication bindings:\n%s", src)
Expand Down
1 change: 0 additions & 1 deletion cmd/mobyextgen/model.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ package main
// model

type point struct {
pkgName string // Go package name
importPath string // package import path
protoPath string // module-relative path of the .proto
licenseHeader string // SPDX notices from the contract interface's source file
Expand Down
8 changes: 4 additions & 4 deletions cmd/mobyextgen/parse.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,21 +38,21 @@ func parseContract(dir, serviceIdentity string) (point, error) {
}

var files []*ast.File
var pkgName string
foundPackage := false
for name, pkg := range pkgs {
if strings.HasSuffix(name, "_test") {
continue
}
pkgName = name
foundPackage = true
for _, f := range pkg.Files {
files = append(files, f)
}
}
if pkgName == "" {
if !foundPackage {
return point{}, fmt.Errorf("no package found in %s", dir)
}

pt := point{pkgName: pkgName}
var pt point

if serviceIdentity != "" {
pkg, service, ok := splitServiceIdentity(serviceIdentity)
Expand Down
2 changes: 1 addition & 1 deletion cmd/mobyextgen/wire.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import (

func emitWire(pt point) ([]byte, error) {
var b strings.Builder
cpkg := pt.pkgName
const cpkg = "mobyextcontract"
svc, iface := pt.service, pt.iface
b.WriteString(pt.licenseHeader)
fmt.Fprintln(&b, "// Code generated by mobyextgen. DO NOT EDIT.")
Expand Down
30 changes: 15 additions & 15 deletions example/greeter/v0/protogen/wire.gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

30 changes: 15 additions & 15 deletions internal/launcher/echo/v1/protogen/wire.gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading