This commit is contained in:
Niranjan Godbole 2017-05-20 15:00:04 +05:30
Родитель 358d80c5ad
Коммит d8abdbf5a9
4 изменённых файлов: 6 добавлений и 52 удалений

Просмотреть файл

@ -109,7 +109,7 @@ func testIntegration(name, wd string, externalProc bool, run test.RunFunc) func(
t.Parallel()
// Set up environment
testCase := test.NewTestCase(t, name, wd)
testCase := test.NewTestCase(t, name, "harness_tests", wd)
defer testCase.Cleanup()
testProj := test.NewTestProject(t, testCase.InitialPath(), wd, externalProc, run)
defer testProj.Cleanup()
@ -158,9 +158,9 @@ func testRelativePath(name, wd string, externalProc bool, run test.RunFunc) func
t.Parallel()
// Set up environment
testCase := test.NewTestCaseRelPath(t, name, wd)
testCase := test.NewTestCase(t, name, "init_path_tests", wd)
defer testCase.Cleanup()
testProj := test.NewTestProjectRelPath(t, testCase.InitialPath(), testCase.InitPath, wd, externalProc, run)
testProj := test.NewTestProject(t, testCase.InitialPath(), wd, externalProc, run)
defer testProj.Cleanup()
// Create and checkout the vendor revisions
@ -196,7 +196,6 @@ func testRelativePath(name, wd string, externalProc bool, run test.RunFunc) func
testCase.CompareFile(dep.ManifestName, testProj.ProjPath(dep.ManifestName))
testCase.CompareFile(dep.LockName, testProj.ProjPath(dep.LockName))
// Check vendor paths
testProj.CompareImportPaths()
}
}

Просмотреть файл

@ -27,7 +27,7 @@ func TestRemoveErrors(t *testing.T) {
func removeErrors(name, wd string, externalProc bool, run test.RunFunc) func(*testing.T) {
return func(t *testing.T) {
testCase := test.NewTestCase(t, name, wd)
testCase := test.NewTestCase(t, name, "harness_tests", wd)
testProj := test.NewTestProject(t, testCase.InitialPath(), wd, externalProc, run)
defer testProj.Cleanup()

Просмотреть файл

@ -36,28 +36,8 @@ type IntegrationTestCase struct {
InitPath string `json:"init-path"`
}
func NewTestCase(t *testing.T, name, wd string) *IntegrationTestCase {
rootPath := filepath.FromSlash(filepath.Join(wd, "testdata", "harness_tests", name))
n := &IntegrationTestCase{
t: t,
name: name,
rootPath: rootPath,
initialPath: filepath.Join(rootPath, "initial"),
finalPath: filepath.Join(rootPath, "final"),
}
j, err := ioutil.ReadFile(filepath.Join(rootPath, "testcase.json"))
if err != nil {
panic(err)
}
err = json.Unmarshal(j, n)
if err != nil {
panic(err)
}
return n
}
func NewTestCaseRelPath(t *testing.T, name, wd string) *IntegrationTestCase {
rootPath := filepath.FromSlash(filepath.Join(wd, "testdata", "init_path_tests", name))
func NewTestCase(t *testing.T, name, test_dir, wd string) *IntegrationTestCase {
rootPath := filepath.FromSlash(filepath.Join(wd, "testdata", test_dir, name))
n := &IntegrationTestCase{
t: t,
name: name,

Просмотреть файл

@ -64,31 +64,6 @@ func NewTestProject(t *testing.T, initPath, wd string, externalProc bool, run Ru
return new
}
func NewTestProjectRelPath(t *testing.T, initPath, wd, relativePath string, externalProc bool, run RunFunc) *IntegrationTestProject {
new := &IntegrationTestProject{
t: t,
origWd: wd,
env: os.Environ(),
run: run,
}
new.makeRootTempDir()
new.TempDir(ProjectRoot, "vendor")
new.CopyTree(initPath)
// Note that the Travis darwin platform, directories with certain roots such
// as /var are actually links to a dirtree under /private. Without the patch
// below the wd, and therefore the GOPATH, is recorded as "/var/..." but the
// actual process runs in "/private/var/..." and dies due to not being in the
// GOPATH because the roots don't line up.
if externalProc && runtime.GOOS == "darwin" && needsPrivateLeader(new.tempdir) {
new.Setenv("GOPATH", filepath.Join("/private", new.tempdir))
} else {
new.Setenv("GOPATH", new.tempdir)
}
return new
}
func (p *IntegrationTestProject) Cleanup() {
os.RemoveAll(p.tempdir)
}