← Back to team overview

nrtb-core team mailing list archive

[Branch ~fpstovall/nrtb/cpp_common] Rev 23: Altered unit testing so that it was more complete and automatic on library builds. The build will...

 

------------------------------------------------------------
revno: 23
committer: fpstovall@xxxxxxxxx
branch nick: dev
timestamp: Fri 2010-12-31 07:21:51 -0500
message:
  Altered unit testing so that it was more complete and automatic on library builds. The build will now fail if units are not successful.
modified:
  common/logger/Makefile
  common/logger/log_test.cpp


--
lp:~fpstovall/nrtb/cpp_common
https://code.launchpad.net/~fpstovall/nrtb/cpp_common

Your team NRTB Core is subscribed to branch lp:~fpstovall/nrtb/cpp_common.
To unsubscribe from this branch go to https://code.launchpad.net/~fpstovall/nrtb/cpp_common/+edit-subscription
=== modified file 'common/logger/Makefile'
--- common/logger/Makefile	2010-12-27 03:55:39 +0000
+++ common/logger/Makefile	2010-12-31 12:21:51 +0000
@@ -16,8 +16,14 @@
 #
 #***********************************************
 
-build:	log_test Makefile
-	@echo build complete
+lib:	log_test
+	@echo "Testing..."
+	@rm -f test_output.log
+	@./log_test
+	@grep "Program run complete." test_output.log
+	@cp -fv log_setup.h ../include
+	@cp -fv log_setup.o ../obj
+
 
 log_setup.o:	log_setup.h log_setup.cpp Makefile
 	@rm -f log_setup.o
@@ -32,8 +38,5 @@
 clean:
 	@rm -vf *.o log_test ../include/log_setup.h ../obj/log_setup.o
 
-lib:	log_test
-	@cp -fv log_setup.h ../include
-	@cp -fv log_setup.o ../obj
 
 

=== modified file 'common/logger/log_test.cpp'
--- common/logger/log_test.cpp	2010-12-27 03:55:39 +0000
+++ common/logger/log_test.cpp	2010-12-31 12:21:51 +0000
@@ -19,6 +19,7 @@
 #include "log_setup.h"
 
 #include <string>
+#include <iostream>
 #include <Poco/Logger.h>
 #include "Poco/LogStream.h"
 
@@ -26,10 +27,20 @@
 
 int main()
 {
-  nrtb::setup_global_logging("test_ouput.log");
-  Poco::Logger & logger = Poco::Logger::get("log_test");
-  logger.notice("Logging should be set up now.");
-  Poco::LogStream log(logger);
-  log << "This message used the stream interface" << endl;
-  logger.fatal("Program run complete.");
+  bool set_if_failed = false;
+  try
+  {
+	nrtb::setup_global_logging("test_output.log");
+	Poco::Logger & logger = Poco::Logger::get("log_test");
+	logger.notice("Logging should be set up now.");
+	Poco::LogStream log(logger);
+	log << "This message used the stream interface" << endl;
+	logger.notice("Program run complete.");
+  }
+  catch (...)
+  {
+	set_if_failed = true;
+	cout << "** UNIT TEST FAILED **" << endl;
+  };
+  return set_if_failed;
 }