mirror of
https://github.com/XRPLF/rippled.git
synced 2025-11-20 11:05:54 +00:00
Run an individual unit test
This commit is contained in:
@@ -120,6 +120,4 @@
|
|||||||
//#define BEAST_BIND_USES_TR1 1
|
//#define BEAST_BIND_USES_TR1 1
|
||||||
//#define BEAST_BIND_USES_BOOST 1
|
//#define BEAST_BIND_USES_BOOST 1
|
||||||
|
|
||||||
//#define BEAST_UNIT_TESTS 1
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -120,6 +120,4 @@
|
|||||||
//#define BEAST_BIND_USES_TR1 1
|
//#define BEAST_BIND_USES_TR1 1
|
||||||
//#define BEAST_BIND_USES_BOOST 1
|
//#define BEAST_BIND_USES_BOOST 1
|
||||||
|
|
||||||
#define BEAST_UNIT_TESTS 1
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -224,6 +224,4 @@ public:
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
#if BEAST_UNIT_TESTS
|
|
||||||
static AbstractFifoTests abstractFifoTests;
|
static AbstractFifoTests abstractFifoTests;
|
||||||
#endif
|
|
||||||
|
|||||||
@@ -182,9 +182,9 @@ void UnitTests::beginNewTest (UnitTest* const test, const String& subCategory)
|
|||||||
r->passes = 0;
|
r->passes = 0;
|
||||||
r->failures = 0;
|
r->failures = 0;
|
||||||
|
|
||||||
logMessage ("Test: " + r->unitTestName + "/" + subCategory + "...");
|
logMessage ("Test '" + r->unitTestName + "': " + subCategory);
|
||||||
|
|
||||||
resultsUpdated();
|
resultsUpdated ();
|
||||||
}
|
}
|
||||||
|
|
||||||
void UnitTests::endTest()
|
void UnitTests::endTest()
|
||||||
@@ -241,8 +241,8 @@ void UnitTests::addFail (const String& failureMessage)
|
|||||||
|
|
||||||
r->failures++;
|
r->failures++;
|
||||||
|
|
||||||
String message ("!!! Test ");
|
String message ("Failure, #");
|
||||||
message << (r->failures + r->passes) << " failed";
|
message << (r->failures + r->passes);
|
||||||
|
|
||||||
if (failureMessage.isNotEmpty())
|
if (failureMessage.isNotEmpty())
|
||||||
message << ": " << failureMessage;
|
message << ": " << failureMessage;
|
||||||
|
|||||||
@@ -1106,7 +1106,5 @@ public:
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
#if BEAST_UNIT_TESTS
|
|
||||||
static FileTests fileTests;
|
static FileTests fileTests;
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|||||||
@@ -199,16 +199,18 @@ public:
|
|||||||
HeapBlock <char> data;
|
HeapBlock <char> data;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
void runTest ()
|
void runTest ()
|
||||||
{
|
{
|
||||||
|
RandomAccessFile file;
|
||||||
|
|
||||||
|
beginTest ("open");
|
||||||
|
|
||||||
Result result = file.open (File::createTempFile ("tests"), RandomAccessFile::readWrite);
|
Result result = file.open (File::createTempFile ("tests"), RandomAccessFile::readWrite);
|
||||||
|
|
||||||
expect (result.wasOk (), "Should be ok");
|
expect (result.wasOk (), "Should be ok");
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
RandomAccessFile file;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
static RandomAccessFileTests randomAccessFileTests;
|
static RandomAccessFileTests randomAccessFileTests;
|
||||||
|
|||||||
@@ -639,6 +639,4 @@ public:
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
#if BEAST_UNIT_TESTS
|
|
||||||
static JSONTests jsonTests;
|
static JSONTests jsonTests;
|
||||||
#endif
|
|
||||||
|
|||||||
@@ -165,6 +165,4 @@ public:
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
#if BEAST_UNIT_TESTS
|
|
||||||
static RandomTests randomTests;
|
static RandomTests randomTests;
|
||||||
#endif
|
|
||||||
|
|||||||
@@ -148,6 +148,4 @@ public:
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
#if BEAST_UNIT_TESTS
|
|
||||||
static MemoryStreamTests memoryStreamTests;
|
static MemoryStreamTests memoryStreamTests;
|
||||||
#endif
|
|
||||||
|
|||||||
@@ -2402,6 +2402,4 @@ public:
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
#if BEAST_UNIT_TESTS
|
|
||||||
static StringTests stringTests;
|
static StringTests stringTests;
|
||||||
#endif
|
|
||||||
|
|||||||
@@ -229,6 +229,4 @@ public:
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
#if BEAST_UNIT_TESTS
|
|
||||||
static DiffTests diffTests;
|
static DiffTests diffTests;
|
||||||
#endif
|
|
||||||
|
|||||||
@@ -82,6 +82,4 @@ public:
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
#if BEAST_UNIT_TESTS
|
|
||||||
static ChildProcessTests childProcessTests;
|
static ChildProcessTests childProcessTests;
|
||||||
#endif
|
|
||||||
|
|||||||
@@ -350,6 +350,4 @@ public:
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
#if BEAST_UNIT_TESTS
|
|
||||||
static AtomicTests atomicTests;
|
static AtomicTests atomicTests;
|
||||||
#endif
|
|
||||||
|
|||||||
@@ -205,6 +205,4 @@ public:
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
#if BEAST_UNIT_TESTS
|
|
||||||
static GZIPTests gzipTests;
|
static GZIPTests gzipTests;
|
||||||
#endif
|
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ public:
|
|||||||
{
|
{
|
||||||
String s;
|
String s;
|
||||||
|
|
||||||
s << "UnsignedInteger <" << String(Bytes) << ">";
|
s << "Bytes=" << String(Bytes);
|
||||||
|
|
||||||
beginTest (s);
|
beginTest (s);
|
||||||
|
|
||||||
@@ -82,6 +82,4 @@ public:
|
|||||||
private:
|
private:
|
||||||
};
|
};
|
||||||
|
|
||||||
#if BEAST_UNIT_TESTS
|
|
||||||
static UnsignedIntegerTests unsignedIntegerTests;
|
static UnsignedIntegerTests unsignedIntegerTests;
|
||||||
#endif
|
|
||||||
|
|||||||
@@ -619,7 +619,7 @@ public:
|
|||||||
typedef UnsignedInteger <KeyBytes> KeyType;
|
typedef UnsignedInteger <KeyBytes> KeyType;
|
||||||
|
|
||||||
String s;
|
String s;
|
||||||
s << "keyBytes=" << String (KeyBytes);
|
s << "keyBytes=" << String (KeyBytes) << ", maxItems=" << String (maxItems);
|
||||||
beginTest (s);
|
beginTest (s);
|
||||||
|
|
||||||
// Set up the key and value files and open the db.
|
// Set up the key and value files and open the db.
|
||||||
|
|||||||
@@ -141,14 +141,21 @@ public:
|
|||||||
|
|
||||||
/** Run the Beast unit tests.
|
/** Run the Beast unit tests.
|
||||||
*/
|
*/
|
||||||
static void runBeastUnitTests ()
|
static void runBeastUnitTests (std::string const& individualTest = "")
|
||||||
{
|
{
|
||||||
RippleUnitTests tr;
|
RippleUnitTests tr;
|
||||||
|
|
||||||
tr.setAssertOnFailure (false);
|
tr.setAssertOnFailure (false);
|
||||||
tr.setPassesAreLogged (false);
|
tr.setPassesAreLogged (false);
|
||||||
|
|
||||||
tr.runAllTests ();
|
if (individualTest.empty ())
|
||||||
|
{
|
||||||
|
tr.runAllTests ();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
tr.runTest (individualTest.c_str ());
|
||||||
|
}
|
||||||
|
|
||||||
// Report
|
// Report
|
||||||
for (int i = 0; i < tr.getNumResults (); ++i)
|
for (int i = 0; i < tr.getNumResults (); ++i)
|
||||||
@@ -232,7 +239,7 @@ int rippleMain (int argc, char** argv)
|
|||||||
("standalone,a", "Run with no peers.")
|
("standalone,a", "Run with no peers.")
|
||||||
("testnet,t", "Run in test net mode.")
|
("testnet,t", "Run in test net mode.")
|
||||||
("unittest,u", "Perform unit tests.")
|
("unittest,u", "Perform unit tests.")
|
||||||
("unittest2", "Perform new unit tests.")
|
("unittest2", po::value <std::string> ()->implicit_value (""), "Perform new unit tests.")
|
||||||
("parameters", po::value< vector<string> > (), "Specify comma separated parameters.")
|
("parameters", po::value< vector<string> > (), "Specify comma separated parameters.")
|
||||||
("quiet,q", "Reduce diagnotics.")
|
("quiet,q", "Reduce diagnotics.")
|
||||||
("verbose,v", "Verbose logging.")
|
("verbose,v", "Verbose logging.")
|
||||||
@@ -332,7 +339,10 @@ int rippleMain (int argc, char** argv)
|
|||||||
|
|
||||||
if (vm.count ("unittest2"))
|
if (vm.count ("unittest2"))
|
||||||
{
|
{
|
||||||
runBeastUnitTests ();
|
std::string const test = vm ["unittest2"].as <std::string> ();
|
||||||
|
|
||||||
|
runBeastUnitTests (test);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user