Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

READY : Full command return #1229

Merged
merged 1 commit into from
Mar 21, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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