Let tests pass for the moment.
[awesomized/libmemcached] / libtest / main.cc
index 3ae8ff988ebe14e0662dd9cd49b99ee582dab703..03a40fc8aeea4d6b39540845c01189d05728f91b 100644 (file)
@@ -43,6 +43,7 @@
 #include <ctime>
 #include <fnmatch.h>
 #include <iostream>
+#include <fstream>
 #include <memory>
 #include <sys/stat.h>
 #include <sys/time.h>
@@ -58,7 +59,7 @@
 
 using namespace libtest;
 
-static void stats_print(Framework *frame)
+static void stats_print(libtest::Framework *frame)
 {
   if (frame->failed() == 0 and frame->success() == 0)
   {
@@ -87,6 +88,34 @@ int main(int argc, char *argv[])
   bool opt_quiet= false;
   std::string collection_to_run;
   std::string wildcard;
+  std::string binary_name;
+
+  const char *just_filename= rindex(argv[0], '/');
+  if (just_filename)
+  {
+    just_filename++;
+  }
+  else
+  {
+    just_filename= argv[0];
+  }
+
+  if (just_filename[0] == 'l' and just_filename[1] == 't' and  just_filename[2] == '-')
+  {
+    just_filename+= 3;
+  }
+  binary_name.append(just_filename);
+
+  /*
+    Valgrind does not currently work reliably, or sometimes at all, on OSX
+    - Fri Jun 15 11:24:07 EDT 2012
+  */
+#if defined(TARGET_OS_OSX) && TARGET_OS_OSX
+  if (valgrind_is_caller())
+  {
+    return EXIT_SKIP;
+  }
+#endif
 
   // Options parsing
   {
@@ -176,11 +205,21 @@ int main(int argc, char *argv[])
     }
   }
 
+  if ((bool(getenv("YATL_RUN_MASSIVE_TESTS"))) or opt_massive)
+  {
+    opt_massive= true;
+  }
+
   if (opt_quiet)
   {
     close(STDOUT_FILENO);
   }
 
+  if (opt_massive)
+  {
+    is_massive(opt_massive);
+  }
+
   char buffer[1024];
   if (getenv("LIBTEST_TMP"))
   {
@@ -240,7 +279,7 @@ int main(int argc, char *argv[])
         return EXIT_FAILURE;
       }
 
-      std::auto_ptr<Framework> frame(new Framework(signal, collection_to_run, wildcard));
+      std::auto_ptr<libtest::Framework> frame(new libtest::Framework(signal, binary_name, collection_to_run, wildcard));
 
       // Run create(), bail on error.
       {
@@ -250,10 +289,10 @@ int main(int argc, char *argv[])
           break;
 
         case TEST_SKIPPED:
-          Out << "SKIP " << argv[0];
-          return EXIT_SUCCESS;
+          return EXIT_SKIP;
 
         case TEST_FAILURE:
+          std::cerr << "frame->create()" << std::endl;
           return EXIT_FAILURE;
         }
       }
@@ -282,17 +321,34 @@ int main(int argc, char *argv[])
       }
       else if (frame->success() and (frame->failed() == 0))
       {
+        Out;
         Out << "All tests completed successfully.";
       }
 
       stats_print(frame.get());
 
+      std::ofstream xml_file;
+      std::string file_name;
+      if (getenv("LIBTEST_TEMP"))
+      {
+        file_name.append(getenv("LIBTEST_TEMP"));
+      }
+      file_name.append(frame->name());
+      file_name.append(".xml");
+      xml_file.open(file_name.c_str(), std::ios::trunc);
+      libtest::Formatter::xml(*frame, xml_file);
+
       Outn(); // Generate a blank to break up the messages if make check/test has been run
     } while (exit_code == EXIT_SUCCESS and --opt_repeat);
   }
   catch (libtest::fatal& e)
   {
-    std::cerr << e.what() << std::endl;
+    std::cerr << "FATAL:" << e.what() << std::endl;
+    exit_code= EXIT_FAILURE;
+  }
+  catch (libtest::start& e)
+  {
+    std::cerr << "Failure to start:" << e.what() << std::endl;
     exit_code= EXIT_FAILURE;
   }
   catch (libtest::disconnected& e)
@@ -302,7 +358,12 @@ int main(int argc, char *argv[])
   }
   catch (std::exception& e)
   {
-    std::cerr << e.what() << std::endl;
+    std::cerr << "std::exception:" << e.what() << std::endl;
+    exit_code= EXIT_FAILURE;
+  }
+  catch (char const*)
+  {
+    std::cerr << "Exception:" << std::endl;
     exit_code= EXIT_FAILURE;
   }
   catch (...)