@@ -77,37 +77,8 @@ use url::Url;
77
77
/// a problem.
78
78
/// - Carriage returns are removed, which can help when running on Windows.
79
79
pub fn assert_ui ( ) -> snapbox:: Assert {
80
- let root = paths:: root ( ) ;
81
- // Use `from_file_path` instead of `from_dir_path` so the trailing slash is
82
- // put in the users output, rather than hidden in the variable
83
- let root_url = url:: Url :: from_file_path ( & root) . unwrap ( ) . to_string ( ) ;
84
-
85
80
let mut subs = snapbox:: Redactions :: new ( ) ;
86
- subs. extend ( MIN_LITERAL_REDACTIONS . into_iter ( ) . cloned ( ) )
87
- . unwrap ( ) ;
88
- subs. insert ( "[ROOT]" , root) . unwrap ( ) ;
89
- subs. insert ( "[ROOTURL]" , root_url) . unwrap ( ) ;
90
- subs. insert (
91
- "[ELAPSED]" ,
92
- regex:: Regex :: new ( "Finished.*in (?<redacted>[0-9]+(\\ .[0-9]+))s" ) . unwrap ( ) ,
93
- )
94
- . unwrap ( ) ;
95
- // output from libtest
96
- subs. insert (
97
- "[ELAPSED]" ,
98
- regex:: Regex :: new ( "; finished in (?<redacted>[0-9]+(\\ .[0-9]+))s" ) . unwrap ( ) ,
99
- )
100
- . unwrap ( ) ;
101
- subs. insert (
102
- "[FILE_SIZE]" ,
103
- regex:: Regex :: new ( "(?<redacted>[0-9]+(\\ .[0-9]+)([a-zA-Z]i)?)B" ) . unwrap ( ) ,
104
- )
105
- . unwrap ( ) ;
106
- subs. insert (
107
- "[HASH]" ,
108
- regex:: Regex :: new ( "home/\\ .cargo/registry/src/-(?<redacted>[a-z0-9]+)" ) . unwrap ( ) ,
109
- )
110
- . unwrap ( ) ;
81
+ add_common_redactions ( & mut subs) ;
111
82
snapbox:: Assert :: new ( )
112
83
. action_env ( snapbox:: assert:: DEFAULT_ACTION_ENV )
113
84
. redact_with ( subs)
@@ -145,23 +116,38 @@ pub fn assert_ui() -> snapbox::Assert {
145
116
/// a problem.
146
117
/// - Carriage returns are removed, which can help when running on Windows.
147
118
pub fn assert_e2e ( ) -> snapbox:: Assert {
119
+ let mut subs = snapbox:: Redactions :: new ( ) ;
120
+ add_common_redactions ( & mut subs) ;
121
+ subs. extend ( E2E_LITERAL_REDACTIONS . into_iter ( ) . cloned ( ) )
122
+ . unwrap ( ) ;
123
+
124
+ snapbox:: Assert :: new ( )
125
+ . action_env ( snapbox:: assert:: DEFAULT_ACTION_ENV )
126
+ . redact_with ( subs)
127
+ }
128
+
129
+ fn add_common_redactions ( subs : & mut snapbox:: Redactions ) {
148
130
let root = paths:: root ( ) ;
149
131
// Use `from_file_path` instead of `from_dir_path` so the trailing slash is
150
132
// put in the users output, rather than hidden in the variable
151
133
let root_url = url:: Url :: from_file_path ( & root) . unwrap ( ) . to_string ( ) ;
152
134
153
- let mut subs = snapbox:: Redactions :: new ( ) ;
154
135
subs. extend ( MIN_LITERAL_REDACTIONS . into_iter ( ) . cloned ( ) )
155
136
. unwrap ( ) ;
156
- subs. extend ( E2E_LITERAL_REDACTIONS . into_iter ( ) . cloned ( ) )
157
- . unwrap ( ) ;
158
137
subs. insert ( "[ROOT]" , root) . unwrap ( ) ;
159
138
subs. insert ( "[ROOTURL]" , root_url) . unwrap ( ) ;
139
+ // For e2e tests
160
140
subs. insert (
161
141
"[ELAPSED]" ,
162
142
regex:: Regex :: new ( "[FINISHED].*in (?<redacted>[0-9]+(\\ .[0-9]+))s" ) . unwrap ( ) ,
163
143
)
164
144
. unwrap ( ) ;
145
+ // for UI tests
146
+ subs. insert (
147
+ "[ELAPSED]" ,
148
+ regex:: Regex :: new ( "Finished.*in (?<redacted>[0-9]+(\\ .[0-9]+))s" ) . unwrap ( ) ,
149
+ )
150
+ . unwrap ( ) ;
165
151
// output from libtest
166
152
subs. insert (
167
153
"[ELAPSED]" ,
@@ -178,9 +164,6 @@ pub fn assert_e2e() -> snapbox::Assert {
178
164
regex:: Regex :: new ( "home/\\ .cargo/registry/src/-(?<redacted>[a-z0-9]+)" ) . unwrap ( ) ,
179
165
)
180
166
. unwrap ( ) ;
181
- snapbox:: Assert :: new ( )
182
- . action_env ( snapbox:: assert:: DEFAULT_ACTION_ENV )
183
- . redact_with ( subs)
184
167
}
185
168
186
169
static MIN_LITERAL_REDACTIONS : & [ ( & str , & str ) ] = & [
0 commit comments