File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ use crate :: local_logger:: icons:: Icon ;
2+ use clap:: Args ;
3+ use console:: style;
4+
5+ /// Experimental flags that may change or be removed without notice.
6+ ///
7+ /// These flags are under active development and their behavior is not guaranteed
8+ /// to remain stable across releases.
9+ #[ derive( Args , Debug , Clone ) ]
10+ pub struct ExperimentalArgs {
11+ /// Enable valgrind's --fair-sched option.
12+ #[ arg( long, default_value_t = false , help_heading = "Experimental" ) ]
13+ pub fair_sched : bool ,
14+ }
15+
16+ impl ExperimentalArgs {
17+ /// Returns the names of all experimental flags that were explicitly set by the user.
18+ pub fn active_flags ( & self ) -> Vec < & ' static str > {
19+ let mut flags = Vec :: new ( ) ;
20+ if self . fair_sched {
21+ flags. push ( "--fair-sched" ) ;
22+ }
23+ flags
24+ }
25+
26+ /// If any experimental flags are active, prints a warning to stderr.
27+ pub fn warn_if_active ( & self ) {
28+ let flags = self . active_flags ( ) ;
29+ if flags. is_empty ( ) {
30+ return ;
31+ }
32+
33+ let flag_list = flags
34+ . iter ( )
35+ . map ( |f| style ( * f) . bold ( ) . to_string ( ) )
36+ . collect :: < Vec < _ > > ( )
37+ . join ( ", " ) ;
38+
39+ eprintln ! (
40+ "\n {} Experimental flags enabled: {}\n \
41+ These may change or be removed without notice.\n \
42+ Share feedback at {}.\n ",
43+ style( Icon :: Warning . to_string( ) ) . yellow( ) ,
44+ flag_list,
45+ style( "https://github.com/CodSpeedHQ/codspeed/issues" ) . underlined( ) ,
46+ ) ;
47+ }
48+ }
Original file line number Diff line number Diff line change 11mod auth;
22pub ( crate ) mod exec;
3+ pub ( crate ) mod experimental;
34pub ( crate ) mod run;
45mod setup;
56mod shared;
@@ -148,6 +149,7 @@ pub async fn run() -> Result<()> {
148149
149150 match cli. command {
150151 Commands :: Run ( args) => {
152+ args. shared . experimental . warn_if_active ( ) ;
151153 run:: run (
152154 * args,
153155 & api_client,
@@ -158,6 +160,7 @@ pub async fn run() -> Result<()> {
158160 . await ?
159161 }
160162 Commands :: Exec ( args) => {
163+ args. shared . experimental . warn_if_active ( ) ;
161164 exec:: run (
162165 * args,
163166 & api_client,
Original file line number Diff line number Diff line change @@ -49,6 +49,7 @@ impl RunArgs {
4949 /// Constructs a new `RunArgs` with default values for testing purposes
5050 pub fn test ( ) -> Self {
5151 use super :: PerfRunArgs ;
52+ use super :: experimental:: ExperimentalArgs ;
5253 use crate :: RunnerMode ;
5354
5455 Self {
@@ -72,6 +73,7 @@ impl RunArgs {
7273 enable_perf : false ,
7374 perf_unwinding_mode : None ,
7475 } ,
76+ experimental : ExperimentalArgs { fair_sched : false } ,
7577 } ,
7678 instruments : vec ! [ ] ,
7779 mongo_uri_env_name : None ,
Original file line number Diff line number Diff line change 1+ use super :: experimental:: ExperimentalArgs ;
12use crate :: VERSION ;
23use crate :: executor:: config:: SimulationTool ;
34use crate :: local_logger:: CODSPEED_U8_COLOR_CODE ;
@@ -116,6 +117,9 @@ pub struct ExecAndRunSharedArgs {
116117
117118 #[ command( flatten) ]
118119 pub perf_run_args : PerfRunArgs ,
120+
121+ #[ command( flatten) ]
122+ pub experimental : ExperimentalArgs ,
119123}
120124
121125impl ExecAndRunSharedArgs {
You can’t perform that action at this time.
0 commit comments