Package: spamassassin
Version: 3.3.2-6
Severity: wishlist
Tags: patch
User: yolanda.ro...@canonical.com
Usertags: origin-ubuntu  ubuntu-patch

Added autopkgtests


*** /tmp/tmpszzVtv/bug_body

In Ubuntu, the attached patch was applied to achieve the following:

Improve QA of packages


  * debian/tests: Added autopkgtests


Thanks for considering the patch.


-- System Information:
Debian Release: wheezy/sid
  APT prefers saucy-updates
  APT policy: (500, 'saucy-updates'), (500, 'saucy-security'), (500, 'saucy')
Architecture: amd64 (x86_64)

Kernel: Linux 3.8.0-14-generic (SMP w/1 CPU core)
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash
=== modified file 'debian/changelog'

=== modified file 'debian/control'
--- debian/control	2012-09-07 12:05:50 +0000
+++ debian/control	2013-06-03 08:31:36 +0000
@@ -11,6 +11,7 @@
 Homepage: http://www.spamassassin.org/
 Vcs-Svn: svn://svn.debian.org/svn/collab-maint/deb-maint/spamassassin/trunk
 Vcs-Browser: http://svn.debian.org/viewsvn/collab-maint/deb-maint/spamassassin/trunk/
+XS-Testsuite: autopkgtest
 
 Package: spamassassin
 Architecture: all

=== added directory 'debian/tests'
=== added file 'debian/tests/control'
--- debian/tests/control	1970-01-01 00:00:00 +0000
+++ debian/tests/control	2013-06-03 08:30:26 +0000
@@ -0,0 +1,3 @@
+Tests: spamassassin_nospam spamassassin_spam daemon
+Depends: spamassassin, procps
+Restrictions: needs-root

=== added file 'debian/tests/daemon'
--- debian/tests/daemon	1970-01-01 00:00:00 +0000
+++ debian/tests/daemon	2013-06-03 08:30:26 +0000
@@ -0,0 +1,18 @@
+#!/bin/bash
+#----------------------------
+# Testing spamassassin daemon
+#----------------------------
+set -e
+
+# modify /etc/default/spamassassin to enable the daemon
+CONFIG_FILE=/etc/default/spamassassin
+sed -i -e "s/ENABLED=0/ENABLED=1/g" $CONFIG_FILE
+/etc/init.d/spamassassin restart >/dev/null 2>&1
+
+if pgrep spamd > /dev/null; then
+    echo "OK"
+    exit 0
+else
+    echo "ERROR: SPAMD IS NOT RUNNING"
+    exit 1
+fi

=== added file 'debian/tests/get_spam_points.py'
--- debian/tests/get_spam_points.py	1970-01-01 00:00:00 +0000
+++ debian/tests/get_spam_points.py	2013-06-03 08:30:26 +0000
@@ -0,0 +1,23 @@
+import sys
+import subprocess
+
+
+if __name__ == '__main__':
+    try:
+        file_name = sys.argv[1]
+
+        # call spamassassin with the given file and return the points
+        output = subprocess.check_output("spamassassin --test-mode < " + file_name, shell=True, stderr=subprocess.STDOUT)
+        if output:
+            lines = output.split('\n')
+            if lines and lines[-4]:
+                results = lines[-4].split(' ')
+                if results and len(results)>0:
+                    points = results[0]
+                    print "%d" % round(float(points))
+                    exit()
+        print "0"
+    except Exception as e:
+        print "ERROR"
+
+

=== added file 'debian/tests/spamassassin_nospam'
--- debian/tests/spamassassin_nospam	1970-01-01 00:00:00 +0000
+++ debian/tests/spamassassin_nospam	2013-06-03 08:30:26 +0000
@@ -0,0 +1,13 @@
+#!/bin/bash
+#----------------------------
+# Testing spamassassin nospam
+#----------------------------
+set -e
+
+if python `dirname $0`/get_spam_points.py `dirname $0`/../../sample-nonspam.txt 2>&1; then
+    echo "OK"
+    exit 0
+else
+    echo "ERROR: POINTS SHOULD BE ZERO"
+    exit 1
+fi

=== added file 'debian/tests/spamassassin_spam'
--- debian/tests/spamassassin_spam	1970-01-01 00:00:00 +0000
+++ debian/tests/spamassassin_spam	2013-06-03 08:30:26 +0000
@@ -0,0 +1,13 @@
+#!/bin/bash
+#----------------------------
+# Testing spamassassin nospam
+#----------------------------
+set -e
+
+if python `dirname $0`/get_spam_points.py `dirname $0`/../../sample-spam.txt 2>&1; then
+    echo "OK"
+    exit 0
+else
+    echo "ERROR: POINTS SHOULD BE HIGHER THAN ZERO"
+    exit 1
+fi

Reply via email to