@@ -752,7 +752,10 @@ impl Xtasks {
752
752
Xtasks :: Bench {
753
753
name,
754
754
enable_profiling,
755
- } => Self :: bench ( app_settings, enable_profiling, name) ,
755
+ } => {
756
+ let _ = Self :: bench ( app_settings, enable_profiling, name, false ) ?;
757
+ Ok ( ( ) )
758
+ }
756
759
} ?;
757
760
758
761
Ok ( "" . into ( ) )
@@ -840,6 +843,7 @@ impl Xtasks {
840
843
context : & str ,
841
844
add_args : I ,
842
845
dir : Option < & Path > ,
846
+ capture_streams_in_output : bool ,
843
847
) -> Result < Output > {
844
848
let coverage_mode = app_settings
845
849
. coverage
@@ -898,10 +902,12 @@ impl Xtasks {
898
902
} ;
899
903
900
904
let mut cmd = Command :: new ( "cargo" ) ;
901
- cmd. args ( args)
902
- . stdout ( std:: process:: Stdio :: inherit ( ) )
903
- . stderr ( std:: process:: Stdio :: inherit ( ) )
904
- . current_dir ( working_dir) ;
905
+ cmd. args ( args) . current_dir ( working_dir) ;
906
+
907
+ if !capture_streams_in_output {
908
+ cmd. stdout ( std:: process:: Stdio :: inherit ( ) )
909
+ . stderr ( std:: process:: Stdio :: inherit ( ) ) ;
910
+ }
905
911
906
912
info ! ( "Using command: {:?}" , cmd) ;
907
913
@@ -925,6 +931,7 @@ impl Xtasks {
925
931
"Failed to build workspace" ,
926
932
vec ! [ "--all-targets" ] ,
927
933
None ,
934
+ false ,
928
935
) ?;
929
936
Ok ( ( ) )
930
937
}
@@ -943,6 +950,7 @@ impl Xtasks {
943
950
"Failed to run clippy" ,
944
951
clippy_args,
945
952
None ,
953
+ false ,
946
954
) ?;
947
955
948
956
if ide_mode {
@@ -956,6 +964,7 @@ impl Xtasks {
956
964
"Failed to run cargo fmt" ,
957
965
vec ! [ "--all" , "--" , "--check" ] ,
958
966
None ,
967
+ false ,
959
968
) ?;
960
969
961
970
Ok ( ( ) )
@@ -983,6 +992,7 @@ impl Xtasks {
983
992
"Failed to run clippy on codegen crate" ,
984
993
clippy_args,
985
994
None ,
995
+ false ,
986
996
) ?;
987
997
988
998
// TODO: for now do nothing, it's difficult to get rust analyzer to accept the nightly version
@@ -1124,6 +1134,7 @@ impl Xtasks {
1124
1134
"-v" ,
1125
1135
] ,
1126
1136
Some ( & bevy_dir) ,
1137
+ false ,
1127
1138
) ?;
1128
1139
1129
1140
// collect
@@ -1142,6 +1153,7 @@ impl Xtasks {
1142
1153
"-v" ,
1143
1154
] ,
1144
1155
Some ( & bevy_dir) ,
1156
+ false ,
1145
1157
) ?;
1146
1158
1147
1159
Ok ( ( ) )
@@ -1234,6 +1246,7 @@ impl Xtasks {
1234
1246
"Failed to build crates.io docs" ,
1235
1247
args,
1236
1248
None ,
1249
+ false ,
1237
1250
) ?;
1238
1251
}
1239
1252
@@ -1252,7 +1265,12 @@ impl Xtasks {
1252
1265
Ok ( ( ) )
1253
1266
}
1254
1267
1255
- fn bench ( app_settings : GlobalArgs , profile : bool , name : Option < String > ) -> Result < ( ) > {
1268
+ fn bench (
1269
+ app_settings : GlobalArgs ,
1270
+ profile : bool ,
1271
+ name : Option < String > ,
1272
+ capture_streams_in_output : bool ,
1273
+ ) -> Result < Output > {
1256
1274
log:: info!( "Profiling enabled: {profile}" ) ;
1257
1275
1258
1276
let mut features = vec ! [
@@ -1274,17 +1292,18 @@ impl Xtasks {
1274
1292
vec ! [ ]
1275
1293
} ;
1276
1294
1277
- Self :: run_workspace_command (
1295
+ let output = Self :: run_workspace_command (
1278
1296
// run with just lua54
1279
1297
& app_settings. with_features ( Features :: new ( features) ) ,
1280
1298
"bench" ,
1281
1299
"Failed to run benchmarks" ,
1282
1300
args,
1283
1301
None ,
1302
+ capture_streams_in_output,
1284
1303
)
1285
1304
. with_context ( || "when executing criterion benchmarks" ) ?;
1286
1305
1287
- Ok ( ( ) )
1306
+ Ok ( output )
1288
1307
}
1289
1308
1290
1309
fn bencher ( app_settings : GlobalArgs , publish : bool ) -> Result < ( ) > {
@@ -1320,6 +1339,13 @@ impl Xtasks {
1320
1339
1321
1340
let token = std:: env:: var ( "BENCHER_API_TOKEN" ) . ok ( ) ;
1322
1341
1342
+ // first of all run bench, and save output to a file
1343
+
1344
+ let result = Self :: bench ( app_settings, false , None , true ) ?;
1345
+ let bench_file_path = PathBuf :: from ( "./bencher_output.txt" ) ;
1346
+ let mut file = std:: fs:: File :: create ( & bench_file_path) ?;
1347
+ file. write_all ( & result. stdout ) ?;
1348
+
1323
1349
let mut bencher_cmd = Command :: new ( "bencher" ) ;
1324
1350
bencher_cmd
1325
1351
. stdout ( std:: process:: Stdio :: inherit ( ) )
@@ -1347,7 +1373,8 @@ impl Xtasks {
1347
1373
1348
1374
bencher_cmd
1349
1375
. args ( [ "--adapter" , "rust_criterion" ] )
1350
- . arg ( "cargo xtask bench" ) ;
1376
+ . arg ( "--file" )
1377
+ . arg ( bench_file_path) ;
1351
1378
1352
1379
log:: info!( "Running bencher command: {:?}" , bencher_cmd) ;
1353
1380
@@ -1547,6 +1574,7 @@ impl Xtasks {
1547
1574
"Failed to run tests" ,
1548
1575
test_args,
1549
1576
None ,
1577
+ false ,
1550
1578
) ?;
1551
1579
1552
1580
// generate coverage report and lcov file
@@ -1880,6 +1908,7 @@ impl Xtasks {
1880
1908
"Failed to run example" ,
1881
1909
vec ! [ "--example" , example. as_str( ) ] ,
1882
1910
None ,
1911
+ false ,
1883
1912
) ?;
1884
1913
1885
1914
Ok ( ( ) )
0 commit comments