Skip to content

Commit

Permalink
Overhaul the entire test suite.
Browse files Browse the repository at this point in the history
Rather than generating test scripts via bmake, just directly write .bats
files, and make them self-contained rather than depending on a previous
run to simplify things and make them easier to extend.

It was getting very difficult to maintain, as any minor change to add a
new test required lots of changes to each repository and exp files.

Now each individual *.bats test suite can be run independently, and the
only variable that the user needs to set if necessary is PKGIN to point
at the binary to test.

While here rewrite a bunch of tests to make more sense now that they
aren't linked together.

Hopefully no tests have been lost, this has been tested against a bunch
of different versions.  There may still be some cleanups to find.
  • Loading branch information
Jonathan Perkin committed Oct 21, 2020
1 parent df5fca5 commit 800afb2
Show file tree
Hide file tree
Showing 71 changed files with 2,515 additions and 1,930 deletions.
501 changes: 18 additions & 483 deletions Makefile

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions bin/httpd
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@

set -eu

: ${REPO_HTTPD_ERR:=${HTTPD_ERR}}
: ${REPO_HTTPD_LOG:=${HTTPD_LOG}}

if [ -z "${REPO_PACKAGES}" ]; then
echo "REPO_PACKAGES is a required variable" >&2
exit 1
Expand Down
14 changes: 14 additions & 0 deletions bin/pkg_add
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/bin/sh
#
# Wrapper script for pkg_add(1).
#

set -eu

if [ ${BATS_PKGIN_TEST_SUITE} -ne 1 ]; then
echo "ERROR: BATS_PKGIN_TEST_SUITE is not set." >&2
echo "This script only works in the pkgin-test-suite environment" >&2
exit 1
fi

pkg_add -K ${PKG_DBDIR} -C /dev/null "$@"
14 changes: 14 additions & 0 deletions bin/pkg_admin
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/bin/sh
#
# Wrapper script for pkg_admin(1).
#

set -eu

if [ ${BATS_PKGIN_TEST_SUITE} -ne 1 ]; then
echo "ERROR: BATS_PKGIN_TEST_SUITE is not set." >&2
echo "This script only works in the pkgin-test-suite environment" >&2
exit 1
fi

pkg_admin -K ${PKG_DBDIR} -C /dev/null "$@"
14 changes: 14 additions & 0 deletions bin/pkg_create
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/bin/sh
#
# Wrapper script for pkg_create(1).
#

set -eu

if [ ${BATS_PKGIN_TEST_SUITE} -ne 1 ]; then
echo "ERROR: BATS_PKGIN_TEST_SUITE is not set." >&2
echo "This script only works in the pkgin-test-suite environment" >&2
exit 1
fi

pkg_create -K ${PKG_DBDIR} "$@"
14 changes: 14 additions & 0 deletions bin/pkg_delete
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/bin/sh
#
# Wrapper script for pkg_delete(1).
#

set -eu

if [ ${BATS_PKGIN_TEST_SUITE} -ne 1 ]; then
echo "ERROR: BATS_PKGIN_TEST_SUITE is not set." >&2
echo "This script only works in the pkgin-test-suite environment" >&2
exit 1
fi

pkg_delete -K ${PKG_DBDIR} "$@"
14 changes: 14 additions & 0 deletions bin/pkg_info
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/bin/sh
#
# Wrapper script for pkg_info(1).
#

set -eu

if [ ${BATS_PKGIN_TEST_SUITE} -ne 1 ]; then
echo "ERROR: BATS_PKGIN_TEST_SUITE is not set." >&2
echo "This script only works in the pkgin-test-suite environment" >&2
exit 1
fi

pkg_info -K ${PKG_DBDIR} "$@"
17 changes: 17 additions & 0 deletions bin/pkgin
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/bin/sh
#
# Wrapper script for pkgin(1)
#

set -eu

if [ ${BATS_PKGIN_TEST_SUITE} -ne 1 ]; then
echo "ERROR: BATS_PKGIN_TEST_SUITE is not set." >&2
echo "This script only works in the pkgin-test-suite environment" >&2
exit 1
fi

