]> gitweb.hhaalo.de Git - scantopdf.git/commitdiff
add ocr tests in extra file
authorBastian Dehn <hhaalo@arcor.de>
Sat, 4 Apr 2026 06:42:35 +0000 (08:42 +0200)
committerBastian Dehn <hhaalo@arcor.de>
Sat, 4 Apr 2026 06:42:35 +0000 (08:42 +0200)
Makefile
tests/addocr.bats [new file with mode: 0755]
tests/scanbasic.bats

index 4962ca831589b702f91d83ad725f693bacae6d66..9221bc69c20619dfd396be8ed6cfa9045ae03ac4 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -16,7 +16,11 @@ SHAREDIR = usr/local/share
 
 all: test package
 
-test: $(BUILDDIR)/parts/scanbasic.sh
+test: $(BUILDDIR)/parts/scanbasic.sh \
+       $(SRCDIR)/errlog.sh \
+       $(SRCDIR)/addocr.sh
+
+       ./tests/addocr.bats
        ./tests/scanbasic.bats
 
 build: $(PACKAGEDIR)/$(BINDIR)/scantopdf \
diff --git a/tests/addocr.bats b/tests/addocr.bats
new file mode 100755 (executable)
index 0000000..d23f3bd
--- /dev/null
@@ -0,0 +1,85 @@
+#!/usr/bin/bats
+
+setup() {
+       load "/usr/lib/bats/bats-assert/load"
+       load "/usr/lib/bats/bats-support/load"
+
+       source ./src/errlog.sh
+       source ./src/addocr.sh
+}
+
+@test "should failure optimize input parameter is missing" {
+       run optimize
+
+       assert_failure
+       assert_line --index 0 "❌ ERROR: missing input"
+} 
+
+@test "should failure optimize when qpdf failes" {
+       qpdf() {
+               return 1
+       }
+
+       run optimize "testfile"
+
+       assert_failure
+       assert_line --index 0 "❌ ERROR: could not linearize testfile"
+}
+
+@test "should failure optimize when mv fails" {
+       qpdf() {
+               :
+       }
+       mv() {
+               return 1
+       }
+
+       run optimize "testfile"
+
+       assert_failure
+       assert_line --index 0 \
+               "❌ ERROR: could not rename testfile-out to testfile"
+}
+
+@test "should success optimize" {
+       qpdf() {
+               :
+       }
+       mv() {
+               :
+       }
+
+       run optimize "testfile"
+
+       assert_success
+}
+
+@test "should failure addocr missing input parameter" {
+       run addocr
+
+       assert_failure
+       assert_line --index 0 "❌ ERROR: missing input"
+}
+
+@test "should failure addocr ocrmypdf fails" {
+       ocrmypdf() {
+               return 1
+       }
+
+       run addocr "testfile"
+
+       assert_failure
+       assert_line --index 0 "ℹ️  INFO: adding ocr on file testfile"
+       assert_line --index 1 "❌ ERROR: could not add ocr on testfile"
+}
+
+@test "should success addocr" {
+       ocrmypdf() {
+               :
+       }
+
+       run addocr "testfile"
+
+       assert_success
+       assert_line --index 0 "ℹ️  INFO: adding ocr on file testfile"
+}
index 481c9d92daa7921870aaf3914825c7d90ea86c75..3114cd2d3d06a3ba959c63cf9a4d127086f14917 100755 (executable)
@@ -7,82 +7,6 @@ setup() {
        source ./build/parts/scanbasic.sh
 }
 
-@test "should failure optimize input parameter is missing" {
-       run optimize
-
-       assert_failure
-       assert_line --index 0 "❌ ERROR: missing input"
-} 
-
-@test "should failure optimize when qpdf failes" {
-       qpdf() {
-               return 1
-       }
-
-       run optimize "testfile"
-
-       assert_failure
-       assert_line --index 0 "❌ ERROR: could not linearize testfile"
-}
-
-@test "should failure optimize when mv fails" {
-       qpdf() {
-               :
-       }
-       mv() {
-               return 1
-       }
-
-       run optimize "testfile"
-
-       assert_failure
-       assert_line --index 0 \
-               "❌ ERROR: could not rename testfile-out to testfile"
-}
-
-@test "should success optimize" {
-       qpdf() {
-               :
-       }
-       mv() {
-               :
-       }
-
-       run optimize "testfile"
-
-       assert_success
-}
-
-@test "should failure addocr missing input parameter" {
-       run addocr
-
-       assert_failure
-       assert_line --index 0 "❌ ERROR: missing input"
-}
-
-@test "should failure addocr ocrmypdf fails" {
-       ocrmypdf() {
-               return 1
-       }
-
-       run addocr "testfile"
-
-       assert_failure
-       assert_line --index 0 "ℹ️  INFO: adding ocr on file testfile"
-       assert_line --index 1 "❌ ERROR: could not add ocr on testfile"
-}
-
-@test "should success addocr" {
-       ocrmypdf() {
-               :
-       }
-
-       run addocr "testfile"
-
-       assert_success
-       assert_line --index 0 "ℹ️  INFO: adding ocr on file testfile"
-}
-
 @test "should failure createonepdf missing output parameter" {
        run createonepdf