aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Guldstrand <andreas.guldstrand@gmail.com>2017-02-06 12:25:44 +0100
committerAndreas Guldstrand <andreas.guldstrand@gmail.com>2017-02-06 12:25:44 +0100
commita4320f0285d9b118a6fbc3933d12a15a1eb6eb6c (patch)
tree0298bed634e673f7aa3c3ff54d8a669fe91ea101
parent2ae090fba0cb30f95ba406b62e5da150577bd538 (diff)
downloadsbotools-a4320f0285d9b118a6fbc3933d12a15a1eb6eb6c.tar.xz
t/31-template.t: add tests for useradd/groupadd commands which span lines; see #57
-rwxr-xr-xt/31-template.t39
-rw-r--r--t/LO-readme/commandinreadmespanslines/README5
-rw-r--r--t/LO-readme/commandinreadmespanslines/commandinreadmespanslines.SlackBuild20
-rw-r--r--t/LO-readme/commandinreadmespanslines/commandinreadmespanslines.info10
4 files changed, 73 insertions, 1 deletions
diff --git a/t/31-template.t b/t/31-template.t
index dacb801..06a1b8f 100755
--- a/t/31-template.t
+++ b/t/31-template.t
@@ -11,7 +11,7 @@ use Test::Sbotools qw/ make_slackbuilds_txt set_lo sboinstall sboremove restore_
use File::Temp qw/ tempdir /;
if ($ENV{TEST_INSTALL}) {
- plan tests => 26;
+ plan tests => 29;
} else {
plan skip_all => 'Only run these tests if TEST_INSTALL=1';
}
@@ -20,12 +20,20 @@ sub cleanup {
capture_merged {
system(qw!/sbin/removepkg envsettingtest!);
system(qw!/sbin/removepkg envsettingtest2!);
+ system(qw!/sbin/removepkg commandinreadme!);
+ system(qw!/sbin/removepkg commandinreadmespanslines!);
unlink "$RealBin/LO-readme/envsettingtest/perf.dummy";
unlink "$RealBin/LO-readme/envsettingtest2/perf.dummy";
+ unlink "$RealBin/LO-readme/commandinreadme/perf.dummy";
+ unlink "$RealBin/LO-readme/commandinreadmespanslines/perf.dummy";
system(qw!rm -rf /tmp/SBo/envsettingtest-1.0!);
system(qw!rm -rf /tmp/SBo/envsettingtest2-1.0!);
+ system(qw!rm -rf /tmp/SBo/commandinreadme-1.0!);
+ system(qw!rm -rf /tmp/SBo/commandinreadmespanslines-1.0!);
system(qw!rm -rf /tmp/package-envsettingtest!);
system(qw!rm -rf /tmp/package-envsettingtest2!);
+ system(qw!rm -rf /tmp/package-commandinreadme!);
+ system(qw!rm -rf /tmp/package-commandinreadmespanslines!);
};
}
@@ -173,6 +181,35 @@ sboinstall '--use-template', '', { expected => qr/Usage/, exit => 1 };
sboinstall '--use-template', '', '', { expected => qr/Usage/, exit => 1 };
sboinstall '--create-template', '', '', { expected => qr/Usage/, exit => 1 };
+# 27-29: sboinstall commandinreadmespanslines
+SKIP: {
+ skip "Only run useradd/groupadd commands under Travis CI", 2 unless (defined $ENV{TRAVIS} and $ENV{TRAVIS} eq 'true');
+ skip "Only run useradd/groupadd commands if there is no test user/group", 2 if (defined getgrnam('test') or defined getpwnam('test'));
+
+ sboinstall '-i', '--create-template', "$tempdir/10.temp", 'commandinreadmespanslines', { input => "y\ny\ny", expected => qr!Template \Q$tempdir/10.temp saved.\E\n! };
+ capture_merged { system(qw/ userdel test /); system(qw/ groupdel test /); };
+ is (scalar capture_merged { system cat => "$tempdir/10.temp" }, <<'TEMP10', "10.temp is correct");
+{
+ "build_queue" : [
+ "commandinreadmespanslines"
+ ],
+ "commands" : {
+ "commandinreadmespanslines" : [
+ "groupadd -g 199 test",
+ "useradd -u 199 -g 199 -d /tmp \\\n -s /bin/sh test"
+ ]
+ },
+ "options" : {
+ "commandinreadmespanslines" : 0
+ }
+}
+TEMP10
+ sboinstall '--use-template', "$tempdir/10.temp", { expected => sub { ! m/exited non-zero/ } };
+ sboremove 'commandinreadmespanslines', { input => "y\ny", test => 0 };
+
+ capture_merged { system(qw/ userdel test /); system(qw/ groupdel test /); };
+}
+
# Cleanup
END {
cleanup();
diff --git a/t/LO-readme/commandinreadmespanslines/README b/t/LO-readme/commandinreadmespanslines/README
new file mode 100644
index 0000000..696c2fe
--- /dev/null
+++ b/t/LO-readme/commandinreadmespanslines/README
@@ -0,0 +1,5 @@
+This doesn't exist!
+
+ groupadd -g 199 test
+ useradd -u 199 -g 199 -d /tmp \
+ -s /bin/sh test
diff --git a/t/LO-readme/commandinreadmespanslines/commandinreadmespanslines.SlackBuild b/t/LO-readme/commandinreadmespanslines/commandinreadmespanslines.SlackBuild
new file mode 100644
index 0000000..0ff4195
--- /dev/null
+++ b/t/LO-readme/commandinreadmespanslines/commandinreadmespanslines.SlackBuild
@@ -0,0 +1,20 @@
+#!/bin/bash
+PRGNAM="commandinreadmespanslines"
+VERSION=${VERSION:-1.0}
+BUILD=${BUILD:-1}
+TAG=${TAG:-_SBo}
+TMP=${TMP:-/tmp/SBo}
+OUTPUT=${OUTPUT:-/tmp}
+
+if ! getent passwd "test"; then
+ echo "test user doesn't exist!"
+ exit 1
+fi
+
+mkdir -p $TMP/$PRGNAM-$VERSION
+cp README $TMP/$PRGNAM-$VERSION
+mkdir -p $OUTPUT/package-$PRGNAM/usr/doc/$PRGNAM-$VERSION
+cp README $OUTPUT/package-$PRGNAM/usr/doc/$PRGNAM-$VERSION
+cd $OUTPUT/package-$PRGNAM
+
+/sbin/makepkg -l y -c n $OUTPUT/$PRGNAM-$VERSION-noarch-$BUILD$TAG.tgz
diff --git a/t/LO-readme/commandinreadmespanslines/commandinreadmespanslines.info b/t/LO-readme/commandinreadmespanslines/commandinreadmespanslines.info
new file mode 100644
index 0000000..e6f71b6
--- /dev/null
+++ b/t/LO-readme/commandinreadmespanslines/commandinreadmespanslines.info
@@ -0,0 +1,10 @@
+PRGNAM="commandinreadmespanslines"
+VERSION="1.0"
+HOMEPAGE="http://www.example.com"
+DOWNLOAD="http://pink-mist.github.io/sbotools/testing/perf.dummy"
+MD5SUM="9cba6c70fb57a22a155073d54748b614"
+DOWNLOAD_x86_64=""
+MD5SUM_x86_64=""
+REQUIRES=""
+MAINTAINER="Andreas Guldstrand"
+EMAIL="doesnt@matter.org"