aboutsummaryrefslogtreecommitdiffstats
path: root/testing/perl-mail-sendmail
diff options
context:
space:
mode:
authorNatanael Copa <ncopa@alpinelinux.org>2018-08-07 18:50:54 +0000
committerNatanael Copa <ncopa@alpinelinux.org>2018-08-07 18:55:20 +0000
commit84fa53cb3e2eb62d7eadba3ae1a3a81090413e5f (patch)
treebcedb2f343397ddceddfee1142b5c29d757c7688 /testing/perl-mail-sendmail
parent702d5fdb2af2c4fab8782c59cd6d8ccc977936c1 (diff)
downloadaports-84fa53cb3e2eb62d7eadba3ae1a3a81090413e5f.tar.bz2
aports-84fa53cb3e2eb62d7eadba3ae1a3a81090413e5f.tar.xz
testing/perl-mail-sendmail: run test against dummy smtp
the test suite will send an actual email to the atuthor. We don't want to do that and some of the build servers may have smtp port blocked. Create a dummy smtp server on localhost and patch test to use that.
Diffstat (limited to 'testing/perl-mail-sendmail')
-rw-r--r--testing/perl-mail-sendmail/APKBUILD21
-rw-r--r--testing/perl-mail-sendmail/fake-smtp.py18
-rw-r--r--testing/perl-mail-sendmail/test-localhost.patch22
3 files changed, 57 insertions, 4 deletions
diff --git a/testing/perl-mail-sendmail/APKBUILD b/testing/perl-mail-sendmail/APKBUILD
index 2213d7acda..41cfd42947 100644
--- a/testing/perl-mail-sendmail/APKBUILD
+++ b/testing/perl-mail-sendmail/APKBUILD
@@ -4,7 +4,7 @@
pkgname=perl-mail-sendmail
_pkgreal=Mail-Sendmail
pkgver=0.80
-pkgrel=0
+pkgrel=1
pkgdesc="Simple platform independent mailer"
url="http://search.cpan.org/dist/Mail-Sendmail/"
arch="noarch"
@@ -13,8 +13,11 @@ cpandepends=""
cpanmakedepends=" "
depends="$cpandepends"
makedepends="perl-dev $cpanmakedepends"
+checkdepends="python3"
subpackages="$pkgname-doc"
-source="http://search.cpan.org/CPAN/authors/id/N/NE/NEILB/$_pkgreal-$pkgver.tar.gz"
+source="http://search.cpan.org/CPAN/authors/id/N/NE/NEILB/$_pkgreal-$pkgver.tar.gz
+ test-localhost.patch
+ fake-smtp.py"
builddir="$srcdir/$_pkgreal-$pkgver"
prepare() {
@@ -33,7 +36,15 @@ build() {
check() {
cd "$builddir"
- make test
+ # run dummy smtp server
+ python3 "$srcdir"/fake-smtp.py &
+ local pid=$!
+ local rc=0
+ if ! make test; then
+ rc=1
+ fi
+ kill $pid
+ return $rc
}
package() {
@@ -42,4 +53,6 @@ package() {
find "$pkgdir" \( -name perllocal.pod -o -name .packlist \) -delete
}
-sha512sums="848ec471938d679645dfb4e032a33d35e49655a336dc6ff3a24ffa35606bff77e73162af672d1a60ad3a7bf571113e802fc42d6cb9a072cdca0d89f707f54a08 Mail-Sendmail-0.80.tar.gz"
+sha512sums="848ec471938d679645dfb4e032a33d35e49655a336dc6ff3a24ffa35606bff77e73162af672d1a60ad3a7bf571113e802fc42d6cb9a072cdca0d89f707f54a08 Mail-Sendmail-0.80.tar.gz
+2592c4aafd9f58d9e4f8c0f78e8d87e7e6160b4a53aa73b929ad12d26d677f8a7baec540a57a8edabbba6f05bd33c9e2dc5ee707cfaaccd14837a6ddc681d742 test-localhost.patch
+dbff85dc3924274c2f640e0f6ea4d782c0221e841763fb122c9942ef8e2c5d7a0c73aa2cfd1f7b59708fe27a392a000dcfbc2a04ad7e7e8885d21a27df339410 fake-smtp.py"
diff --git a/testing/perl-mail-sendmail/fake-smtp.py b/testing/perl-mail-sendmail/fake-smtp.py
new file mode 100644
index 0000000000..25929d9b8a
--- /dev/null
+++ b/testing/perl-mail-sendmail/fake-smtp.py
@@ -0,0 +1,18 @@
+import smtpd
+import asyncore
+
+class FakeSMTPServer(smtpd.SMTPServer):
+ """A Fake smtp server"""
+
+ def __init__(*args, **kwargs):
+ smtpd.SMTPServer.__init__(*args, **kwargs)
+
+ def process_message(*args, **kwargs):
+ pass
+
+if __name__ == "__main__":
+ smtp_server = FakeSMTPServer(('127.0.0.1', 2525), None)
+ try:
+ asyncore.loop(timeout=1, count=30)
+ except KeyboardInterrupt:
+ smtp_server.close()
diff --git a/testing/perl-mail-sendmail/test-localhost.patch b/testing/perl-mail-sendmail/test-localhost.patch
new file mode 100644
index 0000000000..01a199a6c1
--- /dev/null
+++ b/testing/perl-mail-sendmail/test-localhost.patch
@@ -0,0 +1,22 @@
+diff --git a/t/original.t b/t/original.t
+index bba3fa0..2765eba 100755
+--- a/t/original.t
++++ b/t/original.t
+@@ -14,7 +14,8 @@ $mail{To} = 'Sendmail Test <sendmail@alma.ch>';
+
+ # if you want to get a copy of the test mail, you need to specify your
+ # own server here, by name or IP address
+-$server = 'mail.alma.ch';
++$server = '127.0.0.1';
++$port = 2525;
+ #$server = 'my.usual.mail.server';
+
+ BEGIN { $| = 1; print "1..2\n"; }
+@@ -42,6 +43,7 @@ print "ok 1\n";
+
+ if ($server) {
+ $mail{Smtp} = $server;
++ $mail{Port} = $port;
+ print "Server set to: $server\n";
+ }
+