Example #1
0
 std::vector<std::string> getAllSuiteNames() {
     std::vector<std::string> result;
     for (SuiteMap::const_iterator i = _allSuites().begin(); i != _allSuites().end(); ++i) {
             result.push_back(i->first);
     }
     return result;
 }
Example #2
0
Suite* Suite::getSuite(const std::string& name) {
    std::shared_ptr<Suite>& result = _allSuites()[name];
    if (!result) {
        // Suites are self-registering.
        new Suite(name);
    }
    invariant(result);
    return result.get();
}
Example #3
0
 Suite* Suite::getSuite(const std::string& name) {
     Suite* result = _allSuites()[name];
     if (!result)
         result = new Suite(name);  // Suites are self-registering.
     return result;
 }
Example #4
0
 void Suite::registerSuite( const std::string& name , Suite* s ) {
     Suite*& m = _allSuites()[name];
     fassert( 10162, ! m );
     m = s;
 }
Example #5
0
        int Suite::run( const std::vector<std::string>& suites , const std::string& filter , int runsPerTest ) {

            if (_allSuites().empty()) {
                log() << "error: no suites registered.";
                return EXIT_FAILURE;
            }

            for ( unsigned int i = 0; i < suites.size(); i++ ) {
                if ( _allSuites().count( suites[i] ) == 0 ) {
                    log() << "invalid test suite [" << suites[i] << "], use --list to see valid names" << std::endl;
                    return EXIT_FAILURE;
                }
            }

            std::vector<std::string> torun(suites);

            if ( torun.empty() ) {
                for ( SuiteMap::const_iterator i = _allSuites().begin();
                      i !=_allSuites().end(); ++i ) {

                    torun.push_back( i->first );
                }
            }

            std::vector<Result*> results;

            for ( std::vector<std::string>::iterator i=torun.begin(); i!=torun.end(); i++ ) {
                std::string name = *i;
                Suite* s = _allSuites()[name];
                fassert( 16145,  s );

                log() << "going to run suite: " << name << std::endl;
                results.push_back( s->run( filter, runsPerTest ) );
            }

            log() << "**************************************************" << std::endl;

            int rc = 0;

            int tests = 0;
            int asserts = 0;
            int millis = 0;

            Result totals ("TOTALS");
            std::vector<std::string> failedSuites;

            for ( std::vector<Result*>::iterator i=results.begin(); i!=results.end(); i++ ) {
                Result* r = *i;
                log() << r->toString();
                if ( abs( r->rc() ) > abs( rc ) )
                    rc = r->rc();

                tests += r->_tests;
                if ( !r->_fails.empty() ) {
                    failedSuites.push_back(r->toString());
                    for ( std::vector<std::string>::const_iterator j=r->_fails.begin();
                          j!=r->_fails.end(); j++ ) {
                        const std::string& s = (*j);
                        totals._fails.push_back(r->_name + "/" + s);
                    }
                }
                asserts += r->_asserts;
                millis += r->_millis;
            }

            totals._tests = tests;
            totals._asserts = asserts;
            totals._millis = millis;

            log() << totals.toString(); // includes endl

            // summary
            if ( !totals._fails.empty() ) {
                log() << "Failing tests:" << std::endl;
                for ( std::vector<std::string>::const_iterator i=totals._fails.begin();
                      i!=totals._fails.end(); i++ ) {
                    const std::string& s = (*i);
                    log() << "\t " << s << " Failed";
                }
                log() << "FAILURE - " << totals._fails.size() << " tests in "
                      << failedSuites.size() << " suites failed";
            }
            else {
                log() << "SUCCESS - All tests in all suites passed";
            }

            return rc;
        }
Example #6
0
        int Suite::run( const std::vector<std::string>& suites , const std::string& filter , int runsPerTest ) {

            if (_allSuites().empty()) {
                log() << "error: no suites registered.";
                return EXIT_FAILURE;
            }

            for ( unsigned int i = 0; i < suites.size(); i++ ) {
                if ( _allSuites().count( suites[i] ) == 0 ) {
                    log() << "invalid test suite [" << suites[i] << "], use --list to see valid names" << std::endl;
                    return EXIT_FAILURE;
                }
            }

            std::vector<std::string> torun(suites);

            if ( torun.empty() ) {
                for ( SuiteMap::const_iterator i = _allSuites().begin();
                      i !=_allSuites().end(); ++i ) {

                    torun.push_back( i->first );
                }
            }

            std::vector<Result*> results;

            for ( std::vector<std::string>::iterator i=torun.begin(); i!=torun.end(); i++ ) {
                std::string name = *i;
                Suite* s = _allSuites()[name];
                fassert( 16145,  s );

                log() << "going to run suite: " << name << std::endl;
                results.push_back( s->run( filter, runsPerTest ) );
            }

            log() << "**************************************************" << std::endl;

            int rc = 0;

            int tests = 0;
            int fails = 0;
            int asserts = 0;

            for ( std::vector<Result*>::iterator i=results.begin(); i!=results.end(); i++ ) {
                Result* r = *i;
                log() << r->toString();
                if ( abs( r->rc() ) > abs( rc ) )
                    rc = r->rc();

                tests += r->_tests;
                fails += r->_fails;
                asserts += r->_asserts;
            }

            Result totals ("TOTALS");
            totals._tests = tests;
            totals._fails = fails;
            totals._asserts = asserts;

            log() << totals.toString(); // includes endl

            return rc;
        }
Example #7
0
void Suite::registerSuite(const std::string& name, Suite* s) {
    std::shared_ptr<Suite>& m = _allSuites()[name];
    fassert(10162, !m);
    m.reset(s);
}