aboutsummaryrefslogtreecommitdiff
path: root/src/unitsuite.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/unitsuite.cpp')
-rw-r--r--src/unitsuite.cpp47
1 files changed, 44 insertions, 3 deletions
diff --git a/src/unitsuite.cpp b/src/unitsuite.cpp
index 711b9b5..7d8cc2a 100644
--- a/src/unitsuite.cpp
+++ b/src/unitsuite.cpp
@@ -8,6 +8,8 @@
8#include "bu/unitsuite.h" 8#include "bu/unitsuite.h"
9#include "bu/file.h" 9#include "bu/file.h"
10#include "bu/sio.h" 10#include "bu/sio.h"
11#include "bu/optparser.h"
12#include <stdlib.h>
11 13
12using namespace Bu; 14using namespace Bu;
13 15
@@ -30,8 +32,17 @@ Bu::UnitSuite::~UnitSuite()
30} 32}
31 33
32// Argument handling is coming soon, I promise. 34// Argument handling is coming soon, I promise.
33int Bu::UnitSuite::run( int /*argc*/, char * /*argv */ [] ) 35int Bu::UnitSuite::run( int argc, char *argv[] )
34{ 36{
37 bool bCleanup = true;
38 OptParser p;
39 p.addOption( Bu::slot( this, &Bu::UnitSuite::onListCases ), 'l', "list",
40 "List available test cases." );
41 p.addOption( bCleanup, "no-cleanup", "Don't erase temp files.");
42 p.setOverride( "no-cleanup", "false" );
43 p.addHelpOption();
44 p.parse( argc, argv );
45
35 int iEPass = 0; 46 int iEPass = 0;
36 int iEFail = 0; 47 int iEFail = 0;
37 int iUPass = 0; 48 int iUPass = 0;
@@ -133,9 +144,12 @@ int Bu::UnitSuite::run( int /*argc*/, char * /*argv */ [] )
133 if( iUPass == 0 && iUFail == 0 ) 144 if( iUPass == 0 && iUFail == 0 )
134 sio << "\tNothing unexpected." << sio.nl << sio.nl; 145 sio << "\tNothing unexpected." << sio.nl << sio.nl;
135 146
136 for( StrList::iterator i = lFileCleanup.begin(); i; i++ ) 147 if( bCleanup )
137 { 148 {
138 unlink( (*i).getStr() ); 149 for( StrList::iterator i = lFileCleanup.begin(); i; i++ )
150 {
151 unlink( (*i).getStr() );
152 }
139 } 153 }
140 154
141 return 0; 155 return 0;
@@ -171,3 +185,30 @@ void Bu::UnitSuite::setName( const FString &sName )
171 sSuiteName = sName; 185 sSuiteName = sName;
172} 186}
173 187
188int Bu::UnitSuite::onListCases( StrArray aParam )
189{
190 sio << "Test cases:" << sio.nl;
191 for( TestList::iterator i = lTests.begin(); i; i++ )
192 {
193 sio << "\t- " << Fmt( iNameWidth, 10, Fmt::Left ) << (*i).sName << " "
194 << (*i).eExpect << sio.nl;
195 }
196 sio << sio.nl;
197 exit( 0 );
198 return 0;
199}
200
201Bu::Formatter &Bu::operator<<( Bu::Formatter &f, const Bu::UnitSuite::Expect &e )
202{
203 switch( e )
204 {
205 case Bu::UnitSuite::expectPass:
206 return f << "expect pass";
207
208 case Bu::UnitSuite::expectFail:
209 return f << "expect fail";
210 }
211
212 return f << "**error**";
213}
214