mirror of
https://github.com/yuin/goldmark
synced 2025-03-04 23:04:52 +00:00
Merge pull request #337 from piggynl/test-timeout-multiplier
extra_test.go: Add test timeout multiplier environment variable
This commit is contained in:
commit
4536092b45
1 changed files with 21 additions and 10 deletions
|
|
@ -2,6 +2,8 @@ package goldmark_test
|
|||
|
||||
import (
|
||||
"bytes"
|
||||
"os"
|
||||
"strconv"
|
||||
"strings"
|
||||
"testing"
|
||||
"time"
|
||||
|
|
@ -13,6 +15,15 @@ import (
|
|||
"github.com/yuin/goldmark/testutil"
|
||||
)
|
||||
|
||||
var testTimeoutMultiplier = 1.0
|
||||
|
||||
func init() {
|
||||
m, err := strconv.ParseFloat(os.Getenv("GOLDMARK_TEST_TIMEOUT_MULTIPLIER"), 64)
|
||||
if err == nil {
|
||||
testTimeoutMultiplier = m
|
||||
}
|
||||
}
|
||||
|
||||
func TestExtras(t *testing.T) {
|
||||
markdown := New(WithRendererOptions(
|
||||
html.WithXHTML(),
|
||||
|
|
@ -108,8 +119,8 @@ func TestDeepNestedLabelPerformance(t *testing.T) {
|
|||
var b bytes.Buffer
|
||||
_ = markdown.Convert(source, &b)
|
||||
finished := nowMillis()
|
||||
if (finished - started) > 5000 {
|
||||
t.Error("Parsing deep nested labels took more 5 secs")
|
||||
if (finished - started) > int64(5000*testTimeoutMultiplier) {
|
||||
t.Error("Parsing deep nested labels took too long")
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -128,8 +139,8 @@ func TestManyProcessingInstructionPerformance(t *testing.T) {
|
|||
var b bytes.Buffer
|
||||
_ = markdown.Convert(source, &b)
|
||||
finished := nowMillis()
|
||||
if (finished - started) > 5000 {
|
||||
t.Error("Parsing processing instructions took more 5 secs")
|
||||
if (finished - started) > int64(5000*testTimeoutMultiplier) {
|
||||
t.Error("Parsing processing instructions took too long")
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -148,8 +159,8 @@ func TestManyCDATAPerformance(t *testing.T) {
|
|||
var b bytes.Buffer
|
||||
_ = markdown.Convert(source, &b)
|
||||
finished := nowMillis()
|
||||
if (finished - started) > 5000 {
|
||||
t.Error("Parsing processing instructions took more 5 secs")
|
||||
if (finished - started) > int64(5000*testTimeoutMultiplier) {
|
||||
t.Error("Parsing processing instructions took too long")
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -168,8 +179,8 @@ func TestManyDeclPerformance(t *testing.T) {
|
|||
var b bytes.Buffer
|
||||
_ = markdown.Convert(source, &b)
|
||||
finished := nowMillis()
|
||||
if (finished - started) > 5000 {
|
||||
t.Error("Parsing processing instructions took more 5 secs")
|
||||
if (finished - started) > int64(5000*testTimeoutMultiplier) {
|
||||
t.Error("Parsing processing instructions took too long")
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -188,7 +199,7 @@ func TestManyCommentPerformance(t *testing.T) {
|
|||
var b bytes.Buffer
|
||||
_ = markdown.Convert(source, &b)
|
||||
finished := nowMillis()
|
||||
if (finished - started) > 5000 {
|
||||
t.Error("Parsing processing instructions took more 5 secs")
|
||||
if (finished - started) > int64(5000*testTimeoutMultiplier) {
|
||||
t.Error("Parsing processing instructions took too long")
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue