Skip to content

Release preparations #74

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 13 commits into from
Feb 26, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions .github/workflows/haskell-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
#
# For more information, see https://github.com/haskell-CI/haskell-ci
#
# version: 0.19.20241223
# version: 0.19.20250216
#
# REGENDATA ("0.19.20241223",["github","cabal.project"])
# REGENDATA ("0.19.20250216",["github","cabal.project"])
#
name: Haskell-CI
on:
Expand All @@ -23,7 +23,7 @@ on:
jobs:
linux:
name: Haskell-CI - Linux - ${{ matrix.compiler }}
runs-on: ubuntu-20.04
runs-on: ubuntu-24.04
timeout-minutes:
60
container:
Expand Down Expand Up @@ -111,8 +111,8 @@ jobs:
chmod a+x "$HOME/.ghcup/bin/ghcup"
- name: Install cabal-install
run: |
"$HOME/.ghcup/bin/ghcup" install cabal 3.14.1.0 || (cat "$HOME"/.ghcup/logs/*.* && false)
echo "CABAL=$HOME/.ghcup/bin/cabal-3.14.1.0 -vnormal+nowrap" >> "$GITHUB_ENV"
"$HOME/.ghcup/bin/ghcup" install cabal 3.12.1.0 || (cat "$HOME"/.ghcup/logs/*.* && false)
echo "CABAL=$HOME/.ghcup/bin/cabal-3.12.1.0 -vnormal+nowrap" >> "$GITHUB_ENV"
- name: Install GHC (GHCup)
if: matrix.setup-method == 'ghcup'
run: |
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,5 @@
/.ghc.environment.*
/dist/
/dist-newstyle/
.stack-work/
stack*.yaml.lock
22 changes: 22 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
[![Hackage version](https://img.shields.io/hackage/v/test-framework.svg?label=Hackage&color=informational)](http://hackage.haskell.org/package/test-framework)
[![test-framework on Stackage Nightly](https://stackage.org/package/test-framework/badge/nightly)](https://stackage.org/nightly/package/test-framework)
[![Stackage LTS version](https://www.stackage.org/package/test-framework/badge/lts?label=Stackage)](https://www.stackage.org/package/test-framework)
[![Cabal build](https://github.com/haskell/test-framework/workflows/Haskell-CI/badge.svg)](https://github.com/haskell/test-framework/actions)


test-framework
==============

This framework for organizing tests is mature and stable, but it is no longer actively developed.

NEW FEATURE REQUESTS AND CONTRIBUTIONS ARE NO LONGER ACCEPTED!

Old homepage: https://haskell.github.io/test-framework/

New users are encouraged to look into more actively developed test frameworks,
for instance:

- [hspec](https://hackage.haskell.org/package/hspec)
- [tasty](https://hackage.haskell.org/package/tasty)

Copy link

@Bodigrim Bodigrim Feb 26, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be helpful to guide users how to migrate to modern frameworks. Here is an instruction for tasty:

### Migration to `tasty`

The following steps are sufficient for the majority of packages:

* Replace packages in `build-depends`:
  * `test-framework` -> `tasty`,
  * `test-framework-hunit` -> `tasty-hunit`,
  * `test-framework-quickcheck2` -> `tasty-quickcheck`.
* Replace module imports:
  * `Test.Framework` -> `Test.Tasty`,
  * `Test.Framework.Providers.HUnit` -> `Test.Tasty.HUnit`,
  * `Test.Framework.Providers.QuickCheck2` -> `Test.Tasty.QuickCheck`.
* Replace in type signatures:
  * `Test` -> `TestTree`.
* Replace `defaultMain tests` with `defaultMain (testGroup "All" tests)`.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This section is for "new users" and kept brief on purpose.

  1. For existing users, there is no need to necessarily migrate to anything.
  2. If existing users choose to migrate to something else, I trust them to be able to figure out themselves how to do this.
  3. If you want to provide instructions on how to migrate from test-framework to your project then I think this belongs into the documentation of your project.

Copy link
Member

@sol sol Feb 26, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, for what it's worth:

### Migration to `hspec`
The following steps are sufficient:
 * Add to `build-depends`:
   * `hspec-test-framework`
 * Remove from`build-depends`:
   * `test-framework`
   * `test-framework-hunit`
   * `test-framework-quickcheck2`
 * Replace `test-framework-th` with `hspec-test-framework-th`

But really, I don't think any of this belongs here.

(Developers: if you want to see your test framework listed here, please open a pull request.)
8 changes: 0 additions & 8 deletions TODO

This file was deleted.

19 changes: 13 additions & 6 deletions cabal.project
Original file line number Diff line number Diff line change
@@ -1,12 +1,19 @@
-- See also http://cabal.readthedocs.io/en/latest/nix-local-build-overview.html

-- NB: ./quickcheck is deprecated
packages: ./core
./hunit
./quickcheck2
./example
packages:
./core
./hunit
./quickcheck2
./example

-- On Debian/Ubuntu you may need the following to workaround an issue in libxml's packaging

-- package libxml
-- extra-include-dirs: /usr/include/libxml2

program-options
ghc-options:
-Wall
-Wcompat
-Wno-deprecations
-- This package is legacy and won't address deprecation warnings.
-Wno-x-partial
9 changes: 9 additions & 0 deletions core/ChangeLog.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
#### 0.8.2.1

_2025-02-26, Andreas Abel_

- Support `random-1.3` and other latest dependencies
- Drop support for GHC 7
- Drop support for dependency versions that predate Stackage LTS 9.21
- Tested building with GHC 8.0 - 9.12.1

### 0.8.2.0

- Add `Semigroup` instances
Expand Down
2 changes: 0 additions & 2 deletions core/Setup.hs

This file was deleted.

2 changes: 1 addition & 1 deletion core/src/Test/Framework.hs
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ import Test.Framework.Core (Test, TestName, testGroup, plusTestOptions, buildTes
import Test.Framework.Options
import Test.Framework.Runners.Console
import Test.Framework.Runners.Options
import Test.Framework.Seed
import Test.Framework.Seed
4 changes: 2 additions & 2 deletions core/src/Test/Framework/Core.hs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import Test.Framework.Improving
import Test.Framework.Options

import Control.Arrow (first, second)
import Control.Concurrent.MVar
import Data.Typeable
import Control.Concurrent.MVar ( withMVar, newMVar, MVar )
import Data.Typeable ( Typeable )


-- | Something like the result of a test: works in concert with 'Testlike'.
Expand Down
8 changes: 4 additions & 4 deletions core/src/Test/Framework/Improving.hs
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ module Test.Framework.Improving (
) where

import Control.Concurrent
import Control.Monad
import Control.Applicative as App
( yield, getChanContents, newChan, writeChan, Chan )
import Control.Monad (ap, liftM)

import System.Timeout
import System.Timeout ( timeout )


data i :~> f = Finished f
Expand Down Expand Up @@ -41,7 +41,7 @@ instance Applicative (ImprovingIO i f) where
(<*>) = ap

instance Monad (ImprovingIO i f) where
return = App.pure
return = pure
ma >>= f = IIO $ \chan -> do
a <- unIIO ma chan
unIIO (f a) chan
Expand Down
6 changes: 3 additions & 3 deletions core/src/Test/Framework/Options.hs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ module Test.Framework.Options where
import Test.Framework.Seed
import Test.Framework.Utilities

import Data.Monoid
import Data.Semigroup as Sem hiding (Last(..))
import Data.Monoid ( Last(Last, getLast) )
import Data.Semigroup as Sem ( Semigroup((<>)) )


type TestOptions = TestOptions' Maybe
Expand Down Expand Up @@ -43,5 +43,5 @@ instance Monoid (TestOptions' Maybe) where
topt_maximum_test_depth = Nothing,
topt_timeout = Nothing
}

mappend = (Sem.<>)
2 changes: 1 addition & 1 deletion core/src/Test/Framework/Providers/API.hs
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@ import Test.Framework.Core
import Test.Framework.Improving
import Test.Framework.Options
import Test.Framework.Seed
import Test.Framework.Utilities
import Test.Framework.Utilities
17 changes: 8 additions & 9 deletions core/src/Test/Framework/Runners/Console.hs
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,15 @@ import Test.Framework.Utilities

import Control.Monad (when)
import System.Console.GetOpt
import System.Environment
( getOpt,
usageInfo,
ArgDescr(NoArg, ReqArg),
ArgOrder(Permute),
OptDescr(..) )
import System.Environment ( getArgs, getProgName )
import System.Exit
import System.IO

#if !MIN_VERSION_base(4,8,0)
import Data.Monoid
#endif
#if !(MIN_VERSION_base(4,7,0))
import Data.Orphans ()
#endif
( exitSuccess, exitWith, ExitCode(ExitFailure, ExitSuccess) )
import System.IO ( hIsTerminalDevice, hPutStrLn, stderr, stdout )

-- | @Nothing@ signifies that usage information should be displayed.
-- @Just@ simply gives us the contribution to overall options by the command line option.
Expand Down
4 changes: 2 additions & 2 deletions core/src/Test/Framework/Runners/Console/Colors.hs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module Test.Framework.Runners.Console.Colors where

import Text.PrettyPrint.ANSI.Leijen
import Text.PrettyPrint.ANSI.Leijen ( green, red, Doc )


colorFail, colorPass :: Doc -> Doc
Expand All @@ -9,4 +9,4 @@ colorPass = green

colorPassOrFail :: Bool -> Doc -> Doc
colorPassOrFail True = colorPass
colorPassOrFail False = colorFail
colorPassOrFail False = colorFail
4 changes: 2 additions & 2 deletions core/src/Test/Framework/Runners/Console/ProgressBar.hs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ module Test.Framework.Runners.Console.ProgressBar (
Progress(..), progressBar
) where

import Text.PrettyPrint.ANSI.Leijen hiding (width)
import Text.PrettyPrint.ANSI.Leijen ( (<>), char, text, Doc )


data Progress = Progress Int Int
Expand All @@ -16,4 +16,4 @@ progressBar color width (Progress count total) = char '[' <> progress_doc <> spa
progress_chars = round (characters_per_tick * fromIntegral count)
space_chars = available_width - progress_chars
progress_doc = color (text (reverse (take progress_chars ('>' : repeat '='))))
space_doc = text (replicate space_chars ' ')
space_doc = text (replicate space_chars ' ')
19 changes: 9 additions & 10 deletions core/src/Test/Framework/Runners/Console/Run.hs
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,13 @@ import Test.Framework.Runners.Statistics
import Test.Framework.Runners.TimedConsumption
import Test.Framework.Utilities

import System.Console.ANSI
import System.IO
import System.Console.ANSI ( clearLine, cursorUpLine )
import System.IO ( hFlush, stdout )

import Text.PrettyPrint.ANSI.Leijen

#if !MIN_VERSION_base(4,8,0)
import Data.Monoid (mempty)
#endif
( (<>), (<+>),
brackets, char, empty, indent, linebreak, plain, putDoc, text,
Doc )

import Control.Arrow (second, (&&&))
import Control.Monad (unless)
Expand All @@ -31,11 +30,11 @@ showRunTestsTop isplain hide_successes running_tests = (if isplain then id else
-- Show those test results to the user as we get them. Gather statistics on the fly for a progress bar
let test_statistics = initialTestStatistics (totalRunTestsList running_tests)
(test_statistics', finished_tests) <- showRunTests isplain hide_successes 0 test_statistics running_tests

-- Show the final statistics
putStrLn ""
putDoc $ possiblyPlain isplain $ showFinalTestStatistics test_statistics'

return finished_tests


Expand Down Expand Up @@ -74,7 +73,7 @@ showImprovingTestResult isplain hide_successes indent_level test_name progress_b
unless (success && hide_successes) $ do
let (result_doc, extra_doc) | success = (brackets $ colorPass (text result), empty)
| otherwise = (brackets (colorFail (text "Failed")), text result <> linebreak)

-- Output the final test status and a trailing newline
putTestHeader indent_level test_name (possiblyPlain isplain result_doc)
-- Output any extra information that may be required, e.g. to show failure reason
Expand All @@ -97,7 +96,7 @@ showImprovingTestResultProgress erase indent_level test_name progress_bar improv
showImprovingTestResultProgress' :: IO () -> Int -> String -> Doc -> (String :~> (String, Bool)) -> IO (String, Bool)
showImprovingTestResultProgress' erase _ _ _ (Finished result) = do
erase
-- There may still be a progress bar on the line below the final test result, so
-- There may still be a progress bar on the line below the final test result, so
-- remove it as a precautionary measure in case this is the last test in a group
-- and hence it will not be erased in the normal course of test display.
putStrLn ""
Expand Down
10 changes: 5 additions & 5 deletions core/src/Test/Framework/Runners/Console/Statistics.hs
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ import Test.Framework.Runners.Statistics
import Test.Framework.Runners.Console.Colors
import Test.Framework.Runners.Console.Table

import Text.PrettyPrint.ANSI.Leijen
import Text.PrettyPrint.ANSI.Leijen ( empty, text, Doc )

import Data.List
import Data.List ( sort )


-- | Displays statistics as a string something like this:
Expand All @@ -23,14 +23,14 @@ showFinalTestStatistics :: TestStatistics -> Doc
showFinalTestStatistics ts = renderTable $ [Column label_column] ++ (map Column test_type_columns) ++ [Column total_column]
where
test_types = sort $ testCountTestTypes (ts_total_tests ts)

label_column = [TextCell empty, TextCell (text "Passed"), TextCell (text "Failed"), TextCell (text "Total")]
total_column = [TextCell (text "Total"), testStatusTotal colorPass ts_passed_tests, testStatusTotal colorFail ts_failed_tests, testStatusTotal (colorPassOrFail (ts_no_failures ts)) ts_total_tests]
test_type_columns = [ [TextCell (text test_type), testStat colorPass (countTests ts_passed_tests), testStat colorFail failures, testStat (colorPassOrFail (failures <= 0)) (countTests ts_total_tests)]
| test_type <- test_types
, let countTests = testCountForType test_type . ($ ts)
failures = countTests ts_failed_tests ]

testStatusTotal color status_accessor = TextCell (coloredNumber color (testCountTotal (status_accessor ts)))
testStat color number = TextCell (coloredNumber color number)

Expand All @@ -39,4 +39,4 @@ coloredNumber color number
| number == 0 = number_doc
| otherwise = color number_doc
where
number_doc = text (show number)
number_doc = text (show number)
9 changes: 3 additions & 6 deletions core/src/Test/Framework/Runners/Console/Table.hs
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,8 @@ module Test.Framework.Runners.Console.Table (

import Test.Framework.Utilities

#if MIN_VERSION_ansi_wl_pprint(0,6,6)
import Text.PrettyPrint.ANSI.Leijen hiding (column, columns)
#else
import Text.PrettyPrint.ANSI.Leijen hiding (column)
#endif
import Text.PrettyPrint.ANSI.Leijen
( (<>), char, empty, fill, hcat, line, text, Doc )

data Cell = TextCell Doc
| SeperatorCell
Expand Down Expand Up @@ -65,7 +62,7 @@ renderFirstColumnCell column_width (Column cells) _ = case cells of
[] -> text $ replicate (column_width + 2) ' '
(SeperatorCell:_) -> text $ replicate (column_width + 2) '-'
(TextCell contents:_) -> char ' ' <> fill column_width contents <> char ' '
renderFirstColumnCell _ SeperatorColumn either_side_seperator
renderFirstColumnCell _ SeperatorColumn either_side_seperator
= if either_side_seperator then char '+' else char '|'

columnFinished :: Column -> Bool
Expand Down
4 changes: 2 additions & 2 deletions core/src/Test/Framework/Runners/Console/Utilities.hs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ module Test.Framework.Runners.Console.Utilities (
hideCursorDuring
) where

import System.Console.ANSI
import System.IO
import System.Console.ANSI ( hideCursor, showCursor )
import System.IO ( hFlush, stdout )

import Control.Exception (bracket)

Expand Down
11 changes: 4 additions & 7 deletions core/src/Test/Framework/Runners/Core.hs
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,11 @@ import Test.Framework.Runners.ThreadPool
import Test.Framework.Seed
import Test.Framework.Utilities

import Control.Concurrent.MVar
import Control.Concurrent.MVar ( newEmptyMVar, putMVar, takeMVar )
import Control.Exception (mask, finally, onException)
import Control.Monad
import Data.Maybe
#if !MIN_VERSION_base(4,8,0)
import Data.Monoid
#endif
import Data.Typeable
import Control.Monad ( liftM, forM )
import Data.Maybe ( catMaybes )
import Data.Typeable ( Typeable )


-- | A test that has been executed or is in the process of execution
Expand Down
4 changes: 2 additions & 2 deletions core/src/Test/Framework/Runners/Options.hs
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import Test.Framework.Options
import Test.Framework.Utilities
import Test.Framework.Runners.TestPattern

import Data.Monoid
import Data.Semigroup as Sem hiding (Last(..))
import Data.Monoid ( Last(Last, getLast) )
import Data.Semigroup as Sem ( Semigroup((<>)) )

data ColorMode = ColorAuto | ColorNever | ColorAlways

Expand Down
2 changes: 1 addition & 1 deletion core/src/Test/Framework/Runners/Processors.hs
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ processorCount = numCapabilities
processorCount :: Int
processorCount = 1

#endif
#endif
Loading