mirror of
https://github.com/gohugoio/hugo.git
synced 2025-08-30 22:39:58 +02:00
Pull in the latest code from Go's template packages (#11771)
Fixes #10707 Fixes #11507
This commit is contained in:
committed by
GitHub
parent
14d85ec136
commit
9f978d387f
@@ -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")
|
||||
}
|
||||
|
Reference in New Issue
Block a user