Skip to content

Commit

Permalink
Merge pull request #1229 from SRetip/full_command_return
Browse files Browse the repository at this point in the history
READY : Full command return
  • Loading branch information
Wandalen authored Mar 21, 2024
2 parents fe6661f + 87895ae commit e2cb41a
Showing 1 changed file with 57 additions and 4 deletions.
61 changes: 57 additions & 4 deletions module/move/willbe/src/command/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,58 @@ mod private

use std::collections::HashSet;
use std::path::PathBuf;
use wca::{ Args, Props };
use wca::
{
Args,
Props,
Value,
};
use wtools::error::Result;
use _path::AbsolutePath;
use action::test::TestsCommandOptions;
use former::Former;
use channel::Channel;
use error_tools::for_app::bail;
use iter_tools::Itertools;
use optimization::Optimization;

trait ToString
{
fn to_string( &self ) -> String;
}


impl ToString for Value
{
fn to_string( &self ) -> String
{
match self
{
Value::String( s ) =>
{
format!( "{s}" )
}
Value::Number( n ) =>
{
format!( "{n}" )
}
Value::Path( p ) =>
{
format!( "{}", p.display() )
}
Value::Bool( b ) =>
{
format!( "{b}" )
}
Value::List( list ) =>
{
let list = list.iter().map( | element | element.to_string() ).join( ", "); // qqq : don't hardcode ", " find way to get original separator
format!( "{list}" )
}
}
}
}

#[ derive( Former, Debug ) ]
struct TestsProperties
{
Expand Down Expand Up @@ -48,6 +91,8 @@ mod private
/// run tests in specified crate
pub fn test( args : Args, properties : Props ) -> Result< () >
{
let args_line = format!( "{}", args.get_owned( 0 ).unwrap_or( "" ) );
let prop_line = format!( "{}", properties.iter().map( | p | format!( "{}:{}", p.0, p.1.to_string() ) ).collect::< Vec< _ > >().join(" ") );
let path : PathBuf = args.get_owned( 0 ).unwrap_or_else( || "./".into() );
let path = AbsolutePath::try_from( path )?;
let TestsProperties
Expand Down Expand Up @@ -99,10 +144,18 @@ mod private

match action::test( args, dry )
{

Ok( report ) =>
{
println!( "{report} ");

if dry
{
print!( "You can execute the plan with 'will .test {} dry:0 {}'.", args_line.trim(), prop_line.trim() );
}
else
{
println!( "{report} ");
}

Ok( () )
}
Err( ( report, e ) ) =>
Expand All @@ -121,7 +174,7 @@ mod private
let mut this = Self::former();

this = if let Some( v ) = value.get_owned( "dry" ) { this.dry::< bool >( v ) } else { this };
this = if let Some( v ) = value.get_owned( "temp" ) { this.dry::< bool >( v ) } else { this };
this = if let Some( v ) = value.get_owned( "temp" ) { this.temp::< bool >( v ) } else { this };
this = if let Some( v ) = value.get_owned( "with_stable" ) { this.with_stable::< bool >( v ) } else { this };
this = if let Some( v ) = value.get_owned( "with_nightly" ) { this.with_nightly::< bool >( v ) } else { this };
this = if let Some( v ) = value.get_owned( "concurrent" ) { this.concurrent::< u32 >( v ) } else { this };
Expand Down

0 comments on commit e2cb41a

Please sign in to comment.