From 49a7da77d9253e6eb01585e2fc2302b4b2c9e7f9 Mon Sep 17 00:00:00 2001
From: Eduardo Trujillo <ed@chromabits.com>
Date: Sun, 27 Dec 2020 19:00:14 -0800
Subject: [PATCH] test: Use tasty and generate a JUnit XML report for GitLab

---
 .gitlab-ci.yml                 | 10 +++++++++-
 package.yaml                   |  5 ++++-
 shift.cabal                    |  5 ++++-
 test/Spec.hs                   |  2 +-
 test/Test/Shift/ParsersSpec.hs |  4 ++--
 5 files changed, 20 insertions(+), 6 deletions(-)

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index d3b9dfa..588d78b 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -40,7 +40,15 @@ stack-test:
   before_script:
     - export STACK_ROOT="$CI_PROJECT_DIR/.stack"
   script:
-    - stack --no-terminal test
+    - stack --no-terminal test --ta "--xml=report.xml"
+  artifacts:
+    when: always
+    untracked: false
+    expire_in: 30 days
+    paths:
+      - report.xml
+    reports:
+      junit: report.xml
 
 upload:
   stage: upload
diff --git a/package.yaml b/package.yaml
index 609126c..2c8b705 100644
--- a/package.yaml
+++ b/package.yaml
@@ -78,8 +78,11 @@ tests:
     dependencies:
       - shift
       - hspec
-      - hspec-discover
       - hspec-megaparsec
+      - tasty
+      - tasty-hspec
+      - tasty-discover
+      - tasty-test-reporter
   doctest:
     main: Doctest.hs
     dependencies:
diff --git a/shift.cabal b/shift.cabal
index 395d5d7..b104465 100644
--- a/shift.cabal
+++ b/shift.cabal
@@ -166,7 +166,6 @@ test-suite spec
     , gitlab-haskell
     , hgit
     , hspec
-    , hspec-discover
     , hspec-megaparsec
     , http-client
     , http-client-tls
@@ -181,6 +180,10 @@ test-suite spec
     , semigroups
     , shift
     , string-conversions
+    , tasty
+    , tasty-discover
+    , tasty-hspec
+    , tasty-test-reporter
     , text
     , transformers
     , unordered-containers
diff --git a/test/Spec.hs b/test/Spec.hs
index 52ef578..8b2a545 100644
--- a/test/Spec.hs
+++ b/test/Spec.hs
@@ -1 +1 @@
-{-# OPTIONS_GHC -F -pgmF hspec-discover #-}
\ No newline at end of file
+{-# OPTIONS_GHC -F -pgmF tasty-discover -optF --ingredient=Test.Tasty.Runners.Reporter.ingredient #-}
\ No newline at end of file
diff --git a/test/Test/Shift/ParsersSpec.hs b/test/Test/Shift/ParsersSpec.hs
index c0a8641..6b634d0 100644
--- a/test/Test/Shift/ParsersSpec.hs
+++ b/test/Test/Shift/ParsersSpec.hs
@@ -30,8 +30,8 @@ import Test.Hspec.Megaparsec (shouldFailOn, shouldParse)
 import Text.Megaparsec (parse)
 import Text.Megaparsec.Char (eol, string)
 
-spec :: Spec
-spec = do
+spec_Parsers :: Spec
+spec_Parsers = do
   -- spaced
   describe "spaced" $ do
     it "parses using the inner parser" $ do
-- 
GitLab