Patch TUT

From Second Life Wiki
Revision as of 15:45, 21 July 2009 by Rob Linden (talk | contribs) (Fixing the patch, and adding direct download links)
Jump to navigation Jump to search

The TUT source code can be found here:

Details

Our unit test framework did not have any method for skipping tests. Sometimes known failure cases are found which require temporarily skipping tests. This patch adds that functionality.

TUT-2008-11-30

diff -r 12b2ceb31753 tut/tut_assert.hpp
--- a/tut/tut_assert.hpp	Tue Jul 21 15:09:02 2009 -0700
+++ b/tut/tut_assert.hpp	Tue Jul 21 15:37:32 2009 -0700
@@ -154,9 +154,23 @@
     throw failure(msg);
 }
 
+/**
+ * Skip test because of known failure.
+ */
+void skip(const char* msg = "")
+{
+    throw skip_failure(msg);
+}
+
+void skip(const std::string& msg)
+{
+    throw skip_failure(msg);
+}
+
 } // end of namespace
 
 }
 
+
 #endif
 
diff -r 12b2ceb31753 tut/tut_exception.hpp
--- a/tut/tut_exception.hpp	Tue Jul 21 15:09:02 2009 -0700
+++ b/tut/tut_exception.hpp	Tue Jul 21 15:37:32 2009 -0700
@@ -201,6 +201,26 @@
     const test_result tr;
 };
 
+/**
+ * Exception to be throwed when skip_fail() is called.
+ */
+struct skip_failure : public failure
+{
+    skip_failure(const std::string& msg) 
+        : failure(msg) 
+    {
+    }
+
+    test_result::result_type result() const
+    {
+        return test_result::skip;
+    }
+
+    ~skip_failure() throw()
+    {
+    }
+};
+
 }
 
 #endif
diff -r 12b2ceb31753 tut/tut_posix.hpp
--- a/tut/tut_posix.hpp	Tue Jul 21 15:09:02 2009 -0700
+++ b/tut/tut_posix.hpp	Tue Jul 21 15:37:32 2009 -0700
@@ -248,13 +248,13 @@
                     return;
                 }
                 else
-            {
-                std::stringstream ss;
+                {
+                    std::stringstream ss;
                     char e[1024];
                     ss << "child " << pid << " could not be killed with SIGKILL, " << strerror_r(errno, e, sizeof(e)) << std::endl;
-                fail(ss.str());
+                    fail(ss.str());
+                }
             }
-        }
 
             ensure_equals("wait after SIGKILL", waitpid_(pid, &status), pid);
             ensure_child_signal_(status, SIGKILL);
diff -r 12b2ceb31753 tut/tut_result.hpp
--- a/tut/tut_result.hpp	Tue Jul 21 15:09:02 2009 -0700
+++ b/tut/tut_result.hpp	Tue Jul 21 15:37:32 2009 -0700
@@ -51,6 +51,7 @@
      * ex - test throwed an exceptions
      * warn - test finished successfully, but test destructor throwed
      * term - test forced test application to terminate abnormally
+     * skip - test skpped because it is a known failure case
      */
     enum result_type
     {
@@ -60,7 +61,8 @@
         warn,
         term,
         ex_ctor,
-        rethrown
+        rethrown,
+        skip,
     };
 
     result_type result;

Save this patch as tut.patch in the tut-2008-11-30 directory and apply it from a terminal program like xterm or cygwin with the command:

 $ patch -p1 < tut.patch