@@ -1072,6 +1072,9 @@ pub async fn debug_recipe(
10721072) -> miette:: Result < ( ) > {
10731073 let recipe_path = get_recipe_path ( & debug_data. recipe_path ) ?;
10741074
1075+ let is_test_mode = debug_data. test_index . is_some ( ) ;
1076+ let test_index = debug_data. test_index . unwrap_or ( 0 ) ;
1077+
10751078 let build_data = BuildData {
10761079 build_platform : debug_data. build_platform ,
10771080 target_platform : debug_data. target_platform ,
@@ -1177,22 +1180,64 @@ pub async fn debug_recipe(
11771180 }
11781181 }
11791182
1180- tracing:: info!( "\n To run the actual build, use:" ) ;
1181- tracing:: info!(
1182- "rattler-build build --recipe {}" ,
1183- output. build_configuration. directories. recipe_path. display( )
1184- ) ;
1185- tracing:: info!( "Or run the build script directly with:" ) ;
1186- if cfg ! ( windows) {
1187- tracing:: info!(
1188- "cd {} && ./conda_build.bat" ,
1189- output. build_configuration. directories. work_dir. display( )
1190- ) ;
1183+ if is_test_mode {
1184+ // Test mode: setup test environment and run specific test
1185+ let tests = & output. recipe . tests ;
1186+
1187+ if tests. is_empty ( ) {
1188+ return Err ( miette:: miette!(
1189+ "No tests found in recipe. Cannot run tests in debug mode."
1190+ ) ) ;
1191+ }
1192+
1193+ if test_index >= tests. len ( ) {
1194+ return Err ( miette:: miette!(
1195+ "Test index {} out of range. Recipe has {} test(s)." ,
1196+ test_index,
1197+ tests. len( )
1198+ ) ) ;
1199+ }
1200+
1201+ tracing:: info!( "\n === Test Debug Mode ===" ) ;
1202+ tracing:: info!( "Running test {} of {}" , test_index, tests. len( ) - 1 ) ;
1203+ tracing:: info!( "Available tests:" ) ;
1204+ for ( idx, test) in tests. iter ( ) . enumerate ( ) {
1205+ let test_type = match test {
1206+ crate :: recipe:: parser:: TestType :: Python { .. } => "Python" ,
1207+ crate :: recipe:: parser:: TestType :: Perl { .. } => "Perl" ,
1208+ crate :: recipe:: parser:: TestType :: R { .. } => "R" ,
1209+ crate :: recipe:: parser:: TestType :: Ruby { .. } => "Ruby" ,
1210+ crate :: recipe:: parser:: TestType :: Command ( _) => "Command" ,
1211+ crate :: recipe:: parser:: TestType :: Downstream ( _) => "Downstream" ,
1212+ crate :: recipe:: parser:: TestType :: PackageContents { .. } => "PackageContents" ,
1213+ } ;
1214+ let marker = if idx == test_index { ">>>" } else { " " } ;
1215+ tracing:: info!( "{} Test {}: {}" , marker, idx, test_type) ;
1216+ }
1217+
1218+ tracing:: info!( "\n Test environment will be prepared for test index {}." , test_index) ;
1219+ tracing:: info!( "\n To execute tests after setting up the environment, use:" ) ;
1220+ tracing:: info!( " rattler-build test <package_file>" ) ;
1221+ tracing:: info!( "\n Note: The test environment has been created, but the package must be built first before running tests." ) ;
11911222 } else {
1223+ // Build mode: provide instructions to run the build script
1224+ tracing:: info!( "\n To run the actual build, use:" ) ;
11921225 tracing:: info!(
1193- "cd {} && ./conda_build.sh " ,
1194- output. build_configuration. directories. work_dir . display( )
1226+ "rattler-build build --recipe {} " ,
1227+ output. build_configuration. directories. recipe_path . display( )
11951228 ) ;
1229+ tracing:: info!( "Or run the build script directly with:" ) ;
1230+ if cfg ! ( windows) {
1231+ tracing:: info!(
1232+ "cd {} && ./conda_build.bat" ,
1233+ output. build_configuration. directories. work_dir. display( )
1234+ ) ;
1235+ } else {
1236+ tracing:: info!(
1237+ "cd {} && ./conda_build.sh" ,
1238+ output. build_configuration. directories. work_dir. display( )
1239+ ) ;
1240+ }
11961241 }
11971242 }
11981243
0 commit comments