summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNick White <git@njw.name>2020-02-26 16:28:57 +0000
committerNick White <git@njw.name>2020-02-26 16:28:57 +0000
commita47b35dc44f0e770a1bb1f7b53b6aa11d6895e0b (patch)
tree3994c41d70fafe44e94eae89dd4be5653c51e616
parentd900d8bd656fffc1d2f2581d50eaac15c428ba17 (diff)
Fix flag parsing with go test, and switch to -short to gate long tests
-rw-r--r--init_test.go19
-rw-r--r--sauvola_test.go8
-rw-r--r--wipesides_test.go2
3 files changed, 21 insertions, 8 deletions
diff --git a/init_test.go b/init_test.go
new file mode 100644
index 0000000..37e510b
--- /dev/null
+++ b/init_test.go
@@ -0,0 +1,19 @@
+// Copyright 2019 Nick White.
+// Use of this source code is governed by the GPLv3
+// license that can be found in the LICENSE file.
+
+package preproc
+
+import (
+ "flag"
+ "os"
+ "testing"
+)
+
+var update = flag.Bool("update", false, "update golden files")
+
+// TestMain is needed to ensure flags are parsed
+func TestMain(m *testing.M) {
+ flag.Parse()
+ os.Exit(m.Run())
+}
diff --git a/sauvola_test.go b/sauvola_test.go
index f0433ba..fd5da60 100644
--- a/sauvola_test.go
+++ b/sauvola_test.go
@@ -5,7 +5,6 @@
package preproc
import (
- "flag"
"fmt"
"image"
"image/png"
@@ -14,9 +13,6 @@ import (
)
func TestBinarization(t *testing.T) {
- var slow = flag.Bool("slow", false, "include slow tests")
- var update = flag.Bool("updatesauvola", false, "update golden files")
-
cases := []struct {
name string
orig string
@@ -43,10 +39,10 @@ func TestBinarization(t *testing.T) {
case "integralsauvola":
actual = IntegralSauvola(orig, c.ksize, c.wsize)
case "sauvola":
- if *slow {
+ if !testing.Short() {
actual = Sauvola(orig, c.ksize, c.wsize)
} else {
- t.Skip("Skipping slow test; use -slow to run it.\n")
+ t.Skip("Skipping long test due to -short flag.\n")
}
default:
t.Fatalf("No method %s\n", c.name)
diff --git a/wipesides_test.go b/wipesides_test.go
index ffd60cb..4906c5b 100644
--- a/wipesides_test.go
+++ b/wipesides_test.go
@@ -8,7 +8,6 @@ package preproc
// TODO: test non integral img version
import (
- "flag"
"fmt"
"image"
"image/png"
@@ -17,7 +16,6 @@ import (
)
func TestWipeSides(t *testing.T) {
- var update = flag.Bool("updatewipe", false, "update golden files")
cases := []struct {
name string
orig string