// Copyright 2011 The Go Authors. All rights reserved.
|
// Copyright 2011 The Go Authors. All rights reserved.
|
// Use of this source code is governed by a BSD-style
|
// Use of this source code is governed by a BSD-style
|
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
|
|
package main
|
package main
|
|
|
import (
|
import (
|
"path/filepath"
|
"path/filepath"
|
"runtime"
|
"runtime"
|
"testing"
|
"testing"
|
)
|
)
|
|
|
func runTest(t *testing.T, path, pkg string) {
|
func runTest(t *testing.T, path, pkg string) {
|
exitCode = 0
|
exitCode = 0
|
*pkgName = pkg
|
*pkgName = pkg
|
*recursive = false
|
*recursive = false
|
|
|
if pkg == "" {
|
if pkg == "" {
|
processFiles([]string{path}, true)
|
processFiles([]string{path}, true)
|
} else {
|
} else {
|
processDirectory(path)
|
processDirectory(path)
|
}
|
}
|
|
|
if exitCode != 0 {
|
if exitCode != 0 {
|
t.Errorf("processing %s failed: exitCode = %d", path, exitCode)
|
t.Errorf("processing %s failed: exitCode = %d", path, exitCode)
|
}
|
}
|
}
|
}
|
|
|
var tests = []struct {
|
var tests = []struct {
|
path string
|
path string
|
pkg string
|
pkg string
|
}{
|
}{
|
// individual files
|
// individual files
|
{"testdata/test1.go", ""},
|
{"testdata/test1.go", ""},
|
|
|
// directories
|
// directories
|
{filepath.Join(runtime.GOROOT(), "src/pkg/go/ast"), "ast"},
|
{filepath.Join(runtime.GOROOT(), "src/pkg/go/ast"), "ast"},
|
{filepath.Join(runtime.GOROOT(), "src/pkg/go/doc"), "doc"},
|
{filepath.Join(runtime.GOROOT(), "src/pkg/go/doc"), "doc"},
|
{filepath.Join(runtime.GOROOT(), "src/pkg/go/token"), "scanner"},
|
{filepath.Join(runtime.GOROOT(), "src/pkg/go/token"), "scanner"},
|
{filepath.Join(runtime.GOROOT(), "src/pkg/go/scanner"), "scanner"},
|
{filepath.Join(runtime.GOROOT(), "src/pkg/go/scanner"), "scanner"},
|
{filepath.Join(runtime.GOROOT(), "src/pkg/go/parser"), "parser"},
|
{filepath.Join(runtime.GOROOT(), "src/pkg/go/parser"), "parser"},
|
{filepath.Join(runtime.GOROOT(), "src/pkg/exp/types"), "types"},
|
{filepath.Join(runtime.GOROOT(), "src/pkg/exp/types"), "types"},
|
}
|
}
|
|
|
func Test(t *testing.T) {
|
func Test(t *testing.T) {
|
for _, test := range tests {
|
for _, test := range tests {
|
runTest(t, test.path, test.pkg)
|
runTest(t, test.path, test.pkg)
|
}
|
}
|
}
|
}
|
|
|