Skip to content

WIP: Explicit imports #75

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

Draft
wants to merge 5 commits into
base: master
Choose a base branch
from
Draft
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
7 changes: 7 additions & 0 deletions core/ChangeLog.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
#### 0.8.2.1

- Support `random-1.3`
- 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
4 changes: 4 additions & 0 deletions core/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
This package is legacy and no longer developed.

Users are encouraged to look into more actively developed test frameworks,
e.g. [tasty](https://hackage.haskell.or/package/tasty).
2 changes: 0 additions & 2 deletions core/Setup.hs

This file was deleted.

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
3 changes: 2 additions & 1 deletion core/src/Test/Framework/Improving.hs
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,11 @@ module Test.Framework.Improving (
) where

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

import System.Timeout
import System.Timeout ( timeout )


data i :~> f = Finished f
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.<>)
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
2 changes: 1 addition & 1 deletion 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 Down
2 changes: 1 addition & 1 deletion 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 Down
26 changes: 16 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,20 @@ 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 +37,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 +80,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 +103,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
8 changes: 4 additions & 4 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 Down
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
5 changes: 1 addition & 4 deletions core/src/Test/Framework/Runners/Statistics.hs
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,7 @@ import Test.Framework.Runners.Core

import Data.Map (Map)
import qualified Data.Map as Map
#if !MIN_VERSION_base(4,8,0)
import Data.Monoid
#endif
import Data.Semigroup as Sem
import Data.Semigroup as Sem ( Semigroup((<>)) )


-- | Records a count of the various kinds of test that have been run
Expand Down
8 changes: 4 additions & 4 deletions core/src/Test/Framework/Runners/TestPattern.hs
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ module Test.Framework.Runners.TestPattern (

import Test.Framework.Utilities

import Text.Regex.Posix.Wrap
import Text.Regex.Posix.Wrap ( (=~) )
import Text.Regex.Posix.String()

import Data.List
import Data.List ( inits, intersperse )


data Token = SlashToken
Expand Down Expand Up @@ -65,7 +65,7 @@ testPatternMatches test_pattern path = not_maybe $ any (=~ tokens_regex) things_
path_to_consider | tp_categories_only test_pattern = dropLast 1 path
| otherwise = path
tokens_regex = buildTokenRegex (tp_tokens test_pattern)

things_to_match = case tp_match_mode test_pattern of
-- See if the tokens match any single path component
TestMatchMode -> path_to_consider
Expand All @@ -79,7 +79,7 @@ buildTokenRegex (token:tokens) = concat (firstTokenToRegex token : map tokenToRe
where
firstTokenToRegex SlashToken = "^"
firstTokenToRegex other = tokenToRegex other

tokenToRegex SlashToken = "/"
tokenToRegex WildcardToken = "[^/]*"
tokenToRegex DoubleWildcardToken = "*"
Expand Down
18 changes: 13 additions & 5 deletions core/src/Test/Framework/Runners/ThreadPool.hs
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,19 @@ module Test.Framework.Runners.ThreadPool (
) where

import Control.Concurrent
import Control.Monad
( forkIO,
myThreadId,
getChanContents,
newChan,
readChan,
writeChan,
writeList2Chan,
Chan )
import Control.Monad ( forM_ )

import qualified Data.IntMap as IM

import Foreign.StablePtr
import Foreign.StablePtr ( newStablePtr )


data WorkerEvent token a = WorkerTermination
Expand All @@ -24,13 +32,13 @@ executeOnPool n actions = do
-- Prepare the channels
input_chan <- newChan
output_chan <- newChan

-- Write the actions as items to the channel followed by one termination per thread
-- that indicates they should terminate. We do this on another thread for
-- maximum laziness (in case one the actions we are going to run depend on the
-- output from previous actions..)
_ <- forkIO $ writeList2Chan input_chan (zipWith WorkerItem [0..] actions ++ replicate n WorkerTermination)

-- Spawn workers
forM_ [1..n] (const $ forkIO $ poolWorker input_chan output_chan)

Expand All @@ -53,7 +61,7 @@ executeOnPool n actions = do
-- lazily-demanded tail of the list, but its a bit of a pain. For now, just
-- grit our teeth and accept the leak.
_stablePtr <- myThreadId >>= newStablePtr

-- Return the results generated by the worker threads lazily and in
-- the same order as we got the inputs
fmap (reorderFrom 0 . takeWhileWorkersExist n) $ getChanContents output_chan
Expand Down
2 changes: 1 addition & 1 deletion core/src/Test/Framework/Runners/TimedConsumption.hs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ module Test.Framework.Runners.TimedConsumption (

import Test.Framework.Utilities

import System.CPUTime
import System.CPUTime ( getCPUTime )


-- | Evaluates the given list for the given number of microseconds. After the time limit
Expand Down
Loading
Loading