diff options
author | Karen Arutyunov <karen@codesynthesis.com> | 2021-08-11 20:17:12 +0300 |
---|---|---|
committer | Karen Arutyunov <karen@codesynthesis.com> | 2021-08-13 11:55:24 +0300 |
commit | d1fa0047be1db658b165514dc429ce494517b39c (patch) | |
tree | be114b36341ee49b3d835687291974a0ac3661ed /tests | |
parent | aac298fcef914b99cf28d9cf1f4f58cc6714fb92 (diff) |
Add support for cfg-unlink
Diffstat (limited to 'tests')
-rw-r--r-- | tests/cfg-unlink.testscript | 275 | ||||
l--------- | tests/cfg-unlink/t7a | 1 | ||||
-rw-r--r-- | tests/common.testscript | 1 | ||||
-rw-r--r-- | tests/pkg-drop.testscript | 36 | ||||
l--------- | tests/pkg-drop/t7b | 1 |
5 files changed, 282 insertions, 32 deletions
diff --git a/tests/cfg-unlink.testscript b/tests/cfg-unlink.testscript new file mode 100644 index 0000000..b65f4b1 --- /dev/null +++ b/tests/cfg-unlink.testscript @@ -0,0 +1,275 @@ +# file : tests/cfg-link.testscript +# license : MIT; see accompanying LICENSE file + +.include common.testscript remote.testscript + +# Source repository (see pkg-build for details): +# +# cfg-unlink +# `-- t7a + +# Prepare repositories used by tests if running in the local mode. +# ++if! $remote + rep_create += 2>! + + cp -r $src/t7a $out/t7a && $rep_create $out/t7a &$out/t7a/packages.manifest +end + +cfg_create += 2>! +cfg_info += --link +pkg_build += --yes 2>! +pkg_drop += --yes 2>! +rep_add += 2>! +rep_fetch += --trust-yes 2>! + +cfg1_uuid = '18f48b4b-b5d9-4712-b98c-1930df1c4228' +cfg2_uuid ='28f48b4b-b5d9-4712-b98c-1930df1c4228' + ++$cfg_create -d cfg1 --name 'main' --uuid "$cfg1_uuid" &cfg1/*** ++$cfg_create -d cfg2 --name 'shared' --uuid "$cfg2_uuid" --type host &cfg2/*** + ++$cfg_link -d cfg1 cfg2 2>! + +clone_root_cfgs = cp -r $~/cfg1 $~/cfg2 ./ + +: unlink +: +{ + : name-dir + : + { + $clone_root_cfgs; + + $* -d cfg1 cfg2 --name 'host' 2>/'error: both --name and directory argument specified' != 0 + } + + : dir + : + { + $clone_root_cfgs; + + $* -d cfg1 cfg1 2>/"error: no configuration with path $~/cfg1/ is linked with cfg1/" != 0; + + $* -d cfg1 cfg2 2>/"unlinked configuration $~/cfg2/"; + + $cfg_info -d cfg1 >>/"EOO"; + path: $~/cfg1/ + uuid: $cfg1_uuid + type: target + name: main + EOO + + $cfg_info -d cfg2 >>/"EOO" + path: $~/cfg2/ + uuid: $cfg2_uuid + type: host + name: shared + EOO + } + + : name + : + { + $clone_root_cfgs; + + $* -d cfg1 --name 'target' 2>/"error: no configuration with name 'target' is linked with cfg1/" != 0; + + $* -d cfg1 --name 'shared' 2>/"unlinked configuration $~/cfg2/"; + + $cfg_info -d cfg1 >>/"EOO"; + path: $~/cfg1/ + uuid: $cfg1_uuid + type: target + name: main + EOO + + $cfg_info -d cfg2 >>/"EOO" + path: $~/cfg2/ + uuid: $cfg2_uuid + type: host + name: shared + EOO + } + + : id + : + { + $clone_root_cfgs; + + $* -d cfg1 --id 2 2>/"error: no configuration with id 2 is linked with cfg1/" != 0; + + $* -d cfg1 --id 1 2>/"unlinked configuration $~/cfg2/"; + + $cfg_info -d cfg1 >>/"EOO"; + path: $~/cfg1/ + uuid: $cfg1_uuid + type: target + name: main + EOO + + $cfg_info -d cfg2 >>/"EOO" + path: $~/cfg2/ + uuid: $cfg2_uuid + type: host + name: shared + EOO + } + + : uuid + : + { + $clone_root_cfgs; + + $* -d cfg1 --uuid $cfg1_uuid 2>/"error: no configuration with uuid $cfg1_uuid is linked with cfg1/" != 0; + + $* -d cfg1 --uuid $cfg2_uuid 2>/"unlinked configuration $~/cfg2/"; + + $cfg_info -d cfg1 >>/"EOO"; + path: $~/cfg1/ + uuid: $cfg1_uuid + type: target + name: main + EOO + + $cfg_info -d cfg2 >>/"EOO" + path: $~/cfg2/ + uuid: $cfg2_uuid + type: host + name: shared + EOO + } + + : mutual + : + { + $clone_root_cfgs; + + $cfg_link -d cfg2 cfg1 2>!; + + $* -d cfg1 cfg2 2>>/"EOE"; + info: configurations cfg2/ and cfg1/ are mutually linked, turning the link to cfg2/ into implicit back-link + unlinked configuration $~/cfg2/ + EOE + + $cfg_info -d cfg1 >>/"EOO"; + path: $~/cfg1/ + uuid: $cfg1_uuid + type: target + name: main + EOO + + $cfg_info -d cfg2 >>/"EOO" + path: $~/cfg2/ + uuid: $cfg2_uuid + type: host + name: shared + + path: $~/cfg1/ + uuid: $cfg1_uuid + type: target + name: main + EOO + } + + : dependency + : + { + $clone_root_cfgs; + + $rep_add -d cfg1 $rep/t7a && $rep_fetch -d cfg1; + + $pkg_build -d cfg1 libbar &cfg2/.bpkg/build2/***; + + $* -d cfg1 cfg2 2>>/EOE != 0; + error: configuration cfg1/ still depends on configuration cfg2/ + info: package foo [cfg2/] has dependents: + info: package libbar on foo ^1.0.0 + EOE + + $pkg_drop -d cfg1 --keep-unused libbar; + + $* -d cfg1 cfg2 2>>/"EOE"; + unlinked configuration $~/cfg2/ + EOE + + $cfg_info -d cfg1 >>/"EOO"; + path: $~/cfg1/ + uuid: $cfg1_uuid + type: target + name: main + EOO + + $cfg_info -d cfg2 >>/~"%EOO%"; + path: $~/cfg2/ + uuid: $cfg2_uuid + type: host + name: shared + + path: $~/cfg2/.bpkg/build2/ + %uuid: .{36}% + type: build2 + name: build2 + EOO + + $pkg_drop -d cfg1 libbaz; + $pkg_drop -d cfg2 foo + } + + : dependency-private + : + { + $clone_root_cfgs; + + $rep_add -d cfg2 $rep/t7a && $rep_fetch -d cfg2; + + $pkg_build -d cfg2 foo; + + $* -d cfg2 --name build2 2>>/EOE != 0; + error: configuration cfg2/ still depends on private configuration cfg2/.bpkg/build2/ + info: package libbuild2-bar [cfg2/.bpkg/build2/] has dependents: + info: package foo on libbuild2-bar ^1.0.0 + EOE + + $pkg_drop -d cfg2 --keep-unused foo; + + test -d cfg2/.bpkg/build2/; + + $* -d cfg2 --name build2 2>>/"EOE"; + unlinked and removed configuration $~/cfg2/.bpkg/build2/ + EOE + + $cfg_info -d cfg2 >>/"EOO"; + path: $~/cfg2/ + uuid: $cfg2_uuid + type: host + name: shared + EOO + + test -d cfg2/.bpkg/build2/ == 1; + + $pkg_drop -d cfg2 libbaz + } +} +: remove-dangling +: +{ + : success + : + { + $clone_root_cfgs; + + mv cfg1 cfg3; + + $* -d cfg2 --dangling 2>'removed 1 dangling implicit back-link(s)'; + $* -d cfg2 --dangling 2>'removed 0 dangling implicit back-link(s)' + } + + : error + : + { + $clone_root_cfgs; + + $* -d cfg1 --dangling --name 'host' 2>'error: both --dangling and --name specified' != 0 + } +} diff --git a/tests/cfg-unlink/t7a b/tests/cfg-unlink/t7a new file mode 120000 index 0000000..d02b5d4 --- /dev/null +++ b/tests/cfg-unlink/t7a @@ -0,0 +1 @@ +../common/linked/t7a
\ No newline at end of file diff --git a/tests/common.testscript b/tests/common.testscript index 8af2cc7..25671c6 100644 --- a/tests/common.testscript +++ b/tests/common.testscript @@ -35,6 +35,7 @@ test.options += --default-options $options_guard \ cfg_create = $* cfg-create cfg_info = $* cfg-info cfg_link = $* cfg-link +cfg_unlink = $* cfg-unlink pkg_build = $* pkg-build pkg_checkout = $* pkg-checkout pkg_configure = $* pkg-configure diff --git a/tests/pkg-drop.testscript b/tests/pkg-drop.testscript index 83fa13b..7a93c2d 100644 --- a/tests/pkg-drop.testscript +++ b/tests/pkg-drop.testscript @@ -3,39 +3,14 @@ .include common.testscript config.testscript remote.testscript -# Source repository: +# Source repository (see pkg-build for details): # # pkg-drop # |-- t4a -# | |-- libfoo-1.1.0.tar.gz -# | `-- repositories.manifest -# | -# |-- t4b -> t4a (prerequisite repository) -# | |-- libbar-1.1.0.tar.gz -> libfoo == 1.1.0 -# | `-- repositories.manifest -# | -# |-- t4c -> t4b (prerequisite repository) -# | |-- libbaz-1.1.0.tar.gz -> libfoo, libbar -# | |-- libfoo-1.0.0.tar.gz -# | `-- repositories.manifest -# | -# |-- t4d -> t4c (complement) -# | |-- libbiz-1.0.0.tar.gz -> libfox, libfoo, libbaz -# | |-- libfox-1.0.0.tar.gz -# | `-- repositories.manifest -# | -# |-- t7a -# | |-- libbaz-1.0.0.tar.gz -# | |-- libbuild2-bar-1.0.0.tar.gz -# | |-- foo-1.0.0.tar.gz -> * libbuild2-bar ^1.0.0, libbaz ^1.0.0 -# | |-- libbar-1.0.0.tar.gz -> * foo ^1.0.0, libbaz ^1.0.0 -# | `-- repositories.manifest -# | -# `-- t7b -> t7a (complement repository) -# |-- libbaz-1.1.0.tar.gz -# |-- foo-1.1.0.tar.gz -> libbaz ^1.1.0 -# |-- libbar-1.1.0.tar.gz -> * foo ^1.1.0, libbaz ^1.0.0 -# `-- repositories.manifest +# |-- t4b +# |-- t4c +# |-- t4d +# `-- t7a # Prepare repositories used by tests if running in the local mode. # @@ -47,7 +22,6 @@ cp -r $src/t4c $out/t4c && $rep_create $out/t4c &$out/t4c/packages.manifest cp -r $src/t4d $out/t4d && $rep_create $out/t4d &$out/t4d/packages.manifest cp -r $src/t7a $out/t7a && $rep_create $out/t7a &$out/t7a/packages.manifest - cp -r $src/t7b $out/t7b && $rep_create $out/t7b &$out/t7b/packages.manifest end cfg_create += 2>! diff --git a/tests/pkg-drop/t7b b/tests/pkg-drop/t7b deleted file mode 120000 index 808039d..0000000 --- a/tests/pkg-drop/t7b +++ /dev/null @@ -1 +0,0 @@ -../common/linked/t7b
\ No newline at end of file |