Skip to content

Commit

Permalink
Allow webrpc-test binary to print out ridl scheme (#176)
Browse files Browse the repository at this point in the history
Allow test binary to print out ridl scheme
  • Loading branch information
LukasJenicek committed Dec 29, 2022
1 parent 25708e7 commit 0339b83
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
8 changes: 8 additions & 0 deletions cmd/webrpc-test/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,20 @@ import (
"net/http"
"os"
"time"
_ "embed"

"github.com/webrpc/webrpc"
"github.com/webrpc/webrpc/tests/client"
"github.com/webrpc/webrpc/tests/server"
"github.com/webrpc/webrpc/tests"
)

var (
flags = flag.NewFlagSet("webrpc-test", flag.ContinueOnError)
clientFlag = flags.Bool("client", false, "client mode")
serverFlag = flags.Bool("server", false, "server mode")
versionFlag = flags.Bool("version", false, "print version and exit")
printSchema = flags.Bool("print-schema", false, "print RIDL schema used for testing client/server communication")

// -client
clientFlags = flag.NewFlagSet("webrpc-test -client", flag.ExitOnError)
Expand All @@ -43,6 +46,11 @@ func main() {
os.Exit(0)
}

if *printSchema {
fmt.Println(tests.GetSchema())
os.Exit(0)
}

if !*serverFlag && !*clientFlag {
fmt.Fprintf(os.Stderr, "-server or -client flag is required\n")
os.Exit(1)
Expand Down
12 changes: 12 additions & 0 deletions tests/schema.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package tests

import (
_ "embed"
)

//go:embed schema/api.ridl
var schema string

func GetSchema() string {
return schema
}

0 comments on commit 0339b83

Please sign in to comment.