[MOAB-dev] r4140 - in MOAB/trunk/test: . h5file

kraftche at cae.wisc.edu kraftche at cae.wisc.edu
Fri Sep 24 13:42:53 CDT 2010


Author: kraftche
Date: 2010-09-24 13:42:53 -0500 (Fri, 24 Sep 2010)
New Revision: 4140

Modified:
   MOAB/trunk/test/TestUtil.hpp
   MOAB/trunk/test/h5file/h5partial.cpp
Log:
Add a simple test running framework to TestUtil.  

Using it is fairly similar to using the old manual test running:  

Old way:
   error_count += RUN_TEST( test_func_1 );
   error_count += RUN_TEST( test_func_2 );
   ...
   return error_count;
New (alternate) way:
   REGISTER_TEST( test_func_1 );
   REGISTER_TEST( test_func_2 );
   ...
   return RUN_TESTS( argc, argv );

The advantages of the new test running framework are that a) it allows
only a subset of the tests by specifying the test names as command line
arguments, making debuging of a failing test easier and b) it allows
unit tests to depend on the successful completion of other unit tests, 
making it easire to find the root cause of a failure in test output.



Modified: MOAB/trunk/test/TestUtil.hpp
===================================================================
--- MOAB/trunk/test/TestUtil.hpp	2010-09-22 19:45:04 UTC (rev 4139)
+++ MOAB/trunk/test/TestUtil.hpp	2010-09-24 18:42:53 UTC (rev 4140)
@@ -58,6 +58,37 @@
 
 
 /***************************************************************************************
+ * Begin test runner implememtation.
+ * This is a higher-level API that can be used to register tests,
+ * test dependencies, and to run-time select a subset of tests to 
+ * run.
+ ***************************************************************************************/
+
+/* Register a test to be run */
+#define REGISTER_TEST( TEST_FUNC ) \
+  runner_register_test( __FILE__, __LINE__, #TEST_FUNC, (TEST_FUNC), NULL )
+
+/* Mark a dependency between tests.  The second argument must be
+ * an alredy-regsitered test.  The first argument will be registered
+ * as a test if it has not already been registered.  The test specified
+ * by the first argument will be run only if the test specified by
+ * the second argument is run and succeeds.
+ */
+#define REGISTER_DEP_TEST( TEST_FUNC, REQUIRED_FUNC ) \
+  runner_register_test( __FILE__, __LINE__, #TEST_FUNC, (TEST_FUNC), (REQUIRED_FUNC) )
+
+/* Run registered tests.  
+ * Arguments should be argc and argv passed to main.
+ * If ARGC is less than or equal to 1 then all tests are run.
+ * Otherwse only tests specified in the argument list are run.
+ * Returns number of failed tests.
+ */
+#define RUN_TESTS( ARGC, ARGV ) \
+  runner_run_tests( (ARGC), (ARGV) )
+
+
+
+/***************************************************************************************
  * NOTE: The remainder of this file contains the implementation of the above macros.
  *       The above macros constitute the entire intended API.
  ***************************************************************************************/
@@ -551,8 +582,281 @@
   flag_error();
 }
 
-#endif 
+#endif  /* ifdef MOAB_RANGE_HPP */
+    
+#endif /* ifdef __cplusplus */
 


More information about the moab-dev mailing list