aboutsummaryrefslogtreecommitdiff
path: root/tests/pkg-purge.testscript
diff options
context:
space:
mode:
authorKaren Arutyunov <karen@codesynthesis.com>2018-09-04 14:02:11 +0300
committerKaren Arutyunov <karen@codesynthesis.com>2018-09-04 14:02:11 +0300
commitf8fdb500cc705e2b8b4a74166ceb2c6d8cee3fd3 (patch)
tree3f94b0b79ebad275904b9dc4a4165326ff598492 /tests/pkg-purge.testscript
parentf727c2b8fe273a12d059826291523060dab4b512 (diff)
Rename .test/test{} to .testscript/testscript{}
Diffstat (limited to 'tests/pkg-purge.testscript')
-rw-r--r--tests/pkg-purge.testscript177
1 files changed, 177 insertions, 0 deletions
diff --git a/tests/pkg-purge.testscript b/tests/pkg-purge.testscript
new file mode 100644
index 0000000..0b677cb
--- /dev/null
+++ b/tests/pkg-purge.testscript
@@ -0,0 +1,177 @@
+# file : tests/pkg-purge.testscript
+# copyright : Copyright (c) 2014-2018 Code Synthesis Ltd
+# license : MIT; see accompanying LICENSE file
+
+.include common.testscript config.testscript
+
+# Source repository:
+#
+# pkg-purge
+# |-- libfoo-1.0.0.tar.gz
+# `-- libfoo-1.1.0 ->
+# |-- build
+# | `-- bootstrap.build
+# |-- buildfile
+# `-- manifest
+
+pkg_fetch += -d cfg 2>!
+pkg_unpack += -d cfg 2>!
+pkg_status += -d cfg
+
+: no-name
+:
+$clone_cfg;
+$* 2>>EOE != 0
+ error: package name argument expected
+ info: run 'bpkg help pkg-purge' for more information
+ EOE
+
+: no-package
+:
+$clone_cfg;
+$* libfoo 2>>/EOE != 0
+ error: package libfoo does not exist in configuration cfg/
+ EOE
+
+: fetched
+:
+{
+ $clone_cfg && $pkg_fetch -e $src/libfoo-1.0.0.tar.gz;
+
+ $* libfoo 2>'purged libfoo/1.0.0';
+ $pkg_status libfoo 1>'libfoo unknown'
+}
+
+: keep
+:
+{
+ $clone_cfg && $pkg_fetch -e $src/libfoo-1.0.0.tar.gz;
+
+ $* -k libfoo 2>'keeping archive libfoo/1.0.0';
+ $pkg_status libfoo 1>'libfoo fetched 1.0.0';
+ $* libfoo 2>'purged libfoo/1.0.0'
+}
+
+: purge-archive
+:
+{
+ $clone_cfg;
+ cp --no-cleanup $src/libfoo-1.0.0.tar.gz cfg/;
+ $pkg_fetch -e -p cfg/libfoo-1.0.0.tar.gz;
+
+ $* libfoo 2>'purged libfoo/1.0.0';
+ $pkg_status libfoo 1>'libfoo unknown';
+ test -f cfg/libfoo-1.0.0.tar.gz == 1
+}
+
+: no-archive-keep
+:
+{
+ $clone_cfg && $pkg_unpack -e $src/libfoo-1.1.0;
+
+ $* --keep libfoo 2>>EOE != 0;
+ error: package libfoo has no archive to keep
+ EOE
+
+ $pkg_status libfoo 1>'libfoo unpacked 1.1.0';
+ $* libfoo 2>'purged libfoo/1.1.0'
+}
+
+: unpacked-dir
+:
+{
+ $clone_cfg && $pkg_unpack -e $src/libfoo-1.1.0;
+
+ $* libfoo 2>'purged libfoo/1.1.0';
+ $pkg_status libfoo 1>'libfoo unknown'
+}
+
+: unpacked-archive
+:
+{
+ $clone_cfg;
+ $pkg_fetch -e $src/libfoo-1.0.0.tar.gz && $pkg_unpack libfoo;
+
+ $* libfoo 2>'purged libfoo/1.0.0';
+ $pkg_status libfoo 1>'libfoo unknown';
+ test -d cfg/libfoo-1.0.0 == 1
+}
+
+: keep-unpacked-archive
+:
+{
+ $clone_cfg;
+ $pkg_fetch -e $src/libfoo-1.0.0.tar.gz && $pkg_unpack libfoo;
+
+ $* --keep libfoo 2>'keeping archive libfoo/1.0.0';
+ $pkg_status libfoo 1>'libfoo fetched 1.0.0';
+ test -d cfg/libfoo-1.0.0 == 1;
+ $* libfoo 2>'purged libfoo/1.0.0';
+ $pkg_status libfoo 1>'libfoo unknown'
+}
+
+: purge-dir
+:
+{
+ $clone_cfg;
+ cp --no-cleanup -r $src/libfoo-1.1.0 cfg/;
+
+ $pkg_unpack -e -p cfg/libfoo-1.1.0;
+
+ $* libfoo 2>'purged libfoo/1.1.0';
+ $pkg_status libfoo 1>'libfoo unknown';
+ test -d cfg/libfoo-1.1.0 == 1
+}
+
+: purge-unpacked-archive
+:
+{
+ $clone_cfg;
+ cp --no-cleanup $src/libfoo-1.0.0.tar.gz cfg/;
+ $pkg_fetch -e -p cfg/libfoo-1.0.0.tar.gz && $pkg_unpack libfoo;
+
+ $* libfoo 2>'purged libfoo/1.0.0';
+ $pkg_status libfoo 1>'libfoo unknown';
+ test -d cfg/libfoo-1.0.0 == 1;
+ test -f cfg/libfoo-1.0.0.tar.gz == 1
+}
+
+: broken
+:
+if ($cxx.target.class != 'windows')
+{
+ $clone_cfg;
+ cp --no-cleanup $src/libfoo-1.0.0.tar.gz cfg/;
+ $pkg_fetch -e -p cfg/libfoo-1.0.0.tar.gz;
+ $pkg_unpack libfoo;
+ chmod 000 cfg/libfoo-1.0.0;
+
+ $* libfoo 2>>/~%EOE% != 0;
+ %error: unable to remove directory cfg/libfoo-1.0.0/.+%
+ info: package libfoo is now broken; use 'pkg-purge --force' to remove
+ EOE
+
+ $pkg_status libfoo/1.0.0 >'libfoo broken 1.0.0';
+
+ $* -f -k libfoo 2>'error: cannot keep broken package libfoo' != 0;
+ $pkg_status libfoo/1.0.0 >'libfoo broken 1.0.0';
+
+ $* -f libfoo 2>>/EOE != 0;
+ error: source directory of broken package libfoo still exists
+ info: remove cfg/libfoo-1.0.0/ manually then re-run pkg-purge
+ EOE
+
+ $pkg_status libfoo/1.0.0 >'libfoo broken 1.0.0';
+
+ chmod 755 cfg/libfoo-1.0.0;
+ rm -r cfg/libfoo-1.0.0;
+
+ $* -f libfoo 2>>/EOE != 0;
+ error: archive file of broken package libfoo still exists
+ info: remove cfg/libfoo-1.0.0.tar.gz manually then re-run pkg-purge
+ EOE
+
+ rm cfg/libfoo-1.0.0.tar.gz;
+ $* -f libfoo 2>'purged libfoo/1.0.0';
+ $pkg_status libfoo >'libfoo unknown'
+}