@@ -6,9 +6,18 @@ use cargo_test_support::basic_bin_manifest;
6
6
use cargo_test_support:: prelude:: * ;
7
7
use cargo_test_support:: { basic_manifest, project} ;
8
8
9
- const MISS : & str = "[..] rustc info cache miss[..]" ;
10
- const HIT : & str = "[..]rustc info cache hit[..]" ;
11
- const UPDATE : & str = "[..]updated rustc info cache[..]" ;
9
+ // Here, we distinguish between a cache hit where the command succeeded versus
10
+ // a cache hit where the command failed. Commands that fail are recorded into
11
+ // the cache, but are re-run anyways.
12
+ //
13
+ // Beware of checking for the absence of failure, as a probe for supported
14
+ // rustc flags may fail under normal conditions, such as when a new feature
15
+ // is added. See Cargo issue #15358 for details.
16
+ const MISS : & str = "[..] rustc info cache miss (MissNoEntry)[..]" ;
17
+ const HIT_SUCCESS : & str = "[..]rustc info cache hit (HitSuccess)[..]" ;
18
+ const HIT_FAILURE : & str = "[..]rustc info cache hit (HitFailure)[..]" ;
19
+ const UPDATE_NEWCACHE : & str = "[..]updated rustc info cache (NewCache)[..]" ;
20
+ const UPDATE_FAILURE : & str = "[..]updated rustc info cache (HitFailure)[..]" ;
12
21
13
22
#[ cargo_test]
14
23
fn rustc_info_cache ( ) {
@@ -20,23 +29,23 @@ fn rustc_info_cache() {
20
29
. env ( "CARGO_LOG" , "cargo::util::rustc=debug" )
21
30
. with_stderr_contains ( "[..]failed to read rustc info cache[..]" )
22
31
. with_stderr_contains ( MISS )
23
- . with_stderr_does_not_contain ( HIT )
24
- . with_stderr_contains ( UPDATE )
32
+ . with_stderr_does_not_contain ( HIT_SUCCESS )
33
+ . with_stderr_contains ( UPDATE_NEWCACHE )
25
34
. run ( ) ;
26
35
27
36
p. cargo ( "build" )
28
37
. env ( "CARGO_LOG" , "cargo::util::rustc=debug" )
29
38
. with_stderr_contains ( "[..]reusing existing rustc info cache[..]" )
30
- . with_stderr_contains ( HIT )
39
+ . with_stderr_contains ( HIT_SUCCESS )
31
40
. with_stderr_does_not_contain ( MISS )
32
- . with_stderr_does_not_contain ( UPDATE )
41
+ . with_stderr_does_not_contain ( UPDATE_NEWCACHE )
33
42
. run ( ) ;
34
43
35
44
p. cargo ( "build" )
36
45
. env ( "CARGO_LOG" , "cargo::util::rustc=debug" )
37
46
. env ( "CARGO_CACHE_RUSTC_INFO" , "0" )
38
47
. with_stderr_contains ( "[..]rustc info cache disabled[..]" )
39
- . with_stderr_does_not_contain ( UPDATE )
48
+ . with_stderr_does_not_contain ( UPDATE_NEWCACHE )
40
49
. run ( ) ;
41
50
42
51
let other_rustc = {
@@ -71,17 +80,17 @@ fn rustc_info_cache() {
71
80
. env ( "RUSTC" , other_rustc. display ( ) . to_string ( ) )
72
81
. with_stderr_contains ( "[..]different compiler, creating new rustc info cache[..]" )
73
82
. with_stderr_contains ( MISS )
74
- . with_stderr_does_not_contain ( HIT )
75
- . with_stderr_contains ( UPDATE )
83
+ . with_stderr_does_not_contain ( HIT_SUCCESS )
84
+ . with_stderr_contains ( UPDATE_NEWCACHE )
76
85
. run ( ) ;
77
86
78
87
p. cargo ( "build" )
79
88
. env ( "CARGO_LOG" , "cargo::util::rustc=debug" )
80
89
. env ( "RUSTC" , other_rustc. display ( ) . to_string ( ) )
81
90
. with_stderr_contains ( "[..]reusing existing rustc info cache[..]" )
82
- . with_stderr_contains ( HIT )
91
+ . with_stderr_contains ( HIT_SUCCESS )
83
92
. with_stderr_does_not_contain ( MISS )
84
- . with_stderr_does_not_contain ( UPDATE )
93
+ . with_stderr_does_not_contain ( UPDATE_NEWCACHE )
85
94
. run ( ) ;
86
95
87
96
other_rustc. move_into_the_future ( ) ;
@@ -91,17 +100,17 @@ fn rustc_info_cache() {
91
100
. env ( "RUSTC" , other_rustc. display ( ) . to_string ( ) )
92
101
. with_stderr_contains ( "[..]different compiler, creating new rustc info cache[..]" )
93
102
. with_stderr_contains ( MISS )
94
- . with_stderr_does_not_contain ( HIT )
95
- . with_stderr_contains ( UPDATE )
103
+ . with_stderr_does_not_contain ( HIT_SUCCESS )
104
+ . with_stderr_contains ( UPDATE_NEWCACHE )
96
105
. run ( ) ;
97
106
98
107
p. cargo ( "build" )
99
108
. env ( "CARGO_LOG" , "cargo::util::rustc=debug" )
100
109
. env ( "RUSTC" , other_rustc. display ( ) . to_string ( ) )
101
110
. with_stderr_contains ( "[..]reusing existing rustc info cache[..]" )
102
- . with_stderr_contains ( HIT )
111
+ . with_stderr_contains ( HIT_SUCCESS )
103
112
. with_stderr_does_not_contain ( MISS )
104
- . with_stderr_does_not_contain ( UPDATE )
113
+ . with_stderr_does_not_contain ( UPDATE_NEWCACHE )
105
114
. run ( ) ;
106
115
}
107
116
@@ -149,16 +158,16 @@ fn rustc_info_cache_with_wrappers() {
149
158
. env ( wrapper_env, & wrapper)
150
159
. with_stderr_contains ( "[..]failed to read rustc info cache[..]" )
151
160
. with_stderr_contains ( MISS )
152
- . with_stderr_contains ( UPDATE )
153
- . with_stderr_does_not_contain ( HIT )
161
+ . with_stderr_contains ( UPDATE_NEWCACHE )
162
+ . with_stderr_does_not_contain ( HIT_SUCCESS )
154
163
. with_status ( 0 )
155
164
. run ( ) ;
156
165
p. cargo ( "build" )
157
166
. env ( "CARGO_LOG" , "cargo::util::rustc=debug" )
158
167
. env ( wrapper_env, & wrapper)
159
168
. with_stderr_contains ( "[..]reusing existing rustc info cache[..]" )
160
- . with_stderr_contains ( HIT )
161
- . with_stderr_does_not_contain ( UPDATE )
169
+ . with_stderr_contains ( HIT_SUCCESS )
170
+ . with_stderr_does_not_contain ( UPDATE_NEWCACHE )
162
171
. with_stderr_does_not_contain ( MISS )
163
172
. with_status ( 0 )
164
173
. run ( ) ;
@@ -171,16 +180,18 @@ fn rustc_info_cache_with_wrappers() {
171
180
. env ( wrapper_env, & wrapper)
172
181
. with_stderr_contains ( "[..]different compiler, creating new rustc info cache[..]" )
173
182
. with_stderr_contains ( MISS )
174
- . with_stderr_contains ( UPDATE )
175
- . with_stderr_does_not_contain ( HIT )
183
+ . with_stderr_contains ( UPDATE_NEWCACHE )
184
+ . with_stderr_does_not_contain ( HIT_SUCCESS )
176
185
. with_status ( 101 )
177
186
. run ( ) ;
178
187
p. cargo ( "build" )
179
188
. env ( "CARGO_LOG" , "cargo::util::rustc=debug" )
180
189
. env ( wrapper_env, & wrapper)
181
190
. with_stderr_contains ( "[..]reusing existing rustc info cache[..]" )
182
- . with_stderr_contains ( HIT )
183
- . with_stderr_does_not_contain ( UPDATE )
191
+ . with_stderr_does_not_contain ( HIT_SUCCESS )
192
+ . with_stderr_contains ( HIT_FAILURE )
193
+ . with_stderr_does_not_contain ( UPDATE_NEWCACHE )
194
+ . with_stderr_contains ( UPDATE_FAILURE )
184
195
. with_stderr_does_not_contain ( MISS )
185
196
. with_status ( 101 )
186
197
. run ( ) ;
0 commit comments