vitess-gh/go/testfiles/locate.go

35 строки
758 B
Go
Исходник Обычный вид История

2013-12-03 07:53:16 +04:00
// Copyright 2013, Google Inc. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// Package testfiles locates test files within the Vitess directory tree.
2013-12-03 07:53:16 +04:00
package testfiles
import (
"fmt"
"os"
"path"
"path/filepath"
2013-12-03 07:53:16 +04:00
)
func Locate(filename string) string {
vtroot := os.Getenv("VTROOT")
if vtroot == "" {
panic(fmt.Errorf("VTROOT is not set"))
}
return path.Join(vtroot, "data", "test", filename)
}
func Glob(pattern string) []string {
vtroot := os.Getenv("VTROOT")
if vtroot == "" {
panic(fmt.Errorf("VTROOT is not set"))
}
resolved := path.Join(vtroot, "data", "test", pattern)
out, err := filepath.Glob(resolved)
if err != nil {
panic(err)
}
return out
}