From 4cd45d66b867532d61740cf3a903f78de5ab2e2d Mon Sep 17 00:00:00 2001 From: "Jason C. McDonald" Date: Sat, 30 Jan 2021 13:23:27 -0800 Subject: [PATCH] T1437: Add --runall to Goldilocks 1.0 --- pawlib-source/include/pawlib/goldilocks.hpp | 4 ++++ pawlib-source/src/goldilocks.cpp | 13 +++++++++++++ pawlib-source/src/goldilocks_shell.cpp | 10 ++++++++++ 3 files changed, 27 insertions(+) diff --git a/pawlib-source/include/pawlib/goldilocks.hpp b/pawlib-source/include/pawlib/goldilocks.hpp index f5a6c25..d60e559 100644 --- a/pawlib-source/include/pawlib/goldilocks.hpp +++ b/pawlib-source/include/pawlib/goldilocks.hpp @@ -296,6 +296,10 @@ class TestManager * \return true if the item ran successfully, else false */ bool run(testname_t, unsigned int = 1); + /** Run all tests. + * \return true if the items ran successfully, else false */ + bool runall(); + /**Run a test by name. * \param the name of the test to run * \param the number of times to repeat the test diff --git a/pawlib-source/src/goldilocks.cpp b/pawlib-source/src/goldilocks.cpp index a9875c3..3415103 100644 --- a/pawlib-source/src/goldilocks.cpp +++ b/pawlib-source/src/goldilocks.cpp @@ -444,6 +444,19 @@ bool TestManager::run(testname_t item, unsigned int number) return false; } +bool TestManager::runall() +{ + /* Loop through all the indexes in the map `suites`... + * SOURCE: http://stackoverflow.com/a/110255/472647 + */ + for(std::map::iterator it = suites.begin(); it != suites.end(); ++it) + { + // Run each suite. + run_suite(it->first); + } + return true; +} + bool TestManager::run_suite(testsuitename_t suite) { /* ENTRY: Run a suite of tests.*/ diff --git a/pawlib-source/src/goldilocks_shell.cpp b/pawlib-source/src/goldilocks_shell.cpp index 1c7a24a..fe5a01a 100644 --- a/pawlib-source/src/goldilocks_shell.cpp +++ b/pawlib-source/src/goldilocks_shell.cpp @@ -141,6 +141,16 @@ int GoldilocksShell::command(int argc_s, char* argv[], unsigned int skip) // If run item succeeds, set the return code to 0, else 1 (error). r = this->testmanager->run(tokens[++i]) ? 0 : 1; } + // If runall flag is provided... + else if(tokens[i] == "--runall") + { + // Load all the suites first. + this->testmanager->load_suite(); + loaded = true; + + // If run item succeeds, set the return code to 0, else 1 (error). + r = this->testmanager->runall() ? 0 : 1; + } // If benchmark flag and subsequent argument are provided... else if(tokens[i] == "--benchmark") {