File: cxxtest-cmdline.patch

package info (click to toggle)
0ad 0.0.17-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 51,248 kB
  • ctags: 46,933
  • sloc: cpp: 223,208; ansic: 31,240; python: 16,343; perl: 4,083; sh: 1,011; makefile: 915; xml: 733; java: 621; ruby: 229; erlang: 53; sql: 40
file content (126 lines) | stat: -rw-r--r-- 3,756 bytes parent folder | download | duplicates (8)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
diff --git a/cxxtest/PsExtensions.cpp b/cxxtest/PsExtensions.cpp
new file mode 100644
index 0000000..e633195
--- /dev/null
+++ b/cxxtest/PsExtensions.cpp
@@ -0,0 +1,4 @@
+namespace CxxTest
+{
+    bool g_RunDisabled = false;
+}
diff --git a/cxxtest/RealDescriptions.cpp b/cxxtest/RealDescriptions.cpp
index 60b4f20..16adad0 100644
--- a/cxxtest/RealDescriptions.cpp
+++ b/cxxtest/RealDescriptions.cpp
@@ -248,7 +248,16 @@ unsigned RealWorldDescription::numTotalTests(void) const
     unsigned count = 0;
     for (const SuiteDescription *sd = firstSuite(); sd != 0; sd = sd->next())
     {
-        count += sd->numTests();
+        if (g_RunDisabled)
+            count += sd->numTests();
+        else
+        {
+            for (const TestDescription *td = sd->firstTest(); td != 0; td = td->next())
+            {
+                if (!strstr(td->testName(), "DISABLED"))
+                    count++;
+            }
+        }
     }
     return count;
 }
diff --git a/cxxtest/Root.cpp b/cxxtest/Root.cpp
index 39aa599..809d1fc 100644
--- a/cxxtest/Root.cpp
+++ b/cxxtest/Root.cpp
@@ -25,5 +25,6 @@
 #include <cxxtest/RealDescriptions.cpp>
 #include <cxxtest/TestSuite.cpp>
 #include <cxxtest/TestTracker.cpp>
+#include <cxxtest/PsExtensions.cpp>
 
 #endif // __cxxtest__Root_cpp__
diff --git a/cxxtest/TestMain.h b/cxxtest/TestMain.h
index c4d14bb..83f040c 100644
--- a/cxxtest/TestMain.h
+++ b/cxxtest/TestMain.h
@@ -30,6 +30,8 @@
 #   include <cstring>
 #endif // _CXXTEST_OLD_STD
 
+#include "ps/DllLoader.h"
+
 namespace CxxTest
 {
 
@@ -41,6 +43,8 @@ inline void print_help(const char* name)
     CXXTEST_STD(cerr) << name << " --help" << CXXTEST_STD(endl);
     CXXTEST_STD(cerr) << name << " --help-tests" << CXXTEST_STD(endl);
     CXXTEST_STD(cerr) << name << " -v             Enable tracing output." << CXXTEST_STD(endl);
+    CXXTEST_STD(cerr) << name << " -disabled      Also run disabled tests." << CXXTEST_STD(endl);
+    CXXTEST_STD(cerr) << name << " -libdir <dir>  Specify library directory." << CXXTEST_STD(endl);
 }
 #endif
 
@@ -84,20 +88,35 @@ int Main(TesterT& tmp, int argc, char* argv[])
 //
     while ((argc > 1) && (argv[1][0] == '-'))
     {
+        int args = 1;
         if (CXXTEST_STD(strcmp)(argv[1], "-v") == 0)
         {
             tracker().print_tracing = true;
         }
+        else if (CXXTEST_STD(strcmp)(argv[1], "-libdir") == 0)
+        {
+            if (argc < 2)
+            {
+                CXXTEST_STD(cerr) << "ERROR: not enough arguments" << CXXTEST_STD(endl);
+                return -1;
+            }
+            DllLoader::OverrideLibdir(argv[2]);
+            args = 2;
+        }
+        else if (CXXTEST_STD(strcmp)(argv[1], "-disabled") == 0)
+        {
+            g_RunDisabled = true;
+        }
         else
         {
             CXXTEST_STD(cerr) << "ERROR: unknown option '" << argv[1] << "'" << CXXTEST_STD(endl);
             return -1;
         }
-        for (int i = 1; i < (argc - 1); i++)
+        for (int i = 1; i < (argc - args); i++)
         {
-            argv[i] = argv[i + 1];
+            argv[i] = argv[i + args];
         }
-        argc--;
+        argc -= args;
     }
 
 //
diff --git a/cxxtest/TestRunner.h b/cxxtest/TestRunner.h
index 25ff3f8..9c10fac 100644
--- a/cxxtest/TestRunner.h
+++ b/cxxtest/TestRunner.h
@@ -25,6 +25,8 @@
 
 namespace CxxTest
 {
+extern bool g_RunDisabled;
+
 class TestRunner
 {
 public:
@@ -82,7 +84,7 @@ private:
         {
             for (TestDescription *td = sd.firstTest(); td; td = td->next())
             {
-                if (td->active())
+                if ((g_RunDisabled || !strstr(td->testName(), "DISABLED")) && td->active())
                 {
                     runTest(*td);
                 }