aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.perlcriticrc2
-rw-r--r--.travis.yml34
-rw-r--r--ChangeLog.md10
-rw-r--r--README.md19
-rw-r--r--docker/sbotools2-test:15.0.dockerfile31
-rw-r--r--man5/sbotools.conf.52
-rwxr-xr-xt/01-unit.t2
-rwxr-xr-xt/05-upgrade.t4
-rwxr-xr-xt/11-git.t56
-rwxr-xr-xt/22-race.t2
-rw-r--r--t/Test/Sbotools.pm6
11 files changed, 103 insertions, 65 deletions
diff --git a/.perlcriticrc b/.perlcriticrc
deleted file mode 100644
index 89b9bbe..0000000
--- a/.perlcriticrc
+++ /dev/null
@@ -1,2 +0,0 @@
-theme = freenode
-severity = 1
diff --git a/.travis.yml b/.travis.yml
deleted file mode 100644
index 2cc09f6..0000000
--- a/.travis.yml
+++ /dev/null
@@ -1,34 +0,0 @@
-language: perl
-perl:
- - "5.28"
- - "5.22"
- - "5.18"
- - "5.16"
-env:
- - TEST_ONLINE=1 TEST_INSTALL=1 TEST_MULTILIB=0
- - TEST_ONLINE=1 TEST_INSTALL=1 TEST_MULTILIB=1
- - TEST_ONLINE=1 TEST_INSTALL=1 TEST_MULTILIB=2
- - TEST_ONLINE=0 TEST_INSTALL=1 TEST_MULTILIB=0
- - TEST_ONLINE=0 TEST_INSTALL=1 TEST_MULTILIB=1
- - TEST_ONLINE=0 TEST_INSTALL=1 TEST_MULTILIB=2
-sudo: required
-install:
- - sudo bash t/travis-deps/install.sh
- - cpanm Text::Diff Capture::Tiny Test::Output Devel::Cover Test::Exit
-script:
- - bash -c '
- PROVE=`which prove`;
- sudo
- PERL5OPT=-MDevel::Cover=-coverage,statement,branch,condition,path,subroutine,+ignore,t/,+ignore,prove,db,/home/travis/build/pink-mist/sbotools/cover_db
- $PROVE -v t/*.t;'
- - sudo chmod -R a+x cover_db;
- tar cf cover_db.tar cover_db
-addons:
- artifacts:
- paths: "./cover_db.tar"
-notifications:
- irc:
- channels:
- - "chat.freenode.net#sbotools"
- on_success: change
- on_failure: change
diff --git a/ChangeLog.md b/ChangeLog.md
index a5dbaa5..ac7e29d 100644
--- a/ChangeLog.md
+++ b/ChangeLog.md
@@ -2,6 +2,16 @@
All notable changes to this project will be documented in this file.
+## [Unreleased]
+
+### Added
+
+ - Dockerfile for 15.0 testing.
+
+### Fixed
+
+ - Tests under 't/' for 15.0.
+
## [2.7.2] - 2024-12-03
### Changed
diff --git a/README.md b/README.md
index 7b9e083..126940f 100644
--- a/README.md
+++ b/README.md
@@ -39,3 +39,22 @@ else
echo "verification failed"
fi
```
+
+## Testing
+
+Unit tests are defined under 't/'.
+
+```
+prove -v t/*.t
+```
+
+You can use the Dockerfile to remove the headache for setting up the test
+environment. You will need to build the docker image before being able to use
+it.
+
+Test categories are enabled via environment variables enabled via docker's '--env' parameter.
+
+```
+docker build -t sbotools2-test:15.0 --file docker/sbotools2-test:15.0.dockerfile .
+docker run -v $(realpath .):/root/sbotools2 --env TEST_INSTALL=1 --env TEST_ONLINE=1 -t sbotools2-test:15.0
+```
diff --git a/docker/sbotools2-test:15.0.dockerfile b/docker/sbotools2-test:15.0.dockerfile
new file mode 100644
index 0000000..2f36e5f
--- /dev/null
+++ b/docker/sbotools2-test:15.0.dockerfile
@@ -0,0 +1,31 @@
+# docker run -v $(realpath .):/root/sbotools2 -t sbotools2-test:15.0
+
+FROM vbatts/slackware:15.0
+
+# Project must be mounted here.
+VOLUME /root/sbotools2
+
+# Upgrade and install all
+RUN sed -i 's/^WGETFLAGS=".*"/WGETFLAGS="--quiet --no-check-certificate"/g' /etc/slackpkg/slackpkg.conf
+RUN yes y | slackpkg update && \
+ slackpkg install-new -terse && \
+ slackpkg upgrade-all -terse -batch=yes -default_answer=yes && \
+ slackpkg install -terse -batch=yes -default_answer=yes a ap d f n l t tcl
+
+# Fix SSL certificate errors
+RUN yes y | slackpkg reinstall ca-certificates
+
+RUN cpan install \
+ Capture::Tiny \
+ Devel::Cover\
+ Test::Diff \
+ Test::Exit \
+ Test::More
+
+# Git configuration some test's setup.
+RUN git config --global user.name root \
+ && git config --global user.email root@localhost
+
+WORKDIR /root/sbotools2
+
+CMD prove -v t/*.t
diff --git a/man5/sbotools.conf.5 b/man5/sbotools.conf.5
index b99a82e..a01a817 100644
--- a/man5/sbotools.conf.5
+++ b/man5/sbotools.conf.5
@@ -45,7 +45,7 @@ If set to a version specification, use the SBo repository for that version inste
.P
REPO=(FALSE|url)
.RS
-If set to a url, use that repository instead of the SlackBuilds.org repository for your SLACKWARE_VERSION. Setting this will make the SLACKWARE_VERSION setting redundant. URLs need to either lead to a git repository or an rsync repository. The repository needs to be laid out like the SlackBuilds.org one with a couple of broad categories at the root and under those are subdirectories for each package.
+If set to a url, use that repository instead of the SlackBuilds.org repository for your SLACKWARE_VERSION. Setting this will make the SLACKWARE_VERSION setting redundant. URLs need to either lead to a git repository or an rsync repository. The repository needs to be laid out like the SlackBuilds.org one with a couple of broad categories at the root and under those are subdirectories for each package. When using a local git repository, be sure to tell git it is safe with 'git config --system --add safe.directory URL'.
.RE
.SH SEE ALSO
.P
diff --git a/t/01-unit.t b/t/01-unit.t
index ea5bb33..d94fd9b 100755
--- a/t/01-unit.t
+++ b/t/01-unit.t
@@ -152,7 +152,7 @@ SKIP: {
my $out = capture_merged { $res = SBO::Lib::rsync_sbo_tree('/foo-bar'); };
ok (!$res, q"rsync_sbo_tree('/foo-bar') returned false");
- like ($out, qr!rsync: change_dir "/foo-bar" failed!, q"rsync_sbo_tree('/foo-bar') gave correct output");
+ like ($out, qr!rsync: (.*)change_dir "/foo-bar" failed!, q"rsync_sbo_tree('/foo-bar') gave correct output");
}
# 28-37: test git_sbo_tree(), check_git_remote(), generate_slackbuilds_txt(), and pull_sbo_tree();
diff --git a/t/05-upgrade.t b/t/05-upgrade.t
index 1d7d541..b976d8c 100755
--- a/t/05-upgrade.t
+++ b/t/05-upgrade.t
@@ -119,9 +119,7 @@ sboupgrade qw/ -f nonexistentslackbuild4 /, { input => "y\ny\ny", expected => qr
# 13-16: sbosnap + sboupgrade --all
my $temp = tempdir(CLEANUP => 1);
set_repo("file://$temp");
-capture_merged { system <<"END"; };
-cd $temp; git init;
-END
+capture_merged { system("cd $temp; git init;"); };
sbosnap 'fetch', { expected => qr/Pulling SlackBuilds tree[.][.][.]/ };
install( 'LO2', 'nonexistentslackbuild' );
my @sbos = glob("/var/log/packages/*_SBo");
diff --git a/t/11-git.t b/t/11-git.t
index 3f57f46..b8025f1 100755
--- a/t/11-git.t
+++ b/t/11-git.t
@@ -16,13 +16,13 @@ if ($ENV{TEST_INSTALL}) {
}
sub cleanup {
- capture_merged {
- system(qw!rm -rf !, "$RealBin/gitrepo");
- if (defined $ENV{TRAVIS} and $ENV{TRAVIS} eq 'true') {
- system(qw!userdel test!);
- system(qw!groupdel test!);
- }
- };
+ capture_merged {
+ system(qw!rm -rf !, "/tmp/gitrepo");
+ if (defined $ENV{TRAVIS} and $ENV{TRAVIS} eq 'true') {
+ system(qw!userdel test!);
+ system(qw!groupdel test!);
+ }
+ };
}
sub slurp {
@@ -37,22 +37,35 @@ cleanup();
# initialise repo
capture_merged { system(<<"END"); };
-cd "$RealBin"; rm -rf gitrepo; mkdir gitrepo; cd gitrepo;
+rm -fr /tmp/gitrepo;
+mkdir -p /tmp/gitrepo;
+cd /tmp/gitrepo;
+
git init;
-echo "echo Hello" > test; git add test; git commit -m 'initial';
-git checkout -b b1; echo 'echo "Hello World."' > test; git commit -am 'branch commit';
-git checkout master; echo 'echo "Hello World"' > test; git commit -am 'master commit';
+echo -n "Hello" > test;
+git add test;
+git commit -m 'initial';
+
+git checkout -b b1;
+echo -n "Hello World." > test;
+git commit -am 'branch commit';
+
+git checkout master;
+echo -n "Hello World" > test;
+git commit -am 'master commit';
END
if (defined $ENV{TRAVIS} and $ENV{TRAVIS} eq 'true') {
capture_merged { system(<<"END"); };
groupadd -g 199 test
useradd -u 199 -g 199 -d /tmp test
-chown -R 199:199 $RealBin/gitrepo
+chown -R 199:199 /tmp/gitrepo
+
+git config --system --add safe.directory /tmp/gitrepo/.git
END
}
-set_repo("$RealBin/gitrepo/");
+set_repo("/tmp/gitrepo/");
# 1: sbosnap get initial repo
sbosnap 'fetch', { expected => qr!Pulling SlackBuilds tree.*Cloning into '/usr/sbo/repo'!s };
@@ -61,25 +74,28 @@ sbosnap 'fetch', { expected => qr!Pulling SlackBuilds tree.*Cloning into '/usr/s
SKIP: {
skip "Only run under Travis CI", 2 unless defined $ENV{TRAVIS} and $ENV{TRAVIS} eq 'true';
- my @fnames = glob "$RealBin/gitrepo/.git/objects/*/*";
+ my @fnames = glob "/tmp/gitrepo/.git/objects/*/*";
my @stat = stat shift @fnames;
- is ($stat[4], 199, "Correct owner uid for $RealBin/gitrepo");
- is ($stat[5], 199, "Correct owner gid for $RealBin/gitrepo");
+ is ($stat[4], 199, "Correct owner uid for /tmp/gitrepo");
+ is ($stat[5], 199, "Correct owner gid for /tmp/gitrepo");
}
# make a conflict
capture_merged { system(<<"END"); };
-cd "$RealBin"; cd gitrepo; git reset --hard b1
+cd /tmp/gitrepo
+if find /tmp/gitrepo . -maxdepth 0 -user test; then
+ sudo -u test git reset --hard b1
+else
+ git reset --hard b1
+fi
END
# 4: sbosnap update through merge conflict
sbosnap 'update', { expected => qr!Updating SlackBuilds tree.*master.*->.*origin/master.*forced update.*HEAD is now at!s };
# 5: make sure test repo is merged correctly
-is (slurp('/usr/sbo/repo/test'), <<"END", 'repo test file updated correctly');
-echo "Hello World."
-END
+is (slurp('/usr/sbo/repo/test'), 'Hello World.', 'repo test file updated correctly');
# Cleanup
END {
diff --git a/t/22-race.t b/t/22-race.t
index 335ef7c..8323a75 100755
--- a/t/22-race.t
+++ b/t/22-race.t
@@ -94,7 +94,7 @@ GIT
$out = capture_merged { $res = SBO::Lib::git_sbo_tree("file://$tempdir"); };
is ($res, 0, 'git_sbo_tree() returned 0');
- is ($out, "fatal: Not a git repository (or any of the parent directories): .git\n", 'git_sbo_tree() gave correct output');
+ is ($out, "fatal: not a git repository (or any of the parent directories): .git\n", 'git_sbo_tree() gave correct output');
chdir $cwd;
system('rm', '-rf', $repo);
diff --git a/t/Test/Sbotools.pm b/t/Test/Sbotools.pm
index 7c6d98b..8be5536 100644
--- a/t/Test/Sbotools.pm
+++ b/t/Test/Sbotools.pm
@@ -62,11 +62,11 @@ sub set_repo {
_set_config('REPO', @_);
if (-e "/usr/sbo/repo" and not $repo) {
$repo = 1;
- rename '/usr/sbo/repo', "$RealBin/repo.backup";
+ system('mv', '/usr/sbo/repo', "/tmp/repo.backup");
# if $sbt is true, the SLACKBUILDS.TXT has been created by
# make_slackbuilds_txt and should not be backed up
- if ($sbt) { system('rm', "$RealBin/repo.backup/SLACKBUILDS.TXT"); }
+ if ($sbt) { system('rm', "/tmp/repo.backup/SLACKBUILDS.TXT"); }
}
}
@@ -142,7 +142,7 @@ END {
}
if ($repo) {
system(qw! rm -rf /usr/sbo/repo !);
- rename "$RealBin/repo.backup", "/usr/sbo/repo";
+ system('mv', "/tmp/repo.backup", '/usr/sbo/repo');
}
if ($tags) {
system(qw!rm -rf !, $tags_txt);