2
2
//!
3
3
//! Tests for message caching can be found in `cache_messages`.
4
4
5
- #![ allow( deprecated) ]
6
-
5
+ use cargo_test_support:: compare:: assert_e2e;
7
6
use cargo_test_support:: prelude:: * ;
8
7
use cargo_test_support:: { process, project, Project } ;
9
8
use cargo_util:: ProcessError ;
@@ -48,6 +47,14 @@ pub fn raw_rustc_output(project: &Project, path: &str, extra: &[&str]) -> String
48
47
result
49
48
}
50
49
50
+ fn redact_rustc_message ( msg : & str ) -> impl IntoData {
51
+ use snapbox:: filter:: { Filter , FilterPaths } ;
52
+ let assert = assert_e2e ( ) ;
53
+ let redactions = assert. redactions ( ) ;
54
+ let msg = redactions. redact ( msg) ;
55
+ FilterPaths . filter ( msg. into ( ) )
56
+ }
57
+
51
58
#[ cargo_test]
52
59
fn deduplicate_messages_basic ( ) {
53
60
let p = project ( )
@@ -63,19 +70,24 @@ fn deduplicate_messages_basic() {
63
70
let rustc_message = raw_rustc_output ( & p, "src/lib.rs" , & [ ] ) ;
64
71
let expected_output = format ! (
65
72
"{}\
66
- warning: `foo` (lib) generated 1 warning[..]
67
- warning: `foo` (lib test) generated 1 warning (1 duplicate)
68
- [FINISHED] [..]
69
- [EXECUTABLE] unittests src/lib.rs (target/debug/deps/foo-[.. ][EXE])
73
+ [WARNING] `foo` (lib) generated 1 warning[..]
74
+ [WARNING] `foo` (lib test) generated 1 warning (1 duplicate)
75
+ [FINISHED] `test` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
76
+ [EXECUTABLE] unittests src/lib.rs (target/debug/deps/foo-[HASH ][EXE])
70
77
" ,
71
78
rustc_message
72
79
) ;
73
80
p. cargo ( "test --no-run -j1" )
74
- . with_stderr ( & format ! ( "[COMPILING] foo [..]\n {}" , expected_output) )
81
+ . with_stderr_data ( redact_rustc_message ( & format ! (
82
+ "\
83
+ [COMPILING] foo v0.0.1 ([ROOT]/foo)
84
+ {}" ,
85
+ expected_output
86
+ ) ) )
75
87
. run ( ) ;
76
88
// Run again, to check for caching behavior.
77
89
p. cargo ( "test --no-run -j1" )
78
- . with_stderr ( expected_output)
90
+ . with_stderr_data ( redact_rustc_message ( & expected_output) )
79
91
. run ( ) ;
80
92
}
81
93
@@ -106,20 +118,25 @@ fn deduplicate_messages_mismatched_warnings() {
106
118
let expected_output = format ! (
107
119
"\
108
120
{}\
109
- warning: `foo` (lib) generated 1 warning[..]
121
+ [WARNING] `foo` (lib) generated 1 warning[..]
110
122
{}\
111
- warning: `foo` (lib test) generated 2 warnings (1 duplicate)
112
- [FINISHED] [..]
113
- [EXECUTABLE] unittests src/lib.rs (target/debug/deps/foo-[.. ][EXE])
123
+ [WARNING] `foo` (lib test) generated 2 warnings (1 duplicate)
124
+ [FINISHED] `test` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
125
+ [EXECUTABLE] unittests src/lib.rs (target/debug/deps/foo-[HASH ][EXE])
114
126
" ,
115
127
lib_output, lib_test_output
116
128
) ;
117
129
p. cargo ( "test --no-run -j1" )
118
- . with_stderr ( & format ! ( "[COMPILING] foo v0.0.1 [..]\n {}" , expected_output) )
130
+ . with_stderr_data ( redact_rustc_message ( & format ! (
131
+ "\
132
+ [COMPILING] foo v0.0.1 ([ROOT]/foo)
133
+ {}" ,
134
+ expected_output
135
+ ) ) )
119
136
. run ( ) ;
120
137
// Run again, to check for caching behavior.
121
138
p. cargo ( "test --no-run -j1" )
122
- . with_stderr ( expected_output)
139
+ . with_stderr_data ( redact_rustc_message ( & expected_output) )
123
140
. run ( ) ;
124
141
}
125
142
@@ -136,12 +153,12 @@ fn deduplicate_errors() {
136
153
let rustc_message = raw_rustc_output ( & p, "src/lib.rs" , & [ ] ) ;
137
154
p. cargo ( "test -j1" )
138
155
. with_status ( 101 )
139
- . with_stderr ( & format ! (
156
+ . with_stderr_data ( redact_rustc_message ( & format ! (
140
157
"\
141
- [COMPILING] foo v0.0.1 [..]
142
- {}error: could not compile `foo` (lib) due to 1 previous error
158
+ [COMPILING] foo v0.0.1 ([ROOT]/foo)
159
+ {}[ERROR] could not compile `foo` (lib) due to 1 previous error
143
160
" ,
144
161
rustc_message
145
- ) )
162
+ ) ) )
146
163
. run ( ) ;
147
164
}
0 commit comments