Merge "cmd/vdl: use v23tests library in vdl_test"
diff --git a/cmd/vdl/v23_internal_test.go b/cmd/vdl/v23_internal_test.go
index ae59080..a80e0ec 100644
--- a/cmd/vdl/v23_internal_test.go
+++ b/cmd/vdl/v23_internal_test.go
@@ -12,9 +12,11 @@
"testing"
"v.io/x/ref/test"
+ "v.io/x/ref/test/modules"
)
func TestMain(m *testing.M) {
test.Init()
+ modules.DispatchAndExitIfChild()
os.Exit(m.Run())
}
diff --git a/cmd/vdl/vdl_test.go b/cmd/vdl/vdl_test.go
index da17bb9..7a127cd 100644
--- a/cmd/vdl/vdl_test.go
+++ b/cmd/vdl/vdl_test.go
@@ -8,12 +8,11 @@
"bytes"
"fmt"
"io/ioutil"
- "os"
"path/filepath"
"strings"
"testing"
- "v.io/x/lib/cmdline"
+ "v.io/x/ref/test/v23tests"
)
const (
@@ -25,18 +24,15 @@
// Compares generated VDL files against the copy in the repo.
func TestVDLGenerator(t *testing.T) {
+ testEnv := v23tests.New(t)
+ defer testEnv.Cleanup()
+ vdlBin := testEnv.BuildGoPkg("v.io/x/ref/cmd/vdl")
+
// Use vdl to generate Go code from input, into a temporary directory.
- outDir, err := ioutil.TempDir("", "vdltest")
- if err != nil {
- t.Fatalf("TempDir() failed: %v", err)
- }
- defer os.RemoveAll(outDir)
+ outDir := testEnv.NewTempDir("")
// TODO(toddw): test the generated java and javascript files too.
outOpt := fmt.Sprintf("--go-out-dir=%s", outDir)
- env := cmdline.EnvFromOS()
- if err := cmdline.ParseAndRun(cmdVDL, env, []string{"generate", "--lang=go", outOpt, testDir}); err != nil {
- t.Fatalf("Execute() failed: %v", err)
- }
+ vdlBin.Run("generate", "--lang=go", outOpt, testDir)
// Check that each *.vdl.go file in the testDir matches the generated output.
entries, err := ioutil.ReadDir(testDir)
if err != nil {