forked from UnkindPartition/tasty
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathConsoleFormat.hs
More file actions
87 lines (76 loc) · 2.31 KB
/
ConsoleFormat.hs
File metadata and controls
87 lines (76 loc) · 2.31 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
-- | This module can be used by providers to perform colorful/formatted
-- output and possibly reuse tasty's own output formats.
--
-- @since 1.3.1
module Test.Tasty.Providers.ConsoleFormat
( ResultDetailsPrinter(..)
, ConsoleFormat(..)
, ConsoleFormatPrinter
, noResultDetails
, failFormat
, infoFailFormat
, infoOkFormat
, okFormat
, skippedFormat
)
where
import System.Console.ANSI
-- | Console output format
--
-- @since 1.3.1
data ConsoleFormat = ConsoleFormat
{ consoleIntensity :: ConsoleIntensity
, colorIntensity :: ColorIntensity
, color :: Color
}
-- | Type of console format printer functions
--
-- @since 1.3.1
type ConsoleFormatPrinter
= ConsoleFormat -- ^ selected console format
-> IO () -- ^ action to be executed with active console format
-> IO ()
-- | Noop result details printer. The default for most providers.
--
-- @since 1.3.1
noResultDetails :: ResultDetailsPrinter
noResultDetails = ResultDetailsPrinter . const . const $ return ()
-- | An action that prints additional information about a test using
-- colors/formatting; see 'Test.Tasty.Providers.testFailedDetails' and
-- 'Test.Tasty.Runners.resultDetailsPrinter'.
--
-- As input, this action is provided with the current indentation level and
-- a 'ConsoleFormatPrinter', which tells it how perform output.
--
-- This is a newtype to allow a 'Show' instance.
--
-- @since 1.3.1
newtype ResultDetailsPrinter = ResultDetailsPrinter
(Int -> ConsoleFormatPrinter -> IO ())
instance Show ResultDetailsPrinter where
show _printer = "ResultDetailsPrinter"
-- | Format used to display failures
--
-- @since 1.3.1
failFormat :: ConsoleFormat
failFormat = ConsoleFormat BoldIntensity Vivid Red
-- | Format used to display additional information on failures
--
-- @since 1.3.1
infoFailFormat :: ConsoleFormat
infoFailFormat = ConsoleFormat NormalIntensity Dull Red
-- | Format used to display successes
--
-- @since 1.3.1
okFormat :: ConsoleFormat
okFormat = ConsoleFormat NormalIntensity Dull Green
-- | Format used to display additional information on successes
--
-- @since 1.3.1
infoOkFormat :: ConsoleFormat
infoOkFormat = ConsoleFormat NormalIntensity Dull White
-- | Format used to display skipped tests
--
-- @since 1.3.1
skippedFormat :: ConsoleFormat
skippedFormat = ConsoleFormat NormalIntensity Dull Magenta