From 6a63694a3e2878da95bea2376f267061a2e60ac1 Mon Sep 17 00:00:00 2001 From: Eike Kettner Date: Wed, 10 Mar 2021 19:48:56 +0100 Subject: [PATCH] Convert unit tests to munit --- build.sbt | 38 +++--- .../StanfordTextClassifierSuite.scala | 4 +- .../contact/ContactAnnotateSpec.scala | 4 +- .../docspell/analysis/date/DateFindSpec.scala | 4 +- .../analysis/nlp/BaseCRFAnnotatorSuite.scala | 12 +- .../nlp/StanfordNerAnnotatorSuite.scala | 16 +-- .../analysis/split/TestSplitterSpec.scala | 4 +- .../scala/docspell/common/FileNameTest.scala | 4 +- .../test/scala/docspell/common/GlobTest.scala | 4 +- .../common/MetaProposalListTest.scala | 4 +- .../docspell/common/NerLabelSpanTest.scala | 4 +- .../docspell/convert/ConversionTest.scala | 87 +++++++------- .../convert/extern/ExternConvTest.scala | 113 +++++++++--------- .../extract/ocr/TextExtractionSuite.scala | 10 +- .../docspell/extract/odf/OdfExtractTest.scala | 4 +- .../extract/pdfbox/PdfMetaDataTest.scala | 4 +- .../extract/pdfbox/PdfboxExtractTest.scala | 4 +- .../extract/pdfbox/PdfboxPreviewTest.scala | 4 +- .../docspell/extract/poi/PoiExtractTest.scala | 4 +- .../docspell/extract/rtf/RtfExtractTest.scala | 4 +- .../scala/docspell/files/ImageSizeTest.scala | 4 +- .../test/scala/docspell/files/ZipTest.scala | 4 +- .../docspell/joex/analysis/NerFileTest.scala | 4 +- .../joex/scheduler/CountingSchemeSpec.scala | 4 +- .../generator/ItemQueryGeneratorTest.scala | 4 +- .../docspell/store/qb/QueryBuilderTest.scala | 4 +- .../store/qb/impl/ConditionBuilderTest.scala | 4 +- .../docspell/store/qb/impl/DSLTest.scala | 4 +- .../store/qb/impl/SelectBuilderTest.scala | 4 +- .../store/queries/QueryWildcardTest.scala | 4 +- 30 files changed, 175 insertions(+), 197 deletions(-) diff --git a/build.sbt b/build.sbt index 3a1ca00a..290f5109 100644 --- a/build.sbt +++ b/build.sbt @@ -45,12 +45,6 @@ val sharedSettings = Seq( (scalacOptions.value.filter(o => !o.contains("-Xlint") && !o.contains("-W"))) ) ++ scalafixSettings -val testSettings = Seq( - testFrameworks += new TestFramework("minitest.runner.Framework"), - libraryDependencies ++= Dependencies.miniTest ++ Dependencies.logging.map(_ % Test), - Test / fork := true -) - val testSettingsMUnit = Seq( libraryDependencies ++= Dependencies.munit.map(_ % Test), testFrameworks += new TestFramework("munit.Framework") @@ -231,7 +225,7 @@ val common = project .in(file("modules/common")) .disablePlugins(RevolverPlugin) .settings(sharedSettings) - .settings(testSettings) + .settings(testSettingsMUnit) .settings( name := "docspell-common", libraryDependencies ++= @@ -249,7 +243,7 @@ val files = project .in(file("modules/files")) .disablePlugins(RevolverPlugin) .settings(sharedSettings) - .settings(testSettings) + .settings(testSettingsMUnit) .settings( name := "docspell-files", libraryDependencies ++= @@ -308,7 +302,7 @@ val store = project .in(file("modules/store")) .disablePlugins(RevolverPlugin) .settings(sharedSettings) - .settings(testSettings) + .settings(testSettingsMUnit) .settings( name := "docspell-store", libraryDependencies ++= @@ -330,7 +324,7 @@ val extract = project .in(file("modules/extract")) .disablePlugins(RevolverPlugin) .settings(sharedSettings) - .settings(testSettings) + .settings(testSettingsMUnit) .settings( name := "docspell-extract", libraryDependencies ++= @@ -347,7 +341,7 @@ val convert = project .in(file("modules/convert")) .disablePlugins(RevolverPlugin) .settings(sharedSettings) - .settings(testSettings) + .settings(testSettingsMUnit) .settings( name := "docspell-convert", libraryDependencies ++= @@ -361,7 +355,7 @@ val analysis = project .disablePlugins(RevolverPlugin) .enablePlugins(NerModelsPlugin) .settings(sharedSettings) - .settings(testSettings) + .settings(testSettingsMUnit) .settings(NerModelsPlugin.nerClassifierSettings) .settings( name := "docspell-analysis", @@ -375,7 +369,7 @@ val ftsclient = project .in(file("modules/fts-client")) .disablePlugins(RevolverPlugin) .settings(sharedSettings) - .settings(testSettings) + .settings(testSettingsMUnit) .settings( name := "docspell-fts-client", libraryDependencies ++= Seq.empty @@ -386,7 +380,7 @@ val ftssolr = project .in(file("modules/fts-solr")) .disablePlugins(RevolverPlugin) .settings(sharedSettings) - .settings(testSettings) + .settings(testSettingsMUnit) .settings( name := "docspell-fts-solr", libraryDependencies ++= @@ -402,7 +396,7 @@ val restapi = project .disablePlugins(RevolverPlugin) .enablePlugins(OpenApiSchema) .settings(sharedSettings) - .settings(testSettings) + .settings(testSettingsMUnit) .settings(openapiScalaSettings) .settings( name := "docspell-restapi", @@ -420,7 +414,7 @@ val joexapi = project .disablePlugins(RevolverPlugin) .enablePlugins(OpenApiSchema) .settings(sharedSettings) - .settings(testSettings) + .settings(testSettingsMUnit) .settings(openapiScalaSettings) .settings( name := "docspell-joexapi", @@ -438,7 +432,7 @@ val backend = project .in(file("modules/backend")) .disablePlugins(RevolverPlugin) .settings(sharedSettings) - .settings(testSettings) + .settings(testSettingsMUnit) .settings( name := "docspell-backend", libraryDependencies ++= @@ -473,7 +467,7 @@ val joex = project .in(file("modules/joex")) .enablePlugins(BuildInfoPlugin, JavaServerAppPackaging, DebianPlugin, SystemdPlugin) .settings(sharedSettings) - .settings(testSettings) + .settings(testSettingsMUnit) .settings(debianSettings("docspell-joex")) .settings(buildInfoSettings) .settings( @@ -512,7 +506,7 @@ val restserver = project .in(file("modules/restserver")) .enablePlugins(BuildInfoPlugin, JavaServerAppPackaging, DebianPlugin, SystemdPlugin) .settings(sharedSettings) - .settings(testSettings) + .settings(testSettingsMUnit) .settings(debianSettings("docspell-server")) .settings(buildInfoSettings) .settings( @@ -740,7 +734,8 @@ def packageTools(logger: Logger, dir: File, version: String): Seq[File] = { wx / "icons" / "logo-96.png" -> "icons/logo-96.png", wx / "manifest.json" -> "manifest.json" ), - webext + webext, + None ) val excludes = Seq(wx, target) @@ -757,7 +752,8 @@ def packageTools(logger: Logger, dir: File, version: String): Seq[File] = { wx / "native/app_manifest.json" -> s"docspell-tools-${version}/firefox/native/app_manifest.json", wx / "native/native.py" -> s"docspell-tools-${version}/firefox/native/native.py" ) ++ files, - archive + archive, + None ) Seq(archive) diff --git a/modules/analysis/src/test/scala/docspell/analysis/classifier/StanfordTextClassifierSuite.scala b/modules/analysis/src/test/scala/docspell/analysis/classifier/StanfordTextClassifierSuite.scala index 0229585c..1fcf5e81 100644 --- a/modules/analysis/src/test/scala/docspell/analysis/classifier/StanfordTextClassifierSuite.scala +++ b/modules/analysis/src/test/scala/docspell/analysis/classifier/StanfordTextClassifierSuite.scala @@ -1,6 +1,6 @@ package docspell.analysis.classifier -import minitest._ +import munit._ import cats.effect._ import scala.concurrent.ExecutionContext import java.nio.file.Paths @@ -10,7 +10,7 @@ import fs2.Stream import cats.data.Kleisli import TextClassifier.Data -object StanfordTextClassifierSuite extends SimpleTestSuite { +class StanfordTextClassifierSuite extends FunSuite { val logger = Logger.log4s[IO](org.log4s.getLogger) implicit val CS = IO.contextShift(ExecutionContext.global) diff --git a/modules/analysis/src/test/scala/docspell/analysis/contact/ContactAnnotateSpec.scala b/modules/analysis/src/test/scala/docspell/analysis/contact/ContactAnnotateSpec.scala index aaff9203..106dad9e 100644 --- a/modules/analysis/src/test/scala/docspell/analysis/contact/ContactAnnotateSpec.scala +++ b/modules/analysis/src/test/scala/docspell/analysis/contact/ContactAnnotateSpec.scala @@ -1,9 +1,9 @@ package docspell.analysis.contact import docspell.common.{NerLabel, NerTag} -import minitest.SimpleTestSuite +import munit._ -object ContactAnnotateSpec extends SimpleTestSuite { +class ContactAnnotateSpec extends FunSuite { test("find email") { diff --git a/modules/analysis/src/test/scala/docspell/analysis/date/DateFindSpec.scala b/modules/analysis/src/test/scala/docspell/analysis/date/DateFindSpec.scala index 705d0f43..3711434f 100644 --- a/modules/analysis/src/test/scala/docspell/analysis/date/DateFindSpec.scala +++ b/modules/analysis/src/test/scala/docspell/analysis/date/DateFindSpec.scala @@ -1,11 +1,11 @@ package docspell.analysis.date import docspell.files.TestFiles -import minitest.SimpleTestSuite +import munit._ import docspell.common._ import java.time._ -object DateFindSpec extends SimpleTestSuite { +class DateFindSpec extends FunSuite { test("find simple dates") { val expect = Vector( diff --git a/modules/analysis/src/test/scala/docspell/analysis/nlp/BaseCRFAnnotatorSuite.scala b/modules/analysis/src/test/scala/docspell/analysis/nlp/BaseCRFAnnotatorSuite.scala index 29b3b966..340359e1 100644 --- a/modules/analysis/src/test/scala/docspell/analysis/nlp/BaseCRFAnnotatorSuite.scala +++ b/modules/analysis/src/test/scala/docspell/analysis/nlp/BaseCRFAnnotatorSuite.scala @@ -2,19 +2,17 @@ package docspell.analysis.nlp import docspell.analysis.Env import docspell.common.Language.NLPLanguage -import minitest.SimpleTestSuite +import munit._ import docspell.files.TestFiles import docspell.common._ -object BaseCRFAnnotatorSuite extends SimpleTestSuite { +class BaseCRFAnnotatorSuite extends FunSuite { def annotate(language: NLPLanguage): String => Vector[NerLabel] = BasicCRFAnnotator.nerAnnotate(BasicCRFAnnotator.Cache.getAnnotator(language)) test("find english ner labels") { - if (Env.isCI) { - ignore("Test ignored on travis.") - } + assume(!Env.isCI, "Test ignored on travis.") val labels = annotate(Language.English)(TestFiles.letterENText) val expect = Vector( @@ -52,9 +50,7 @@ object BaseCRFAnnotatorSuite extends SimpleTestSuite { } test("find german ner labels") { - if (Env.isCI) { - ignore("Test ignored on travis.") - } + assume(!Env.isCI, "Test ignored on travis.") val labels = annotate(Language.German)(TestFiles.letterDEText) val expect = Vector( diff --git a/modules/analysis/src/test/scala/docspell/analysis/nlp/StanfordNerAnnotatorSuite.scala b/modules/analysis/src/test/scala/docspell/analysis/nlp/StanfordNerAnnotatorSuite.scala index 91ab7a39..46bcb841 100644 --- a/modules/analysis/src/test/scala/docspell/analysis/nlp/StanfordNerAnnotatorSuite.scala +++ b/modules/analysis/src/test/scala/docspell/analysis/nlp/StanfordNerAnnotatorSuite.scala @@ -4,22 +4,20 @@ import java.nio.file.Paths import cats.effect.IO import docspell.analysis.Env -import minitest.SimpleTestSuite +import munit._ import docspell.files.TestFiles import docspell.common._ import docspell.common.syntax.FileSyntax._ import edu.stanford.nlp.pipeline.StanfordCoreNLP -object StanfordNerAnnotatorSuite extends SimpleTestSuite { +class StanfordNerAnnotatorSuite extends FunSuite { lazy val germanClassifier = new StanfordCoreNLP(Properties.nerGerman(None, false)) lazy val englishClassifier = new StanfordCoreNLP(Properties.nerEnglish(None)) test("find english ner labels") { - if (Env.isCI) { - ignore("Test ignored on travis.") - } + assume(!Env.isCI, "Test ignored on travis.") val labels = StanfordNerAnnotator.nerAnnotate(englishClassifier, TestFiles.letterENText) @@ -58,9 +56,7 @@ object StanfordNerAnnotatorSuite extends SimpleTestSuite { } test("find german ner labels") { - if (Env.isCI) { - ignore("Test ignored on travis.") - } + assume(!Env.isCI, "Test ignored on travis.") val labels = StanfordNerAnnotator.nerAnnotate(germanClassifier, TestFiles.letterDEText) @@ -83,9 +79,7 @@ object StanfordNerAnnotatorSuite extends SimpleTestSuite { } test("regexner-only annotator") { - if (Env.isCI) { - ignore("Test ignored on travis.") - } + assume(!Env.isCI, "Test ignored on travis.") val regexNerContent = s"""(?i)volantino ag${"\t"}ORGANIZATION${"\t"}LOCATION,PERSON,MISC${"\t"}3 diff --git a/modules/analysis/src/test/scala/docspell/analysis/split/TestSplitterSpec.scala b/modules/analysis/src/test/scala/docspell/analysis/split/TestSplitterSpec.scala index 4c17741d..81c37702 100644 --- a/modules/analysis/src/test/scala/docspell/analysis/split/TestSplitterSpec.scala +++ b/modules/analysis/src/test/scala/docspell/analysis/split/TestSplitterSpec.scala @@ -1,8 +1,8 @@ package docspell.analysis.split -import minitest.SimpleTestSuite +import munit._ -object TestSplitterSpec extends SimpleTestSuite { +class TestSplitterSpec extends FunSuite { test("simple splitting") { val text = """hiermit kündige ich meine Mitgliedschaft in der Kranken- und diff --git a/modules/common/src/test/scala/docspell/common/FileNameTest.scala b/modules/common/src/test/scala/docspell/common/FileNameTest.scala index 8b2778d7..05b12d74 100644 --- a/modules/common/src/test/scala/docspell/common/FileNameTest.scala +++ b/modules/common/src/test/scala/docspell/common/FileNameTest.scala @@ -1,8 +1,8 @@ package docspell.common -import minitest._ +import munit._ -object FileNameTest extends SimpleTestSuite { +class FileNameTest extends FunSuite { test("make filename") { val data = List( diff --git a/modules/common/src/test/scala/docspell/common/GlobTest.scala b/modules/common/src/test/scala/docspell/common/GlobTest.scala index 2e650174..be20b9ba 100644 --- a/modules/common/src/test/scala/docspell/common/GlobTest.scala +++ b/modules/common/src/test/scala/docspell/common/GlobTest.scala @@ -1,9 +1,9 @@ package docspell.common -import minitest._ +import munit._ import Glob._ -object GlobTest extends SimpleTestSuite { +class GlobTest extends FunSuite { test("literals") { assert(Glob.pattern(Pattern(Segment(Token.Literal("hello")))).matches(true)("hello")) diff --git a/modules/common/src/test/scala/docspell/common/MetaProposalListTest.scala b/modules/common/src/test/scala/docspell/common/MetaProposalListTest.scala index c35bafcc..fd705510 100644 --- a/modules/common/src/test/scala/docspell/common/MetaProposalListTest.scala +++ b/modules/common/src/test/scala/docspell/common/MetaProposalListTest.scala @@ -1,10 +1,10 @@ package docspell.common -import minitest._ +import munit._ import cats.data.NonEmptyList import docspell.common.MetaProposal.Candidate -object MetaProposalListTest extends SimpleTestSuite { +class MetaProposalListTest extends FunSuite { test("flatten retains order of candidates") { val cand1 = Candidate(IdRef(Ident.unsafe("123"), "name"), Set.empty) diff --git a/modules/common/src/test/scala/docspell/common/NerLabelSpanTest.scala b/modules/common/src/test/scala/docspell/common/NerLabelSpanTest.scala index add1376a..2d3568cf 100644 --- a/modules/common/src/test/scala/docspell/common/NerLabelSpanTest.scala +++ b/modules/common/src/test/scala/docspell/common/NerLabelSpanTest.scala @@ -1,8 +1,8 @@ package docspell.common -import minitest._ +import munit._ -object NerLabelSpanTest extends SimpleTestSuite { +class NerLabelSpanTest extends FunSuite { test("build") { val labels = List( diff --git a/modules/convert/src/test/scala/docspell/convert/ConversionTest.scala b/modules/convert/src/test/scala/docspell/convert/ConversionTest.scala index 4d7e80ed..f0ce80a4 100644 --- a/modules/convert/src/test/scala/docspell/convert/ConversionTest.scala +++ b/modules/convert/src/test/scala/docspell/convert/ConversionTest.scala @@ -11,10 +11,10 @@ import docspell.convert.ConversionResult.Handler import docspell.convert.extern.{TesseractConfig, UnoconvConfig, WkHtmlPdfConfig} import docspell.convert.flexmark.MarkdownConfig import docspell.files.{ExampleFiles, TestFiles} -import minitest.SimpleTestSuite +import munit._ import docspell.convert.extern.OcrMyPdfConfig -object ConversionTest extends SimpleTestSuite with FileChecks { +class ConversionTest extends FunSuite with FileChecks { val blocker = TestFiles.blocker implicit val CS = TestFiles.CS @@ -101,59 +101,58 @@ object ConversionTest extends SimpleTestSuite with FileChecks { ) test("convert to pdf") { - if (!commandsExist) ignore("At least one of the conversion programs not found") - else - File - .withTempDir[IO](target, "convpdf") - .use { dir => - conversion.use { conv => - def check(n: Long): Handler[IO, Unit] = - storePdfHandler(dir.resolve(s"test-$n.pdf")).map { p => - assert(p.isNonEmpty && p.isPDF) - } + assume(commandsExist, "At least one of the conversion programs not found") - runConversion(pdfOnly, check, conv).compile.drain - } + File + .withTempDir[IO](target, "convpdf") + .use { dir => + conversion.use { conv => + def check(n: Long): Handler[IO, Unit] = + storePdfHandler(dir.resolve(s"test-$n.pdf")).map { p => + assert(p.isNonEmpty && p.isPDF) + } + + runConversion(pdfOnly, check, conv).compile.drain } - .unsafeRunSync() + } + .unsafeRunSync() } test("convert image to pdf and txt") { - if (!commandsExist) ignore("At least one of the conversion programs not found") - else - File - .withTempDir[IO](target, "convimgpdf") - .use { dir => - conversion.use { conv => - def check(n: Long): Handler[IO, Unit] = - storePdfTxtHandler(dir.resolve(s"test-$n.pdf"), dir.resolve(s"test-$n.txt")) - .map { case (p, t) => - assert(p.isNonEmpty && p.isPDF) - assert(t.isNonEmpty && t.isPlainText) - } + assume(commandsExist, "At least one of the conversion programs not found") + File + .withTempDir[IO](target, "convimgpdf") + .use { dir => + conversion.use { conv => + def check(n: Long): Handler[IO, Unit] = + storePdfTxtHandler(dir.resolve(s"test-$n.pdf"), dir.resolve(s"test-$n.txt")) + .map { case (p, t) => + assert(p.isNonEmpty && p.isPDF) + assert(t.isNonEmpty && t.isPlainText) + } - runConversion(pdfAndTxt, check, conv).compile.drain - } + runConversion(pdfAndTxt, check, conv).compile.drain } - .unsafeRunSync() + } + .unsafeRunSync() } test("do not convert image bombs") { - if (!commandsExist) ignore("At least one of the conversion programs not found") - else - conversion - .use { conv => - def check: Handler[IO, Unit] = - Kleisli({ - case ConversionResult.InputMalformed(_, _) => - ().pure[IO] - case cr => - IO.raiseError(new Exception(s"Unexpected result: $cr")) - }) + assume(commandsExist, "At least one of the conversion programs not found") - runConversion(bombs, _ => check, conv).compile.drain - } - .unsafeRunSync() + conversion + .use { conv => + def check: Handler[IO, Unit] = + Kleisli({ + case ConversionResult.InputMalformed(_, _) => + ().pure[IO] + case cr => + IO.raiseError(new Exception(s"Unexpected result: $cr")) + }) + + runConversion(bombs, _ => check, conv).compile.drain + } + .unsafeRunSync() } def runConversion[A]( diff --git a/modules/convert/src/test/scala/docspell/convert/extern/ExternConvTest.scala b/modules/convert/src/test/scala/docspell/convert/extern/ExternConvTest.scala index d0f6c8b7..87cb3d33 100644 --- a/modules/convert/src/test/scala/docspell/convert/extern/ExternConvTest.scala +++ b/modules/convert/src/test/scala/docspell/convert/extern/ExternConvTest.scala @@ -6,10 +6,10 @@ import cats.effect._ import docspell.common._ import docspell.convert._ import docspell.files.{ExampleFiles, TestFiles} -import minitest.SimpleTestSuite +import munit._ import java.nio.charset.StandardCharsets -object ExternConvTest extends SimpleTestSuite with FileChecks { +class ExternConvTest extends FunSuite with FileChecks { val blocker = TestFiles.blocker implicit val CS = TestFiles.CS val utf8 = StandardCharsets.UTF_8 @@ -22,26 +22,24 @@ object ExternConvTest extends SimpleTestSuite with FileChecks { Seq("-s", "A4", "--encoding", "UTF-8", "-", "{{outfile}}"), Duration.seconds(20) ) + assume(commandExists(cfg.program), s"Command ${cfg.program} not found. Ignore tests.") + File + .withTempDir[IO](target, "wkhtmltopdf") + .use(dir => + IO { + val wkCfg = WkHtmlPdfConfig(cfg, target) + val p = + WkHtmlPdf + .toPDF[IO, Path](wkCfg, 8192, utf8, SanitizeHtml.none, blocker, logger)( + ExampleFiles.letter_de_html.readURL[IO](8192, blocker), + storePdfHandler(dir.resolve("test.pdf")) + ) + .unsafeRunSync() - if (!commandExists(cfg.program)) ignore(s"Command ${cfg.program} not found") - else - File - .withTempDir[IO](target, "wkhtmltopdf") - .use(dir => - IO { - val wkCfg = WkHtmlPdfConfig(cfg, target) - val p = - WkHtmlPdf - .toPDF[IO, Path](wkCfg, 8192, utf8, SanitizeHtml.none, blocker, logger)( - ExampleFiles.letter_de_html.readURL[IO](8192, blocker), - storePdfHandler(dir.resolve("test.pdf")) - ) - .unsafeRunSync() - - assert(p.isNonEmpty && p.isPDF) - } - ) - .unsafeRunSync() + assert(p.isNonEmpty && p.isPDF) + } + ) + .unsafeRunSync() } test("convert office to pdf") { @@ -51,25 +49,24 @@ object ExternConvTest extends SimpleTestSuite with FileChecks { Duration.seconds(20) ) - if (!commandExists(cfg.program)) ignore(s"Command ${cfg.program} not found") - else - File - .withTempDir[IO](target, "unoconv") - .use(dir => - IO { - val ucCfg = UnoconvConfig(cfg, target) - val p = - Unoconv - .toPDF[IO, Path](ucCfg, 8192, blocker, logger)( - ExampleFiles.examples_sample_docx.readURL[IO](8192, blocker), - storePdfHandler(dir.resolve("test.pdf")) - ) - .unsafeRunSync() + assume(commandExists(cfg.program), s"Command ${cfg.program} not found. Ignore tests.") + File + .withTempDir[IO](target, "unoconv") + .use(dir => + IO { + val ucCfg = UnoconvConfig(cfg, target) + val p = + Unoconv + .toPDF[IO, Path](ucCfg, 8192, blocker, logger)( + ExampleFiles.examples_sample_docx.readURL[IO](8192, blocker), + storePdfHandler(dir.resolve("test.pdf")) + ) + .unsafeRunSync() - assert(p.isNonEmpty && p.isPDF) - } - ) - .unsafeRunSync() + assert(p.isNonEmpty && p.isPDF) + } + ) + .unsafeRunSync() } test("convert image to pdf") { @@ -78,27 +75,25 @@ object ExternConvTest extends SimpleTestSuite with FileChecks { Seq("{{infile}}", "out", "-l", "deu", "pdf", "txt"), Duration.seconds(20) ) + assume(commandExists(cfg.program), s"Command ${cfg.program} not found") + File + .withTempDir[IO](target, "tesseract") + .use(dir => + IO { + val tessCfg = TesseractConfig(cfg, target) + val (pdf, txt) = + Tesseract + .toPDF[IO, (Path, Path)](tessCfg, Language.German, 8192, blocker, logger)( + ExampleFiles.camera_letter_en_jpg.readURL[IO](8192, blocker), + storePdfTxtHandler(dir.resolve("test.pdf"), dir.resolve("test.txt")) + ) + .unsafeRunSync() - if (!commandExists(cfg.program)) ignore(s"Command ${cfg.program} not found") - else - File - .withTempDir[IO](target, "tesseract") - .use(dir => - IO { - val tessCfg = TesseractConfig(cfg, target) - val (pdf, txt) = - Tesseract - .toPDF[IO, (Path, Path)](tessCfg, Language.German, 8192, blocker, logger)( - ExampleFiles.camera_letter_en_jpg.readURL[IO](8192, blocker), - storePdfTxtHandler(dir.resolve("test.pdf"), dir.resolve("test.txt")) - ) - .unsafeRunSync() - - assert(pdf.isNonEmpty && pdf.isPDF) - assert(txt.isNonEmpty && txt.isPlainText) - } - ) - .unsafeRunSync() + assert(pdf.isNonEmpty && pdf.isPDF) + assert(txt.isNonEmpty && txt.isPlainText) + } + ) + .unsafeRunSync() } } diff --git a/modules/extract/src/test/scala/docspell/extract/ocr/TextExtractionSuite.scala b/modules/extract/src/test/scala/docspell/extract/ocr/TextExtractionSuite.scala index 4693fd6b..c880ad6c 100644 --- a/modules/extract/src/test/scala/docspell/extract/ocr/TextExtractionSuite.scala +++ b/modules/extract/src/test/scala/docspell/extract/ocr/TextExtractionSuite.scala @@ -3,15 +3,14 @@ package docspell.extract.ocr import cats.effect.IO import docspell.common.Logger import docspell.files.TestFiles -import minitest.SimpleTestSuite +import munit._ -object TextExtractionSuite extends SimpleTestSuite { +class TextExtractionSuite extends FunSuite { import TestFiles._ val logger = Logger.log4s[IO](org.log4s.getLogger) - test("extract english pdf") { - ignore() + test("extract english pdf".ignore) { val text = TextExtract .extract[IO](letterSourceEN, blocker, logger, "eng", OcrConfig.default) .compile @@ -20,8 +19,7 @@ object TextExtractionSuite extends SimpleTestSuite { println(text) } - test("extract german pdf") { - ignore() + test("extract german pdf".ignore) { val expect = TestFiles.letterDEText val extract = TextExtract .extract[IO](letterSourceDE, blocker, logger, "deu", OcrConfig.default) diff --git a/modules/extract/src/test/scala/docspell/extract/odf/OdfExtractTest.scala b/modules/extract/src/test/scala/docspell/extract/odf/OdfExtractTest.scala index 5de1fe48..ea1d8a49 100644 --- a/modules/extract/src/test/scala/docspell/extract/odf/OdfExtractTest.scala +++ b/modules/extract/src/test/scala/docspell/extract/odf/OdfExtractTest.scala @@ -2,9 +2,9 @@ package docspell.extract.odf import cats.effect._ import docspell.files.{ExampleFiles, TestFiles} -import minitest.SimpleTestSuite +import munit._ -object OdfExtractTest extends SimpleTestSuite { +class OdfExtractTest extends FunSuite { val blocker = TestFiles.blocker implicit val CS = TestFiles.CS diff --git a/modules/extract/src/test/scala/docspell/extract/pdfbox/PdfMetaDataTest.scala b/modules/extract/src/test/scala/docspell/extract/pdfbox/PdfMetaDataTest.scala index b3cfb12d..4ea52331 100644 --- a/modules/extract/src/test/scala/docspell/extract/pdfbox/PdfMetaDataTest.scala +++ b/modules/extract/src/test/scala/docspell/extract/pdfbox/PdfMetaDataTest.scala @@ -1,8 +1,8 @@ package docspell.extract.pdfbox -import minitest.SimpleTestSuite +import munit._ -object PdfMetaDataTest extends SimpleTestSuite { +class PdfMetaDataTest extends FunSuite { test("split keywords on comma") { val md = PdfMetaData.empty.copy(keywords = Some("a,b, c")) diff --git a/modules/extract/src/test/scala/docspell/extract/pdfbox/PdfboxExtractTest.scala b/modules/extract/src/test/scala/docspell/extract/pdfbox/PdfboxExtractTest.scala index d9115b71..d39ef1c2 100644 --- a/modules/extract/src/test/scala/docspell/extract/pdfbox/PdfboxExtractTest.scala +++ b/modules/extract/src/test/scala/docspell/extract/pdfbox/PdfboxExtractTest.scala @@ -2,9 +2,9 @@ package docspell.extract.pdfbox import cats.effect._ import docspell.files.{ExampleFiles, TestFiles} -import minitest.SimpleTestSuite +import munit._ -object PdfboxExtractTest extends SimpleTestSuite { +class PdfboxExtractTest extends FunSuite { val blocker = TestFiles.blocker implicit val CS = TestFiles.CS diff --git a/modules/extract/src/test/scala/docspell/extract/pdfbox/PdfboxPreviewTest.scala b/modules/extract/src/test/scala/docspell/extract/pdfbox/PdfboxPreviewTest.scala index 19ded5ea..b6f356b5 100644 --- a/modules/extract/src/test/scala/docspell/extract/pdfbox/PdfboxPreviewTest.scala +++ b/modules/extract/src/test/scala/docspell/extract/pdfbox/PdfboxPreviewTest.scala @@ -2,11 +2,11 @@ package docspell.extract.pdfbox import cats.effect._ import docspell.files.{ExampleFiles, TestFiles} -import minitest.SimpleTestSuite +import munit._ import java.nio.file.Path import fs2.Stream -object PdfboxPreviewTest extends SimpleTestSuite { +class PdfboxPreviewTest extends FunSuite { val blocker = TestFiles.blocker implicit val CS = TestFiles.CS diff --git a/modules/extract/src/test/scala/docspell/extract/poi/PoiExtractTest.scala b/modules/extract/src/test/scala/docspell/extract/poi/PoiExtractTest.scala index 0af7e8fb..d89d2c84 100644 --- a/modules/extract/src/test/scala/docspell/extract/poi/PoiExtractTest.scala +++ b/modules/extract/src/test/scala/docspell/extract/poi/PoiExtractTest.scala @@ -3,9 +3,9 @@ package docspell.extract.poi import cats.effect._ import docspell.common.MimeTypeHint import docspell.files.{ExampleFiles, TestFiles} -import minitest.SimpleTestSuite +import munit._ -object PoiExtractTest extends SimpleTestSuite { +class PoiExtractTest extends FunSuite { val blocker = TestFiles.blocker implicit val CS = TestFiles.CS diff --git a/modules/extract/src/test/scala/docspell/extract/rtf/RtfExtractTest.scala b/modules/extract/src/test/scala/docspell/extract/rtf/RtfExtractTest.scala index af98fec9..6736c0cd 100644 --- a/modules/extract/src/test/scala/docspell/extract/rtf/RtfExtractTest.scala +++ b/modules/extract/src/test/scala/docspell/extract/rtf/RtfExtractTest.scala @@ -1,9 +1,9 @@ package docspell.extract.rtf import docspell.files.ExampleFiles -import minitest.SimpleTestSuite +import munit._ -object RtfExtractTest extends SimpleTestSuite { +class RtfExtractTest extends FunSuite { test("extract text from rtf using java input-stream") { val file = ExampleFiles.examples_sample_rtf diff --git a/modules/files/src/test/scala/docspell/files/ImageSizeTest.scala b/modules/files/src/test/scala/docspell/files/ImageSizeTest.scala index c717c5b0..8cbc02c9 100644 --- a/modules/files/src/test/scala/docspell/files/ImageSizeTest.scala +++ b/modules/files/src/test/scala/docspell/files/ImageSizeTest.scala @@ -2,12 +2,12 @@ package docspell.files import cats.implicits._ import cats.effect.{Blocker, IO} -import minitest.SimpleTestSuite +import munit._ import scala.concurrent.ExecutionContext import scala.util.Using -object ImageSizeTest extends SimpleTestSuite { +class ImageSizeTest extends FunSuite { val blocker = Blocker.liftExecutionContext(ExecutionContext.global) implicit val CS = IO.contextShift(ExecutionContext.global) diff --git a/modules/files/src/test/scala/docspell/files/ZipTest.scala b/modules/files/src/test/scala/docspell/files/ZipTest.scala index 05cf1866..51dbb50a 100644 --- a/modules/files/src/test/scala/docspell/files/ZipTest.scala +++ b/modules/files/src/test/scala/docspell/files/ZipTest.scala @@ -1,12 +1,12 @@ package docspell.files -import minitest._ +import munit._ import cats.effect._ import cats.implicits._ import scala.concurrent.ExecutionContext import docspell.common.Glob -object ZipTest extends SimpleTestSuite { +class ZipTest extends FunSuite { val blocker = Blocker.liftExecutionContext(ExecutionContext.global) implicit val CS = IO.contextShift(ExecutionContext.global) diff --git a/modules/joex/src/test/scala/docspell/joex/analysis/NerFileTest.scala b/modules/joex/src/test/scala/docspell/joex/analysis/NerFileTest.scala index 03cdcbf4..fa8412a4 100644 --- a/modules/joex/src/test/scala/docspell/joex/analysis/NerFileTest.scala +++ b/modules/joex/src/test/scala/docspell/joex/analysis/NerFileTest.scala @@ -1,10 +1,10 @@ package docspell.joex.analysis -import minitest._ +import munit._ import NerFile.Pattern import java.{util => ju} -object NerFileTest extends SimpleTestSuite { +class NerFileTest extends FunSuite { test("create valid case insensitive patterns") { val names = List( diff --git a/modules/joex/src/test/scala/docspell/joex/scheduler/CountingSchemeSpec.scala b/modules/joex/src/test/scala/docspell/joex/scheduler/CountingSchemeSpec.scala index 5d867e87..56a5352d 100644 --- a/modules/joex/src/test/scala/docspell/joex/scheduler/CountingSchemeSpec.scala +++ b/modules/joex/src/test/scala/docspell/joex/scheduler/CountingSchemeSpec.scala @@ -1,9 +1,9 @@ package docspell.joex.scheduler import docspell.common.Priority -import minitest.SimpleTestSuite +import munit._ -object CountingSchemeSpec extends SimpleTestSuite { +class CountingSchemeSpec extends FunSuite { test("counting") { val cs = CountingScheme(2, 1) diff --git a/modules/store/src/test/scala/docspell/store/generator/ItemQueryGeneratorTest.scala b/modules/store/src/test/scala/docspell/store/generator/ItemQueryGeneratorTest.scala index ebc8fd33..74612153 100644 --- a/modules/store/src/test/scala/docspell/store/generator/ItemQueryGeneratorTest.scala +++ b/modules/store/src/test/scala/docspell/store/generator/ItemQueryGeneratorTest.scala @@ -3,14 +3,14 @@ package docspell.store.generator import java.time.LocalDate import docspell.store.records._ -import minitest._ +import munit._ import docspell.common._ import docspell.query.ItemQueryParser import docspell.store.queries.AttachCountTable import docspell.store.qb.DSL._ import docspell.store.qb.generator.{ItemQueryGenerator, Tables} -object ItemQueryGeneratorTest extends SimpleTestSuite { +class ItemQueryGeneratorTest extends FunSuite { import docspell.store.impl.DoobieMeta._ val tables = Tables( diff --git a/modules/store/src/test/scala/docspell/store/qb/QueryBuilderTest.scala b/modules/store/src/test/scala/docspell/store/qb/QueryBuilderTest.scala index edbe8769..f7d8b990 100644 --- a/modules/store/src/test/scala/docspell/store/qb/QueryBuilderTest.scala +++ b/modules/store/src/test/scala/docspell/store/qb/QueryBuilderTest.scala @@ -1,10 +1,10 @@ package docspell.store.qb -import minitest._ +import munit._ import docspell.store.qb.model._ import docspell.store.qb.DSL._ -object QueryBuilderTest extends SimpleTestSuite { +class QueryBuilderTest extends FunSuite { test("simple") { val c = CourseRecord.as("c") diff --git a/modules/store/src/test/scala/docspell/store/qb/impl/ConditionBuilderTest.scala b/modules/store/src/test/scala/docspell/store/qb/impl/ConditionBuilderTest.scala index 1e035f71..0d8bc32f 100644 --- a/modules/store/src/test/scala/docspell/store/qb/impl/ConditionBuilderTest.scala +++ b/modules/store/src/test/scala/docspell/store/qb/impl/ConditionBuilderTest.scala @@ -1,11 +1,11 @@ package docspell.store.qb.impl -import minitest._ +import munit._ import docspell.store.qb._ import docspell.store.qb.DSL._ import docspell.store.qb.model.{CourseRecord, PersonRecord} -object ConditionBuilderTest extends SimpleTestSuite { +class ConditionBuilderTest extends FunSuite { val c = CourseRecord.as("c") val p = PersonRecord.as("p") diff --git a/modules/store/src/test/scala/docspell/store/qb/impl/DSLTest.scala b/modules/store/src/test/scala/docspell/store/qb/impl/DSLTest.scala index 4a3f062e..8a8872d1 100644 --- a/modules/store/src/test/scala/docspell/store/qb/impl/DSLTest.scala +++ b/modules/store/src/test/scala/docspell/store/qb/impl/DSLTest.scala @@ -1,11 +1,11 @@ package docspell.store.qb.impl -import minitest._ +import munit._ import docspell.store.qb._ import docspell.store.qb.DSL._ import docspell.store.qb.model.{CourseRecord, PersonRecord} -object DSLTest extends SimpleTestSuite { +class DSLTest extends FunSuite { val course = CourseRecord.as("c") val person = PersonRecord.as("p") diff --git a/modules/store/src/test/scala/docspell/store/qb/impl/SelectBuilderTest.scala b/modules/store/src/test/scala/docspell/store/qb/impl/SelectBuilderTest.scala index f3fc8a9e..976cf4de 100644 --- a/modules/store/src/test/scala/docspell/store/qb/impl/SelectBuilderTest.scala +++ b/modules/store/src/test/scala/docspell/store/qb/impl/SelectBuilderTest.scala @@ -1,11 +1,11 @@ package docspell.store.qb.impl -import minitest._ +import munit._ import docspell.store.qb._ import docspell.store.qb.model._ import docspell.store.qb.DSL._ -object SelectBuilderTest extends SimpleTestSuite { +class SelectBuilderTest extends FunSuite { test("basic fragment") { val c = CourseRecord.as("c") diff --git a/modules/store/src/test/scala/docspell/store/queries/QueryWildcardTest.scala b/modules/store/src/test/scala/docspell/store/queries/QueryWildcardTest.scala index 91961d1f..92b92834 100644 --- a/modules/store/src/test/scala/docspell/store/queries/QueryWildcardTest.scala +++ b/modules/store/src/test/scala/docspell/store/queries/QueryWildcardTest.scala @@ -1,8 +1,8 @@ package docspell.store.queries -import minitest._ +import munit._ -object QueryWildcardTest extends SimpleTestSuite { +class QueryWildcardTest extends FunSuite { test("replace prefix") { assertEquals("%name", QueryWildcard("*name"))