@@ -7,7 +7,10 @@ use indent_write::indentable::Indented;
77use itertools:: Itertools ;
88use nextest_filtering:: errors:: FiltersetParseErrors ;
99use nextest_metadata:: NextestExitCode ;
10- use nextest_runner:: { errors:: * , helpers:: plural, redact:: Redactor } ;
10+ use nextest_runner:: {
11+ config:: ConfigExperimental , errors:: * , helpers:: plural, redact:: Redactor ,
12+ run_mode:: NextestRunMode ,
13+ } ;
1114use owo_colors:: OwoColorize ;
1215use semver:: Version ;
1316use std:: { error:: Error , io, path:: PathBuf , process:: ExitStatus , string:: FromUtf8Error } ;
@@ -212,6 +215,7 @@ pub enum ExpectedError {
212215 TestRunFailed ,
213216 #[ error( "no tests to run" ) ]
214217 NoTestsRun {
218+ mode : NextestRunMode ,
215219 /// The no-tests-run error was chosen because it was the default (we show a hint in this
216220 /// case)
217221 is_default : bool ,
@@ -249,6 +253,11 @@ pub enum ExpectedError {
249253 name : & ' static str ,
250254 var_name : & ' static str ,
251255 } ,
256+ #[ error( "config experimental features not enabled" ) ]
257+ ConfigExperimentalFeaturesNotEnabled {
258+ config_file : Utf8PathBuf ,
259+ missing : Vec < ConfigExperimental > ,
260+ } ,
252261 #[ error( "filterset parse error" ) ]
253262 FiltersetParseError {
254263 all_errors : Vec < FiltersetParseErrors > ,
@@ -467,9 +476,7 @@ impl ExpectedError {
467476 | Self :: DebugExtractWriteError { .. } => NextestExitCode :: WRITE_OUTPUT_ERROR ,
468477 #[ cfg( feature = "self-update" ) ]
469478 Self :: UpdateError { .. } => NextestExitCode :: UPDATE_ERROR ,
470- Self :: ExperimentalFeatureNotEnabled { .. } => {
471- NextestExitCode :: EXPERIMENTAL_FEATURE_NOT_ENABLED
472- }
479+ Self :: ExperimentalFeatureNotEnabled { .. } | Self :: ConfigExperimentalFeaturesNotEnabled { .. } => NextestExitCode :: EXPERIMENTAL_FEATURE_NOT_ENABLED ,
473480 Self :: FiltersetParseError { .. } => NextestExitCode :: INVALID_FILTERSET ,
474481 }
475482 }
@@ -870,13 +877,16 @@ impl ExpectedError {
870877 error ! ( "test run failed" ) ;
871878 None
872879 }
873- Self :: NoTestsRun { is_default } => {
880+ Self :: NoTestsRun { mode , is_default } => {
874881 let hint_str = if * is_default {
875882 "\n (hint: use `--no-tests` to customize)"
876883 } else {
877884 ""
878885 } ;
879- error ! ( "no tests to run{hint_str}" ) ;
886+ error ! (
887+ "no {} to run{hint_str}" ,
888+ plural:: tests_plural_if( * mode, true ) ,
889+ ) ;
880890 None
881891 }
882892 Self :: ShowTestGroupsError { err } => {
@@ -936,6 +946,34 @@ impl ExpectedError {
936946 ) ;
937947 None
938948 }
949+ Self :: ConfigExperimentalFeaturesNotEnabled {
950+ config_file,
951+ missing,
952+ } => {
953+ if missing. len ( ) == 1 {
954+ let env_hint = if let Some ( env_var) = missing[ 0 ] . env_var ( ) {
955+ format ! ( " or set {env_var}=1" )
956+ } else {
957+ String :: new ( )
958+ } ;
959+ error ! (
960+ "experimental feature not enabled: {}\n (hint: add to the {} list in {}{})" ,
961+ missing[ 0 ] . style( styles. bold) ,
962+ "experimental" . style( styles. bold) ,
963+ config_file. style( styles. bold) ,
964+ env_hint,
965+ ) ;
966+ } else {
967+ error ! (
968+ "experimental features not enabled: {}\n (hint: add to the {} list in {})" ,
969+ missing. iter( ) . map( |f| f. style( styles. bold) ) . join( ", " ) ,
970+ "experimental" . style( styles. bold) ,
971+ config_file. style( styles. bold) ,
972+ ) ;
973+ // TODO: env_hint?
974+ }
975+ None
976+ }
939977 Self :: FiltersetParseError { all_errors } => {
940978 for errors in all_errors {
941979 for single_error in & errors. errors {
0 commit comments