@@ -7,6 +7,7 @@ use std::str;
7
7
use cargo:: util:: process;
8
8
use cargotest:: is_nightly;
9
9
use cargotest:: support:: paths:: CargoPathExt ;
10
+ use cargotest:: support:: registry:: Package ;
10
11
use cargotest:: support:: { project, execs, basic_bin_manifest, basic_lib_manifest} ;
11
12
use hamcrest:: { assert_that, existing_file} ;
12
13
@@ -1128,3 +1129,136 @@ test bench_bar ... bench: 0 ns/iter (+/- 0)
1128
1129
test result: ok. 0 passed; 0 failed; 0 ignored; 1 measured
1129
1130
" ) ) ;
1130
1131
}
1132
+
1133
+ #[ test]
1134
+ fn bench_all_workspace ( ) {
1135
+ if !is_nightly ( ) { return }
1136
+
1137
+ let p = project ( "foo" )
1138
+ . file ( "Cargo.toml" , r#"
1139
+ [project]
1140
+ name = "foo"
1141
+ version = "0.1.0"
1142
+
1143
+ [dependencies]
1144
+ bar = { path = "bar" }
1145
+
1146
+ [workspace]
1147
+ "# )
1148
+ . file ( "src/main.rs" , r#"
1149
+ fn main() {}
1150
+ "# )
1151
+ . file ( "benches/foo.rs" , r#"
1152
+ #![feature(test)]
1153
+ extern crate test;
1154
+
1155
+ use test::Bencher;
1156
+
1157
+ #[bench]
1158
+ fn bench_foo(_: &mut Bencher) -> () { () }
1159
+ "# )
1160
+ . file ( "bar/Cargo.toml" , r#"
1161
+ [project]
1162
+ name = "bar"
1163
+ version = "0.1.0"
1164
+ "# )
1165
+ . file ( "bar/src/lib.rs" , r#"
1166
+ pub fn bar() {}
1167
+ "# )
1168
+ . file ( "bar/benches/bar.rs" , r#"
1169
+ #![feature(test)]
1170
+ extern crate test;
1171
+
1172
+ use test::Bencher;
1173
+
1174
+ #[bench]
1175
+ fn bench_bar(_: &mut Bencher) -> () { () }
1176
+ "# ) ;
1177
+
1178
+ assert_that ( p. cargo_process ( "bench" )
1179
+ . arg ( "--all" ) ,
1180
+ execs ( ) . with_status ( 0 )
1181
+ . with_stderr_contains ( "\
1182
+ [RUNNING] target[/]release[/]deps[/]bar-[..][EXE]")
1183
+ . with_stdout_contains ( "
1184
+ running 1 test
1185
+ test bench_bar ... bench: 0 ns/iter (+/- 0)
1186
+
1187
+ test result: ok. 0 passed; 0 failed; 0 ignored; 1 measured
1188
+ " )
1189
+ . with_stderr_contains ( "\
1190
+ [RUNNING] target[/]release[/]deps[/]foo-[..][EXE]")
1191
+ . with_stdout_contains ( "
1192
+ running 1 test
1193
+ test bench_foo ... bench: 0 ns/iter (+/- 0)
1194
+
1195
+ test result: ok. 0 passed; 0 failed; 0 ignored; 1 measured
1196
+ " ) ) ;
1197
+ }
1198
+
1199
+ #[ test]
1200
+ fn bench_all_virtual_manifest ( ) {
1201
+ if !is_nightly ( ) { return }
1202
+
1203
+ let p = project ( "workspace" )
1204
+ . file ( "Cargo.toml" , r#"
1205
+ [workspace]
1206
+ members = ["foo", "bar"]
1207
+ "# )
1208
+ . file ( "foo/Cargo.toml" , r#"
1209
+ [project]
1210
+ name = "foo"
1211
+ version = "0.1.0"
1212
+ "# )
1213
+ . file ( "foo/src/lib.rs" , r#"
1214
+ pub fn foo() {}
1215
+ "# )
1216
+ . file ( "foo/benches/foo.rs" , r#"
1217
+ #![feature(test)]
1218
+ extern crate test;
1219
+
1220
+ use test::Bencher;
1221
+
1222
+ #[bench]
1223
+ fn bench_foo(_: &mut Bencher) -> () { () }
1224
+ "# )
1225
+ . file ( "bar/Cargo.toml" , r#"
1226
+ [project]
1227
+ name = "bar"
1228
+ version = "0.1.0"
1229
+ "# )
1230
+ . file ( "bar/src/lib.rs" , r#"
1231
+ pub fn bar() {}
1232
+ "# )
1233
+ . file ( "bar/benches/bar.rs" , r#"
1234
+ #![feature(test)]
1235
+ extern crate test;
1236
+
1237
+ use test::Bencher;
1238
+
1239
+ #[bench]
1240
+ fn bench_bar(_: &mut Bencher) -> () { () }
1241
+ "# ) ;
1242
+
1243
+ // The order in which foo and bar are built is not guaranteed
1244
+ assert_that ( p. cargo_process ( "bench" )
1245
+ . arg ( "--all" ) ,
1246
+ execs ( ) . with_status ( 0 )
1247
+ . with_stderr_contains ( "\
1248
+ [RUNNING] target[/]release[/]deps[/]bar-[..][EXE]")
1249
+ . with_stdout_contains ( "
1250
+ running 1 test
1251
+ test bench_bar ... bench: 0 ns/iter (+/- 0)
1252
+
1253
+ test result: ok. 0 passed; 0 failed; 0 ignored; 1 measured
1254
+ " )
1255
+ . with_stderr_contains ( "\
1256
+ [RUNNING] target[/]release[/]deps[/]foo-[..][EXE]")
1257
+ . with_stdout_contains ( "
1258
+ running 1 test
1259
+ test bench_foo ... bench: 0 ns/iter (+/- 0)
1260
+
1261
+ test result: ok. 0 passed; 0 failed; 0 ignored; 1 measured
1262
+ " ) ) ;
1263
+ }
1264
+
0 commit comments