On 04/09/2015 11:32 AM, Ander Juaristi wrote:
On 04/09/2015 11:26 AM, Tim Rühsen wrote:
Hi Ander,

attached is a (experimental) patch that allows you to
$ cd tests
$ GDB_TESTS=1 ./Test--spider.px

If you successfully test it, you might also add GDB_TESTS to the python test
suite and send a git-format patch to the list for reviewing.

Regards, Tim

Wow! Sounds good!

I'll review it and get back to you.

As promised, here go the two patches. I haven't changed your Perl patch. I've 
tested both test suites and work perfect, altough some tests rely on Wget's 
return code to check for failures, and those tests, when run through GDB, claim 
to fail incorrectly because GDB's return code is always zero if everything went 
OK. However, it's worth noting that this feature should *only* be used during 
development, to tackle down specific bugs, etc. One could write a test case for 
certain bug and run it through GDB in order to fix it (as I do). Otherwise, a 
dedicated web server would have to be set up (e.g. Apache) and write some 
server-side CGI to test that bug, which IMO would be tedious. I'll send one 
more patch stating this fact in the documentation.

--
Regards,
- AJ
>From 5d720731319400079d872abd01daaee03946dec3 Mon Sep 17 00:00:00 2001
From: Tim Ruehsen <[email protected]>
Date: Sat, 11 Apr 2015 17:14:56 +0200
Subject: [PATCH] Added GDB support to Perl tests.

* WgetTests.pm (run): Check GDB_TESTS environment variable.
---
 tests/WgetTests.pm | 16 +++++++++++++---
 1 file changed, 13 insertions(+), 3 deletions(-)

diff --git a/tests/WgetTests.pm b/tests/WgetTests.pm
index 3d3b9dd..3418c0d 100644
--- a/tests/WgetTests.pm
+++ b/tests/WgetTests.pm
@@ -114,10 +114,20 @@ sub run
       ($cmdline =~ m{^/.*}msx) ? $cmdline : "$self->{_workdir}/$cmdline";
 
     my $valgrind = $ENV{VALGRIND_TESTS};
-    if (!defined $valgrind || $valgrind eq q{} || $valgrind == 0)
+    if (!defined $valgrind)
     {
+        $valgrind = 0;
+    }
+
+    my $gdb = $ENV{GDB_TESTS};
+    if (!defined $gdb)
+    {
+        $gdb = 0;
+    }
 
-        # Valgrind not requested - leave $cmdline as it is
+    if ($gdb == 1)
+    {
+        $cmdline = 'gdb --args ' . $cmdline;
     }
     elsif ($valgrind == 1)
     {
@@ -125,7 +135,7 @@ sub run
           'valgrind --error-exitcode=301 --leak-check=yes --track-origins=yes '
           . $cmdline;
     }
-    else
+    elsif ($valgrind ne q{} && $valgrind != 0)
     {
         $cmdline = "$valgrind $cmdline";
     }
-- 
1.9.1

>From 9676434e7cc5fc4d46a24e0fa1d2932583d86cae Mon Sep 17 00:00:00 2001
From: Ander Juaristi <[email protected]>
Date: Sat, 11 Apr 2015 17:06:23 +0200
Subject: [PATCH] Added support for GDB in Python tests.

* base_test.py (gen_cmd_line): Check GDB_TESTS environment variable.
---
 testenv/test/base_test.py | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/testenv/test/base_test.py b/testenv/test/base_test.py
index 34f0b14..3494319 100644
--- a/testenv/test/base_test.py
+++ b/testenv/test/base_test.py
@@ -101,12 +101,19 @@ class BaseTest:
         wget_options = '--debug --no-config %s' % self.wget_options
 
         valgrind = os.getenv("VALGRIND_TESTS", "")
-        if valgrind in ("", "0"):
-            cmd_line = '%s %s ' % (wget_path, wget_options)
+        gdb = os.getenv("GDB_TESTS", "")
+
+        # GDB has precedence over Valgrind
+        # If both VALGRIND_TESTS and GDB_TESTS are defined,
+        # GDB will be executed.
+        if gdb == "1":
+            cmd_line = 'gdb --args %s %s ' % (wget_path, wget_options)
         elif valgrind == "1":
             cmd_line = 'valgrind --error-exitcode=301 --leak-check=yes --track-origins=yes %s %s ' % (wget_path, wget_options)
-        else:
+        elif valgrind not in ("", "0"):
             cmd_line = '%s %s %s ' % (os.getenv("VALGRIND_TESTS", ""), wget_path, wget_options)
+        else:
+           cmd_line = '%s %s ' % (wget_path, wget_options) 
 
         for protocol, urls, domain in zip(self.protocols,
                                           self.urls,
-- 
1.9.1

Reply via email to