Skip to content

Commit

Permalink
Merge pull request #2101 from rfay/20200301_bump_build_tools_golang_1_14
Browse files Browse the repository at this point in the history
Bump to build-tools 2.4.0, golang 1.14
* Improve some Test*MissingDirectory tests because they tried to rename directory while it was active. They couldn't succeed when using NFS on docker 2.2.0.3 Windows with NFS. Now the tests check with directories missing but with project stopped/paused.
  • Loading branch information
rfay committed Mar 3, 2020
2 parents 6b20975 + 0e349ec commit e9e963c
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 8 deletions.
File renamed without changes.
3 changes: 2 additions & 1 deletion build-tools/makefile_components/base_build_go.mak
Expand Up @@ -21,6 +21,7 @@ DOCKERTESTCMD=docker run -t --rm -u $(shell id -u):$(shell id -g)
-v "$(S)$(PWD):/workdir$(DOCKERMOUNTFLAG)" \
-e GOPATH="//workdir/$(GOTMP)" \
-e GOCACHE="//workdir/$(GOTMP)/.cache" \
-e GOLANGCI_LINT_CACHE="//workdir/$(GOTMP)/.golanci-lint-cache" \
-e GOFLAGS="$(USEMODVENDOR)" \
-w //workdir \
$(BUILD_IMAGE)
Expand All @@ -34,7 +35,7 @@ GOFILES = $(shell find $(SRC_DIRS) -name "*.go")

BUILD_OS = $(shell go env GOHOSTOS)

BUILD_IMAGE ?= drud/golang-build-container:v1.13.0
BUILD_IMAGE ?= drud/golang-build-container:v1.14.0

BUILD_BASE_DIR ?= $(PWD)

Expand Down
5 changes: 4 additions & 1 deletion cmd/ddev/cmd/describe_test.go
Expand Up @@ -235,7 +235,10 @@ func TestCmdDescribeMissingProjectDirectory(t *testing.T) {

_, err = exec.RunCommand(DdevBin, []string{"start"})
//nolint: errcheck
defer exec.RunCommand(DdevBin, []string{"remove", "-RO", projectName})
defer exec.RunCommand(DdevBin, []string{"delete", "-Oy", projectName})
assert.NoError(err)

_, err = exec.RunCommand(DdevBin, []string{"stop"})
assert.NoError(err)

err = os.Chdir(projDir)
Expand Down
3 changes: 3 additions & 0 deletions cmd/ddev/cmd/pause_test.go
Expand Up @@ -84,6 +84,9 @@ func TestCmdPauseContainersMissingProjectDirectory(t *testing.T) {
//nolint: errcheck
defer exec.RunCommand(DdevBin, []string{"stop", "-RO", projectName})

_, err = exec.RunCommand(DdevBin, []string{"pause", projectName})
assert.NoError(err)

err = os.Chdir(projDir)
assert.NoError(err)

Expand Down
3 changes: 3 additions & 0 deletions cmd/ddev/cmd/start_test.go
Expand Up @@ -81,6 +81,9 @@ func TestCmdStartMissingProjectDirectory(t *testing.T) {
defer exec.RunCommand(DdevBin, []string{"remove", "-RO", projectName})
assert.NoError(err)

_, err = exec.RunCommand(DdevBin, []string{"stop"})
assert.NoError(err)

err = os.Chdir(projDir)
assert.NoError(err)

Expand Down
7 changes: 5 additions & 2 deletions cmd/ddev/cmd/stop_test.go
Expand Up @@ -84,17 +84,20 @@ func TestCmdStopMissingProjectDirectory(t *testing.T) {
_, err = exec.RunCommand(DdevBin, []string{"start"})
assert.NoError(err)

_, err = exec.RunCommand(DdevBin, []string{"stop", projectName})
assert.NoError(err)

err = os.Chdir(projDir)
assert.NoError(err)

copyDir := filepath.Join(testcommon.CreateTmpDir(t.Name()), util.RandString(4))
err = os.Rename(tmpDir, copyDir)
assert.NoError(err)
//nolint: errcheck
defer os.Rename(copyDir, tmpDir)

out, err = exec.RunCommand(DdevBin, []string{"stop", projectName})
assert.NoError(err)
assert.Contains(out, "has been stopped")

err = os.Rename(copyDir, tmpDir)
assert.NoError(err)
}
13 changes: 9 additions & 4 deletions pkg/ddevapp/ddevapp_test.go
Expand Up @@ -1884,18 +1884,21 @@ func TestDdevStopMissingDirectory(t *testing.T) {
siteCopyDest := filepath.Join(tempPath, "site")
defer removeAllErrCheck(tempPath, assert)

_ = app.Stop(false, false)
// Move the site directory to a temp location to mimic a missing directory.
err = os.Rename(site.Dir, siteCopyDest)
assert.NoError(err)

//nolint: errcheck
defer os.Rename(siteCopyDest, site.Dir)

// ddev stop (in cmd) actually does the check for missing project files,
// so we imitate that here.
err = ddevapp.CheckForMissingProjectFiles(app)
assert.Error(err)
assert.Contains(err.Error(), "If you would like to continue using ddev to manage this project please restore your files to that directory.")
// Move the site directory back to its original location.
err = os.Rename(siteCopyDest, site.Dir)
assert.NoError(err)
if err != nil {
assert.Contains(err.Error(), "If you would like to continue using ddev to manage this project please restore your files to that directory.")
}
}

// TestDdevDescribe tests that the describe command works properly on a running
Expand Down Expand Up @@ -1976,6 +1979,8 @@ func TestDdevDescribeMissingDirectory(t *testing.T) {
t.Fatalf("app.StartAndWait failed err=%v logs from broken container: \n=======\n%s\n========\n", startErr, logs)
}
// Move the site directory to a temp location to mimick a missing directory.
err = app.Stop(false, false)
assert.NoError(err)
err = os.Rename(site.Dir, siteCopyDest)
assert.NoError(err)

Expand Down

0 comments on commit e9e963c

Please sign in to comment.