Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/gohugoio/hugo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2019-08-18 12:21:27 +0300
committerBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2019-08-26 16:00:44 +0300
commitf9978ed16476ca6d233a89669c62c798cdf9db9d (patch)
tree02edb31008b997a3e77055060a34971fe9e8c5a4 /htesting/test_helpers.go
parent58d4c0a8be8beefbd7437b17bf7a9a381164d09b (diff)
Image resource refactor
This commit pulls most of the image related logic into its own package, to make it easier to reason about and extend. This is also a rewrite of the transformation logic used in Hugo Pipes, mostly to allow constructs like the one below: {{ ($myimg | fingerprint ).Width }} Fixes #5903 Fixes #6234 Fixes #6266
Diffstat (limited to 'htesting/test_helpers.go')
-rw-r--r--htesting/test_helpers.go19
1 files changed, 19 insertions, 0 deletions
diff --git a/htesting/test_helpers.go b/htesting/test_helpers.go
index dc303b2e5..660c76a44 100644
--- a/htesting/test_helpers.go
+++ b/htesting/test_helpers.go
@@ -14,8 +14,10 @@
package htesting
import (
+ "math/rand"
"runtime"
"strings"
+ "time"
"github.com/spf13/afero"
)
@@ -37,3 +39,20 @@ func CreateTempDir(fs afero.Fs, prefix string) (string, func(), error) {
}
return tempDir, func() { fs.RemoveAll(tempDir) }, nil
}
+
+// BailOut panics with a stack trace after the given duration. Useful for
+// hanging tests.
+func BailOut(after time.Duration) {
+ time.AfterFunc(after, func() {
+ buf := make([]byte, 1<<16)
+ runtime.Stack(buf, true)
+ panic(string(buf))
+ })
+
+}
+
+var rnd = rand.New(rand.NewSource(time.Now().UnixNano()))
+
+func RandIntn(n int) int {
+ return rnd.Intn(n)
+}