Author: brane
Date: Thu Jul 3 11:02:37 2025
New Revision: 1926937
URL: http://svn.apache.org/viewvc?rev=1926937&view=rev
Log:
In the SCons build, run unit tests separately by test suite.
* test/test_all.c: Reorder includes, putting system headers first.
(main): Add a new flag -L that prints just the names of the test
suites without details about the tests.
* build/check.py: Call 'test_all -L' to get the list of test suites, then
invok each one of them separately. Don't exit after the first failure.
(print_exception): Common handler for CalledProcessError exceptions.
Modified:
serf/trunk/build/check.py
serf/trunk/test/test_all.c
Modified: serf/trunk/build/check.py
URL:
http://svn.apache.org/viewvc/serf/trunk/build/check.py?rev=1926937&r1=1926936&r2=1926937&view=diff
==============================================================================
--- serf/trunk/build/check.py (original)
+++ serf/trunk/build/check.py Thu Jul 3 11:02:37 2025
@@ -10,9 +10,9 @@
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
-#
+#
# http://www.apache.org/licenses/LICENSE-2.0
-#
+#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@@ -60,8 +60,25 @@ if __name__ == '__main__':
sys.exit(1)
print("== Running the unit tests ==")
+
+ fails = 0
+ def print_exception(x):
+ global fails
+ print("ERROR: test(s) failed in '%s', exit code=%d"
+ % (' '.join(x.cmd), x.returncode))
+ fails += 1
+
try:
- subprocess.check_call(TEST_ALL_EXE)
+ suites = subprocess.check_output([TEST_ALL_EXE, '-L']).decode()
+ for suite in suites.splitlines():
+ testcase = (TEST_ALL_EXE, suite.strip())
+ print("==== %s %s" % testcase)
+ try:
+ subprocess.check_call(testcase)
+ except subprocess.CalledProcessError as x:
+ print_exception(x)
except subprocess.CalledProcessError as x:
- print("ERROR: test(s) failed in '%s', exit code=%d" % (x.cmd,
x.returncode))
+ print_exception(x)
+
+ if fails > 0:
sys.exit(1)
Modified: serf/trunk/test/test_all.c
URL:
http://svn.apache.org/viewvc/serf/trunk/test/test_all.c?rev=1926937&r1=1926936&r2=1926937&view=diff
==============================================================================
--- serf/trunk/test/test_all.c (original)
+++ serf/trunk/test/test_all.c Thu Jul 3 11:02:37 2025
@@ -18,12 +18,12 @@
* ====================================================================
*/
-#include "apr.h"
-#include "apr_pools.h"
+#include <stdlib.h>
+
+#include <apr.h>
#include <apr_signal.h>
#include "test_serf.h"
-#include <stdlib.h>
static const struct testlist {
const char *testname;
@@ -62,19 +62,22 @@ int main(int argc, char *argv[])
if (!strcmp(argv[i], "-v")) {
continue;
}
- if (!strcmp(argv[i], "-l")) {
+ if (!strcmp(argv[i], "-l") || !strcmp(argv[i], "-L")) {
+ const int details = !strcmp(argv[i], "-l");
for (i = 0; tests[i].func != NULL; i++) {
CuSuite *suite;
- int j = 0;
printf("%s\n", tests[i].testname);
- suite = tests[i].func();
+ if (details) {
+ int j;
- for (j = 0; j < suite->count; j++) {
- printf(" %3d - %s\n", j+1, suite->list[j]->name);
- }
+ suite = tests[i].func();
+ for (j = 0; j < suite->count; j++) {
+ printf(" %3d - %s\n", j+1, suite->list[j]->name);
+ }
- printf("\n");
+ printf("\n");
+ }
}
exit(0);
}