From 3817567db19ab1f5897318c2095a8cb5ae1fa6d0 Mon Sep 17 00:00:00 2001 From: David Francoeur Date: Tue, 27 Sep 2022 10:29:35 -0400 Subject: [PATCH] Add a test suite to ensure `sbt` does not exit eagerly --- .../sbt-mdoc/extra-arguments/build.sbt | 3 +++ .../extra-arguments/project/build.properties | 1 + .../extra-arguments/project/plugins.sbt | 2 ++ .../sbt-test/sbt-mdoc/extra-arguments/test | 22 +++++++++++++++++++ .../extra-arguments/test-docs/invalid.md | 7 ++++++ .../extra-arguments/test-docs/valid-check.md | 1 + .../extra-arguments/test-docs/valid.md | 7 ++++++ 7 files changed, 43 insertions(+) create mode 100644 mdoc-sbt/src/sbt-test/sbt-mdoc/extra-arguments/build.sbt create mode 100644 mdoc-sbt/src/sbt-test/sbt-mdoc/extra-arguments/project/build.properties create mode 100644 mdoc-sbt/src/sbt-test/sbt-mdoc/extra-arguments/project/plugins.sbt create mode 100644 mdoc-sbt/src/sbt-test/sbt-mdoc/extra-arguments/test create mode 100644 mdoc-sbt/src/sbt-test/sbt-mdoc/extra-arguments/test-docs/invalid.md create mode 100644 mdoc-sbt/src/sbt-test/sbt-mdoc/extra-arguments/test-docs/valid-check.md create mode 100644 mdoc-sbt/src/sbt-test/sbt-mdoc/extra-arguments/test-docs/valid.md diff --git a/mdoc-sbt/src/sbt-test/sbt-mdoc/extra-arguments/build.sbt b/mdoc-sbt/src/sbt-test/sbt-mdoc/extra-arguments/build.sbt new file mode 100644 index 000000000..d5bc86887 --- /dev/null +++ b/mdoc-sbt/src/sbt-test/sbt-mdoc/extra-arguments/build.sbt @@ -0,0 +1,3 @@ +ThisBuild / scalaVersion := "2.13.9" + +enablePlugins(MdocPlugin) diff --git a/mdoc-sbt/src/sbt-test/sbt-mdoc/extra-arguments/project/build.properties b/mdoc-sbt/src/sbt-test/sbt-mdoc/extra-arguments/project/build.properties new file mode 100644 index 000000000..d738b858c --- /dev/null +++ b/mdoc-sbt/src/sbt-test/sbt-mdoc/extra-arguments/project/build.properties @@ -0,0 +1 @@ +sbt.version = 1.7.1 diff --git a/mdoc-sbt/src/sbt-test/sbt-mdoc/extra-arguments/project/plugins.sbt b/mdoc-sbt/src/sbt-test/sbt-mdoc/extra-arguments/project/plugins.sbt new file mode 100644 index 000000000..0b0ecc4ee --- /dev/null +++ b/mdoc-sbt/src/sbt-test/sbt-mdoc/extra-arguments/project/plugins.sbt @@ -0,0 +1,2 @@ +addSbtPlugin("org.scala-js" % "sbt-scalajs" % "1.9.0") +addSbtPlugin("org.scalameta" % "sbt-mdoc" % sys.props("plugin.version")) diff --git a/mdoc-sbt/src/sbt-test/sbt-mdoc/extra-arguments/test b/mdoc-sbt/src/sbt-test/sbt-mdoc/extra-arguments/test new file mode 100644 index 000000000..a60ca3527 --- /dev/null +++ b/mdoc-sbt/src/sbt-test/sbt-mdoc/extra-arguments/test @@ -0,0 +1,22 @@ +# valid +$ copy-file test-docs/valid.md docs/readme.md +> mdoc + +# --check tests +## file has not changed to `--check` is expected to succeed +> set mdocExtraArguments := Seq("--check") +> mdoc +## replace the content +$ copy-file test-docs/valid-check.md docs/readme.md +-> mdoc + + +# --check-link-hygiene +## file is valid so mdoc is expected to succeed +> set mdocExtraArguments := Seq("--check-link-hygiene") +## replace the content with a markdown with broken links +$ copy-file test-docs/invalid.md docs/readme.md +-> mdoc + +> set mdocExtraArguments := Seq.empty +> mdoc # no error, just warnings \ No newline at end of file diff --git a/mdoc-sbt/src/sbt-test/sbt-mdoc/extra-arguments/test-docs/invalid.md b/mdoc-sbt/src/sbt-test/sbt-mdoc/extra-arguments/test-docs/invalid.md new file mode 100644 index 000000000..6f926c86b --- /dev/null +++ b/mdoc-sbt/src/sbt-test/sbt-mdoc/extra-arguments/test-docs/invalid.md @@ -0,0 +1,7 @@ +# Invalid + +This file contains an invalid link. See [Invalid](#valid). + +```scala mdoc +1 + 1 +``` diff --git a/mdoc-sbt/src/sbt-test/sbt-mdoc/extra-arguments/test-docs/valid-check.md b/mdoc-sbt/src/sbt-test/sbt-mdoc/extra-arguments/test-docs/valid-check.md new file mode 100644 index 000000000..d6304dc08 --- /dev/null +++ b/mdoc-sbt/src/sbt-test/sbt-mdoc/extra-arguments/test-docs/valid-check.md @@ -0,0 +1 @@ +This file is also valid, it's used to check the `--check` flag. diff --git a/mdoc-sbt/src/sbt-test/sbt-mdoc/extra-arguments/test-docs/valid.md b/mdoc-sbt/src/sbt-test/sbt-mdoc/extra-arguments/test-docs/valid.md new file mode 100644 index 000000000..3b063870c --- /dev/null +++ b/mdoc-sbt/src/sbt-test/sbt-mdoc/extra-arguments/test-docs/valid.md @@ -0,0 +1,7 @@ +# Valid + +This file is valid, with no link error. See [Valid](#valid). + +```scala mdoc +1 + 1 +```