env PKGIN_DBDIR="${PKGIN_DBDIR}" \
PKG_INSTALL_DIR="${PKG_INSTALL_DIR}" \
PKG_DBDIR="${PKG_DBDIR}" \
${PKGIN} "$@"
7 changes: 1 addition & 6 deletions exp/conflict/pkg_info.final
Original file line number Diff line number Diff line change
@@ -1,6 +1 @@
deptree-bottom-1.0 Package is at the bottom of a dependency tree
deptree-middle-2.0 Package is in the middle of a dependency tree
deptree-top-2.0 Package is at the top of a dependency tree
keep-1.0 Package should remain at all times
pkgpath-2.0 Package should not be upgraded by newer pkgpath
upgrade-2.0 Package should be upgraded over older upgrade package
preserve-1.0 Package should remain at all times
2 changes: 1 addition & 1 deletion exp/conflict/pkgin-conflicts.remote
Original file line number Diff line number Diff line change
@@ -1 +1 @@
keep-[0-9]*
preserve-[0-9]*
2 changes: 1 addition & 1 deletion exp/file-dl/pkg_info.final
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
download-ok-1.0 Package tests download success
keep-1.0 Package should remain at all times
preserve-1.0 Package should remain at all times
2 changes: 1 addition & 1 deletion exp/http-dl/pkg_info.final
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
download-ok-1.0 Package tests download success
keep-1.0 Package should remain at all times
preserve-1.0 Package should remain at all times
8 changes: 4 additions & 4 deletions exp/install/0.10/install-against-empty.regex
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ processing remote summary .http://.*
downloading pkg_summary.* done.
calculating dependencies...done.
nothing to upgrade.
1 packages to be installed .[0-9]+[BK] to download, 9B to install.:
keep-1.0
downloading keep-1.0.tgz done.
1 packages to be installed .[0-9]+[BK] to download, [0-9]+[BK] to install.:
preserve-1.0
downloading preserve-1.0.tgz done.
installing packages...
installing keep-1.0...
installing preserve-1.0...
pkg_install warnings: 0, errors: 0
reading local summary...
processing local summary...
5 changes: 1 addition & 4 deletions exp/install/0.10/install-remaining.regex
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,19 @@ processing remote summary .http://.*
downloading pkg_summary.* done.
calculating dependencies...done.
nothing to upgrade.
5 packages to be installed .[0-9]+[BK] to download, 78B to install.:
4 packages to be installed .[0-9]+[BK] to download, [0-9]+[BK] to install.:
.*
downloading deptree-bottom-1.0.tgz done.
downloading deptree-middle-1.0.tgz done.
downloading deptree-top-1.0.tgz done.
downloading pkgpath-1.0.tgz done.
downloading upgrade-1.0.tgz done.
installing packages...
installing deptree-bottom-1.0...
installing deptree-middle-1.0...
installing deptree-top-1.0...
installing pkgpath-1.0...
installing upgrade-1.0...
pkg_install warnings: 0, errors: 0
reading local summary...
processing local summary...
marking pkgpath-1.0 as non auto-removable
marking upgrade-1.0 as non auto-removable
marking deptree-top-1.0 as non auto-removable
9 changes: 3 additions & 6 deletions exp/install/0.12/install-remaining.regex
Original file line number Diff line number Diff line change
@@ -1,23 +1,20 @@
processing remote summary .http://.*
downloading pkg_summary.* done.
calculating dependencies...done.
5 packages to install:
4 packages to install:
.*
0 to refresh, 0 to upgrade, 5 to install
[0-9]+[BK] to download, 78B to install
0 to refresh, 0 to upgrade, 4 to install
[0-9]+[BK] to download, [0-9]+[BK] to install
downloading deptree-bottom-1.0.tgz done.
downloading deptree-middle-1.0.tgz done.
downloading deptree-top-1.0.tgz done.
downloading pkgpath-1.0.tgz done.
downloading upgrade-1.0.tgz done.
installing deptree-bottom-1.0...
installing deptree-middle-1.0...
installing deptree-top-1.0...
installing pkgpath-1.0...
installing upgrade-1.0...
pkg_install warnings: 0, errors: 0
reading local summary...
processing local summary...
marking pkgpath-1.0 as non auto-removable
marking upgrade-1.0 as non auto-removable
marking deptree-top-1.0 as non auto-removable
3 changes: 1 addition & 2 deletions exp/install/0.9/cat-share-doc-all.out
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
deptree-bottom-1.0
deptree-middle-1.0
deptree-top-1.0
keep-1.0
preserve-1.0
pkgpath-1.0
upgrade-1.0
6 changes: 1 addition & 5 deletions exp/install/0.9/install-remaining.regex
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ download started.
.*
calculating dependencies... done.
nothing to upgrade.
5 packages to be installed .[0-9]+[BK] to download, 78B to install.:
4 packages to be installed .[0-9]+[BK] to download, [0-9]+[BK] to install.:
.*
downloading packages...
download started.
Expand All @@ -14,17 +14,13 @@ download started.
download ended.
download started.
download ended.
download started.
download ended.
installing packages...
installing deptree-bottom-1.0...
installing deptree-middle-1.0...
installing deptree-top-1.0...
installing pkgpath-1.0...
installing upgrade-1.0...
pkg_install warnings: 0, errors: 0
reading local summary...
processing local summary...
marking pkgpath-1.0 as non auto-removable
marking upgrade-1.0 as non auto-removable
marking deptree-top-1.0 as non auto-removable
3 changes: 1 addition & 2 deletions exp/install/cat-share-doc-all.out
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
deptree-bottom-1.0
deptree-middle-1.0
deptree-top-1.0
keep-1.0
pkgpath-1.0
upgrade-1.0
preserve-1.0
20 changes: 20 additions & 0 deletions exp/install/import.regex
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
processing remote summary .http://.*
downloading pkg_summary.* done.
calculating dependencies...done.
5 packages to install:
.*
0 to refresh, 0 to upgrade, 5 to install
[0-9]+[BK] to download, [0-9]+[BK] to install
downloading preserve-1.0.tgz done.
downloading pkgpath-1.0.tgz done.
downloading deptree-bottom-1.0.tgz done.
downloading deptree-middle-1.0.tgz done.
downloading deptree-top-1.0.tgz done.
installing preserve-1.0...
installing pkgpath-1.0...
installing deptree-top-1.0...
installing deptree-middle-1.0...
installing deptree-bottom-1.0...
pkg_install warnings: 0, errors: 0
reading local summary...
processing local summary...
8 changes: 4 additions & 4 deletions exp/install/install-against-empty.regex
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ processing remote summary .http://.*
downloading pkg_summary.* done.
calculating dependencies...done.
1 package to install:
keep-1.0
preserve-1.0
0 to refresh, 0 to upgrade, 1 to install
[0-9]+[BK] to download, 9B to install
downloading keep-1.0.tgz done.
installing keep-1.0...
[0-9]+[BK] to download, [0-9]+[BK] to install
downloading preserve-1.0.tgz done.
installing preserve-1.0...
pkg_install warnings: 0, errors: 0
reading local summary...
processing local summary...
9 changes: 3 additions & 6 deletions exp/install/install-remaining.regex
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,20 @@ processing local summary...
processing remote summary .http://.*
downloading pkg_summary.* done.
calculating dependencies...done.
5 packages to install:
4 packages to install:
.*
0 to refresh, 0 to upgrade, 5 to install
[0-9]+[BK] to download, 78B to install
0 to refresh, 0 to upgrade, 4 to install
[0-9]+[BK] to download, [0-9]+[BK] to install
downloading deptree-bottom-1.0.tgz done.
downloading deptree-middle-1.0.tgz done.
downloading deptree-top-1.0.tgz done.
downloading pkgpath-1.0.tgz done.
downloading upgrade-1.0.tgz done.
installing deptree-bottom-1.0...
installing deptree-middle-1.0...
installing deptree-top-1.0...
installing pkgpath-1.0...
installing upgrade-1.0...
pkg_install warnings: 0, errors: 0
reading local summary...
processing local summary...
marking pkgpath-1.0 as non auto-removable
marking upgrade-1.0 as non auto-removable
marking deptree-top-1.0 as non auto-removable
5 changes: 2 additions & 3 deletions exp/install/pkg_info.final
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
deptree-bottom-1.0 Package is at the bottom of a dependency tree
deptree-middle-1.0 Package is in the middle of a dependency tree
deptree-top-1.0 Package is at the top of a dependency tree
keep-1.0 Package should remain at all times
pkgpath-1.0 Package should not be upgraded by newer pkgpath
upgrade-1.0 Package should be upgraded to newer upgrade
pkgpath-1.0 PKGPATH differs to pkgpath-2.0
preserve-1.0 Package should remain at all times
2 changes: 1 addition & 1 deletion exp/install/pkg_info.start
Original file line number Diff line number Diff line change
@@ -1 +1 @@
keep-1.0 Package should remain at all times
preserve-1.0 Package should remain at all times
5 changes: 2 additions & 3 deletions exp/install/pkgin-list.final
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
deptree-bottom-1.0 Package is at the bottom of a dependency tree
deptree-middle-1.0 Package is in the middle of a dependency tree
deptree-top-1.0 Package is at the top of a dependency tree
keep-1.0 Package should remain at all times
pkgpath-1.0 Package should not be upgraded by newer pkgpath
upgrade-1.0 Package should be upgraded to newer upgrade
pkgpath-1.0 PKGPATH differs to pkgpath-2.0
preserve-1.0 Package should remain at all times
2 changes: 1 addition & 1 deletion exp/install/pkgin-list.start
Original file line number Diff line number Diff line change
@@ -1 +1 @@
keep-1.0 Package should remain at all times
preserve-1.0 Package should remain at all times
6 changes: 3 additions & 3 deletions exp/install/pkgin-stats.regex
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Local package database:
Installed packages: 6
Disk space occupied: 87B
Installed packages: 5
Disk space occupied: [0-9]+[BK]
Remote package database.s.:
Number of repositories: 1
Packages available: 6
Total size of packages: [0-9]+K
Total size of packages: [0-9]+[BK]
7 changes: 3 additions & 4 deletions exp/install/pkgin.export
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
testsuite/deptree-top
testsuite/keep
testsuite/pkgpath1
testsuite/upgrade
cat1/preserve
cat2/pkgpath1
cat3/deptree-top
2 changes: 1 addition & 1 deletion exp/install/pkgin.search
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
keep-1.0 = Package should remain at all times
preserve-1.0 = Package should remain at all times

