зеркало из https://github.com/microsoft/pict.git
Add alias for max order (#77)
* cli/gcdmodel.cpp: Fix typos in comments. * cli/gcdmodel.cpp (CGcdData::fixModelAndSubmodelOrder): Fix typos in comments. * cli: Support "max" as an alias to the maximum value for the order switch. * cli/cmdline.cpp (parseArg): Understand "all" for the order switch. (showUsage): Document it. * cli/gcdmodel.cpp (CGcdData::fixModelAndSubmodelOrder): Ensure the root model order gets recomputed when "/o:max" was provided as argument. * cli/model.h (UNDEFINED_ORDER): Redefine as the minimum int value. (MAXIMUM_ORDER): New constant. * doc/pict.md: Document it. * test/arg/.tests: Add test. Co-authored-by: Maxim Cournoyer <maxim.cournoyer@savoirfairelinux.com>
This commit is contained in:
Родитель
cc021b8493
Коммит
18945b3139
|
@ -109,6 +109,12 @@ bool parseArg( wchar_t* text, CModelData& modelData )
|
|||
{
|
||||
case SWITCH_ORDER:
|
||||
{
|
||||
// Handle the "max" special case.
|
||||
if ( getStringFromArg( text ) == L"max" )
|
||||
{
|
||||
modelData.Order = MAXIMUM_ORDER;
|
||||
break;
|
||||
}
|
||||
unsigned int i = getUIntFromArg( text );
|
||||
if( i == 0 )
|
||||
{
|
||||
|
@ -293,14 +299,14 @@ void showUsage()
|
|||
wcout << L"Pairwise Independent Combinatorial Testing" << endl << endl;
|
||||
wcout << L"Usage: pict model [options]" << endl << endl;
|
||||
wcout << L"Options:" << endl;
|
||||
wcout << L" /" << charToStr( SWITCH_ORDER ) << L":N - Order of combinations (default: 2)" << endl;
|
||||
wcout << L" /" << charToStr( SWITCH_DELIMITER ) << L":C - Separator for values (default: ,)" << endl;
|
||||
wcout << L" /" << charToStr( SWITCH_ALIAS_DELIMITER ) << L":C - Separator for aliases (default: |)" << endl;
|
||||
wcout << L" /" << charToStr( SWITCH_NEGATIVE_VALUES ) << L":C - Negative value prefix (default: ~)" << endl;
|
||||
wcout << L" /" << charToStr( SWITCH_SEED_FILE ) << L":file - File with seeding rows" << endl;
|
||||
wcout << L" /" << charToStr( SWITCH_RANDOMIZE ) << L"[:N] - Randomize generation, N - seed" << endl;
|
||||
wcout << L" /" << charToStr( SWITCH_CASE_SENSITIVE ) << L" - Case-sensitive model evaluation" << endl;
|
||||
wcout << L" /" << charToStr( SWITCH_STATISTICS ) << L" - Show model statistics" << endl;
|
||||
wcout << L" /" << charToStr( SWITCH_ORDER ) << L":N|max - Order of combinations (default: 2)" << endl;
|
||||
wcout << L" /" << charToStr( SWITCH_DELIMITER ) << L":C - Separator for values (default: ,)" << endl;
|
||||
wcout << L" /" << charToStr( SWITCH_ALIAS_DELIMITER ) << L":C - Separator for aliases (default: |)" << endl;
|
||||
wcout << L" /" << charToStr( SWITCH_NEGATIVE_VALUES ) << L":C - Negative value prefix (default: ~)" << endl;
|
||||
wcout << L" /" << charToStr( SWITCH_SEED_FILE ) << L":file - File with seeding rows" << endl;
|
||||
wcout << L" /" << charToStr( SWITCH_RANDOMIZE ) << L"[:N] - Randomize generation, N - seed" << endl;
|
||||
wcout << L" /" << charToStr( SWITCH_CASE_SENSITIVE ) << L" - Case-sensitive model evaluation" << endl;
|
||||
wcout << L" /" << charToStr( SWITCH_STATISTICS ) << L" - Show model statistics" << endl;
|
||||
// there are hidden parameters:
|
||||
// wcout << L" /x - Approximate generation (best effort, might not cover all combinations)" << endl;
|
||||
// wcout << L" /p - Preview generation (only a few test cases)" << endl;
|
||||
|
|
|
@ -117,7 +117,7 @@ bool CGcdData::FixParamOrder( IN Model* submodel )
|
|||
if( p->Order != UNDEFINED_ORDER )
|
||||
{
|
||||
// TODO: add verification of Order
|
||||
// if p->Order > model->parmeters.count - model.ResultParameters.count then error out
|
||||
// if p->Order > model->parameters.count - model.ResultParameters.count then error out
|
||||
param->SetOrder( p->Order );
|
||||
}
|
||||
else
|
||||
|
@ -402,11 +402,12 @@ void CResult::PrintStatistics()
|
|||
}
|
||||
|
||||
//
|
||||
// figures out order for all model elements with UNDEFINED_ORDER
|
||||
// Figure out order for all model elements with UNDEFINED_ORDER or for
|
||||
// root model with MAXIMUM_ORDER.
|
||||
//
|
||||
bool CGcdData::fixModelAndSubmodelOrder()
|
||||
{
|
||||
if( _modelData.Order < 1 )
|
||||
if( _modelData.Order < 1 and _modelData.Order != UNDEFINED_ORDER )
|
||||
{
|
||||
PrintMessage( InputDataError, L"Order cannot be smaller than 1" );
|
||||
return( false );
|
||||
|
@ -414,14 +415,17 @@ bool CGcdData::fixModelAndSubmodelOrder()
|
|||
|
||||
Model* rootModel = _task.GetRootModel();
|
||||
|
||||
// If the order given as arg to the program has not been explicitely defined it defaults to 2
|
||||
// If there's only one parameter or submodel in the model, the order of 2 will fail to execute
|
||||
// To aviod this, must switch to lower order behind the scenes
|
||||
// If the order given as an argument to the program has not been
|
||||
// explicitly defined it defaults to 2; if it's been provided but
|
||||
// given the "max" value, it defaults to MAXIMUM_ORDER. In both
|
||||
// cases, the order value must be recomputed and set to the real
|
||||
// maximum to avoid failing the later sanity checks.
|
||||
size_t inputParamCount = _modelData.TotalParameterCount() - _modelData.ResultParameterCount();
|
||||
|
||||
if( _modelData.ProvidedArguments.find( SWITCH_ORDER ) == _modelData.ProvidedArguments.end() )
|
||||
if( _modelData.ProvidedArguments.find( SWITCH_ORDER ) == _modelData.ProvidedArguments.end()
|
||||
or _modelData.Order == MAXIMUM_ORDER )
|
||||
{
|
||||
// if submidels were defined, don't need any params, otherwise order = params without submodels
|
||||
// if submodels were defined, don't need any params, otherwise order = params without submodels
|
||||
if( _modelData.Submodels.size() > 0 )
|
||||
{
|
||||
if( _modelData.Order > static_cast<int>( rootModel->GetSubmodelCount() ) )
|
||||
|
|
|
@ -8,7 +8,8 @@
|
|||
#include "strings.h"
|
||||
using namespace pictcore;
|
||||
|
||||
const int UNDEFINED_ORDER = std::numeric_limits<int>::max();
|
||||
const int UNDEFINED_ORDER = std::numeric_limits<int>::min();
|
||||
const int MAXIMUM_ORDER = std::numeric_limits<int>::max();
|
||||
|
||||
//
|
||||
//
|
||||
|
|
16
doc/pict.md
16
doc/pict.md
|
@ -26,14 +26,14 @@ PICT is a command-line tool that accepts a plain-text model file as an input and
|
|||
Usage: pict model [options]
|
||||
|
||||
Options:
|
||||
/o:N - Order of combinations (default: 2)
|
||||
/d:C - Separator for values (default: ,)
|
||||
/a:C - Separator for aliases (default: |)
|
||||
/n:C - Negative value prefix (default: ~)
|
||||
/e:file - File with seeding rows
|
||||
/r[:N] - Randomize generation, N - seed
|
||||
/c - Case-sensitive model evaluation
|
||||
/s - Show model statistics
|
||||
/o:N|max - Order of combinations (default: 2)
|
||||
/d:C - Separator for values (default: ,)
|
||||
/a:C - Separator for aliases (default: |)
|
||||
/n:C - Negative value prefix (default: ~)
|
||||
/e:file - File with seeding rows
|
||||
/r[:N] - Randomize generation, N - seed
|
||||
/c - Case-sensitive model evaluation
|
||||
/s - Show model statistics
|
||||
|
||||
## Model File
|
||||
|
||||
|
|
|
@ -14,6 +14,7 @@ arg001.txt /o:3 -> SUCCESS
|
|||
arg001.txt -o:3 -> SUCCESS
|
||||
arg001.txt -O:3 -> SUCCESS
|
||||
arg001.txt /O:2.5 -> SUCCESS
|
||||
arg001.txt /o:max -> SUCCESS
|
||||
|
||||
arg001.txt /o:a -> BAD_OPTION
|
||||
arg001.txt /o:" " -> BAD_OPTION
|
||||
|
|
Загрузка…
Ссылка в новой задаче