summaryrefslogtreecommitdiffstats
path: root/tpl/internal/go_templates/testenv/testenv_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'tpl/internal/go_templates/testenv/testenv_test.go')
-rw-r--r--tpl/internal/go_templates/testenv/testenv_test.go27
1 files changed, 25 insertions, 2 deletions
diff --git a/tpl/internal/go_templates/testenv/testenv_test.go b/tpl/internal/go_templates/testenv/testenv_test.go
index 564bff1ab..13e11abfb 100644
--- a/tpl/internal/go_templates/testenv/testenv_test.go
+++ b/tpl/internal/go_templates/testenv/testenv_test.go
@@ -5,13 +5,13 @@
package testenv_test
import (
- "github.com/gohugoio/hugo/tpl/internal/go_templates/testenv"
- //"internal/platform"
"os"
"path/filepath"
"runtime"
"strings"
"testing"
+
+ "github.com/gohugoio/hugo/tpl/internal/go_templates/testenv"
)
func TestGoToolLocation(t *testing.T) {
@@ -83,3 +83,26 @@ func TestMustHaveExec(t *testing.T) {
}
}
}
+
+func TestCleanCmdEnvPWD(t *testing.T) {
+ // Test that CleanCmdEnv sets PWD if cmd.Dir is set.
+ switch runtime.GOOS {
+ case "plan9", "windows":
+ t.Skipf("PWD is not used on %s", runtime.GOOS)
+ }
+ dir := t.TempDir()
+ cmd := testenv.Command(t, testenv.GoToolPath(t), "help")
+ cmd.Dir = dir
+ cmd = testenv.CleanCmdEnv(cmd)
+
+ for _, env := range cmd.Env {
+ if strings.HasPrefix(env, "PWD=") {
+ pwd := strings.TrimPrefix(env, "PWD=")
+ if pwd != dir {
+ t.Errorf("unexpected PWD: want %s, got %s", dir, pwd)
+ }
+ return
+ }
+ }
+ t.Error("PWD not set in cmd.Env")
+}