@@ -433,3 +433,74 @@ fn build_new_project_from_template(template: &str) -> Package {
433433 fs:: remove_dir_all ( new_project_path) . unwrap ( ) ;
434434 package
435435}
436+
437+ #[ test]
438+ fn new_project_integration_tests_pass ( ) {
439+ let _ = env_logger:: Builder :: from_env ( "MIDENC_TRACE" )
440+ . is_test ( true )
441+ . format_timestamp ( None )
442+ . try_init ( ) ;
443+ env:: set_var ( "TEST" , "1" ) ;
444+
445+ let restore_dir = env:: current_dir ( ) . unwrap ( ) ;
446+ let temp_dir = env:: temp_dir ( ) . join ( format ! (
447+ "cargo_miden_integration_{}" ,
448+ std:: time:: SystemTime :: now( )
449+ . duration_since( std:: time:: UNIX_EPOCH )
450+ . unwrap( )
451+ . as_millis( )
452+ ) ) ;
453+ if temp_dir. exists ( ) {
454+ fs:: remove_dir_all ( & temp_dir) . unwrap ( ) ;
455+ }
456+ fs:: create_dir_all ( & temp_dir) . unwrap ( ) ;
457+ env:: set_current_dir ( & temp_dir) . unwrap ( ) ;
458+
459+ let project_name = format ! (
460+ "integration_project_{}" ,
461+ std:: time:: SystemTime :: now( )
462+ . duration_since( std:: time:: UNIX_EPOCH )
463+ . unwrap( )
464+ . as_micros( )
465+ ) ;
466+ let args = new_project_args ( & project_name, "" ) ;
467+
468+ let output = run ( args. into_iter ( ) , OutputType :: Masm )
469+ . expect ( "Failed to create project with `cargo miden new`" )
470+ . expect ( "'cargo miden new' should return Some(CommandOutput)" ) ;
471+ let project_path = match output {
472+ cargo_miden:: CommandOutput :: NewCommandOutput { project_path } => {
473+ project_path. canonicalize ( ) . unwrap ( )
474+ }
475+ other => panic ! ( "Expected NewCommandOutput, got {other:?}" ) ,
476+ } ;
477+ assert ! ( project_path. exists( ) ) ;
478+
479+ let integration_dir = project_path. join ( "integration" ) ;
480+ assert ! (
481+ integration_dir. exists( ) ,
482+ "expected integration workspace at {}" ,
483+ integration_dir. display( )
484+ ) ;
485+
486+ let output = std:: process:: Command :: new ( "cargo" )
487+ . arg ( "test" )
488+ . current_dir ( & integration_dir)
489+ . output ( )
490+ . expect ( "failed to spawn `cargo test` inside integration directory" ) ;
491+ if !output. status . success ( ) {
492+ panic ! (
493+ "`cargo test` failed in {} with status {:?}\n stdout:\n {}\n stderr:\n {}" ,
494+ integration_dir. display( ) ,
495+ output. status. code( ) ,
496+ String :: from_utf8_lossy( & output. stdout) ,
497+ String :: from_utf8_lossy( & output. stderr)
498+ ) ;
499+ }
500+
501+ env:: set_current_dir ( restore_dir) . unwrap ( ) ;
502+ fs:: remove_dir_all ( & project_path) . unwrap ( ) ;
503+ if temp_dir. exists ( ) {
504+ fs:: remove_dir_all ( & temp_dir) . unwrap ( ) ;
505+ }
506+ }
0 commit comments