From cabeb4484df987d22f5f84ca3018b13687f24d5f Mon Sep 17 00:00:00 2001 From: Andreas Abel Date: Fri, 20 Oct 2023 08:13:51 +0200 Subject: [PATCH 1/5] Stylistic reformatting of `filterWithPred` (no semantic changes) --- CHANGELOG.md | 5 +++++ Test/Tasty/Silver/Filter.hs | 30 ++++++++++++++++-------------- tasty-silver.cabal | 8 ++++---- 3 files changed, 25 insertions(+), 18 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index af4b590..b82e8e9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,11 @@ Changes ======= +Unreleased +---------- + +* Drop support for GHC 7.4 + Version 3.3.1.2 (10 Sep 2023) --------------- diff --git a/Test/Tasty/Silver/Filter.hs b/Test/Tasty/Silver/Filter.hs index 4c5c1ae..2ab3223 100644 --- a/Test/Tasty/Silver/Filter.hs +++ b/Test/Tasty/Silver/Filter.hs @@ -118,17 +118,19 @@ checkRF ignNoInc rf tp = filterWithPred :: (TestPath -> Bool) -> TestTree -> TestTree -filterWithPred prd tree = fromMaybe emptyTest (filter' "/" tree) - where x y = x ++ "/" ++ y - - filter' :: TestPath -> TestTree -> Maybe TestTree - filter' pth (SingleTest n t) = if prd (pth n) then Just $ SingleTest n t else Nothing - filter' pth (TestGroup n ts) = Just $ TestGroup n (catMaybes $ map (filter' $ pth n) ts) - filter' pth (PlusTestOptions o t) = PlusTestOptions o <$> filter' pth t - -- we don't know at tree construction time what the tree wrapped inside an AskOptions/WithResource - -- is going to look like. We always return something, and just return an empty test group - -- if later on we see that the child subtree was excluded. - filter' pth (WithResource r t) = Just $ WithResource r (\x -> fromMaybe emptyTest (filter' pth (t x))) - filter' pth (AskOptions t) = Just $ AskOptions (\o -> fromMaybe emptyTest (filter' pth (t o))) - - emptyTest = testGroup "" [] +filterWithPred f tree = fromMaybe emptyTest $ filter' "/" tree + where + filter' :: TestPath -> TestTree -> Maybe TestTree + filter' path = \case + SingleTest n t -> if f (path n) then Just $ SingleTest n t else Nothing + TestGroup n ts -> Just $ TestGroup n $ mapMaybe (filter' $ path n) ts + PlusTestOptions o t -> PlusTestOptions o <$> filter' path t + -- we don't know at tree construction time what the tree wrapped inside an AskOptions/WithResource + -- is going to look like. We always return something, and just return an empty test group + -- if later on we see that the child subtree was excluded. + WithResource r t -> Just $ WithResource r $ \ x -> fromMaybe emptyTest $ filter' path $ t x + AskOptions t -> Just $ AskOptions $ \ o -> fromMaybe emptyTest $ filter' path $ t o + + x y = x ++ "/" ++ y + + emptyTest = testGroup "" [] diff --git a/tasty-silver.cabal b/tasty-silver.cabal index 7f0e95f..3ae79fc 100644 --- a/tasty-silver.cabal +++ b/tasty-silver.cabal @@ -43,8 +43,6 @@ tested-with: GHC == 7.10.3 GHC == 7.8.4 GHC == 7.6.3 - GHC == 7.4.2 - -- GHC 7.0 is not supported by regex-tdfa, needing array >= 0.4 Source-repository head type: git @@ -53,6 +51,8 @@ Source-repository head library Default-language: Haskell2010 + Default-extensions: + LambdaCase exposed-modules: Test.Tasty.Silver Test.Tasty.Silver.Advanced Test.Tasty.Silver.Filter @@ -67,8 +67,8 @@ library -Wcompat build-depends: - base >= 4.5 && < 5 - -- regex-tdfa has this lower bound on base, so we make it explicit here + base >= 4.6 && < 5 + -- LambdaCase supported since GHC 7.6 (base-4.6) , ansi-terminal >= 0.6.2.1 , async , bytestring >= 0.9.2.1 From d606660d870add704e49f1a3ff14bb2a59ec831f Mon Sep 17 00:00:00 2001 From: Andreas Abel Date: Fri, 20 Oct 2023 09:15:55 +0200 Subject: [PATCH 2/5] Cosmetics (incl. fixing a typo in a haddock), no semantic changes --- Test/Tasty/Silver/Filter.hs | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/Test/Tasty/Silver/Filter.hs b/Test/Tasty/Silver/Filter.hs index 2ab3223..97910a5 100644 --- a/Test/Tasty/Silver/Filter.hs +++ b/Test/Tasty/Silver/Filter.hs @@ -44,17 +44,15 @@ type TestPath = String -- we have to store the regex as String, as there is no Typeable instance -- for the Regex data type with GHC < 7.8 data RegexFilter - = RFInclude String -- include tests that match - | RFExclude String -- exclude tests that match + = RFInclude String -- ^ Include tests that match. + | RFExclude String -- ^ Exclude tests that match. deriving (Typeable) --- | Tests to completely exlucde, treating them --- like they do not exist. +-- | Tests to completely exclude, treating them like they do not exist. newtype ExcludeFilters = ExcludeFilters [RegexFilter] deriving (Typeable) --- | Tests to completely include, treating all --- other tests like they do not exist. +-- | Tests to completely include, treating all other tests like they do not exist. newtype IncludeFilters = IncludeFilters [RegexFilter] deriving (Typeable) @@ -85,7 +83,7 @@ parseFilter mkRF mkV = mkV <$> some ( option parse ( long name <> help helpStrin <$> RS.compile R.defaultCompOpt R.defaultExecOpt) parseValue1 :: (String -> RegexFilter) -> String -> Maybe [RegexFilter] -parseValue1 f x = fmap (const $ [f x]) $ compileRegex x +parseValue1 f x = fmap (const [f x]) $ compileRegex x filterWithRegex :: OptionSet -> TestTree -> TestTree filterWithRegex opts = filterWithPred (checkRF True $ excRgxs ++ incRgxs) From 0b233ec00133cfffdf1ff3dee5914f7525dbcfce Mon Sep 17 00:00:00 2001 From: Andreas Abel Date: Fri, 20 Oct 2023 09:49:48 +0200 Subject: [PATCH 3/5] Since `filterWithPred (const True) != id`, don't run it in `filterWithRedex`. `filterWithPred (const True)` is not the identity if the tree contains infinitely branching nodes like `WithResource`. Thus, `filterWithRedex` is called with no regexes, we do not call `filterWithPred` in order to preserve the original tree in obvious cases where nothing is to be filtered out. --- CHANGELOG.md | 1 + Test/Tasty/Silver/Filter.hs | 15 +++++++++++---- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b82e8e9..1053415 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ Changes Unreleased ---------- +* `filterWithRedex` is now the identity if no inclusion/exclusion regexes are given in the options. * Drop support for GHC 7.4 Version 3.3.1.2 (10 Sep 2023) diff --git a/Test/Tasty/Silver/Filter.hs b/Test/Tasty/Silver/Filter.hs index 97910a5..0c4c2a8 100644 --- a/Test/Tasty/Silver/Filter.hs +++ b/Test/Tasty/Silver/Filter.hs @@ -86,10 +86,17 @@ parseValue1 :: (String -> RegexFilter) -> String -> Maybe [RegexFilter] parseValue1 f x = fmap (const [f x]) $ compileRegex x filterWithRegex :: OptionSet -> TestTree -> TestTree -filterWithRegex opts = filterWithPred (checkRF True $ excRgxs ++ incRgxs) - where ExcludeFilters excRgxs = lookupOption opts - IncludeFilters incRgxs = lookupOption opts - +filterWithRegex opts = + -- Andreas, 2023-10-20: Since @filterWithPred (const True)@ is not the identity + -- when the test tree contains 'WithResource' etc., + -- we skip it if it does not actually filter out anything. + if null filters + then id + else filterWithPred (checkRF True filters) + where + ExcludeFilters excRgxs = lookupOption opts + IncludeFilters incRgxs = lookupOption opts + filters = excRgxs ++ incRgxs -- | Check if the given path should be kept using regex filters. -- A Tree leaf is retained if the following conditions From 8e9d0f4885f447454824f957e68d69ea1b6fbe4e Mon Sep 17 00:00:00 2001 From: Andreas Abel Date: Fri, 20 Oct 2023 09:59:07 +0200 Subject: [PATCH 4/5] Bump Haskell-CI to GHC 9.8.1 --- .github/workflows/haskell-ci.yml | 119 ++++++++----------------------- cabal.haskell-ci | 6 +- tasty-silver.cabal | 12 ++-- 3 files changed, 41 insertions(+), 96 deletions(-) diff --git a/.github/workflows/haskell-ci.yml b/.github/workflows/haskell-ci.yml index e45c2d1..59d6986 100644 --- a/.github/workflows/haskell-ci.yml +++ b/.github/workflows/haskell-ci.yml @@ -8,22 +8,18 @@ # # For more information, see https://github.com/andreasabel/haskell-ci # -# version: 0.17.20230827 +# version: 0.17.20231012 # -# REGENDATA ("0.17.20230827",["github","tasty-silver.cabal"]) +# REGENDATA ("0.17.20231012",["github","tasty-silver.cabal"]) # name: Haskell-CI on: push: branches: - master - - ci-* - - release* pull_request: branches: - master - - ci-* - - release* jobs: linux: name: Haskell-CI - Linux - ${{ matrix.compiler }} @@ -31,19 +27,19 @@ jobs: timeout-minutes: 60 container: - image: buildpack-deps:bionic + image: buildpack-deps:focal continue-on-error: ${{ matrix.allow-failure }} strategy: matrix: include: - - compiler: ghc-9.8.0.20230822 + - compiler: ghc-9.8.1 compilerKind: ghc - compilerVersion: 9.8.0.20230822 + compilerVersion: 9.8.1 setup-method: ghcup - allow-failure: true - - compiler: ghc-9.6.2 + allow-failure: false + - compiler: ghc-9.6.3 compilerKind: ghc - compilerVersion: 9.6.2 + compilerVersion: 9.6.3 setup-method: ghcup allow-failure: false - compiler: ghc-9.4.7 @@ -69,71 +65,40 @@ jobs: - compiler: ghc-8.8.4 compilerKind: ghc compilerVersion: 8.8.4 - setup-method: hvr-ppa + setup-method: ghcup allow-failure: false - compiler: ghc-8.6.5 compilerKind: ghc compilerVersion: 8.6.5 - setup-method: hvr-ppa + setup-method: ghcup allow-failure: false - compiler: ghc-8.4.4 compilerKind: ghc compilerVersion: 8.4.4 - setup-method: hvr-ppa + setup-method: ghcup allow-failure: false - compiler: ghc-8.2.2 compilerKind: ghc compilerVersion: 8.2.2 - setup-method: hvr-ppa + setup-method: ghcup allow-failure: false - compiler: ghc-8.0.2 compilerKind: ghc compilerVersion: 8.0.2 - setup-method: hvr-ppa - allow-failure: false - - compiler: ghc-7.10.3 - compilerKind: ghc - compilerVersion: 7.10.3 - setup-method: hvr-ppa - allow-failure: false - - compiler: ghc-7.8.4 - compilerKind: ghc - compilerVersion: 7.8.4 - setup-method: hvr-ppa - allow-failure: false - - compiler: ghc-7.6.3 - compilerKind: ghc - compilerVersion: 7.6.3 - setup-method: hvr-ppa - allow-failure: false - - compiler: ghc-7.4.2 - compilerKind: ghc - compilerVersion: 7.4.2 - setup-method: hvr-ppa + setup-method: ghcup allow-failure: false fail-fast: false steps: - name: apt run: | apt-get update - apt-get install -y --no-install-recommends gnupg ca-certificates dirmngr curl git software-properties-common libtinfo5 - if [ "${{ matrix.setup-method }}" = ghcup ]; then - mkdir -p "$HOME/.ghcup/bin" - curl -sL https://downloads.haskell.org/ghcup/0.1.19.5/x86_64-linux-ghcup-0.1.19.5 > "$HOME/.ghcup/bin/ghcup" - chmod a+x "$HOME/.ghcup/bin/ghcup" - "$HOME/.ghcup/bin/ghcup" config add-release-channel https://raw.githubusercontent.com/haskell/ghcup-metadata/master/ghcup-prereleases-0.0.7.yaml; - "$HOME/.ghcup/bin/ghcup" install ghc "$HCVER" || (cat "$HOME"/.ghcup/logs/*.* && false) - "$HOME/.ghcup/bin/ghcup" install cabal 3.10.1.0 || (cat "$HOME"/.ghcup/logs/*.* && false) - else - apt-add-repository -y 'ppa:hvr/ghc' - apt-get update - apt-get install -y "$HCNAME" - mkdir -p "$HOME/.ghcup/bin" - curl -sL https://downloads.haskell.org/ghcup/0.1.19.5/x86_64-linux-ghcup-0.1.19.5 > "$HOME/.ghcup/bin/ghcup" - chmod a+x "$HOME/.ghcup/bin/ghcup" - "$HOME/.ghcup/bin/ghcup" config add-release-channel https://raw.githubusercontent.com/haskell/ghcup-metadata/master/ghcup-prereleases-0.0.7.yaml; - "$HOME/.ghcup/bin/ghcup" install cabal 3.10.1.0 || (cat "$HOME"/.ghcup/logs/*.* && false) - fi + apt-get install -y --no-install-recommends gnupg ca-certificates dirmngr curl git software-properties-common libtinfo5 libnuma-dev + mkdir -p "$HOME/.ghcup/bin" + curl -sL https://downloads.haskell.org/ghcup/0.1.19.5/x86_64-linux-ghcup-0.1.19.5 > "$HOME/.ghcup/bin/ghcup" + chmod a+x "$HOME/.ghcup/bin/ghcup" + "$HOME/.ghcup/bin/ghcup" config add-release-channel https://raw.githubusercontent.com/haskell/ghcup-metadata/master/ghcup-prereleases-0.0.7.yaml; + "$HOME/.ghcup/bin/ghcup" install ghc "$HCVER" || (cat "$HOME"/.ghcup/logs/*.* && false) + "$HOME/.ghcup/bin/ghcup" install cabal 3.10.1.0 || (cat "$HOME"/.ghcup/logs/*.* && false) env: HCKIND: ${{ matrix.compilerKind }} HCNAME: ${{ matrix.compiler }} @@ -145,27 +110,18 @@ jobs: echo "CABAL_DIR=$HOME/.cabal" >> "$GITHUB_ENV" echo "CABAL_CONFIG=$HOME/.cabal/config" >> "$GITHUB_ENV" HCDIR=/opt/$HCKIND/$HCVER - if [ "${{ matrix.setup-method }}" = ghcup ]; then - HC=$("$HOME/.ghcup/bin/ghcup" whereis ghc "$HCVER") - HCPKG=$(echo "$HC" | sed 's#ghc$#ghc-pkg#') - HADDOCK=$(echo "$HC" | sed 's#ghc$#haddock#') - echo "HC=$HC" >> "$GITHUB_ENV" - echo "HCPKG=$HCPKG" >> "$GITHUB_ENV" - echo "HADDOCK=$HADDOCK" >> "$GITHUB_ENV" - echo "CABAL=$HOME/.ghcup/bin/cabal-3.10.1.0 -vnormal+nowrap" >> "$GITHUB_ENV" - else - HC=$HCDIR/bin/$HCKIND - echo "HC=$HC" >> "$GITHUB_ENV" - echo "HCPKG=$HCDIR/bin/$HCKIND-pkg" >> "$GITHUB_ENV" - echo "HADDOCK=$HCDIR/bin/haddock" >> "$GITHUB_ENV" - echo "CABAL=$HOME/.ghcup/bin/cabal-3.10.1.0 -vnormal+nowrap" >> "$GITHUB_ENV" - fi - + HC=$("$HOME/.ghcup/bin/ghcup" whereis ghc "$HCVER") + HCPKG=$(echo "$HC" | sed 's#ghc$#ghc-pkg#') + HADDOCK=$(echo "$HC" | sed 's#ghc$#haddock#') + echo "HC=$HC" >> "$GITHUB_ENV" + echo "HCPKG=$HCPKG" >> "$GITHUB_ENV" + echo "HADDOCK=$HADDOCK" >> "$GITHUB_ENV" + echo "CABAL=$HOME/.ghcup/bin/cabal-3.10.1.0 -vnormal+nowrap" >> "$GITHUB_ENV" HCNUMVER=$(${HC} --numeric-version|perl -ne '/^(\d+)\.(\d+)\.(\d+)(\.(\d+))?$/; print(10000 * $1 + 100 * $2 + ($3 == 0 ? $5 != 1 : $3))') echo "HCNUMVER=$HCNUMVER" >> "$GITHUB_ENV" echo "ARG_TESTS=--enable-tests" >> "$GITHUB_ENV" echo "ARG_BENCH=--enable-benchmarks" >> "$GITHUB_ENV" - if [ $((HCNUMVER >= 90800)) -ne 0 ] ; then echo "HEADHACKAGE=true" >> "$GITHUB_ENV" ; else echo "HEADHACKAGE=false" >> "$GITHUB_ENV" ; fi + echo "HEADHACKAGE=false" >> "$GITHUB_ENV" echo "ARG_COMPILER=--$HCKIND --with-compiler=$HC" >> "$GITHUB_ENV" echo "GHCJSARITH=0" >> "$GITHUB_ENV" env: @@ -194,18 +150,6 @@ jobs: repository hackage.haskell.org url: http://hackage.haskell.org/ EOF - if $HEADHACKAGE; then - cat >> $CABAL_CONFIG <> $CABAL_CONFIG <= 80200)) -ne 0 ] ; then echo " ghc-options: -Werror=missing-methods" >> cabal.project ; fi cat >> cabal.project <> cabal.project - fi - $HCPKG list --simple-output --names-only | perl -ne 'for (split /\s+/) { print "constraints: $_ installed\n" unless /^(bytestring|directory|process|tasty-silver)$/; }' >> cabal.project.local + $HCPKG list --simple-output --names-only | perl -ne 'for (split /\s+/) { print "constraints: $_ installed\n" unless /^(tasty-silver)$/; }' >> cabal.project.local cat cabal.project cat cabal.project.local - name: dump install plan diff --git a/cabal.haskell-ci b/cabal.haskell-ci index ca75223..d29dc9e 100644 --- a/cabal.haskell-ci +++ b/cabal.haskell-ci @@ -1,2 +1,4 @@ -installed: +all -bytestring -directory -process -branches: master ci-* release* \ No newline at end of file +branches: master + +installed: +all +-- installed: +all -bytestring -directory -process diff --git a/tasty-silver.cabal b/tasty-silver.cabal index 3ae79fc..e26230e 100644 --- a/tasty-silver.cabal +++ b/tasty-silver.cabal @@ -29,8 +29,8 @@ extra-source-files: README.md tested-with: - GHC == 9.8.0 - GHC == 9.6.2 + GHC == 9.8.1 + GHC == 9.6.3 GHC == 9.4.7 GHC == 9.2.8 GHC == 9.0.2 @@ -40,9 +40,11 @@ tested-with: GHC == 8.4.4 GHC == 8.2.2 GHC == 8.0.2 - GHC == 7.10.3 - GHC == 7.8.4 - GHC == 7.6.3 + -- Drop testing with GHC 7 + -- GHC == 7.10.3 + -- GHC == 7.8.4 + -- GHC == 7.6.3 + Source-repository head type: git From 6b0fb7da4fc89ef9e1ef939c6e609748f65670a5 Mon Sep 17 00:00:00 2001 From: Andreas Abel Date: Fri, 20 Oct 2023 09:56:35 +0200 Subject: [PATCH 5/5] Merge macOS and windows workflows - fix malfunctioning `!cache-hit` See https://github.com/actions/cache/issues/1262 - cache dependencies right after their build - add restore-key based on GHC+Cabal version --- .../{macOS.yml => cabal-mac-win.yml} | 34 ++++++---- .github/workflows/windows.yml | 67 ------------------- 2 files changed, 22 insertions(+), 79 deletions(-) rename .github/workflows/{macOS.yml => cabal-mac-win.yml} (51%) delete mode 100644 .github/workflows/windows.yml diff --git a/.github/workflows/macOS.yml b/.github/workflows/cabal-mac-win.yml similarity index 51% rename from .github/workflows/macOS.yml rename to .github/workflows/cabal-mac-win.yml index 4b6f71f..82d92f2 100644 --- a/.github/workflows/macOS.yml +++ b/.github/workflows/cabal-mac-win.yml @@ -1,11 +1,9 @@ -name: macOS +name: Cabal (macOS and Windows) on: push: branches: - master - - ci-* - - release* paths: - '.github/workflows/macOS.yml' - 'tasty-silver.cabal' @@ -26,10 +24,13 @@ defaults: jobs: build-and-test: - runs-on: macos-latest + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: { os: [macos-latest, windows-latest] } steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 with: submodules: recursive @@ -38,26 +39,35 @@ jobs: with: ghc-version: latest cabal-version: latest + cabal-update: true - name: Configure the build plan run: | - cabal update cabal configure -O1 --enable-tests - - uses: actions/cache@v3 - name: Cache dependencies + - name: Restore cached dependencies + uses: actions/cache/restore@v3 id: cache + env: + key: ${{ runner.os }}-cabal-${{ steps.setup-haskell.outputs.cabal-version }}-ghc-${{ steps.setup-haskell.outputs.ghc-version }} with: - path: | - ${{ steps.setup-haskell.outputs.cabal-store }} + path: ${{ steps.setup-haskell.outputs.cabal-store }} # The file `plan.json` contains the build information. - key: macOS-${{ hashFiles('**/plan.json') }} + key: ${{ env.key }}-plan-${{ hashFiles('**/plan.json') }} + restore-keys: ${{ env.key }}- - name: Install dependencies - if: ${{ !steps.cache.outputs.cache-hit }} + if: ${{ steps.cache.outputs.cache-hit != 'true' }} run: | cabal build --only-dependencies + - name: Cache dependencies + uses: actions/cache/save@v3 + if: ${{ steps.cache.outputs.cache-hit != 'true' }} + with: + path: ${{ steps.setup-haskell.outputs.cabal-store }} + key: ${{ steps.cache.outputs.cache-primary-key }} + - name: Build run: | cabal build diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml deleted file mode 100644 index 3f0e40a..0000000 --- a/.github/workflows/windows.yml +++ /dev/null @@ -1,67 +0,0 @@ -name: windows - -on: - push: - branches: - - master - - ci-* - - release* - paths: - - '.github/workflows/windows.yml' - - 'tasty-silver.cabal' - - 'Setup.hs' - - 'Test/**.hs' - - 'tests/**' - pull_request: - paths: - - '.github/workflows/windows.yml' - - 'tasty-silver.cabal' - - 'Setup.hs' - - 'Test/**.hs' - - 'tests/**' - -defaults: - run: - shell: bash - -jobs: - build-and-test: - runs-on: windows-latest - - steps: - - uses: actions/checkout@v3 - with: - submodules: recursive - - - uses: haskell-actions/setup@v2 - id: setup-haskell - with: - ghc-version: latest - cabal-version: latest - - - name: Configure the build plan - run: | - cabal update - cabal configure -O1 --enable-tests - - - uses: actions/cache@v3 - name: Cache dependencies - id: cache - with: - path: | - ${{ steps.setup-haskell.outputs.cabal-store }} - # The file `plan.json` contains the build information. - key: windows-${{ hashFiles('**/plan.json') }} - - - name: Install dependencies - if: ${{ !steps.cache.outputs.cache-hit }} - run: | - cabal build --only-dependencies - - - name: Build - run: | - cabal build - - - name: Test - run: | - cabal test --test-show-details=direct --test-options=-i