=: package is installed and up-to-date
<: package is installed but newer version is available
Expand Down
1 change: 0 additions & 1 deletion exp/install/pkgin.show-all-categories

This file was deleted.

1 change: 0 additions & 1 deletion exp/install/pkgin.show-category

This file was deleted.

2 changes: 1 addition & 1 deletion exp/install/pkgin.show-full-deps
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
full dependency tree for deptree-top-1.0
keep>=1.0
preserve>=1.0
deptree-bottom-[0-9]*
deptree-middle>=1.0
3 changes: 1 addition & 2 deletions exp/install/pkgin.show-keep
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
deptree-top-1.0 is marked as non-autoremovable
keep-1.0 is marked as non-autoremovable
pkgpath-1.0 is marked as non-autoremovable
upgrade-1.0 is marked as non-autoremovable
preserve-1.0 is marked as non-autoremovable
1 change: 0 additions & 1 deletion exp/install/pkgin.show-pkg-category

This file was deleted.

3 changes: 3 additions & 0 deletions exp/provreq/pkg_info.final
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
preserve-1.0 Package should remain at all times
provides-1.0 Package provides libprovides.so
requires-1.0 Package requires libprovides.so
6 changes: 3 additions & 3 deletions exp/upgrade/0.10/full-upgrade-download-only.regex
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ calculating dependencies...done.
5 packages to be downloaded .[0-9]+[BK] to download.:
.*
downloading deptree-middle-2.0.tgz done.
downloading deptree-top-2.0.tgz done.
downloading keep-1.0.tgz done.
downloading pkgpath-1.0.tgz done.
downloading upgrade-2.0.tgz done.
downloading refresh-1.0.tgz done.
downloading deptree-top-2.0.tgz done.
downloading deptree-bottom-2.0.tgz done.
Loading

0 comments on commit 800afb2

Please sign in to comment.