@@ -15,10 +15,10 @@ defmodule ExUnit.CLIFormatter do
15
15
trace: opts [ :trace ] ,
16
16
colors: Keyword . put_new ( opts [ :colors ] , :enabled , IO.ANSI . enabled? ) ,
17
17
width: get_terminal_width ( ) ,
18
- tests_counter : % { } ,
19
- failures_counter : 0 ,
18
+ test_counter : % { } ,
19
+ failure_counter : 0 ,
20
20
skipped_counter: 0 ,
21
- invalids_counter : 0
21
+ invalid_counter : 0
22
22
}
23
23
{ :ok , config }
24
24
end
@@ -43,12 +43,12 @@ defmodule ExUnit.CLIFormatter do
43
43
else
44
44
IO . write success ( "." , config )
45
45
end
46
- { :ok , % { config | tests_counter: update_tests_counter ( config . tests_counter , test ) } }
46
+ { :ok , % { config | test_counter: update_test_counter ( config . test_counter , test ) } }
47
47
end
48
48
49
49
def handle_event ( { :test_finished , % ExUnit.Test { state: { :skip , _ } } = test } , config ) do
50
50
if config . trace , do: IO . puts trace_test_skip ( test )
51
- { :ok , % { config | tests_counter: update_tests_counter ( config . tests_counter , test ) ,
51
+ { :ok , % { config | test_counter: update_test_counter ( config . test_counter , test ) ,
52
52
skipped_counter: config . skipped_counter + 1 } }
53
53
end
54
54
@@ -59,22 +59,22 @@ defmodule ExUnit.CLIFormatter do
59
59
IO . write invalid ( "?" , config )
60
60
end
61
61
62
- { :ok , % { config | tests_counter: update_tests_counter ( config . tests_counter , test ) ,
63
- invalids_counter : config . invalids_counter + 1 } }
62
+ { :ok , % { config | test_counter: update_test_counter ( config . test_counter , test ) ,
63
+ invalid_counter : config . invalid_counter + 1 } }
64
64
end
65
65
66
66
def handle_event ( { :test_finished , % ExUnit.Test { state: { :failed , failures } } = test } , config ) do
67
67
if config . trace do
68
68
IO . puts failure ( trace_test_result ( test ) , config )
69
69
end
70
70
71
- formatted = format_test_failure ( test , failures , config . failures_counter + 1 ,
71
+ formatted = format_test_failure ( test , failures , config . failure_counter + 1 ,
72
72
config . width , & formatter ( & 1 , & 2 , config ) )
73
73
print_failure ( formatted , config )
74
74
print_logs ( test . logs )
75
75
76
- { :ok , % { config | tests_counter: update_tests_counter ( config . tests_counter , test ) ,
77
- failures_counter : config . failures_counter + 1 } }
76
+ { :ok , % { config | test_counter: update_test_counter ( config . test_counter , test ) ,
77
+ failure_counter : config . failure_counter + 1 } }
78
78
end
79
79
80
80
def handle_event ( { :case_started , % ExUnit.TestCase { name: name } } , config ) do
@@ -90,10 +90,10 @@ defmodule ExUnit.CLIFormatter do
90
90
end
91
91
92
92
def handle_event ( { :case_finished , % ExUnit.TestCase { state: { :failed , failures } } = test_case } , config ) do
93
- formatted = format_test_case_failure ( test_case , failures , config . failures_counter + 1 ,
93
+ formatted = format_test_case_failure ( test_case , failures , config . failure_counter + 1 ,
94
94
config . width , & formatter ( & 1 , & 2 , config ) )
95
95
print_failure ( formatted , config )
96
- { :ok , % { config | failures_counter : config . failures_counter + 1 } }
96
+ { :ok , % { config | failure_counter : config . failure_counter + 1 } }
97
97
end
98
98
99
99
## Tracing
@@ -120,8 +120,8 @@ defmodule ExUnit.CLIFormatter do
120
120
end
121
121
end
122
122
123
- defp update_tests_counter ( tests_counter , % { tags: % { type: type } } ) do
124
- Map . update ( tests_counter , type , 1 , & ( & 1 + 1 ) )
123
+ defp update_test_counter ( test_counter , % { tags: % { type: type } } ) do
124
+ Map . update ( test_counter , type , 1 , & ( & 1 + 1 ) )
125
125
end
126
126
127
127
## Printing
@@ -132,16 +132,16 @@ defmodule ExUnit.CLIFormatter do
132
132
133
133
# singular/plural
134
134
test_type_counts = format_test_type_counts ( config )
135
- failure_pl = pluralize ( config . failures_counter , "failure" , "failures" )
135
+ failure_pl = pluralize ( config . failure_counter , "failure" , "failures" )
136
136
137
137
message =
138
- "#{ test_type_counts } #{ config . failures_counter } #{ failure_pl } "
138
+ "#{ test_type_counts } #{ config . failure_counter } #{ failure_pl } "
139
139
|> if_true ( config . skipped_counter > 0 , & & 1 <> ", #{ config . skipped_counter } skipped" )
140
- |> if_true ( config . invalids_counter > 0 , & & 1 <> ", #{ config . invalids_counter } invalid" )
140
+ |> if_true ( config . invalid_counter > 0 , & & 1 <> ", #{ config . invalid_counter } invalid" )
141
141
142
142
cond do
143
- config . failures_counter > 0 -> IO . puts failure ( message , config )
144
- config . invalids_counter > 0 -> IO . puts invalid ( message , config )
143
+ config . failure_counter > 0 -> IO . puts failure ( message , config )
144
+ config . invalid_counter > 0 -> IO . puts invalid ( message , config )
145
145
true -> IO . puts success ( message , config )
146
146
end
147
147
@@ -170,8 +170,8 @@ defmodule ExUnit.CLIFormatter do
170
170
IO . puts formatted
171
171
end
172
172
173
- defp format_test_type_counts ( % { tests_counter: tests_counter } = _config ) do
174
- Enum . map tests_counter , fn { type , count } ->
173
+ defp format_test_type_counts ( % { test_counter: test_counter } = _config ) do
174
+ Enum . map test_counter , fn { type , count } ->
175
175
type_pluralized = pluralize ( count , type , ExUnit . plural_rule ( type |> to_string ( ) ) )
176
176
"#{ count } #{ type_pluralized } , "
177
177
end
0 commit comments