File tree Expand file tree Collapse file tree 3 files changed +17
-31
lines changed Expand file tree Collapse file tree 3 files changed +17
-31
lines changed Original file line number Diff line number Diff line change @@ -76,7 +76,17 @@ pub fn run_benches(
76
76
std:: process:: Command :: new ( bench)
77
77
. env ( "CODSPEED_CARGO_WORKSPACE_ROOT" , workspace_root. as_ref ( ) )
78
78
. status ( )
79
- . map_err ( |_| anyhow ! ( "failed to execute the benchmark process" ) ) ?;
79
+ . map_err ( |_| anyhow ! ( "failed to execute the benchmark process" ) )
80
+ . and_then ( |status| {
81
+ if status. success ( ) {
82
+ Ok ( ( ) )
83
+ } else {
84
+ Err ( anyhow ! (
85
+ "failed to execute the benchmark process, exit code: {}" ,
86
+ status. code( ) . unwrap_or( 1 )
87
+ ) )
88
+ }
89
+ } ) ?;
80
90
ws. config ( ) . shell ( ) . status_with_color (
81
91
"Done" ,
82
92
format ! ( "running {}" , bench_name) ,
Original file line number Diff line number Diff line change 1
1
#[ macro_export]
2
2
macro_rules! abs_file {
3
3
( ) => {
4
- std:: path:: PathBuf :: from( std:: env:: var( "CODSPEED_CARGO_WORKSPACE_ROOT" ) . unwrap( ) )
5
- . join( file!( ) )
6
- . to_string_lossy( )
4
+ std:: path:: PathBuf :: from(
5
+ std:: env:: var( "CODSPEED_CARGO_WORKSPACE_ROOT" )
6
+ . expect( "Could not find CODSPEED_CARGO_WORKSPACE_ROOT env variable, make sure you are using the latest version of cargo-codspeed" )
7
+ )
8
+ . join( file!( ) )
9
+ . to_string_lossy( )
7
10
} ;
8
11
}
9
12
Original file line number Diff line number Diff line change 1
1
use std:: io;
2
2
use std:: path:: { Path , PathBuf } ;
3
- use std:: process:: Command ;
4
3
5
4
fn get_parent_git_repo_path ( abs_path : & Path ) -> io:: Result < PathBuf > {
6
5
if abs_path. join ( ".git" ) . exists ( ) {
28
27
}
29
28
}
30
29
31
- /// Returns the path to the root of the cargo workspace.
32
- /// This is needed since file! returns the path relatively to the workspace root
33
- /// while CARGO_MANIFEST_DIR returns the path to the sub package
34
- pub fn get_cargo_workspace_root ( ) -> PathBuf {
35
- let output = Command :: new ( "cargo" )
36
- . args ( [
37
- "metadata" ,
38
- "--format-version" ,
39
- "1" ,
40
- "--no-deps" ,
41
- "--quiet" ,
42
- "--offline" ,
43
- ] )
44
- . current_dir ( env ! ( "CARGO_MANIFEST_DIR" ) )
45
- . output ( )
46
- . expect ( "Failed to execute `cargo metadata`" ) ;
47
-
48
- let metadata: serde_json:: Value =
49
- serde_json:: from_slice ( & output. stdout ) . expect ( "Failed to parse `cargo metadata` output" ) ;
50
-
51
- let workspace_root = metadata[ "workspace_root" ]
52
- . as_str ( )
53
- . expect ( "`workspace_root` field is missing or not a string" ) ;
54
- PathBuf :: from ( workspace_root)
55
- }
56
-
57
30
/// Fixes spaces around `::` created by stringify!($function).
58
31
pub fn get_formated_function_path ( function_path : impl Into < String > ) -> String {
59
32
let function_path = function_path. into ( ) ;
You can’t perform that action at this time.
0 commit comments