From f8fdb500cc705e2b8b4a74166ceb2c6d8cee3fd3 Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Tue, 4 Sep 2018 14:02:11 +0300 Subject: Rename .test/test{} to .testscript/testscript{} --- tests/auth.test | 23 - tests/auth.testscript | 23 + tests/build/root.build | 2 +- tests/buildfile | 4 +- tests/cfg-create.test | 75 - tests/cfg-create.testscript | 75 + tests/common.test | 50 - tests/common.testscript | 51 + tests/config.test | 27 - tests/config.testscript | 27 + tests/pkg-build.test | 3470 ------------------------------- tests/pkg-build.testscript | 3473 ++++++++++++++++++++++++++++++++ tests/pkg-checkout.test | 105 - tests/pkg-checkout.testscript | 105 + tests/pkg-clean.test | 136 -- tests/pkg-clean.testscript | 136 ++ tests/pkg-configure.test | 408 ---- tests/pkg-configure.testscript | 408 ++++ tests/pkg-drop.test | 447 ---- tests/pkg-drop.testscript | 447 ++++ tests/pkg-fetch.test | 203 -- tests/pkg-fetch.testscript | 203 ++ tests/pkg-purge.test | 177 -- tests/pkg-purge.testscript | 177 ++ tests/pkg-status.test | 212 -- tests/pkg-status.testscript | 215 ++ tests/pkg-system.test | 911 --------- tests/pkg-system.testscript | 911 +++++++++ tests/pkg-test.test | 119 -- tests/pkg-test.testscript | 119 ++ tests/pkg-unpack.test | 297 --- tests/pkg-unpack.testscript | 301 +++ tests/pkg-update.test | 139 -- tests/pkg-update.testscript | 139 ++ tests/pkg-verify.test | 71 - tests/pkg-verify.testscript | 71 + tests/remote-git.test | 69 - tests/remote-git.testscript | 69 + tests/remote.test | 37 - tests/remote.testscript | 37 + tests/rep-add.test | 205 -- tests/rep-add.testscript | 205 ++ tests/rep-auth.test | 634 ------ tests/rep-auth.testscript | 634 ++++++ tests/rep-create.test | 178 -- tests/rep-create.testscript | 178 ++ tests/rep-fetch-git-commit.test | 93 - tests/rep-fetch-git-commit.testscript | 93 + tests/rep-fetch-git-refname.test | 148 -- tests/rep-fetch-git-refname.testscript | 148 ++ tests/rep-fetch-git.test | 79 - tests/rep-fetch-git.testscript | 79 + tests/rep-fetch.test | 977 --------- tests/rep-fetch.testscript | 981 +++++++++ tests/rep-info.test | 251 --- tests/rep-info.testscript | 254 +++ tests/rep-list.test | 147 -- tests/rep-list.testscript | 150 ++ tests/rep-remove.test | 209 -- tests/rep-remove.testscript | 212 ++ 60 files changed, 9924 insertions(+), 9900 deletions(-) delete mode 100644 tests/auth.test create mode 100644 tests/auth.testscript delete mode 100644 tests/cfg-create.test create mode 100644 tests/cfg-create.testscript delete mode 100644 tests/common.test create mode 100644 tests/common.testscript delete mode 100644 tests/config.test create mode 100644 tests/config.testscript delete mode 100644 tests/pkg-build.test create mode 100644 tests/pkg-build.testscript delete mode 100644 tests/pkg-checkout.test create mode 100644 tests/pkg-checkout.testscript delete mode 100644 tests/pkg-clean.test create mode 100644 tests/pkg-clean.testscript delete mode 100644 tests/pkg-configure.test create mode 100644 tests/pkg-configure.testscript delete mode 100644 tests/pkg-drop.test create mode 100644 tests/pkg-drop.testscript delete mode 100644 tests/pkg-fetch.test create mode 100644 tests/pkg-fetch.testscript delete mode 100644 tests/pkg-purge.test create mode 100644 tests/pkg-purge.testscript delete mode 100644 tests/pkg-status.test create mode 100644 tests/pkg-status.testscript delete mode 100644 tests/pkg-system.test create mode 100644 tests/pkg-system.testscript delete mode 100644 tests/pkg-test.test create mode 100644 tests/pkg-test.testscript delete mode 100644 tests/pkg-unpack.test create mode 100644 tests/pkg-unpack.testscript delete mode 100644 tests/pkg-update.test create mode 100644 tests/pkg-update.testscript delete mode 100644 tests/pkg-verify.test create mode 100644 tests/pkg-verify.testscript delete mode 100644 tests/remote-git.test create mode 100644 tests/remote-git.testscript delete mode 100644 tests/remote.test create mode 100644 tests/remote.testscript delete mode 100644 tests/rep-add.test create mode 100644 tests/rep-add.testscript delete mode 100644 tests/rep-auth.test create mode 100644 tests/rep-auth.testscript delete mode 100644 tests/rep-create.test create mode 100644 tests/rep-create.testscript delete mode 100644 tests/rep-fetch-git-commit.test create mode 100644 tests/rep-fetch-git-commit.testscript delete mode 100644 tests/rep-fetch-git-refname.test create mode 100644 tests/rep-fetch-git-refname.testscript delete mode 100644 tests/rep-fetch-git.test create mode 100644 tests/rep-fetch-git.testscript delete mode 100644 tests/rep-fetch.test create mode 100644 tests/rep-fetch.testscript delete mode 100644 tests/rep-info.test create mode 100644 tests/rep-info.testscript delete mode 100644 tests/rep-list.test create mode 100644 tests/rep-list.testscript delete mode 100644 tests/rep-remove.test create mode 100644 tests/rep-remove.testscript (limited to 'tests') diff --git a/tests/auth.test b/tests/auth.test deleted file mode 100644 index 0bac0e7..0000000 --- a/tests/auth.test +++ /dev/null @@ -1,23 +0,0 @@ -# file : tests/auth.test -# copyright : Copyright (c) 2014-2018 Code Synthesis Ltd -# license : MIT; see accompanying LICENSE file - -# OpenSSL passwordless private key. -# -key = $src_base/auth/key.pem - -# Repository certificate generated with the above private key. -# -cert = $src_base/auth/default-cert.pem - -# Repository certificate fingerprint. -# -+set cert_fp <<<$src_base/auth/default-cert-fp - -# Manifest certificate name/value. Can be appended to the repositories.manifest -# file to sign the repository. -# -cert_manifest = $~/cert-manifest -+echo 'certificate: \' >=$cert_manifest -+cat <<<$cert >+$cert_manifest -+echo '\' >+$cert_manifest diff --git a/tests/auth.testscript b/tests/auth.testscript new file mode 100644 index 0000000..06886db --- /dev/null +++ b/tests/auth.testscript @@ -0,0 +1,23 @@ +# file : tests/auth.testscript +# copyright : Copyright (c) 2014-2018 Code Synthesis Ltd +# license : MIT; see accompanying LICENSE file + +# OpenSSL passwordless private key. +# +key = $src_base/auth/key.pem + +# Repository certificate generated with the above private key. +# +cert = $src_base/auth/default-cert.pem + +# Repository certificate fingerprint. +# ++set cert_fp <<<$src_base/auth/default-cert-fp + +# Manifest certificate name/value. Can be appended to the repositories.manifest +# file to sign the repository. +# +cert_manifest = $~/cert-manifest ++echo 'certificate: \' >=$cert_manifest ++cat <<<$cert >+$cert_manifest ++echo '\' >+$cert_manifest diff --git a/tests/build/root.build b/tests/build/root.build index 5818ec1..0c552ae 100644 --- a/tests/build/root.build +++ b/tests/build/root.build @@ -10,7 +10,7 @@ using cxx # Setup the bpkg that we are testing. # import bpkg = bpkg%exe{bpkg} -test{*}: test = $bpkg +testscript{*}: test = $bpkg # Specify the test target for cross-testing. # diff --git a/tests/buildfile b/tests/buildfile index 0990548..9fa6a8b 100644 --- a/tests/buildfile +++ b/tests/buildfile @@ -3,7 +3,7 @@ # license : MIT; see accompanying LICENSE file define common: file -common{*}: extension = test +common{*}: extension = testscript commons = common config auth remote \ remote-git rep-fetch-git rep-fetch-git-refname rep-fetch-git-commit @@ -11,4 +11,4 @@ commons = common config auth remote \ # The common/ directory contains repositories that are reused, being symlinked # in source repositories specific for testscripts. # -./: test{* -{$commons}} common{$commons} {*/ -build/ -test/}{**} $bpkg +./: testscript{* -{$commons}} common{$commons} {*/ -build/ -test/}{**} $bpkg diff --git a/tests/cfg-create.test b/tests/cfg-create.test deleted file mode 100644 index 5466a6e..0000000 --- a/tests/cfg-create.test +++ /dev/null @@ -1,75 +0,0 @@ -# file : tests/cfg-create.test -# copyright : Copyright (c) 2014-2018 Code Synthesis Ltd -# license : MIT; see accompanying LICENSE file - -.include common.test - -pkg_status += -d cfg - -: non-empty -: -$* 2>>/~%EOE% != 0 -error: directory ./ is not empty - info: use --wipe to clean it up but be careful -EOE - -: dir -: -{ - test.arguments += -d cfg - test.cleanups += &cfg/*** - - : no-vars-mods - : - { - $* 2>>/~%EOE%; - %created new configuration in .+/cfg/% - EOE - - $pkg_status libfoo >'libfoo unknown' - } - - : conf-var - : - { - $* "config.install.root=$~/opt" 2>>/~%EOE%; - %created new configuration in .+/cfg/% - EOE - - $pkg_status libfoo >'libfoo unknown'; - - cat cfg/build/config.build >>/~"%EOO%" - %.+ - %config.install.root = '?.+/opt/'?% - %.+ - EOO - } - - : module - : - { - $* cxx "config.cxx=$config.cxx" 2>>/~%EOE%; - %created new configuration in .+/cfg/% - EOE - - $pkg_status libfoo >'libfoo unknown'; - - cat cfg/build/config.build >>/~"%EOO%" - %.+ - %config.cxx = .+% - %.+ - EOO - } - - : wipe - : - { - mkdir -p cfg/foo/bar &!cfg/ &!cfg/foo/ &!cfg/foo/bar/; - - $* --wipe 2>>/~%EOE%; - %created new configuration in .+/cfg/% - EOE - - $pkg_status libfoo >'libfoo unknown' - } -} diff --git a/tests/cfg-create.testscript b/tests/cfg-create.testscript new file mode 100644 index 0000000..d5e58e0 --- /dev/null +++ b/tests/cfg-create.testscript @@ -0,0 +1,75 @@ +# file : tests/cfg-create.testscript +# copyright : Copyright (c) 2014-2018 Code Synthesis Ltd +# license : MIT; see accompanying LICENSE file + +.include common.testscript + +pkg_status += -d cfg + +: non-empty +: +$* 2>>/~%EOE% != 0 +error: directory ./ is not empty + info: use --wipe to clean it up but be careful +EOE + +: dir +: +{ + test.arguments += -d cfg + test.cleanups += &cfg/*** + + : no-vars-mods + : + { + $* 2>>/~%EOE%; + %created new configuration in .+/cfg/% + EOE + + $pkg_status libfoo >'libfoo unknown' + } + + : conf-var + : + { + $* "config.install.root=$~/opt" 2>>/~%EOE%; + %created new configuration in .+/cfg/% + EOE + + $pkg_status libfoo >'libfoo unknown'; + + cat cfg/build/config.build >>/~"%EOO%" + %.+ + %config.install.root = '?.+/opt/'?% + %.+ + EOO + } + + : module + : + { + $* cxx "config.cxx=$config.cxx" 2>>/~%EOE%; + %created new configuration in .+/cfg/% + EOE + + $pkg_status libfoo >'libfoo unknown'; + + cat cfg/build/config.build >>/~"%EOO%" + %.+ + %config.cxx = .+% + %.+ + EOO + } + + : wipe + : + { + mkdir -p cfg/foo/bar &!cfg/ &!cfg/foo/ &!cfg/foo/bar/; + + $* --wipe 2>>/~%EOE%; + %created new configuration in .+/cfg/% + EOE + + $pkg_status libfoo >'libfoo unknown' + } +} diff --git a/tests/common.test b/tests/common.test deleted file mode 100644 index ebf0b43..0000000 --- a/tests/common.test +++ /dev/null @@ -1,50 +0,0 @@ -# file : tests/common.test -# copyright : Copyright (c) 2014-2018 Code Synthesis Ltd -# license : MIT; see accompanying LICENSE file - -# Commonly-used variables setup and driver command line. -# - -# Use the same build system driver as the one running the tests (as opposed -# to one that may or may not be found via PATH). -# -build = $recall($build.path) -test.options += --build $build - -# Helper commands that can be used by tests to prepare the testing environment -# or validate an outcome of the command being tested. They are likely to get -# additional options and redirects appended prior to use. A common approach -# will be to redirect output to the null device for commands that are used for -# test setup, and to match it for commands being tested or performing teardown -# (for example, to make sure that configuration post-test state is valid and is -# as expected). -# -cfg_create = $* cfg-create -pkg_build = $* pkg-build -pkg_checkout = $* pkg-checkout -pkg_configure = $* pkg-configure -pkg_disfigure = $* pkg-disfigure -pkg_drop = $* pkg-drop -pkg_fetch = $* pkg-fetch -pkg_purge = $* pkg-purge -pkg_status = $* pkg-status -pkg_unpack = $* pkg-unpack -pkg_update = $* pkg-update -rep_add = $* rep-add -rep_create = $* rep-create -rep_fetch = $* rep-fetch -rep_info = $* rep-info -rep_list = $* rep-list -rep_remove = $* rep-remove - -# All testscripts are named after bpkg commands, for example pkg-verify.test. -# So the testscript scope id is a name of the command being tested. -# -cmd = [string] $@ -test.arguments = $cmd - -# Each testscript has an associated repository source directory. Its -# subdirectories are copied by tests to manipulate locally and throw away upon -# completion. -# -src = [dir_path] "$src_base/$@" diff --git a/tests/common.testscript b/tests/common.testscript new file mode 100644 index 0000000..b9739fd --- /dev/null +++ b/tests/common.testscript @@ -0,0 +1,51 @@ +# file : tests/common.testscript +# copyright : Copyright (c) 2014-2018 Code Synthesis Ltd +# license : MIT; see accompanying LICENSE file + +# Commonly-used variables setup and driver command line. +# + +# Use the same build system driver as the one running the tests (as opposed +# to one that may or may not be found via PATH). +# +build = $recall($build.path) +test.options += --build $build + +# Helper commands that can be used by tests to prepare the testing environment +# or validate an outcome of the command being tested. They are likely to get +# additional options and redirects appended prior to use. A common approach +# will be to redirect output to the null device for commands that are used for +# test setup, and to match it for commands being tested or performing teardown +# (for example, to make sure that configuration post-test state is valid and is +# as expected). +# +cfg_create = $* cfg-create +pkg_build = $* pkg-build +pkg_checkout = $* pkg-checkout +pkg_configure = $* pkg-configure +pkg_disfigure = $* pkg-disfigure +pkg_drop = $* pkg-drop +pkg_fetch = $* pkg-fetch +pkg_purge = $* pkg-purge +pkg_status = $* pkg-status +pkg_unpack = $* pkg-unpack +pkg_update = $* pkg-update +rep_add = $* rep-add +rep_create = $* rep-create +rep_fetch = $* rep-fetch +rep_info = $* rep-info +rep_list = $* rep-list +rep_remove = $* rep-remove + +# All testscripts are named after bpkg commands, for example +# pkg-verify.testscript. So the testscript scope id is a name of the command +# being tested. +# +cmd = [string] $@ +test.arguments = $cmd + +# Each testscript has an associated repository source directory. Its +# subdirectories are copied by tests to manipulate locally and throw away upon +# completion. +# +src = [dir_path] "$src_base/$@" diff --git a/tests/config.test b/tests/config.test deleted file mode 100644 index cd5eb12..0000000 --- a/tests/config.test +++ /dev/null @@ -1,27 +0,0 @@ -# file : tests/config.test -# copyright : Copyright (c) 2014-2018 Code Synthesis Ltd -# license : MIT; see accompanying LICENSE file - -# Create an empty configuration that will be copied by subsequent tests and -# scopes setup commands. The common approach will be that group scopes copy and -# modify the parent scope configuration as required by the nested tests and -# scopes. Tests will also clone the parent scope configuration to optionally -# modify it, use and cleanup at the end. Note that configuration can not be -# shared between multiple bpkg processes. Also we need to make sure that -# configurations are not cloned while being used by bpkg. -# -+$cfg_create -d cfg 2>- &cfg/*** - -# The most commonly used configuration cloning command that copies it from the -# parent scope working directory. -# -clone_cfg = cp -p -r ../cfg ./ - -# Clones the original (presumably empty) configuration from the root scope -# working directory. -# -clone_root_cfg = cp -p -r $~/cfg ./ - -# Setup a test command to use a cloned configuration directory by default. -# -test.arguments += -d cfg diff --git a/tests/config.testscript b/tests/config.testscript new file mode 100644 index 0000000..bf81799 --- /dev/null +++ b/tests/config.testscript @@ -0,0 +1,27 @@ +# file : tests/config.testscript +# copyright : Copyright (c) 2014-2018 Code Synthesis Ltd +# license : MIT; see accompanying LICENSE file + +# Create an empty configuration that will be copied by subsequent tests and +# scopes setup commands. The common approach will be that group scopes copy and +# modify the parent scope configuration as required by the nested tests and +# scopes. Tests will also clone the parent scope configuration to optionally +# modify it, use and cleanup at the end. Note that configuration can not be +# shared between multiple bpkg processes. Also we need to make sure that +# configurations are not cloned while being used by bpkg. +# ++$cfg_create -d cfg 2>- &cfg/*** + +# The most commonly used configuration cloning command that copies it from the +# parent scope working directory. +# +clone_cfg = cp -p -r ../cfg ./ + +# Clones the original (presumably empty) configuration from the root scope +# working directory. +# +clone_root_cfg = cp -p -r $~/cfg ./ + +# Setup a test command to use a cloned configuration directory by default. +# +test.arguments += -d cfg diff --git a/tests/pkg-build.test b/tests/pkg-build.test deleted file mode 100644 index d120d0c..0000000 --- a/tests/pkg-build.test +++ /dev/null @@ -1,3470 +0,0 @@ -# file : tests/pkg-build.test -# copyright : Copyright (c) 2014-2018 Code Synthesis Ltd -# license : MIT; see accompanying LICENSE file - -.include common.test config.test remote.test remote-git.test - -# Source repository: -# -# pkg-build -# |-- libbar-1.0.0.tar.gz -# |-- libbaz-1.1.0.tar.gz -# |-- libfix-0.0.1.tar.gz -# |-- libfoo-0.0.1.tar.gz -> libfix -# |-- libfoo-1.0.0.tar.gz -# | -# |-- libfoo-1.1.0 -# | |-- build -# | | `-- bootstrap.build -# | |-- buildfile -# | `-- manifest -# | -# |-- libfoo-1.1.0.tar.gz -# |-- libfoo-1.2.0.tar.gz -# | -# |-- t0a -# | |-- libbar-0.0.1.tar.gz -> libbaz == 0.0.1 -# | |-- libbaz-0.0.1.tar.gz -> libfox -# | |-- libbaz-0.0.3.tar.gz -> libfoo -# | |-- libbox-0.0.1.tar.gz -> libbaz -# | |-- libfix-0.0.1.tar.gz -# | |-- libfoo-0.0.1.tar.gz -> libfix -# | |-- libfox-0.0.1.tar.gz -# | `-- repositories.manifest -# | -# |-- t0b -# | |-- libbar-0.0.2.tar.gz -> libbaz <= 0.0.2 -# | |-- libbaz-0.0.2.tar.gz -> libfoo -# | |-- libbiz-0.0.2.tar.gz -> libbaz <= 0.0.3 -# | |-- libfoo-1.0.0.tar.gz -# | `-- repositories.manifest -# | -# |-- t0c -# | |-- libbar-0.0.3.tar.gz -> libbaz -# | |-- libbar-1.0.0.tar.gz -> libfoo -# | |-- libbaz-0.0.3.tar.gz -> libfoo -# | |-- libbaz-0.0.4.tar.gz -# | |-- libbaz-0.1.0.tar.gz -# | |-- libbox-0.0.1.tar.gz -> libbaz -# | |-- libfix-0.0.3.tar.gz -> libbaz >= 0.0.3 -# | |-- libfoo-1.0.0.tar.gz -# | `-- repositories.manifest -# | -# |-- t0d -# | |-- libbiz-0.0.1.tar.gz -> libbox, libfox -# | |-- libbox-0.0.2.tar.gz -> libfoo == 1.0.0 -# | |-- libfix-0.0.1.tar.gz -# | |-- libfox-0.0.2.tar.gz -> libfoo == 0.0.1 -# | |-- libfoo-0.0.1.tar.gz -> libfix -# | |-- libfoo-1.0.0.tar.gz -# | |-- libfox-0.0.1.tar.gz -# | `-- repositories.manifest -# | -# |-- t1 -# | |-- libfoo-1.0.0.tar.gz -# | `-- repositories.manifest -# | -# |-- t2 -# | |-- libbar-1.0.0.tar.gz -> libfoo -# | |-- libfoo-1.0.0.tar.gz -# | `-- repositories.manifest -# | -# |-- t3 -> t2 (prerequisite repository) -# | |-- libbaz-1.0.0.tar.gz -> libbar -# | |-- libfox-1.0.0.tar.gz -# | `-- repositories.manifest -# | -# |-- 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 repository) -# | |-- libbiz-1.0.0.tar.gz -> libfox, libfoo, libbaz -# | |-- libfox-1.0.0.tar.gz -# | `-- repositories.manifest -# | -# |-- t5 -# | |-- libbar-1.2.0.tar.gz -# | `-- repositories.manifest -# | -# |-- t6 -# | |-- libBar-2.0.0.tar.gz -# | `-- repositories.manifest -# | -# |-- libhello-1.0.0 -# | |-- build -# | | |-- bootstrap.build -# | | |-- export.build -# | | `-- root.build -# | `-- * -# | -# `-- git -# |-- libbar.git -> style-basic.git (prerequisite repository) -# |-- libbaz.git -# `-- style-basic.git - -# Prepare repositories used by tests if running in the local mode. -# -+if ($remote != true) - rep_create += 2>! - - cp -r $src/t0a $out/t0a && $rep_create $out/t0a &$out/t0a/packages.manifest - cp -r $src/t0b $out/t0b && $rep_create $out/t0b &$out/t0b/packages.manifest - cp -r $src/t0c $out/t0c && $rep_create $out/t0c &$out/t0c/packages.manifest - cp -r $src/t0d $out/t0d && $rep_create $out/t0d &$out/t0d/packages.manifest - cp -r $src/t1 $out/t1 && $rep_create $out/t1 &$out/t1/packages.manifest - cp -r $src/t2 $out/t2 && $rep_create $out/t2 &$out/t2/packages.manifest - cp -r $src/t3 $out/t3 && $rep_create $out/t3 &$out/t3/packages.manifest - cp -r $src/t4a $out/t4a && $rep_create $out/t4a &$out/t4a/packages.manifest - cp -r $src/t4b $out/t4b && $rep_create $out/t4b &$out/t4b/packages.manifest - 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/t5 $out/t5 && $rep_create $out/t5 &$out/t5/packages.manifest - cp -r $src/t6 $out/t6 && $rep_create $out/t6 &$out/t6/packages.manifest - - # Create git repositories. - # - $git_extract $src/git/style-basic.tar - $git_extract $src/git/libbar.tar &$out_git/state0/*** - $git_extract $src/git/libbaz.tar &$out_git/state1/*** -end - -pkg_configure += -d cfg "config.cxx=$config.cxx" 2>! -pkg_disfigure += -d cfg -pkg_drop += -d cfg --yes 2>! -pkg_fetch += -d cfg 2>! -pkg_purge += -d cfg -pkg_status += -d cfg -pkg_unpack += -d cfg 2>! -rep_add += -d cfg 2>! -rep_remove += -d cfg 2>! -rep_fetch += -d cfg --auth all --trust-yes 2>! - -: libfoo -: -: Test building different versions of libfoo. -: -{ - test.arguments += --print-only - - : no-name - : - $clone_root_cfg; - $* 2>>EOE != 0 - error: package name argument expected - info: run 'bpkg help pkg-build' for more information - EOE - - : unknown-package - : - $clone_root_cfg; - $* libfoo 2>>/EOE != 0 - error: unknown package libfoo - info: configuration cfg/ has no repositories - info: use 'bpkg rep-add' to add a repository - EOE - - : unknown-package-ver - : - $clone_root_cfg; - $* libfoo/1.0.0 2>>/EOE != 0 - error: unknown package libfoo - info: configuration cfg/ has no repositories - info: use 'bpkg rep-add' to add a repository - EOE - - : archive - : - $clone_root_cfg; - $* $src/libfoo-1.1.0.tar.gz >'new libfoo/1.1.0' - - : dir - : - $clone_root_cfg; - $* $src/libfoo-1.1.0/ >'new libfoo/1.1.0' - - : unpacked-dir - : - { - $clone_root_cfg && $pkg_unpack -e $src/libfoo-1.1.0; - - $* libfoo >'update libfoo/1.1.0'; - $* libfoo/1.1.0 >'update libfoo/1.1.0'; - $* libfoo libfoo >'update libfoo/1.1.0'; - - $* libfoo libfoo/1.1.0 2>>EOE != 0; - error: duplicate package libfoo - info: first mentioned as libfoo - info: second mentioned as libfoo/1.1.0 - EOE - - $* libfoo/1.1.0 libfoo 2>>EOE != 0; - error: duplicate package libfoo - info: first mentioned as libfoo/1.1.0 - info: second mentioned as libfoo - EOE - - $* libfoo/1.1.0 libfoo/1.1.0 >'update libfoo/1.1.0'; - - $* libfoo/1.0.0 2>>/EOE != 0; - error: unknown package libfoo - info: configuration cfg/ has no repositories - info: use 'bpkg rep-add' to add a repository - EOE - - $pkg_purge libfoo 2>'purged libfoo/1.1.0' - } - - : t1 - : - { - +$clone_root_cfg && $rep_add $rep/t1 && $rep_fetch - - : downgrade - : - { - $clone_cfg && $pkg_unpack -e $src/libfoo-1.1.0; - - $* libfoo >'update libfoo/1.1.0'; - $* libfoo/1.0.0 >'downgrade libfoo/1.0.0'; - - $* libfoo/0.0.1 2>>EOE != 0; - error: libfoo/0.0.1 is not available in source - info: specify sys:libfoo/0.0.1 if it is available from the system - EOE - - $pkg_purge libfoo 2>'purged libfoo/1.1.0' - } - - : upgrade - : - { - $clone_cfg; - $pkg_fetch -e $src/libfoo-0.0.1.tar.gz && $pkg_unpack libfoo; - $pkg_fetch -e $src/libfix-0.0.1.tar.gz && $pkg_unpack libfix; - - $* libfoo >'upgrade libfoo/1.0.0'; - - $* libfoo/0.0.1 >>EOE; - update libfix/0.0.1 (required by libfoo) - update libfoo/0.0.1 - EOE - - $* libfoo/1.1.0 2>>EOE != 0; - error: libfoo/1.1.0 is not available in source - info: specify sys:libfoo/1.1.0 if it is available from the system - EOE - - $pkg_purge libfoo 2>'purged libfoo/0.0.1'; - $pkg_purge libfix 2>'purged libfix/0.0.1' - } - - : upgrade-failure - : - { - $clone_cfg; - - $* libfoo >'new libfoo/1.0.0'; - $* libfoo/1.0.0 >'new libfoo/1.0.0'; - - $* libfoo/1.1.0 2>>EOE != 0 - error: libfoo/1.1.0 is not available in source - info: specify sys:libfoo/1.1.0 if it is available from the system - EOE - } - } -} - -: libbar-libfoo -: -: Test building libbar that depends on libfoo. -: -{ - test.arguments += --print-only - - : unknown-dependency - : - $clone_root_cfg; - $* $src/libbar-1.0.0.tar.gz 2>>EOE != 0 - error: unknown dependency libfoo of package libbar - info: while satisfying libbar/1.0.0 - EOE - - : t2 - : - { - +$clone_root_cfg && $rep_add $rep/t2 && $rep_fetch - - : build-dependency - : - { - $clone_cfg; - - $* libbar >>EOO; - new libfoo/1.0.0 (required by libbar) - new libbar/1.0.0 - EOO - - $* libbar libfoo >>EOO; - new libfoo/1.0.0 - new libbar/1.0.0 - EOO - - $* libbar libfoo/1.0.0 >>EOO; - new libfoo/1.0.0 - new libbar/1.0.0 - EOO - - $* libbar libfoo libbar/1.0.0 2>>EOE != 0; - error: duplicate package libbar - info: first mentioned as libbar - info: second mentioned as libbar/1.0.0 - EOE - - $* libbar libfoo/1.1.0 2>>EOE != 0 - error: libfoo/1.1.0 is not available in source - info: specify sys:libfoo/1.1.0 if it is available from the system - EOE - } - - : upgrade-dependency - : - { - $clone_cfg; - $pkg_fetch -e $src/libfoo-0.0.1.tar.gz && $pkg_unpack libfoo; - $pkg_fetch -e $src/libfix-0.0.1.tar.gz && $pkg_unpack libfix; - - $* libbar >>EOO; - update libfix/0.0.1 (required by libfoo) - update libfoo/0.0.1 (required by libbar) - new libbar/1.0.0 - EOO - - $* libbar libfoo >>EOO; - upgrade libfoo/1.0.0 - new libbar/1.0.0 - EOO - - $* libbar libfoo/0.0.1 >>EOO; - update libfix/0.0.1 (required by libfoo) - update libfoo/0.0.1 - new libbar/1.0.0 - EOO - - $pkg_purge libfoo 2>'purged libfoo/0.0.1'; - $pkg_purge libfix 2>'purged libfix/0.0.1' - } - - : downgrade-dependency - : - { - $clone_cfg && $pkg_unpack -e $src/libfoo-1.1.0; - - $* libbar >>EOO; - update libfoo/1.1.0 (required by libbar) - new libbar/1.0.0 - EOO - - $* libbar libfoo >>EOO; - update libfoo/1.1.0 - new libbar/1.0.0 - EOO - - $* libbar libfoo/1.0.0 >>EOO; - downgrade libfoo/1.0.0 - new libbar/1.0.0 - EOO - - $pkg_purge libfoo 2>'purged libfoo/1.1.0' - } - } -} - -: libbaz-libbar -: -: Test building libbaz that depends on libbar; libbar is in prerequisite -: repository. -: -{ - test.arguments += --print-only - - : t3 - : - { - +$clone_root_cfg && $rep_add $rep/t3 && $rep_fetch - - : prerequisites-build-failure - : - : Fail to build packages that are only in prerequisite repository. - : - { - $clone_cfg; - - $* libfoo 2>>EOE != 0; - error: unknown package libfoo - EOE - - $* libbar 2>>EOE != 0; - error: unknown package libbar - EOE - - $* libbaz libbar 2>>EOE != 0 - error: unknown package libbar - EOE - } - - : prerequisites-build - : - $clone_cfg; - $* libbaz >>EOO - new libfoo/1.0.0 (required by libbar) - new libbar/1.0.0 (required by libbaz) - new libbaz/1.0.0 - EOO - - : different-build-order - : - { - +$clone_cfg && $rep_add $rep/t2 && $rep_fetch - - : fox-foo - : - $clone_cfg; - $* libfox libfoo >>EOO - new libfox/1.0.0 - new libfoo/1.0.0 - EOO - - : foo-fox - : - $clone_cfg; - $* libfoo libfox >>EOO - new libfoo/1.0.0 - new libfox/1.0.0 - EOO - - : baz-foo - : - $clone_cfg; - $* libbaz libfoo >>EOO - new libfoo/1.0.0 - new libbar/1.0.0 (required by libbaz) - new libbaz/1.0.0 - EOO - - : foo-baz - : - $clone_cfg; - $* libfoo libbaz >>EOO - new libfoo/1.0.0 - new libbar/1.0.0 (required by libbaz) - new libbaz/1.0.0 - EOO - - : baz-fox - : - $clone_cfg; - $* libbaz libfox >>EOO - new libfoo/1.0.0 (required by libbar) - new libbar/1.0.0 (required by libbaz) - new libbaz/1.0.0 - new libfox/1.0.0 - EOO - - : fox-baz - : - $clone_cfg; - $* libfox libbaz >>EOO - new libfox/1.0.0 - new libfoo/1.0.0 (required by libbar) - new libbar/1.0.0 (required by libbaz) - new libbaz/1.0.0 - EOO - - : fox-foo-baz - : - $clone_cfg; - $* libfox libfoo libbaz >>EOO - new libfox/1.0.0 - new libfoo/1.0.0 - new libbar/1.0.0 (required by libbaz) - new libbaz/1.0.0 - EOO - - : fox-baz-foo - : - $clone_cfg; - $* libfox libbaz libfoo >>EOO - new libfox/1.0.0 - new libfoo/1.0.0 - new libbar/1.0.0 (required by libbaz) - new libbaz/1.0.0 - EOO - - : foo-fox-baz - : - $clone_cfg; - $* libfoo libfox libbaz >>EOO - new libfoo/1.0.0 - new libfox/1.0.0 - new libbar/1.0.0 (required by libbaz) - new libbaz/1.0.0 - EOO - - : foo-baz-fox - : - $clone_cfg; - $* libfoo libbaz libfox >>EOO - new libfoo/1.0.0 - new libbar/1.0.0 (required by libbaz) - new libbaz/1.0.0 - new libfox/1.0.0 - EOO - - : baz-fox-foo - : - : This one is contradictory: baz before fox but fox before foo. - : - $clone_cfg; - $* libbaz libfox libfoo >>EOO - new libfox/1.0.0 - new libfoo/1.0.0 - new libbar/1.0.0 (required by libbaz) - new libbaz/1.0.0 - EOO - - : baz-foo-fox - : - $clone_cfg; - $* libbaz libfoo libfox >>EOO - new libfoo/1.0.0 - new libbar/1.0.0 (required by libbaz) - new libbaz/1.0.0 - new libfox/1.0.0 - EOO - - : baz-foo-bar - : - $clone_cfg; - $* libbaz libfoo libbar >>EOO - new libfoo/1.0.0 - new libbar/1.0.0 - new libbaz/1.0.0 - EOO - - : baz-bar-foo - : - $clone_cfg; - $* libbaz libbar libfoo >>EOO - new libfoo/1.0.0 - new libbar/1.0.0 - new libbaz/1.0.0 - EOO - } - } -} - -: libbaz-libfoo-libbar -: -: Test building libbaz that depends on libfoo and libbar; libbar depends on -: libfoo == 1.1.0. -: -{ - test.arguments += --print-only - - : t4c - : - { - +$clone_root_cfg && $rep_add $rep/t4c && $rep_fetch - - : baz - : - $clone_cfg; - $* libbaz >>EOO - new libfoo/1.1.0 (required by libbar libbaz) - new libbar/1.1.0 (required by libbaz) - new libbaz/1.1.0 - EOO - - : foo-baz - : - $clone_cfg; - $* libfoo libbaz >>EOO - new libfoo/1.1.0 - new libbar/1.1.0 (required by libbaz) - new libbaz/1.1.0 - EOO - - : unable-satisfy - : - $clone_cfg; - $* libfoo/1.0.0 libbaz 2>>EOE != 0 - error: unable to satisfy constraints on package libfoo - info: libbar depends on (libfoo == 1.1.0) - info: command line depends on (libfoo == 1.0.0) - info: available libfoo/1.1.0 - info: available libfoo/1.0.0 - info: explicitly specify libfoo version to manually satisfy both constraints - info: while satisfying libbar/1.1.0 - info: while satisfying libbaz/1.1.0 - EOE - - : not-available - : - $clone_cfg; - $* libfoo/1.1.0 libbaz 2>>EOE != 0 - error: libfoo/1.1.0 is not available in source - info: specify sys:libfoo/1.1.0 if it is available from the system - EOE - - : upgrade-warning - : - { - $clone_cfg; - $pkg_fetch -e $src/libfoo-0.0.1.tar.gz && $pkg_unpack libfoo; - $pkg_fetch -e $src/libfix-0.0.1.tar.gz && $pkg_unpack libfix; - - $* libbaz >>EOO 2>>EOE; - upgrade libfoo/1.1.0 (required by libbar libbaz) - new libbar/1.1.0 (required by libbaz) - new libbaz/1.1.0 - EOO - warning: package libbar dependency on (libfoo == 1.1.0) is forcing upgrade of libfoo/0.0.1 to 1.1.0 - EOE - - $pkg_purge libfoo 2>'purged libfoo/0.0.1'; - $pkg_purge libfix 2>'purged libfix/0.0.1' - } - - : downgrade-error - : - { - $clone_cfg; - $pkg_fetch -e $src/libfoo-1.2.0.tar.gz && $pkg_unpack libfoo; - - $* libbaz 2>>EOE != 0; - error: package libbar dependency on (libfoo == 1.1.0) is forcing downgrade of libfoo/1.2.0 to 1.1.0 - info: explicitly request version downgrade to continue - info: while satisfying libbar/1.1.0 - info: while satisfying libbaz/1.1.0 - EOE - - $rep_add $rep/t4a && $rep_fetch; - - $* libfoo/1.1.0 libbaz >>EOO; - downgrade libfoo/1.1.0 - new libbar/1.1.0 (required by libbaz) - new libbaz/1.1.0 - EOO - - $pkg_purge libfoo 2>'purged libfoo/1.2.0' - } - - : unable-downgrade - : - : Test that dependent prevents up/downgrade that would break dependency - : constraints. - : - { - $clone_cfg; - $pkg_fetch libfoo/1.1.0 && $pkg_unpack libfoo && $pkg_configure libfoo; - $pkg_fetch libbar/1.1.0 && $pkg_unpack libbar && $pkg_configure libbar; - - $* libfoo-1.2.0.tar.gz 2>>EOE != 0; - error: unknown package libfoo-1.2.0.tar.gz - EOE - - $* libfoo/1.0.0 2>>EOE != 0; - error: unable to downgrade package libfoo/1.1.0 to 1.0.0 - info: because package libbar depends on (libfoo == 1.1.0) - info: explicitly request up/downgrade of package libbar - info: or explicitly specify package libfoo version to manually satisfy these constraints - EOE - - $* libfoo/1.1.0 --keep-unused >'update libfoo/1.1.0'; - - $pkg_disfigure libbar 2>'disfigured libbar/1.1.0'; - $pkg_purge libbar 2>'purged libbar/1.1.0'; - - $pkg_disfigure libfoo 2>'disfigured libfoo/1.1.0'; - $pkg_purge libfoo 2>'purged libfoo/1.1.0' - } - } - - : dependent-reconfiguration - : - { - test.arguments += --keep-unused - - +$clone_root_cfg - - +$pkg_fetch -e $src/libfoo-1.0.0.tar.gz && $pkg_unpack libfoo - +$pkg_configure libfoo - - +$pkg_fetch -e $src/libbar-1.0.0.tar.gz && $pkg_unpack libbar - +$pkg_configure libbar - - +$pkg_fetch -e $src/libbaz-1.1.0.tar.gz && $pkg_unpack libbaz - +$pkg_configure libbaz - - +$rep_add $rep/t4a && $rep_add $rep/t4b && $rep_fetch - - : bar - : - : Only libbar/1.1.0 (that we are upgrading to) requires libfoo/1.1.0. - : libbaz, that depends on libfoo and libbar, is happy with any version of - : its dependencies. - : - $clone_cfg; - $* libbar >>EOO 2>>EOE - upgrade libfoo/1.1.0 (required by libbar) - upgrade libbar/1.1.0 - reconfigure libbaz (dependent of libbar libfoo) - EOO - warning: package libbar dependency on (libfoo == 1.1.0) is forcing upgrade of libfoo/1.0.0 to 1.1.0 - EOE - - : foo - : - $clone_cfg; - $* libfoo >>EOO - upgrade libfoo/1.1.0 - reconfigure libbar (dependent of libfoo) - reconfigure libbaz (dependent of libbar libfoo) - EOO - - : foo-bar - : - $clone_cfg; - $* libfoo libbar/1.0.0 >>EOO - upgrade libfoo/1.1.0 - reconfigure/update libbar/1.0.0 - reconfigure libbaz (dependent of libbar libfoo) - EOO - - : bar-foo - : - $clone_cfg; - $* libbar/1.0.0 libfoo >>EOO - upgrade libfoo/1.1.0 - reconfigure/update libbar/1.0.0 - reconfigure libbaz (dependent of libbar libfoo) - EOO - - : baz-foo - : - $clone_cfg; - $* libbaz libfoo >>EOO - upgrade libfoo/1.1.0 - reconfigure libbar (dependent of libfoo) - reconfigure/update libbaz/1.1.0 - EOO - - : baz-foo-1.0.0 - : - $clone_cfg; - $* libbaz libfoo/1.0.0 >>EOO - update libfoo/1.0.0 - update libbaz/1.1.0 - EOO - - -$pkg_disfigure libbaz 2>'disfigured libbaz/1.1.0' - -$pkg_purge libbaz 2>'purged libbaz/1.1.0' - - -$pkg_disfigure libbar 2>'disfigured libbar/1.0.0' - -$pkg_purge libbar 2>'purged libbar/1.0.0' - - -$pkg_disfigure libfoo 2>'disfigured libfoo/1.0.0' - -$pkg_purge libfoo 2>'purged libfoo/1.0.0' - } -} - -# Note that when we fetch a package from remote repository the bpkg stderr -# contains fetch program progress output, that comes prior the informational -# message. -# - -: actual-build -: -{ - test.arguments += --yes - - : with-dependencies - : - { - $clone_root_cfg && $rep_add $rep/t4c && $rep_fetch; - - $* libbaz 2>>~%EOE%; - %.* - %.*fetched libfoo/1.1.0% - unpacked libfoo/1.1.0 - configured libfoo/1.1.0 - %.* - %.*fetched libbar/1.1.0% - unpacked libbar/1.1.0 - configured libbar/1.1.0 - %.* - %.*fetched libbaz/1.1.0% - unpacked libbaz/1.1.0 - configured libbaz/1.1.0 - %info: .+ is up to date% - updated libbaz/1.1.0 - EOE - - $pkg_status libfoo/1.1.0 >'libfoo configured 1.1.0'; - $pkg_status libbar/1.1.0 >'libbar configured 1.1.0'; - $pkg_status libbaz/1.1.0 >'!libbaz configured 1.1.0'; - - $pkg_disfigure libbaz 2>'disfigured libbaz/1.1.0'; - $pkg_purge libbaz 2>'purged libbaz/1.1.0'; - - $pkg_disfigure libbar 2>'disfigured libbar/1.1.0'; - $pkg_purge libbar 2>'purged libbar/1.1.0'; - - $pkg_disfigure libfoo 2>'disfigured libfoo/1.1.0'; - $pkg_purge libfoo 2>'purged libfoo/1.1.0' - } - - : hold-fs-fetched - : - { - : direct - : - { - $clone_root_cfg; - - $* $src/libfoo-1.0.0.tar.gz 2>>~%EOE%; - fetched libfoo/1.0.0 - unpacked libfoo/1.0.0 - configured libfoo/1.0.0 - %info: .+ is up to date% - updated libfoo/1.0.0 - EOE - - $pkg_status libfoo >'!libfoo configured !1.0.0'; - - $* $src/libfoo-1.1.0/ 2>>~%EOE%; - disfigured libfoo/1.0.0 - using libfoo/1.1.0 (external) - configured libfoo/1.1.0 - %info: .+ is up to date% - updated libfoo/1.1.0 - EOE - - $pkg_status libfoo >'!libfoo configured !1.1.0'; - - $pkg_disfigure libfoo 2>'disfigured libfoo/1.1.0'; - $pkg_purge libfoo 2>'purged libfoo/1.1.0' - } - - : pre-fetch - : - { - $clone_root_cfg; - $pkg_fetch -e $src/libfoo-1.0.0.tar.gz && $pkg_unpack libfoo; - $pkg_configure libfoo; - - $pkg_status libfoo >'libfoo configured 1.0.0'; - - $* libfoo 2>>~%EOE%; - %info: .+ is up to date% - updated libfoo/1.0.0 - EOE - - $pkg_status libfoo >'!libfoo configured 1.0.0'; - - $pkg_disfigure libfoo 2>'disfigured libfoo/1.0.0'; - $pkg_purge libfoo 2>'purged libfoo/1.0.0' - } - } - - : hold-repo-fetched - : - { - +$clone_root_cfg && $rep_add $rep/t4c && $rep_fetch - - : package-version - : - { - $clone_cfg; - - $* libfoo 2>>~%EOE%; - %.* - %.*fetched libfoo/1.0.0% - unpacked libfoo/1.0.0 - configured libfoo/1.0.0 - %info: .+ is up to date% - updated libfoo/1.0.0 - EOE - - $pkg_status libfoo >'!libfoo configured 1.0.0 available [1.1.0]'; - - $* libfoo/1.0.0 2>>~%EOE%; - %info: .+ is up to date% - updated libfoo/1.0.0 - EOE - - $pkg_status libfoo >'!libfoo configured !1.0.0 available [1.1.0]'; - - $pkg_disfigure libfoo 2>'disfigured libfoo/1.0.0'; - $pkg_purge libfoo 2>'purged libfoo/1.0.0' - } - - : version - : - { - $clone_cfg; - - $* libfoo/1.0.0 2>>~%EOE%; - %.* - %.*fetched libfoo/1.0.0% - unpacked libfoo/1.0.0 - configured libfoo/1.0.0 - %info: .+ is up to date% - updated libfoo/1.0.0 - EOE - - $pkg_status libfoo >'!libfoo configured !1.0.0 available [1.1.0]'; - - $pkg_disfigure libfoo 2>'disfigured libfoo/1.0.0'; - $pkg_purge libfoo 2>'purged libfoo/1.0.0' - } - - : not-held - : - { - $clone_cfg; - - $* libbaz 2>>~%EOE%; - %.* - %.*fetched libfoo/1.1.0% - unpacked libfoo/1.1.0 - configured libfoo/1.1.0 - %.* - %.*fetched libbar/1.1.0% - unpacked libbar/1.1.0 - configured libbar/1.1.0 - %.* - %.*fetched libbaz/1.1.0% - unpacked libbaz/1.1.0 - configured libbaz/1.1.0 - %info: .+ is up to date% - updated libbaz/1.1.0 - EOE - - $pkg_status libfoo >'libfoo configured 1.1.0'; - - $pkg_disfigure libbaz 2>'disfigured libbaz/1.1.0'; - $pkg_purge libbaz 2>'purged libbaz/1.1.0'; - - $pkg_disfigure libbar 2>'disfigured libbar/1.1.0'; - $pkg_purge libbar 2>'purged libbar/1.1.0'; - - $pkg_disfigure libfoo 2>'disfigured libfoo/1.1.0'; - $pkg_purge libfoo 2>'purged libfoo/1.1.0' - } - - : forcing-upgrade-unheld - : - { - $clone_cfg; - - $* libfoo 2>>~%EOE%; - %.* - %.*fetched libfoo/1.0.0% - unpacked libfoo/1.0.0 - configured libfoo/1.0.0 - %info: .+ is up to date% - updated libfoo/1.0.0 - EOE - - $pkg_status libfoo >'!libfoo configured 1.0.0 available [1.1.0]'; - - $* libbaz 2>>~%EOE%; - warning: package libbar dependency on (libfoo == 1.1.0) is forcing upgrade of libfoo/1.0.0 to 1.1.0 - disfigured libfoo/1.0.0 - %.* - %.*fetched libfoo/1.1.0% - unpacked libfoo/1.1.0 - configured libfoo/1.1.0 - %.* - %.*fetched libbar/1.1.0% - unpacked libbar/1.1.0 - configured libbar/1.1.0 - %.* - %.*fetched libbaz/1.1.0% - unpacked libbaz/1.1.0 - configured libbaz/1.1.0 - %info: .+ is up to date% - updated libbaz/1.1.0 - EOE - - $pkg_status libfoo >'!libfoo configured 1.1.0'; - - $pkg_disfigure libbaz 2>'disfigured libbaz/1.1.0'; - $pkg_purge libbaz 2>'purged libbaz/1.1.0'; - - $pkg_disfigure libbar 2>'disfigured libbar/1.1.0'; - $pkg_purge libbar 2>'purged libbar/1.1.0'; - - $pkg_disfigure libfoo 2>'disfigured libfoo/1.1.0'; - $pkg_purge libfoo 2>'purged libfoo/1.1.0' - } - - : forcing-upgrade-held - : - { - $clone_cfg; - - $* libfoo/1.0.0 2>>~%EOE%; - %.* - %.*fetched libfoo/1.0.0% - unpacked libfoo/1.0.0 - configured libfoo/1.0.0 - %info: .+ is up to date% - updated libfoo/1.0.0 - EOE - - $pkg_status libfoo >'!libfoo configured !1.0.0 available [1.1.0]'; - - $* libbaz 2>>EOE != 0; - error: package libbar dependency on (libfoo == 1.1.0) is forcing upgrade of libfoo/1.0.0 to 1.1.0 - info: package version libfoo/1.0.0 is held - info: explicitly request version upgrade to continue - info: while satisfying libbar/1.1.0 - info: while satisfying libbaz/1.1.0 - EOE - - $pkg_disfigure libfoo 2>'disfigured libfoo/1.0.0'; - $pkg_purge libfoo 2>'purged libfoo/1.0.0' - } - } - - : drop-dependencies - : - { - $clone_root_cfg && $rep_add $rep/t2 && $rep_fetch; - - $* libbar 2>>~%EOE%; - %.* - %.*fetched libfoo/1.0.0% - unpacked libfoo/1.0.0 - configured libfoo/1.0.0 - %.* - %.*fetched libbar/1.0.0% - unpacked libbar/1.0.0 - configured libbar/1.0.0 - %info: .+ is up to date% - updated libbar/1.0.0 - EOE - - $pkg_status libfoo >'libfoo configured 1.0.0'; - $pkg_status libbar >'!libbar configured 1.0.0'; - - $rep_add $rep/t5 && $rep_fetch; - - $* libbar 2>>~%EOE%; - disfigured libbar/1.0.0 - disfigured libfoo/1.0.0 - purged libfoo/1.0.0 - %.* - %.*fetched libbar/1.2.0% - unpacked libbar/1.2.0 - configured libbar/1.2.0 - %info: .+ is up to date% - updated libbar/1.2.0 - EOE - - $pkg_status libfoo >'libfoo available 1.0.0'; - $pkg_status libbar >'!libbar configured 1.2.0'; - - $* libbar/1.0.0 libfoo 2>>~%EOE%; - disfigured libbar/1.2.0 - %.* - %.*fetched libfoo/1.0.0% - unpacked libfoo/1.0.0 - configured libfoo/1.0.0 - %.* - %.*fetched libbar/1.0.0% - unpacked libbar/1.0.0 - configured libbar/1.0.0 - %info: .+ is up to date%{2} - updated libfoo/1.0.0 - updated libbar/1.0.0 - EOE - - $pkg_status libfoo >'!libfoo configured 1.0.0'; - $pkg_status libbar >'!libbar configured !1.0.0 available 1.2.0'; - - $* libbar 2>>~%EOE%; - disfigured libbar/1.0.0 - %.* - %.*fetched libbar/1.2.0% - unpacked libbar/1.2.0 - configured libbar/1.2.0 - %info: .+ is up to date% - updated libbar/1.2.0 - EOE - - $pkg_status libfoo >'!libfoo configured 1.0.0'; - $pkg_status libbar >'!libbar configured 1.2.0'; - - $pkg_disfigure libbar 2>'disfigured libbar/1.2.0'; - $pkg_purge libbar 2>'purged libbar/1.2.0'; - - $pkg_disfigure libfoo 2>'disfigured libfoo/1.0.0'; - $pkg_purge libfoo 2>'purged libfoo/1.0.0' - } - - : local-dependency - : - : Test that the local package can be built against the local dependency - : package. - : - { - # Prepare libbar and libbaz (libbaz->libbar) local packages using the - # temporary configuration. - # - $clone_root_cfg; - - $pkg_fetch -e $src/t4b/libbar-1.1.0.tar.gz; - $pkg_unpack libbar &cfg/libbar-1.1.0/***; - - $pkg_fetch -e $src/t4c/libbaz-1.1.0.tar.gz; - $pkg_unpack libbaz &cfg/libbaz-1.1.0/***; - - mv cfg/libbar-1.1.0 libbar; - mv cfg/libbaz-1.1.0 libbaz; - - rm -r cfg && $clone_root_cfg; # Re-clone. - $rep_add $rep/t4a && $rep_fetch; - - $* ./libbar/ 2>>~%EOE%; - %.* - %.*fetched libfoo/1.1.0% - unpacked libfoo/1.1.0 - configured libfoo/1.1.0 - using libbar/1.1.0 (external) - configured libbar/1.1.0 - %info: .+ is up to date% - updated libbar/1.1.0 - EOE - - $* ./libbaz/ 2>>~%EOE%; - using libbaz/1.1.0 (external) - configured libbaz/1.1.0 - %info: .+ is up to date% - updated libbaz/1.1.0 - EOE - - $pkg_disfigure libbaz 2>'disfigured libbaz/1.1.0'; - $pkg_purge libbaz 2>'purged libbaz/1.1.0'; - - $pkg_disfigure libbar 2>'disfigured libbar/1.1.0'; - $pkg_purge libbar 2>'purged libbar/1.1.0'; - - $pkg_disfigure libfoo 2>'disfigured libfoo/1.1.0'; - $pkg_purge libfoo 2>'purged libfoo/1.1.0' - } - - : upgrade-all-held - : - { - $clone_root_cfg && $rep_fetch $rep/t2 $rep/t5; - - $* libbar/1.0 2>>~%EOE%; - %.* - %.*fetched libfoo/1.0.0% - unpacked libfoo/1.0.0 - configured libfoo/1.0.0 - %.* - %.*fetched libbar/1.0.0% - unpacked libbar/1.0.0 - configured libbar/1.0.0 - %info: .+ is up to date% - updated libbar/1.0.0 - EOE - - $* --upgrade 2>>~%EOE%; - disfigured libbar/1.0.0 - disfigured libfoo/1.0.0 - purged libfoo/1.0.0 - %.* - %.*fetched libbar/1.2.0% - unpacked libbar/1.2.0 - configured libbar/1.2.0 - %info: .+ is up to date% - updated libbar/1.2.0 - EOE - - $pkg_status libbar >'!libbar configured 1.2.0'; - - $rep_remove $rep/t2 $rep/t5; - - $* --upgrade 2>>/EOE != 0; - error: libbar is not available - info: configuration cfg/ has no repositories - info: use 'bpkg rep-add' to add a repository - EOE - - $pkg_drop libbar - } -} - -: dependency -: -{ - : unknown - : - { - $clone_root_cfg; - $rep_fetch $rep/t0c; - - $* '?libbux' 2>'error: unknown package libbux' != 0; - $* '?sys:libbux' 2>'error: unknown package sys:libbux' != 0; - $* '?libbar/1.3' 2>'error: unknown package libbar/1.3' != 0 - } - - : unused - : - { - test.arguments += --configure-only - - +$clone_root_cfg - +$rep_fetch $rep/t2 $rep/t5 - - : drop - : - : Test dropping of unused dependencies (default behavior). - : - { - $clone_cfg; - - $* --yes libbar/1.0.0 2>>~%EOE%; - %.* - %.*fetched libfoo/1.0.0% - unpacked libfoo/1.0.0 - configured libfoo/1.0.0 - %.* - %.*fetched libbar/1.0.0% - unpacked libbar/1.0.0 - configured libbar/1.0.0 - EOE - - $* libbar/1.2.0 <'y' 2>>~%EOE%; - drop libfoo/1.0.0 (unused) - upgrade libbar/1.2.0 - continue? [Y/n] disfigured libbar/1.0.0 - disfigured libfoo/1.0.0 - purged libfoo/1.0.0 - %.* - %.*fetched libbar/1.2.0% - unpacked libbar/1.2.0 - configured libbar/1.2.0 - EOE - - $pkg_status libfoo >'libfoo available 1.0.0'; - - $pkg_disfigure libbar 2>'disfigured libbar/1.2.0'; - $pkg_purge libbar 2>'purged libbar/1.2.0' - } - - : keep - : - : Test keeping of unused dependencies (--keep-unused option). - : - { - $clone_cfg; - - $* --yes libbar/1.0.0 2>>~%EOE%; - %.* - %.*fetched libfoo/1.0.0% - unpacked libfoo/1.0.0 - configured libfoo/1.0.0 - %.* - %.*fetched libbar/1.0.0% - unpacked libbar/1.0.0 - configured libbar/1.0.0 - EOE - - $* --keep-unused libbar/1.2.0 <'y' 2>>~%EOE%; - upgrade libbar/1.2.0 - continue? [Y/n] disfigured libbar/1.0.0 - %.* - %.*fetched libbar/1.2.0% - unpacked libbar/1.2.0 - configured libbar/1.2.0 - EOE - - $pkg_status libfoo >'libfoo configured 1.0.0'; - - $pkg_disfigure libbar 2>'disfigured libbar/1.2.0'; - $pkg_purge libbar 2>'purged libbar/1.2.0'; - - $pkg_disfigure libfoo 2>'disfigured libfoo/1.0.0'; - $pkg_purge libfoo 2>'purged libfoo/1.0.0' - } - - : drop-recursive - : - { - test.arguments += --yes - - $clone_root_cfg; - $rep_fetch $rep/t0a $rep/t0c; - - $* libbar/0.0.1 2>!; - - $pkg_status libbaz >'libbaz configured 0.0.1 available 0.1.0 0.0.4 0.0.3'; - $pkg_status libfox >'libfox configured 0.0.1'; - - $* libbar 2>>~%EOE%; - disfigured libbar/0.0.1 - disfigured libbaz/0.0.1 - disfigured libfox/0.0.1 - %.* - %.*fetched libfoo/1.0.0% - unpacked libfoo/1.0.0 - configured libfoo/1.0.0 - purged libfox/0.0.1 - purged libbaz/0.0.1 - %.* - %.*fetched libbar/1.0.0% - unpacked libbar/1.0.0 - configured libbar/1.0.0 - EOE - - $pkg_status libbaz >'libbaz available 0.1.0 0.0.4 0.0.3 0.0.1'; - $pkg_status libfox >'libfox available 0.0.1'; - - $pkg_drop libbar - } - - : drop-unsatisfactory - : - : Test that a dependency (libbaz/0.0.3) that doesn't satisfy its dependent - : (libbar/0.0.1) but get dropped during the plan refinement, doesn't - : prevent the command to succeed. - : - { - test.arguments += --yes - - $clone_root_cfg; - $rep_fetch $rep/t0a $rep/t0c; - - $* libbar/0.0.1 2>!; - - $pkg_status libbaz >'libbaz configured 0.0.1 available 0.1.0 0.0.4 0.0.3'; - $pkg_status libfox >'libfox configured 0.0.1'; - - $* ?libbar ?libbaz/0.0.3 2>>~%EOE%; - disfigured libbar/0.0.1 - disfigured libbaz/0.0.1 - disfigured libfox/0.0.1 - purged libfox/0.0.1 - purged libbaz/0.0.1 - purged libbar/0.0.1 - EOE - - $pkg_status libbar >'libbar available 1.0.0 0.0.3 0.0.1'; - $pkg_status libbaz >'libbaz available 0.1.0 0.0.4 0.0.3 0.0.1'; - $pkg_status libfox >'libfox available 0.0.1' - } - } - - : apply-constraints - : - : Test that the desired dependency version imposes constraint that is taken - : into account during prerequisites collection (see collect_prerequisites() - : for more details). - : - { - test.arguments += --yes --configure-only - - : unable-satisfy - : - { - $clone_root_cfg; - $rep_fetch $rep/t0a $rep/t0b; - - $* libbar/0.0.1 ?libbaz/0.0.2 2>>EOE != 0 - error: unable to satisfy constraints on package libbaz - info: libbar depends on (libbaz == 0.0.1) - info: command line depends on (libbaz == 0.0.2) - info: specify libbaz version to satisfy libbar constraint - info: while satisfying libbar/0.0.1 - EOE - } - - : resolve-conflict - : - { - : satisfy-dependents - : - : Test resolving a conflict when libfix and libbiz have selected such - : versions of their dependency libbaz. that do not satisfy each other - : constraints. We resolve the conflict explicitly specifying - : ?libbaz/0.0.3 on the command line, which satisfies both constraints. - : - { - $clone_root_cfg; - $rep_fetch $rep/t0b $rep/t0c; - - $* libfix libbiz 2>>EOE != 0; - error: unable to satisfy constraints on package libbaz - info: libfix depends on (libbaz >= 0.0.3) - info: libbiz depends on (libbaz <= 0.0.3) - info: available libbaz/0.1.0 - info: available libbaz/0.0.2 - info: explicitly specify libbaz version to manually satisfy both constraints - info: while satisfying libbiz/0.0.2 - EOE - - $* libfix libbiz ?libbaz/0.0.3 2>>~%EOE%; - %.* - %.*fetched libfoo/1.0.0% - unpacked libfoo/1.0.0 - configured libfoo/1.0.0 - %.* - %.*fetched libbaz/0.0.3% - unpacked libbaz/0.0.3 - configured libbaz/0.0.3 - %.* - %.*fetched libfix/0.0.3% - unpacked libfix/0.0.3 - configured libfix/0.0.3 - %.* - %.*fetched libbiz/0.0.2% - unpacked libbiz/0.0.2 - configured libbiz/0.0.2 - EOE - - $pkg_status libbaz >'libbaz configured !0.0.3 available 0.1.0 0.0.4'; - - $pkg_drop libbiz libfix - } - - : postpone - : - : Same as above but with an opposite order of dependents on the command - : line. This would normally fail due the inability to find libbaz/0.0.3 - : in repositories available to libbiz, unless libbaz dependencies - : collection were not postponed (see collect_build_prerequisites() - : function for more details). - : - { - $clone_root_cfg; - $rep_fetch $rep/t0b $rep/t0c; - - $* libbiz libfix ?libbaz/0.0.3 2>>~%EOE%; - %.* - %.*fetched libfoo/1.0.0% - unpacked libfoo/1.0.0 - configured libfoo/1.0.0 - %.* - %.*fetched libbaz/0.0.3% - unpacked libbaz/0.0.3 - configured libbaz/0.0.3 - %.* - %.*fetched libbiz/0.0.2% - unpacked libbiz/0.0.2 - configured libbiz/0.0.2 - %.* - %.*fetched libfix/0.0.3% - unpacked libfix/0.0.3 - configured libfix/0.0.3 - EOE - - $pkg_status libbaz >'libbaz configured !0.0.3 available 0.1.0 0.0.4'; - - $pkg_drop libbiz libfix - } - - : replace-dependent - : - : Test resolving a conflict when libbox and libfox have selected such - : versions of their dependency libfoo, that do not satisfy each other - : constraints. Note that these constraints are incompatible, so we - : resolve the conflict explicitly specifying ?libfox/0.0.1 on the - : command line, to replace one of the conflicting dependents. - : - { - $clone_root_cfg; - $rep_fetch $rep/t0d; - - $* libbiz 2>>EOE != 0; - error: unable to satisfy constraints on package libfoo - info: libbox depends on (libfoo == 1.0.0) - info: libfox depends on (libfoo == 0.0.1) - info: available libfoo/1.0.0 - info: available libfoo/0.0.1 - info: explicitly specify libfoo version to manually satisfy both constraints - info: while satisfying libbox/0.0.2 - info: while satisfying libbiz/0.0.1 - EOE - - $* libbiz ?libfox/0.0.1 2>>~%EOE%; - %.* - %.*fetched libfox/0.0.1% - unpacked libfox/0.0.1 - configured libfox/0.0.1 - %.* - %.*fetched libfoo/1.0.0% - unpacked libfoo/1.0.0 - configured libfoo/1.0.0 - %.* - %.*fetched libbox/0.0.2% - unpacked libbox/0.0.2 - configured libbox/0.0.2 - %.* - %.*fetched libbiz/0.0.1% - unpacked libbiz/0.0.1 - configured libbiz/0.0.1 - EOE - - $pkg_status libfox >'libfox configured !0.0.1 available 0.0.2'; - - $pkg_drop libbiz - } - } - - : selected - : - : Test cases when the selected package (partially) satisfies the - : user-imposed dependency constraint. - : - { - +$clone_root_cfg - +$rep_fetch $rep/t0a $rep/t0b $rep/t0c - - : same - : - { - $clone_cfg; - - $* libbar/0.0.1 2>!; - $* libbar/0.0.2 ?libbaz/0.0.1 2>!; - - $pkg_status libbaz >'libbaz configured !0.0.1 available 0.1.0 0.0.4 0.0.3 0.0.2'; - $pkg_status libfox >'libfox configured 0.0.1'; - - $pkg_drop libbar - } - - : src-to-sys - : - { - $clone_cfg; - - $* libbar/0.0.1 2>!; - $* libbar/0.0.2 '?sys:libbaz/0.0.1' 2>!; - - $pkg_status libbaz >'libbaz configured,system !0.0.1 available 0.1.0 0.0.4 0.0.3 0.0.2'; - $pkg_status libfox >'libfox available 0.0.1'; - - $pkg_drop libbar - } - - : sysver-to-wildcard - : - { - $clone_cfg; - - $* libbar/0.0.1 '?sys:libbaz/0.0.1' 2>!; - $* libbar/0.0.2 '?sys:libbaz' 2>!; - - $pkg_status libbaz >'libbaz configured,system !* available 0.1.0 0.0.4 0.0.3 0.0.2 0.0.1'; - - $pkg_drop libbar - } - - : wildcard-to-sysver - : - { - $clone_cfg; - - $* libbar/0.0.1 '?sys:libbaz' 2>!; - $* libbar/0.0.2 '?sys:libbaz/0.0.1' 2>!; - - $pkg_status libbaz >'libbaz configured,system !0.0.1 available 0.1.0 0.0.4 0.0.3 0.0.2'; - - $pkg_drop libbar - } - } - - : unknown - : - { - $clone_root_cfg; - $rep_fetch $rep/t0a $rep/t0c; - - $* libbar/1.0.0 ?libfoo/0.0.1 2>>EOE != 0 - error: unknown dependency libfoo == 0.0.1 of package libbar - info: while satisfying libbar/1.0.0 - EOE - } - } - - : refine - : - { - test.arguments += --yes --configure-only - - +$clone_root_cfg - +$rep_fetch $rep/t0a $rep/t0c - - : system - : - { - +$clone_cfg - - : wildcard-to-version - : - { - $clone_cfg; - - $* libbar '?sys:libfoo' 2>>~%EOE%; - configured sys:libfoo/* - %.* - %.*fetched libbar/1.0.0% - unpacked libbar/1.0.0 - configured libbar/1.0.0 - EOE - - $* '?sys:libfoo/0.1' 2>>~%EOE%; - disfigured libbar/1.0.0 - purged libfoo/* - configured sys:libfoo/0.1 - configured libbar/1.0.0 - EOE - - $pkg_drop libbar - } - - : wildcard-to-itself - : - { - $clone_cfg; - - $* libbar '?sys:libfoo' 2>>~%EOE%; - configured sys:libfoo/* - %.* - %.*fetched libbar/1.0.0% - unpacked libbar/1.0.0 - configured libbar/1.0.0 - EOE - - $* '?sys:libfoo'; - - $pkg_drop libbar - } - - : wildcard-to-src - : - { - $clone_cfg; - - $* libbar/0.0.1 '?sys:libbaz' 2>>~%EOE%; - configured sys:libbaz/* - %.* - %.*fetched libbar/0.0.1% - unpacked libbar/0.0.1 - configured libbar/0.0.1 - EOE - - $* '?libbaz' 2>>~%EOE%; - disfigured libbar/0.0.1 - purged libbaz/* - %.* - %.*fetched libfox/0.0.1% - unpacked libfox/0.0.1 - configured libfox/0.0.1 - %.* - %.*fetched libbaz/0.0.1% - unpacked libbaz/0.0.1 - configured libbaz/0.0.1 - configured libbar/0.0.1 - EOE - - $pkg_drop libbar - } - - : version-to-wildcard - : - { - $clone_cfg; - - $* libbar '?sys:libfoo/0.1' 2>>~%EOE%; - configured sys:libfoo/0.1 - %.* - %.*fetched libbar/1.0.0% - unpacked libbar/1.0.0 - configured libbar/1.0.0 - EOE - - $* '?sys:libfoo' 2>>~%EOE%; - disfigured libbar/1.0.0 - purged libfoo/0.1 - configured sys:libfoo/* - configured libbar/1.0.0 - EOE - - $pkg_drop libbar - } - - : version-to-itself - : - { - $clone_cfg; - - $* libbar '?sys:libfoo/0.1' 2>>~%EOE%; - configured sys:libfoo/0.1 - %.* - %.*fetched libbar/1.0.0% - unpacked libbar/1.0.0 - configured libbar/1.0.0 - EOE - - $* '?sys:libfoo/0.1'; - - $pkg_drop libbar - } - - : version-to-version - : - { - $clone_cfg; - - $* libbar '?sys:libfoo/0.2' 2>>~%EOE%; - configured sys:libfoo/0.2 - %.* - %.*fetched libbar/1.0.0% - unpacked libbar/1.0.0 - configured libbar/1.0.0 - EOE - - $* '?sys:libfoo/0.1' 2>>~%EOE%; - disfigured libbar/1.0.0 - purged libfoo/0.2 - configured sys:libfoo/0.1 - configured libbar/1.0.0 - EOE - - $pkg_drop libbar - } - - : version-to-src - : - { - $clone_cfg; - - $* libbar/0.0.1 '?sys:libbaz/0.0.1' 2>>~%EOE%; - configured sys:libbaz/0.0.1 - %.* - %.*fetched libbar/0.0.1% - unpacked libbar/0.0.1 - configured libbar/0.0.1 - EOE - - $* '?libbaz/0.0.1' 2>>~%EOE%; - disfigured libbar/0.0.1 - purged libbaz/0.0.1 - %.* - %.*fetched libfox/0.0.1% - unpacked libfox/0.0.1 - configured libfox/0.0.1 - %.* - %.*fetched libbaz/0.0.1% - unpacked libbaz/0.0.1 - configured libbaz/0.0.1 - configured libbar/0.0.1 - EOE - - $pkg_drop libbar - } - - : src-to-wildcard - : - { - $clone_cfg; - - $* libbar/0.0.1 '?libbaz' 2>>~%EOE%; - %.* - %.*fetched libfox/0.0.1% - unpacked libfox/0.0.1 - configured libfox/0.0.1 - %.* - %.*fetched libbaz/0.0.1% - unpacked libbaz/0.0.1 - configured libbaz/0.0.1 - %.* - %.*fetched libbar/0.0.1% - unpacked libbar/0.0.1 - configured libbar/0.0.1 - EOE - - $* '?sys:libbaz' 2>>~%EOE%; - disfigured libbar/0.0.1 - disfigured libbaz/0.0.1 - disfigured libfox/0.0.1 - purged libfox/0.0.1 - purged libbaz/0.0.1 - configured sys:libbaz/* - configured libbar/0.0.1 - EOE - - $pkg_drop libbar - } - - : src-to-version - : - { - $clone_cfg; - - $* libbar/0.0.1 '?libbaz/0.0.1' 2>>~%EOE%; - %.* - %.*fetched libfox/0.0.1% - unpacked libfox/0.0.1 - configured libfox/0.0.1 - %.* - %.*fetched libbaz/0.0.1% - unpacked libbaz/0.0.1 - configured libbaz/0.0.1 - %.* - %.*fetched libbar/0.0.1% - unpacked libbar/0.0.1 - configured libbar/0.0.1 - EOE - - $* '?sys:libbaz/0.0.1' 2>>~%EOE%; - disfigured libbar/0.0.1 - disfigured libbaz/0.0.1 - disfigured libfox/0.0.1 - purged libfox/0.0.1 - purged libbaz/0.0.1 - configured sys:libbaz/0.0.1 - configured libbar/0.0.1 - EOE - - $pkg_drop libbar - } - } - - : source - : - { - +$clone_cfg - - : unavailable - : - { - $clone_cfg; - - $* libbar/1.0.0 2>!; - - $* ?libfoo/0.0.1 2>>EOE != 0; - error: libfoo/0.0.1 is not available from its dependents' repositories - EOE - - $pkg_drop libbar - } - - : satisfy - : - { - $clone_cfg; - $rep_fetch $rep/t0b; - - $* libbar/0.0.1 2>!; - - $pkg_status libbaz >'libbaz configured 0.0.1 available 0.1.0 0.0.4 0.0.3 0.0.2'; - - $* libbar/0.0.2 ?libbaz 2>>~%EOE%; - disfigured libbar/0.0.1 - disfigured libbaz/0.0.1 - disfigured libfox/0.0.1 - purged libfox/0.0.1 - %.* - %.*fetched libfoo/1.0.0% - unpacked libfoo/1.0.0 - configured libfoo/1.0.0 - %.* - %.*fetched libbaz/0.0.2% - unpacked libbaz/0.0.2 - configured libbaz/0.0.2 - %.* - %.*fetched libbar/0.0.2% - unpacked libbar/0.0.2 - configured libbar/0.0.2 - EOE - - $pkg_status libbaz >'libbaz configured 0.0.2 available 0.1.0 0.0.4 0.0.3'; - - $rep_remove $rep/t0b && $rep_fetch; - - # Test that the selected package, that is "better" than the available - # one, is left. - # - $* libbox ?libbaz 2>>~%EOE%; - %.* - %.*fetched libbox/0.0.1% - unpacked libbox/0.0.1 - configured libbox/0.0.1 - EOE - - $pkg_status libbaz >'libbaz configured 0.0.2 available 0.1.0 0.0.4 0.0.3'; - - $rep_remove $rep/t0a && $rep_fetch; - - # Test that the selected package is left as there is no satisfactory - # available package. - # - $* ?libbaz; - - # Test that the above behavior is not triggered for the system package. - # - $* '?sys:libbaz' 2>>~%EOE%; - disfigured libbar/0.0.2 - disfigured libbox/0.0.1 - disfigured libbaz/0.0.2 - disfigured libfoo/1.0.0 - purged libfoo/1.0.0 - purged libbaz/0.0.2 - configured sys:libbaz/* - configured libbox/0.0.1 - configured libbar/0.0.2 - EOE - - $pkg_status libbaz >'libbaz configured,system !* available 0.1.0 0.0.4 0.0.3'; - - $pkg_drop libbar libbox - } - - : unsatisfied - : - { - $clone_cfg; - - $* libbar/0.0.1 2>!; - - $pkg_status libbaz >'libbaz configured 0.0.1 available 0.1.0 0.0.4 0.0.3'; - - $* ?libbaz/0.0.3 2>>EOE != 0; - error: package libbaz doesn't satisfy its dependents - info: libbaz/0.0.3 doesn't satisfy libbar/0.0.1 - EOE - - $pkg_status libbaz >'libbaz configured 0.0.1 available 0.1.0 0.0.4 0.0.3'; - - $pkg_drop libbar - } - } - - : scratch - : - { - $clone_cfg; - - $* libbox 2>!; - - $pkg_status libbaz >'libbaz configured 0.0.3 available 0.1.0 0.0.4'; - $pkg_status libfoo >'libfoo configured 0.0.1 available 1.0.0'; - $pkg_status libfox >'libfox available 0.0.1'; - - # After the first simulation it is discovered that libfoo needs to be - # upgraded to 1.0.0. But after the second simulation, that upgrades - # libfoo, it is discovered that it is now unused (libbaz doesn't need it - # anymore). So we replace libfoo upgrade with drop and start from - # scratch. - # - $* ?libfoo/1.0.0 ?libbaz/0.0.1 2>>~%EOE%; - disfigured libbox/0.0.1 - disfigured libbaz/0.0.3 - disfigured libfoo/0.0.1 - disfigured libfix/0.0.1 - purged libfix/0.0.1 - purged libfoo/0.0.1 - %.* - %.*fetched libfox/0.0.1% - unpacked libfox/0.0.1 - configured libfox/0.0.1 - %.* - %.*fetched libbaz/0.0.1% - unpacked libbaz/0.0.1 - configured libbaz/0.0.1 - configured libbox/0.0.1 - EOE - - $pkg_status libbaz >'libbaz configured !0.0.1 available 0.1.0 0.0.4 0.0.3'; - $pkg_status libfoo >'libfoo available 1.0.0 0.0.1'; - $pkg_status libfox >'libfox configured 0.0.1'; - - $pkg_drop libbox - } - - : reconf-dependent - : - { - $clone_cfg; - $rep_fetch $rep/t0b; - - $* libbar/0.0.2 2>!; - - $pkg_status libbaz >'libbaz configured 0.0.2 available 0.1.0 0.0.4 0.0.3'; - $pkg_status libfoo >'libfoo configured 1.0.0'; - - $* '?sys:libfoo' ?libbaz/0.0.2 2>>EOE; - disfigured libbar/0.0.2 - disfigured libbaz/0.0.2 - disfigured libfoo/1.0.0 - purged libfoo/1.0.0 - configured sys:libfoo/* - configured libbaz/0.0.2 - configured libbar/0.0.2 - EOE - - $pkg_drop libbar - } - } - - : unhold - : - { - test.arguments += --configure-only - - +$clone_root_cfg - +$rep_fetch $rep/t0a - - : drop - : - { - $clone_cfg; - - $* libfox 2>!; - - $* ?libfox --yes 2>>EOE; - disfigured libfox/0.0.1 - purged libfox/0.0.1 - EOE - - $pkg_status libfox >'libfox available 0.0.1' - } - - : silent - : - { - $clone_cfg; - - $* libbar libbaz --yes 2>!; - $pkg_status libbaz >'!libbaz configured 0.0.1 available 0.0.3'; - - $* ?libbaz; - $pkg_status libbaz >'libbaz configured 0.0.1 available 0.0.3'; - - $pkg_drop libbar - } - - : prompt - : - { - $clone_cfg; - - $* libbar libbaz --yes 2>!; - $pkg_status libbaz >'!libbaz configured 0.0.1 available 0.0.3'; - - $* '?sys:libbaz' < 'y' 2>>EOE; - drop libfox/0.0.1 (unused) - reconfigure/unhold sys:libbaz/* - reconfigure libbar (dependent of libbaz) - continue? [Y/n] disfigured libbar/0.0.1 - disfigured libbaz/0.0.1 - disfigured libfox/0.0.1 - purged libfox/0.0.1 - purged libbaz/0.0.1 - configured sys:libbaz/* - configured libbar/0.0.1 - EOE - - $pkg_status libbaz >'libbaz configured,system !* available 0.0.3 0.0.1'; - - $pkg_drop libbar - } - - : unheld - : - { - $clone_cfg; - - $* libbar ?libbaz --yes 2>!; - $pkg_status libbaz >'libbaz configured 0.0.1 available 0.0.3'; - - $* ?libbaz; - $pkg_status libbaz >'libbaz configured 0.0.1 available 0.0.3'; - - $pkg_drop libbar - } - } - - : options - : - { - : keep-out - : - : Test that --keep-out is properly propagated when building libhello - : as a dependency, so it is built incrementally. - : - { - $cfg_create cxx "config.cxx=$config.cxx" -d cfg 2>- &cfg/***; - - # Add libhello as the dir repository. - # - cp -r $src/libhello-1.0.0 ./libhello; - $rep_add libhello --type dir; - - # Add libfoo as the dir repository and make it a dependent of libhello. - # - cp -r $src/libfoo-1.1.0 libfoo; - echo 'depends: libhello' >+libfoo/manifest; - $rep_add libfoo --type dir; - - $rep_fetch; - - # Note that libfoo building doesn't trigger libhello building as it is a - # fake dependent, so build both explicitly. - # - $* libfoo ?libhello 2>!; - - # Move libhello version ahead. - # - sed -i -e 's/(version: 1.0).0/\1.1/' libhello/manifest; - $rep_fetch; - - # Upgrade libhello as a dependency. - # - # Note that despite the fact that we have modified the libhello's - # manifest file after the build, libhello may still be considered up to - # date on filesystems with a low file timestamps resolution (for example - # HFS+). - # - # @@ By some reason the following build occasionally re-links, so the - # test fails (most often reproduced on Windows). We will copy the - # configuration directory preserving file timestamps to research the - # issue when it get reproduced. - # - cp -r cfg cfg-backup; - - $* ?libhello --yes --keep-out 2>>~%EOE% - disfigured libfoo/1.1.0 - disfigured libhello/1.0.0 - using libhello/1.0.1 (external) - configured libhello/1.0.1 - configured libfoo/1.1.0 - %info: .+ is up to date%{1,2} - updated libhello/1.0.1 - updated libfoo/1.1.0 - EOE - } - } - - : dependents - : - { - test.arguments += --yes --configure-only - - : order - : - : Test that libbar that is built but isn't upgraded (and so doesn't order - : itself against dependencies) is still properly reconfigured being - : ordered as (an indirect) dependent of libfoo. - : - { - $clone_root_cfg; - $rep_fetch $rep/t0a $rep/t0b; - - $* libbar libfoo/0.0.1 2>>~%EOE%; - %.* - %.*fetched libfoo/0.0.1% - unpacked libfoo/0.0.1 - configured libfoo/0.0.1 - %.* - %.*fetched libbaz/0.0.2% - unpacked libbaz/0.0.2 - configured libbaz/0.0.2 - %.* - %.*fetched libbar/0.0.2% - unpacked libbar/0.0.2 - configured libbar/0.0.2 - EOE - - $* libbar libfoo 2>>~%EOE%; - disfigured libbar/0.0.2 - disfigured libbaz/0.0.2 - disfigured libfoo/0.0.1 - %.* - %.*fetched libfoo/1.0.0% - unpacked libfoo/1.0.0 - configured libfoo/1.0.0 - configured libbaz/0.0.2 - configured libbar/0.0.2 - EOE - - $pkg_drop libbaz libbar libfoo - } - - : adjust-merge-build - : - : Test that the registered in the map but not ordered package build - : (libfoo) is properly merged into the reconfigure adjustment as a - : dependent of the reconfigured dependency (see collect_order_dependents() - : for more details). - : - { - $clone_root_cfg; - $rep_fetch $rep/t0a; - - $* libfoo 2>>~%EOE%; - %.* - %.*fetched libfix/0.0.1% - unpacked libfix/0.0.1 - configured libfix/0.0.1 - %.* - %.*fetched libfoo/0.0.1% - unpacked libfoo/0.0.1 - configured libfoo/0.0.1 - EOE - - $* libbaz libbar 'sys:libfix' 2>>~%EOE%; - disfigured libfoo/0.0.1 - disfigured libfix/0.0.1 - %.* - %.*fetched libfox/0.0.1% - unpacked libfox/0.0.1 - configured libfox/0.0.1 - %.* - %.*fetched libbaz/0.0.1% - unpacked libbaz/0.0.1 - configured libbaz/0.0.1 - %.* - %.*fetched libbar/0.0.1% - unpacked libbar/0.0.1 - configured libbar/0.0.1 - purged libfix/0.0.1 - configured sys:libfix/* - configured libfoo/0.0.1 - EOE - - $pkg_drop libbaz libbar libfoo - } - } - - : upgrade - : - : Test dependency upgrade using --immediate and --recursive options. - : - { - test.arguments += --configure-only --upgrade - - +$clone_root_cfg - +$rep_fetch $rep/t0a $rep/t0b $rep/t0c - - +$* libbar/0.0.2 libbaz/0.0.2 libfoo/0.0.1 --yes 2>>~%EOE% - %.* - %.*fetched libfix/0.0.1% - unpacked libfix/0.0.1 - configured libfix/0.0.1 - %.* - %.*fetched libfoo/0.0.1% - unpacked libfoo/0.0.1 - configured libfoo/0.0.1 - %.* - %.*fetched libbaz/0.0.2% - unpacked libbaz/0.0.2 - configured libbaz/0.0.2 - %.* - %.*fetched libbar/0.0.2% - unpacked libbar/0.0.2 - configured libbar/0.0.2 - EOE - - clone_cfg = cp --no-cleanup -r ../cfg ./ &cfg/*** - - : immediate - : - { - $clone_cfg; - - $* libbar/0.0.3 --immediate --yes 2>>~%EOE%; - disfigured libbar/0.0.2 - disfigured libbaz/0.0.2 - %.* - %.*fetched libbaz/0.1.0% - unpacked libbaz/0.1.0 - configured libbaz/0.1.0 - %.* - %.*fetched libbar/0.0.3% - unpacked libbar/0.0.3 - configured libbar/0.0.3 - EOE - - $pkg_status libbar >'!libbar configured !0.0.3 available 1.0.0'; - $pkg_status libbaz >'!libbaz configured !0.1.0'; - $pkg_status libfoo >'!libfoo configured !0.0.1 available 1.0.0' - } - - : recursive - : - { - $clone_cfg; - - $* libbar/0.0.3 --recursive --yes 2>>~%EOE%; - disfigured libbar/0.0.2 - disfigured libbaz/0.0.2 - disfigured libfoo/0.0.1 - %.* - %.*fetched libfoo/1.0.0% - unpacked libfoo/1.0.0 - configured libfoo/1.0.0 - %.* - %.*fetched libbaz/0.1.0% - unpacked libbaz/0.1.0 - configured libbaz/0.1.0 - %.* - %.*fetched libbar/0.0.3% - unpacked libbar/0.0.3 - configured libbar/0.0.3 - EOE - - $pkg_status libbar >'!libbar configured !0.0.3 available 1.0.0'; - $pkg_status libbaz >'!libbaz configured !0.1.0'; - $pkg_status libfoo >'!libfoo configured !1.0.0' - } - - : all-held - : - { - $clone_cfg; - - $* ?libfoo/0.0.1 ?libbaz/0.0.2; # Unhold. - - $* --upgrade --recursive <'y' 2>>~%EOE% - drop libfix/0.0.1 (unused) - upgrade libfoo/1.0.0 - drop libbaz/0.0.2 (unused) - upgrade libbar/1.0.0 - continue? [Y/n] disfigured libbar/0.0.2 - disfigured libbaz/0.0.2 - disfigured libfoo/0.0.1 - disfigured libfix/0.0.1 - purged libfix/0.0.1 - %.* - %.*fetched libfoo/1.0.0% - unpacked libfoo/1.0.0 - configured libfoo/1.0.0 - purged libbaz/0.0.2 - %.* - %.*fetched libbar/1.0.0% - unpacked libbar/1.0.0 - configured libbar/1.0.0 - EOE - } - - : prompt - : - { - $clone_cfg; - - $* libbaz/0.0.2 --recursive <'y' 2>>~%EOE% - drop libfix/0.0.1 (unused) - upgrade libfoo/1.0.0 - reconfigure libbaz/0.0.2 - reconfigure libbar (dependent of libbaz) - continue? [Y/n] disfigured libbar/0.0.2 - disfigured libbaz/0.0.2 - disfigured libfoo/0.0.1 - disfigured libfix/0.0.1 - purged libfix/0.0.1 - %.* - %.*fetched libfoo/1.0.0% - unpacked libfoo/1.0.0 - configured libfoo/1.0.0 - configured libbaz/0.0.2 - configured libbar/0.0.2 - EOE - } - - : override - : - { - $clone_cfg; - - $* libbar/0.0.3 ?libbaz/0.0.3 --recursive --yes 2>>~%EOE%; - disfigured libbar/0.0.2 - disfigured libbaz/0.0.2 - disfigured libfoo/0.0.1 - %.* - %.*fetched libfoo/1.0.0% - unpacked libfoo/1.0.0 - configured libfoo/1.0.0 - %.* - %.*fetched libbaz/0.0.3% - unpacked libbaz/0.0.3 - configured libbaz/0.0.3 - %.* - %.*fetched libbar/0.0.3% - unpacked libbar/0.0.3 - configured libbar/0.0.3 - EOE - - $pkg_status libbaz >'libbaz configured !0.0.3 available 0.1.0 0.0.4' - } - - : unhold - : - { - $clone_cfg; - - $* libbar/0.0.3 ?libbaz/0.0.3 ?libfoo --recursive --yes 2>>~%EOE%; - disfigured libbar/0.0.2 - disfigured libbaz/0.0.2 - disfigured libfoo/0.0.1 - %.* - %.*fetched libfoo/1.0.0% - unpacked libfoo/1.0.0 - configured libfoo/1.0.0 - %.* - %.*fetched libbaz/0.0.3% - unpacked libbaz/0.0.3 - configured libbaz/0.0.3 - %.* - %.*fetched libbar/0.0.3% - unpacked libbar/0.0.3 - configured libbar/0.0.3 - EOE - - $pkg_status libbar >'!libbar configured !0.0.3 available 1.0.0'; - $pkg_status libbaz >'libbaz configured !0.0.3 available 0.1.0 0.0.4'; - $pkg_status libfoo >'libfoo configured 1.0.0' - } - - : unavailable - : - : Test that the selected dependency (libfix/0.0.1) is silently left - : unchanged if there is no package available from the dependents - : repositories. - : - { - $clone_cfg; - $rep_remove $rep/t0a $rep/t0b $rep/t0c; - - $* libbar --recursive --yes - } - - -$pkg_drop libbar libbaz libfoo - } -} - -: dependent -: -{ - +$clone_cfg - +$rep_add $rep/t2 && $rep_fetch - - : update - : - : Test --update-dependent option. - : - { - $clone_cfg; - - $* --yes libbar 2>>~%EOE%; - %.* - %.*fetched libfoo/1.0.0% - unpacked libfoo/1.0.0 - configured libfoo/1.0.0 - %.* - %.*fetched libbar/1.0.0% - unpacked libbar/1.0.0 - configured libbar/1.0.0 - %info: .+ is up to date% - updated libbar/1.0.0 - EOE - - $rep_add $rep/t4a && $rep_fetch; - - $* --update-dependent libfoo/1.1.0 <'y' 2>>~%EOE%; - upgrade libfoo/1.1.0 - reconfigure libbar (dependent of libfoo) - continue? [Y/n] disfigured libbar/1.0.0 - disfigured libfoo/1.0.0 - %.* - %.*fetched libfoo/1.1.0% - unpacked libfoo/1.1.0 - configured libfoo/1.1.0 - configured libbar/1.0.0 - %info: .+ is up to date%{2} - updated libfoo/1.1.0 - updated libbar/1.0.0 - EOE - - $pkg_disfigure libbar 2>'disfigured libbar/1.0.0'; - $pkg_purge libbar 2>'purged libbar/1.0.0'; - - $pkg_disfigure libfoo 2>'disfigured libfoo/1.1.0'; - $pkg_purge libfoo 2>'purged libfoo/1.1.0' - } - - : leave - : - : Test --leave-dependent option. - : - { - $clone_cfg; - - $* --yes libbar 2>>~%EOE%; - %.* - %.*fetched libfoo/1.0.0% - unpacked libfoo/1.0.0 - configured libfoo/1.0.0 - %.* - %.*fetched libbar/1.0.0% - unpacked libbar/1.0.0 - configured libbar/1.0.0 - %info: .+ is up to date% - updated libbar/1.0.0 - EOE - - $rep_add $rep/t4a && $rep_fetch; - - $* --leave-dependent libfoo/1.1.0 <'y' 2>>~%EOE%; - upgrade libfoo/1.1.0 - reconfigure libbar (dependent of libfoo) - continue? [Y/n] disfigured libbar/1.0.0 - disfigured libfoo/1.0.0 - %.* - %.*fetched libfoo/1.1.0% - unpacked libfoo/1.1.0 - configured libfoo/1.1.0 - configured libbar/1.0.0 - %info: .+ is up to date% - updated libfoo/1.1.0 - EOE - - $pkg_disfigure libbar 2>'disfigured libbar/1.0.0'; - $pkg_purge libbar 2>'purged libbar/1.0.0'; - - $pkg_disfigure libfoo 2>'disfigured libfoo/1.1.0'; - $pkg_purge libfoo 2>'purged libfoo/1.1.0' - } -} - -: patch -: -{ - test.arguments += --configure-only --yes - - +$clone_root_cfg - - : held - : - { - +$clone_cfg - +$rep_fetch $rep/t0c - - : success - : - { - $clone_cfg; - - $* libbaz/0.0.3 2>!; - - $* libbaz --patch 2>>~%EOE%; - disfigured libbaz/0.0.3 - disfigured libfoo/1.0.0 - purged libfoo/1.0.0 - %.* - %.*fetched libbaz/0.0.4% - unpacked libbaz/0.0.4 - configured libbaz/0.0.4 - EOE - - $pkg_drop libbaz - } - - : ignore - : - { - $clone_cfg; - - $* libbaz/0.0.3 --patch 2>>~%EOE%; - %.* - %.*fetched libfoo/1.0.0% - unpacked libfoo/1.0.0 - configured libfoo/1.0.0 - %.* - %.*fetched libbaz/0.0.3% - unpacked libbaz/0.0.3 - configured libbaz/0.0.3 - EOE - - $* libbaz/0.1.0 --patch 2>>~%EOE%; - disfigured libbaz/0.0.3 - disfigured libfoo/1.0.0 - purged libfoo/1.0.0 - %.* - %.*fetched libbaz/0.1.0% - unpacked libbaz/0.1.0 - configured libbaz/0.1.0 - EOE - - $pkg_drop libbaz - } - - : warn - : - { - $clone_cfg; - - $* 'sys:libbaz/0.0.3-alpha' 2>!; - - $* libbaz --patch 2>>~%EOE%; - warning: unable to patch libbaz/0.0.3-alpha - info: package is not using semantic/standard version - info: nothing to build - EOE - - $pkg_drop libbaz - } - } - - : dependency - : - { - +$clone_cfg - +$rep_fetch $rep/t0c - - +$* libbox libfix ?libbaz/0.0.3 2>>~%EOE% - %.* - %.*fetched libfoo/1.0.0% - unpacked libfoo/1.0.0 - configured libfoo/1.0.0 - %.* - %.*fetched libbaz/0.0.3% - unpacked libbaz/0.0.3 - configured libbaz/0.0.3 - %.* - %.*fetched libbox/0.0.1% - unpacked libbox/0.0.1 - configured libbox/0.0.1 - %.* - %.*fetched libfix/0.0.3% - unpacked libfix/0.0.3 - configured libfix/0.0.3 - EOE - - clone_cfg = cp --no-cleanup -r ../cfg ./ &cfg/*** - - : explicitly - : - : Here we also test that the package --path option overrides the global - : --upgrade option. - : - { - $clone_cfg; - - $* ?libbaz +{ --patch } --upgrade 2>>~%EOE% - disfigured libbox/0.0.1 - disfigured libfix/0.0.3 - disfigured libbaz/0.0.3 - disfigured libfoo/1.0.0 - purged libfoo/1.0.0 - %.* - %.*fetched libbaz/0.0.4% - unpacked libbaz/0.0.4 - configured libbaz/0.0.4 - configured libfix/0.0.3 - configured libbox/0.0.1 - EOE - } - - : warn - : - { - $clone_cfg; - - $* '?sys:libbaz/0.0.4-alpha' 2>!; - - $* ?libbaz --patch 2>>~%EOE% - warning: unable to patch libbaz/0.0.4-alpha - info: package is not using semantic/standard version - EOE - } - - : recursive - : - { - $clone_cfg; - - $* --patch --recursive 2>>~%EOE% - disfigured libfix/0.0.3 - disfigured libbox/0.0.1 - disfigured libbaz/0.0.3 - disfigured libfoo/1.0.0 - purged libfoo/1.0.0 - %.* - %.*fetched libbaz/0.0.4% - unpacked libbaz/0.0.4 - configured libbaz/0.0.4 - configured libbox/0.0.1 - configured libfix/0.0.3 - EOE - } - - : upgrade-wins-patch - : - : Test that --upgrade options wins --patch. - : - { - $clone_cfg; - - $* libbox +{ --upgrade-immediate } libfix +{ --patch-immediate } 2>>~%EOE% - disfigured libfix/0.0.3 - disfigured libbox/0.0.1 - disfigured libbaz/0.0.3 - disfigured libfoo/1.0.0 - purged libfoo/1.0.0 - %.* - %.*fetched libbaz/0.1.0% - unpacked libbaz/0.1.0 - configured libbaz/0.1.0 - configured libbox/0.0.1 - configured libfix/0.0.3 - EOE - } - - : unavailable - : - { - $clone_cfg; - - $* '?sys:libbaz/0.0.3' 2>>EOE; - disfigured libbox/0.0.1 - disfigured libfix/0.0.3 - disfigured libbaz/0.0.3 - disfigured libfoo/1.0.0 - purged libfoo/1.0.0 - purged libbaz/0.0.3 - configured sys:libbaz/0.0.3 - configured libfix/0.0.3 - configured libbox/0.0.1 - EOE - - $rep_remove $rep/t0c; - $rep_fetch $rep/t0b; - - $* ?libbaz --patch --yes 2>>EOE != 0 - error: patch version for sys:libbaz/0.0.3 is not available from its dependents' repositories - EOE - } - - -$pkg_drop libbox libfix libbaz libfoo - } - - : from-repository - : - { - test.arguments += --patch --auth all --trust-yes - - +$clone_cfg - - +$* "libbaz/0.0.3@$rep/t0c" 2>>~%EOE% - added pkg:build2.org/pkg-build/t0c - %.* - %.*fetching pkg:build2.org/pkg-build/t0c% - %.* - %.*fetched libfoo/1.0.0% - unpacked libfoo/1.0.0 - configured libfoo/1.0.0 - %.* - %.*fetched libbaz/0.0.3% - unpacked libbaz/0.0.3 - configured libbaz/0.0.3 - EOE - - clone_cfg = cp --no-cleanup -r ../cfg ./ &cfg/*** - - : explicit - : - { - $clone_cfg; - - $* "libbaz@$rep/t0c" 2>>~%EOE% - fetching pkg:build2.org/pkg-build/t0c - disfigured libbaz/0.0.3 - disfigured libfoo/1.0.0 - purged libfoo/1.0.0 - %.* - %.*fetched libbaz/0.0.4% - unpacked libbaz/0.0.4 - configured libbaz/0.0.4 - EOE - } - - : implicit - : - : Note that libfoo also becomes held. - : - { - $clone_cfg; - - $* "@$rep/t0c" 2>>~%EOE%; - fetching pkg:build2.org/pkg-build/t0c - info: package libbar is not present in configuration - info: package libbox is not present in configuration - info: package libfix is not present in configuration - disfigured libbaz/0.0.3 - %.* - %.*fetched libbaz/0.0.4% - unpacked libbaz/0.0.4 - configured libbaz/0.0.4 - EOE - - $pkg_status libfoo >'!libfoo configured !1.0.0' - } - - -$pkg_drop libbaz libfoo - } -} - -: configure-only -: -: Test --configure-only option. -: -{ - $clone_cfg; - $rep_add $rep/t2 && $rep_fetch; - - $* --configure-only --yes libbar 2>>~%EOE%; - %.* - %.*fetched libfoo/1.0.0% - unpacked libfoo/1.0.0 - configured libfoo/1.0.0 - %.* - %.*fetched libbar/1.0.0% - unpacked libbar/1.0.0 - configured libbar/1.0.0 - EOE - - $pkg_disfigure libbar 2>'disfigured libbar/1.0.0'; - $pkg_purge libbar 2>'purged libbar/1.0.0'; - - $pkg_disfigure libfoo 2>'disfigured libfoo/1.0.0'; - $pkg_purge libfoo 2>'purged libfoo/1.0.0' -} - -: repository-location -: -{ - test.arguments += --yes --auth all --trust-yes - - : all-packages - : - { - : explicit - : - { - $clone_root_cfg; - - $* "@$rep/t4d" 2>>~%EOE%; - %.+ - %info: .+ is up to date%{2} - updated libfox/1.0.0 - updated libbiz/1.0.0 - EOE - - $pkg_disfigure libbiz 2>'disfigured libbiz/1.0.0'; - $pkg_purge libbiz 2>'purged libbiz/1.0.0'; - - $pkg_disfigure libfox 2>'disfigured libfox/1.0.0'; - $pkg_purge libfox 2>'purged libfox/1.0.0'; - - $pkg_disfigure libbaz 2>'disfigured libbaz/1.1.0'; - $pkg_purge libbaz 2>'purged libbaz/1.1.0'; - - $pkg_disfigure libbar 2>'disfigured libbar/1.1.0'; - $pkg_purge libbar 2>'purged libbar/1.1.0'; - - $pkg_disfigure libfoo 2>'disfigured libfoo/1.1.0'; - $pkg_purge libfoo 2>'purged libfoo/1.1.0' - } - - : url-detection - : - { - $clone_root_cfg; - - if ($remote != true) - rep = ($cxx.target.class != 'windows' \ - ? "file:$rep" \ - : "file:/$regex.replace($rep, '\\', '/')") - end; - - $* "$rep/t4d" 2>>~%EOE%; - %.+ - %info: .+ is up to date%{2} - updated libfox/1.0.0 - updated libbiz/1.0.0 - EOE - - $pkg_disfigure libbiz 2>'disfigured libbiz/1.0.0'; - $pkg_purge libbiz 2>'purged libbiz/1.0.0'; - - $pkg_disfigure libfox 2>'disfigured libfox/1.0.0'; - $pkg_purge libfox 2>'purged libfox/1.0.0'; - - $pkg_disfigure libbaz 2>'disfigured libbaz/1.1.0'; - $pkg_purge libbaz 2>'purged libbaz/1.1.0'; - - $pkg_disfigure libbar 2>'disfigured libbar/1.1.0'; - $pkg_purge libbar 2>'purged libbar/1.1.0'; - - $pkg_disfigure libfoo 2>'disfigured libfoo/1.1.0'; - $pkg_purge libfoo 2>'purged libfoo/1.1.0' - } - } - - : multiple-packages - : - { - $clone_root_cfg; - - $* "libfox,libbiz/1.0.0@$rep/t4d" 2>>~%EOE%; - %.+ - %info: .+ is up to date%{2} - updated libfox/1.0.0 - updated libbiz/1.0.0 - EOE - - $pkg_disfigure libbiz 2>'disfigured libbiz/1.0.0'; - $pkg_purge libbiz 2>'purged libbiz/1.0.0'; - - $pkg_disfigure libfox 2>'disfigured libfox/1.0.0'; - $pkg_purge libfox 2>'purged libfox/1.0.0'; - - $pkg_disfigure libbaz 2>'disfigured libbaz/1.1.0'; - $pkg_purge libbaz 2>'purged libbaz/1.1.0'; - - $pkg_disfigure libbar 2>'disfigured libbar/1.1.0'; - $pkg_purge libbar 2>'purged libbar/1.1.0'; - - $pkg_disfigure libfoo 2>'disfigured libfoo/1.1.0'; - $pkg_purge libfoo 2>'purged libfoo/1.1.0' - } - - : version - : - : Test that libfoo/0.0.1 package version is built (repository t0a), rather - : than libfoo/1.0.0 (repository t4a). - : - { - $clone_root_cfg; - - $rep_fetch $rep/t4c 2>!; - - $* "libfoo@$rep/t0a" 2>>~%EOE%; - %.+ - configured libfoo/0.0.1 - %info: .+ is up to date% - updated libfoo/0.0.1 - EOE - - $pkg_drop libfoo - } - - : no-patch - : - : Here we also test that --patch options is ignored if there is no selected - : package in the configuration. - : - { - $clone_root_cfg; - - $* "libfoo@$rep/t1" --patch 2>>~%EOE%; - %.+ - configured libfoo/1.0.0 - %info: .+ is up to date% - updated libfoo/1.0.0 - EOE - - $* "libfoo@$rep/t3" --patch 2>>~%EOE% != 0; - %.+ - error: patch version for libfoo/1.0.0 is not found in pkg:build2.org/pkg-build/t3 - EOE - - $pkg_drop libfoo - } - - : package-in-complement - : - { - $clone_root_cfg; - - $* "libfoo@$rep/t4d" 2>>~%EOE%; - %.+ - %info: .+ is up to date% - updated libfoo/1.0.0 - EOE - - $pkg_disfigure libfoo 2>'disfigured libfoo/1.0.0'; - $pkg_purge libfoo 2>'purged libfoo/1.0.0' - } - - : system - : - { - $clone_root_cfg; - - $* "sys:libbiz/2.0.0@$rep/t4d" 2>>~%EOE%; - %.+ - configured sys:libbiz/2.0.0 - EOE - - $pkg_disfigure libbiz 2>'purged libbiz/2.0.0' - } - - : non-existent-package - : - { - $clone_root_cfg; - - $* "libbar@$rep/t4d" 2>>~%EOE% != 0 - %.+ - error: package libbar is not found in pkg:build2.org/pkg-build/t4d or its complements - EOE - } - - : location-search - : - : Test that the repository location is searched in the database before being - : parsed. The latest would fail as the repository type would be misguessed. - : - { - $clone_root_cfg; - $rep_add $src/libfoo-1.1.0 --type dir && $rep_fetch; - - d = $canonicalize([dir_path] $src/libfoo-1.1.0); - - $* "libfoo@$d" 2>>~"%EOE%"; - fetching dir:$d - using libfoo/1.1.0 \(external\) - configured libfoo/1.1.0 - %info: .+ is up to date% - updated libfoo/1.1.0 - EOE - - $pkg_disfigure libfoo 2>'disfigured libfoo/1.1.0'; - $pkg_purge libfoo 2>'purged libfoo/1.1.0' - } -} - -: dir-rep -: -{ - : preferred - : - : Test that dir (local) repository is preferred over non-dir local repository - : that comes first. - : - { - $clone_root_cfg; - $rep_fetch $rep/t4a; - $rep_add $src/libfoo-1.1.0 --type dir; - $rep_fetch "dir:$canonicalize([dir_path] $src/libfoo-1.1.0)"; - - $* libfoo 2>>~%EOE%; - using libfoo/1.1.0 (external) - configured libfoo/1.1.0 - %info: .+ is up to date% - updated libfoo/1.1.0 - EOE - - $pkg_disfigure libfoo 2>'disfigured libfoo/1.1.0'; - $pkg_purge libfoo 2>'purged libfoo/1.1.0' - } -} - -: keep-out -: -{ - +$cfg_create cxx "config.cxx=$config.cxx" -d cfg 2>- &cfg/*** - - # Build libhello as an external package. - # - +cp -r $src/libhello-1.0.0 ./libhello - +$rep_add libhello --type dir - +$rep_fetch - +$* libhello 2>! - - # Move libhello version ahead. - # - +sed -i -e 's/(version: 1.0).0/\1.1/' libhello/manifest - +$rep_fetch - - test.arguments += --yes # Is a command-specific option. - - : unspecified - : - : Test that libhello is fully rebuilt. - : - { - $clone_cfg; - $rep_fetch; - - $* libhello 2>>~%EOE% - disfigured libhello/1.0.0 - using libhello/1.0.1 (external) - configured libhello/1.0.1 - %(mkdir|c\+\+|ld|ar) .+%{8} - updated libhello/1.0.1 - EOE - } - - : specified - : - { - test.arguments += --keep-out - - +$clone_cfg - - : dir-repo - : - : Test that libhello is built incrementally. May re-link due to the - : configuration copying. - : - { - $clone_cfg; - - $* libhello 2>>~%EOE%; - disfigured libhello/1.0.0 - using libhello/1.0.1 (external) - configured libhello/1.0.1 - %ld .+%? - updated libhello/1.0.1 - EOE - - test -d cfg/libhello/; - test -d cfg/libhello-1.0.1/ == 1 - } - - : directory - : - : Test that libhello is built incrementally. May re-link due to the - : configuration copying. - : - { - +$clone_cfg - - # To avoid 'external package is already available' failure for the - # nested tests. - # - +$rep_remove --all - - : arg - : - { - $clone_cfg; - - $* ../../../libhello/ 2>>~%EOE%; - disfigured libhello/1.0.0 - using libhello/1.0.1 (external) - configured libhello/1.0.1 - %ld .+%? - updated libhello/1.0.1 - EOE - - test -d cfg/libhello/; - test -d cfg/libhello-1.0.1/ == 1 - } - - : unpacked - : - { - $clone_cfg; - $pkg_disfigure libhello --keep-out 2>!; - $pkg_unpack -r -e ../../../libhello; - - $* libhello 2>>~%EOE%; - configured libhello/1.0.1 - %ld .+%? - updated libhello/1.0.1 - EOE - - test -d cfg/libhello/; - test -d cfg/libhello-1.0.1/ == 1 - } - } - - : archive - : - : Test that libhello is fully rebuilt, as the resulted package is not - : external. - { - clone_cfg = cp -p --no-cleanup -r ../../cfg ./ - - +$build 'dist(../../libhello/@./out/)' \ - "config.cxx=$config.cxx" config.dist.root=./ \ - config.dist.archives=tar.gz 2>! \ - &libhello-1.0.1/*** &libhello-1.0.1.tar.gz - - : arg - : - { - $clone_cfg; - - $* ../libhello-1.0.1.tar.gz 2>>~%EOE%; - disfigured libhello/1.0.0 - fetched libhello/1.0.1 - unpacked libhello/1.0.1 - configured libhello/1.0.1 - %(c\+\+|ld|ar) .+%{6} - updated libhello/1.0.1 - EOE - - test -d cfg/libhello-1.0.1/; - test -d cfg/libhello/ == 1; - - $pkg_disfigure libhello 2>'disfigured libhello/1.0.1'; - $pkg_purge libhello 2>'purged libhello/1.0.1'; - - rm -r cfg/ - } - - : unpacked - : - { - $clone_cfg; - - $pkg_disfigure libhello 2>!; - $pkg_fetch -r -e ../libhello-1.0.1.tar.gz; - $pkg_unpack libhello; - - $* libhello 2>>~%EOE%; - configured libhello/1.0.1 - %(c\+\+|ld|ar) .+%{6} - updated libhello/1.0.1 - EOE - - test -d cfg/libhello-1.0.1/; - test -d cfg/libhello/ == 1; - - $pkg_disfigure libhello 2>'disfigured libhello/1.0.1'; - $pkg_purge libhello 2>'purged libhello/1.0.1'; - - rm -r cfg/ - } - } - } - - -$pkg_disfigure libhello 2>'disfigured libhello/1.0.0' - -$pkg_purge libhello 2>'purged libhello/1.0.0' -} - -: iter -: -{ - test.arguments += --yes # Is a command-specific option. - - : already-available - : - { - $clone_root_cfg; - $rep_add $src/libfoo-1.1.0 --type dir && $rep_fetch; - - $* $src/libfoo-1.1.0/ 2>>~%EOE% != 0 - %error: external package libfoo/1.1.0 is already available from dir:.+libfoo-1.1.0% - EOE - } - - : upgrade - : - { - $clone_root_cfg; - - $* $src/libfoo-1.1.0/ 2>>~%EOE%; - using libfoo/1.1.0 (external) - configured libfoo/1.1.0 - %info: .+ is up to date% - updated libfoo/1.1.0 - EOE - - cp -p -r $src/libfoo-1.1.0 libfoo; - - $* libfoo/ 2>>~%EOE%; - disfigured libfoo/1.1.0 - using libfoo/1.1.0#1 (external) - configured libfoo/1.1.0#1 - %info: .+ is up to date% - updated libfoo/1.1.0#1 - EOE - - $rep_add $src/libfoo-1.1.0 --type dir && $rep_fetch; - - $* libfoo 2>>~%EOE%; - disfigured libfoo/1.1.0#1 - using libfoo/1.1.0#2 (external) - configured libfoo/1.1.0#2 - %info: .+ is up to date% - updated libfoo/1.1.0#2 - EOE - - $pkg_disfigure libfoo 2>'disfigured libfoo/1.1.0#2' - } -} - -: ignore-case -: -{ - test.arguments += --yes --auth all --trust-yes - - $clone_cfg; - - $* "libbar@$rep/t5" 2>>~%EOE%; - added pkg:build2.org/pkg-build/t5 - fetching pkg:build2.org/pkg-build/t5 - %.* - %.*fetched libbar/1.2.0% - unpacked libbar/1.2.0 - configured libbar/1.2.0 - %info: .+ is up to date% - updated libbar/1.2.0 - EOE - - $* "libbar@$rep/t6" 2>>~%EOE%; - added pkg:build2.org/pkg-build/t6 - fetching pkg:build2.org/pkg-build/t6 - disfigured libbar/1.2.0 - %.* - %.*fetched libBar/2.0.0% - unpacked libBar/2.0.0 - configured libBar/2.0.0 - %info: .+ is up to date% - updated libBar/2.0.0 - EOE - - $pkg_status libbar >'!libBar configured !2.0.0'; - - test -d cfg/libBar-2.0.0; - - $pkg_drop libbar -} - -: git-rep -: -if ($git_supported != true) -{ - # Skip git repository tests. - # -} -else -{ - rep0 = "$rep_git/state0" - rep1 = "$rep_git/state1" - - test.arguments += --yes - - pkg_disfigure += 2>! - pkg_purge += 2>! - - : prerequisite-repo - : - : Dependency package of the dependent being built is in the prerequisite - : repository. - : - { - $clone_root_cfg; - $rep_add "$rep0/libbar.git#master"; - $rep_add "$rep0/style-basic.git#master"; - $rep_fetch &cfg/.bpkg/repos/*/***; - - $* libmbar 2>>~%EOE%; - %distributing style-basic/.+% - %checked out style-basic/.+% - %configured style-basic/.+% - distributing libmbar/1.0.0 - checked out libmbar/1.0.0 - configured libmbar/1.0.0 - %info: .+ is up to date% - updated libmbar/1.0.0 - EOE - - $pkg_disfigure libmbar; - $pkg_disfigure style-basic; - - $pkg_purge libmbar; - $pkg_purge style-basic - } - - : no-prerequisite-repos - : - : Dependent package repository has no prerequisites nor complements. Its - : dependency is picked up via the root repository that complements its - : repository (see rep_fetch() function implementation for details). - : - { - $clone_root_cfg; - $rep_add "$rep1/libbaz.git#master"; - $rep_add "$rep0/style-basic.git#master"; - $rep_fetch &cfg/.bpkg/repos/*/***; - - $* libbaz 2>>~%EOE%; - %distributing style-basic/.+% - %checked out style-basic/.+% - %configured style-basic/.+% - distributing libbaz/1.0.0 - checked out libbaz/1.0.0 - configured libbaz/1.0.0 - %info: .+ is up to date% - updated libbaz/1.0.0 - EOE - - $pkg_disfigure libbaz; - $pkg_disfigure style-basic; - - $pkg_purge libbaz; - $pkg_purge style-basic - } - - : build-unpacked - : - : Test that the unpacked external package is properly built for the first - : time and is not rebuilt afterwards via the directory argument. - : - if ($remote != true) - { - $clone_root_cfg; - - d = $canonicalize([dir_path] $out_git/state0/style-basic.git); - $pkg_unpack -e $d; - - $* style-basic 2>>~%EOE%; - %configured style-basic/1\.1\.0-a\.0\.\d+\..+% - %info: .+ is up to date% - %updated style-basic/1\.1\.0-a\.0\.\d+\..+% - EOE - - $* $d 2>>~%EOE%; - %info: .+ is up to date% - %updated style-basic/1\.1\.0-a\.0\.\d+\..+% - EOE - - $pkg_disfigure style-basic - } -} diff --git a/tests/pkg-build.testscript b/tests/pkg-build.testscript new file mode 100644 index 0000000..f1bfd08 --- /dev/null +++ b/tests/pkg-build.testscript @@ -0,0 +1,3473 @@ +# file : tests/pkg-build.testscript +# copyright : Copyright (c) 2014-2018 Code Synthesis Ltd +# license : MIT; see accompanying LICENSE file + +.include common.testscript \ + config.testscript \ + remote.testscript \ + remote-git.testscript + +# Source repository: +# +# pkg-build +# |-- libbar-1.0.0.tar.gz +# |-- libbaz-1.1.0.tar.gz +# |-- libfix-0.0.1.tar.gz +# |-- libfoo-0.0.1.tar.gz -> libfix +# |-- libfoo-1.0.0.tar.gz +# | +# |-- libfoo-1.1.0 +# | |-- build +# | | `-- bootstrap.build +# | |-- buildfile +# | `-- manifest +# | +# |-- libfoo-1.1.0.tar.gz +# |-- libfoo-1.2.0.tar.gz +# | +# |-- t0a +# | |-- libbar-0.0.1.tar.gz -> libbaz == 0.0.1 +# | |-- libbaz-0.0.1.tar.gz -> libfox +# | |-- libbaz-0.0.3.tar.gz -> libfoo +# | |-- libbox-0.0.1.tar.gz -> libbaz +# | |-- libfix-0.0.1.tar.gz +# | |-- libfoo-0.0.1.tar.gz -> libfix +# | |-- libfox-0.0.1.tar.gz +# | `-- repositories.manifest +# | +# |-- t0b +# | |-- libbar-0.0.2.tar.gz -> libbaz <= 0.0.2 +# | |-- libbaz-0.0.2.tar.gz -> libfoo +# | |-- libbiz-0.0.2.tar.gz -> libbaz <= 0.0.3 +# | |-- libfoo-1.0.0.tar.gz +# | `-- repositories.manifest +# | +# |-- t0c +# | |-- libbar-0.0.3.tar.gz -> libbaz +# | |-- libbar-1.0.0.tar.gz -> libfoo +# | |-- libbaz-0.0.3.tar.gz -> libfoo +# | |-- libbaz-0.0.4.tar.gz +# | |-- libbaz-0.1.0.tar.gz +# | |-- libbox-0.0.1.tar.gz -> libbaz +# | |-- libfix-0.0.3.tar.gz -> libbaz >= 0.0.3 +# | |-- libfoo-1.0.0.tar.gz +# | `-- repositories.manifest +# | +# |-- t0d +# | |-- libbiz-0.0.1.tar.gz -> libbox, libfox +# | |-- libbox-0.0.2.tar.gz -> libfoo == 1.0.0 +# | |-- libfix-0.0.1.tar.gz +# | |-- libfox-0.0.2.tar.gz -> libfoo == 0.0.1 +# | |-- libfoo-0.0.1.tar.gz -> libfix +# | |-- libfoo-1.0.0.tar.gz +# | |-- libfox-0.0.1.tar.gz +# | `-- repositories.manifest +# | +# |-- t1 +# | |-- libfoo-1.0.0.tar.gz +# | `-- repositories.manifest +# | +# |-- t2 +# | |-- libbar-1.0.0.tar.gz -> libfoo +# | |-- libfoo-1.0.0.tar.gz +# | `-- repositories.manifest +# | +# |-- t3 -> t2 (prerequisite repository) +# | |-- libbaz-1.0.0.tar.gz -> libbar +# | |-- libfox-1.0.0.tar.gz +# | `-- repositories.manifest +# | +# |-- 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 repository) +# | |-- libbiz-1.0.0.tar.gz -> libfox, libfoo, libbaz +# | |-- libfox-1.0.0.tar.gz +# | `-- repositories.manifest +# | +# |-- t5 +# | |-- libbar-1.2.0.tar.gz +# | `-- repositories.manifest +# | +# |-- t6 +# | |-- libBar-2.0.0.tar.gz +# | `-- repositories.manifest +# | +# |-- libhello-1.0.0 +# | |-- build +# | | |-- bootstrap.build +# | | |-- export.build +# | | `-- root.build +# | `-- * +# | +# `-- git +# |-- libbar.git -> style-basic.git (prerequisite repository) +# |-- libbaz.git +# `-- style-basic.git + +# Prepare repositories used by tests if running in the local mode. +# ++if ($remote != true) + rep_create += 2>! + + cp -r $src/t0a $out/t0a && $rep_create $out/t0a &$out/t0a/packages.manifest + cp -r $src/t0b $out/t0b && $rep_create $out/t0b &$out/t0b/packages.manifest + cp -r $src/t0c $out/t0c && $rep_create $out/t0c &$out/t0c/packages.manifest + cp -r $src/t0d $out/t0d && $rep_create $out/t0d &$out/t0d/packages.manifest + cp -r $src/t1 $out/t1 && $rep_create $out/t1 &$out/t1/packages.manifest + cp -r $src/t2 $out/t2 && $rep_create $out/t2 &$out/t2/packages.manifest + cp -r $src/t3 $out/t3 && $rep_create $out/t3 &$out/t3/packages.manifest + cp -r $src/t4a $out/t4a && $rep_create $out/t4a &$out/t4a/packages.manifest + cp -r $src/t4b $out/t4b && $rep_create $out/t4b &$out/t4b/packages.manifest + 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/t5 $out/t5 && $rep_create $out/t5 &$out/t5/packages.manifest + cp -r $src/t6 $out/t6 && $rep_create $out/t6 &$out/t6/packages.manifest + + # Create git repositories. + # + $git_extract $src/git/style-basic.tar + $git_extract $src/git/libbar.tar &$out_git/state0/*** + $git_extract $src/git/libbaz.tar &$out_git/state1/*** +end + +pkg_configure += -d cfg "config.cxx=$config.cxx" 2>! +pkg_disfigure += -d cfg +pkg_drop += -d cfg --yes 2>! +pkg_fetch += -d cfg 2>! +pkg_purge += -d cfg +pkg_status += -d cfg +pkg_unpack += -d cfg 2>! +rep_add += -d cfg 2>! +rep_remove += -d cfg 2>! +rep_fetch += -d cfg --auth all --trust-yes 2>! + +: libfoo +: +: Test building different versions of libfoo. +: +{ + test.arguments += --print-only + + : no-name + : + $clone_root_cfg; + $* 2>>EOE != 0 + error: package name argument expected + info: run 'bpkg help pkg-build' for more information + EOE + + : unknown-package + : + $clone_root_cfg; + $* libfoo 2>>/EOE != 0 + error: unknown package libfoo + info: configuration cfg/ has no repositories + info: use 'bpkg rep-add' to add a repository + EOE + + : unknown-package-ver + : + $clone_root_cfg; + $* libfoo/1.0.0 2>>/EOE != 0 + error: unknown package libfoo + info: configuration cfg/ has no repositories + info: use 'bpkg rep-add' to add a repository + EOE + + : archive + : + $clone_root_cfg; + $* $src/libfoo-1.1.0.tar.gz >'new libfoo/1.1.0' + + : dir + : + $clone_root_cfg; + $* $src/libfoo-1.1.0/ >'new libfoo/1.1.0' + + : unpacked-dir + : + { + $clone_root_cfg && $pkg_unpack -e $src/libfoo-1.1.0; + + $* libfoo >'update libfoo/1.1.0'; + $* libfoo/1.1.0 >'update libfoo/1.1.0'; + $* libfoo libfoo >'update libfoo/1.1.0'; + + $* libfoo libfoo/1.1.0 2>>EOE != 0; + error: duplicate package libfoo + info: first mentioned as libfoo + info: second mentioned as libfoo/1.1.0 + EOE + + $* libfoo/1.1.0 libfoo 2>>EOE != 0; + error: duplicate package libfoo + info: first mentioned as libfoo/1.1.0 + info: second mentioned as libfoo + EOE + + $* libfoo/1.1.0 libfoo/1.1.0 >'update libfoo/1.1.0'; + + $* libfoo/1.0.0 2>>/EOE != 0; + error: unknown package libfoo + info: configuration cfg/ has no repositories + info: use 'bpkg rep-add' to add a repository + EOE + + $pkg_purge libfoo 2>'purged libfoo/1.1.0' + } + + : t1 + : + { + +$clone_root_cfg && $rep_add $rep/t1 && $rep_fetch + + : downgrade + : + { + $clone_cfg && $pkg_unpack -e $src/libfoo-1.1.0; + + $* libfoo >'update libfoo/1.1.0'; + $* libfoo/1.0.0 >'downgrade libfoo/1.0.0'; + + $* libfoo/0.0.1 2>>EOE != 0; + error: libfoo/0.0.1 is not available in source + info: specify sys:libfoo/0.0.1 if it is available from the system + EOE + + $pkg_purge libfoo 2>'purged libfoo/1.1.0' + } + + : upgrade + : + { + $clone_cfg; + $pkg_fetch -e $src/libfoo-0.0.1.tar.gz && $pkg_unpack libfoo; + $pkg_fetch -e $src/libfix-0.0.1.tar.gz && $pkg_unpack libfix; + + $* libfoo >'upgrade libfoo/1.0.0'; + + $* libfoo/0.0.1 >>EOE; + update libfix/0.0.1 (required by libfoo) + update libfoo/0.0.1 + EOE + + $* libfoo/1.1.0 2>>EOE != 0; + error: libfoo/1.1.0 is not available in source + info: specify sys:libfoo/1.1.0 if it is available from the system + EOE + + $pkg_purge libfoo 2>'purged libfoo/0.0.1'; + $pkg_purge libfix 2>'purged libfix/0.0.1' + } + + : upgrade-failure + : + { + $clone_cfg; + + $* libfoo >'new libfoo/1.0.0'; + $* libfoo/1.0.0 >'new libfoo/1.0.0'; + + $* libfoo/1.1.0 2>>EOE != 0 + error: libfoo/1.1.0 is not available in source + info: specify sys:libfoo/1.1.0 if it is available from the system + EOE + } + } +} + +: libbar-libfoo +: +: Test building libbar that depends on libfoo. +: +{ + test.arguments += --print-only + + : unknown-dependency + : + $clone_root_cfg; + $* $src/libbar-1.0.0.tar.gz 2>>EOE != 0 + error: unknown dependency libfoo of package libbar + info: while satisfying libbar/1.0.0 + EOE + + : t2 + : + { + +$clone_root_cfg && $rep_add $rep/t2 && $rep_fetch + + : build-dependency + : + { + $clone_cfg; + + $* libbar >>EOO; + new libfoo/1.0.0 (required by libbar) + new libbar/1.0.0 + EOO + + $* libbar libfoo >>EOO; + new libfoo/1.0.0 + new libbar/1.0.0 + EOO + + $* libbar libfoo/1.0.0 >>EOO; + new libfoo/1.0.0 + new libbar/1.0.0 + EOO + + $* libbar libfoo libbar/1.0.0 2>>EOE != 0; + error: duplicate package libbar + info: first mentioned as libbar + info: second mentioned as libbar/1.0.0 + EOE + + $* libbar libfoo/1.1.0 2>>EOE != 0 + error: libfoo/1.1.0 is not available in source + info: specify sys:libfoo/1.1.0 if it is available from the system + EOE + } + + : upgrade-dependency + : + { + $clone_cfg; + $pkg_fetch -e $src/libfoo-0.0.1.tar.gz && $pkg_unpack libfoo; + $pkg_fetch -e $src/libfix-0.0.1.tar.gz && $pkg_unpack libfix; + + $* libbar >>EOO; + update libfix/0.0.1 (required by libfoo) + update libfoo/0.0.1 (required by libbar) + new libbar/1.0.0 + EOO + + $* libbar libfoo >>EOO; + upgrade libfoo/1.0.0 + new libbar/1.0.0 + EOO + + $* libbar libfoo/0.0.1 >>EOO; + update libfix/0.0.1 (required by libfoo) + update libfoo/0.0.1 + new libbar/1.0.0 + EOO + + $pkg_purge libfoo 2>'purged libfoo/0.0.1'; + $pkg_purge libfix 2>'purged libfix/0.0.1' + } + + : downgrade-dependency + : + { + $clone_cfg && $pkg_unpack -e $src/libfoo-1.1.0; + + $* libbar >>EOO; + update libfoo/1.1.0 (required by libbar) + new libbar/1.0.0 + EOO + + $* libbar libfoo >>EOO; + update libfoo/1.1.0 + new libbar/1.0.0 + EOO + + $* libbar libfoo/1.0.0 >>EOO; + downgrade libfoo/1.0.0 + new libbar/1.0.0 + EOO + + $pkg_purge libfoo 2>'purged libfoo/1.1.0' + } + } +} + +: libbaz-libbar +: +: Test building libbaz that depends on libbar; libbar is in prerequisite +: repository. +: +{ + test.arguments += --print-only + + : t3 + : + { + +$clone_root_cfg && $rep_add $rep/t3 && $rep_fetch + + : prerequisites-build-failure + : + : Fail to build packages that are only in prerequisite repository. + : + { + $clone_cfg; + + $* libfoo 2>>EOE != 0; + error: unknown package libfoo + EOE + + $* libbar 2>>EOE != 0; + error: unknown package libbar + EOE + + $* libbaz libbar 2>>EOE != 0 + error: unknown package libbar + EOE + } + + : prerequisites-build + : + $clone_cfg; + $* libbaz >>EOO + new libfoo/1.0.0 (required by libbar) + new libbar/1.0.0 (required by libbaz) + new libbaz/1.0.0 + EOO + + : different-build-order + : + { + +$clone_cfg && $rep_add $rep/t2 && $rep_fetch + + : fox-foo + : + $clone_cfg; + $* libfox libfoo >>EOO + new libfox/1.0.0 + new libfoo/1.0.0 + EOO + + : foo-fox + : + $clone_cfg; + $* libfoo libfox >>EOO + new libfoo/1.0.0 + new libfox/1.0.0 + EOO + + : baz-foo + : + $clone_cfg; + $* libbaz libfoo >>EOO + new libfoo/1.0.0 + new libbar/1.0.0 (required by libbaz) + new libbaz/1.0.0 + EOO + + : foo-baz + : + $clone_cfg; + $* libfoo libbaz >>EOO + new libfoo/1.0.0 + new libbar/1.0.0 (required by libbaz) + new libbaz/1.0.0 + EOO + + : baz-fox + : + $clone_cfg; + $* libbaz libfox >>EOO + new libfoo/1.0.0 (required by libbar) + new libbar/1.0.0 (required by libbaz) + new libbaz/1.0.0 + new libfox/1.0.0 + EOO + + : fox-baz + : + $clone_cfg; + $* libfox libbaz >>EOO + new libfox/1.0.0 + new libfoo/1.0.0 (required by libbar) + new libbar/1.0.0 (required by libbaz) + new libbaz/1.0.0 + EOO + + : fox-foo-baz + : + $clone_cfg; + $* libfox libfoo libbaz >>EOO + new libfox/1.0.0 + new libfoo/1.0.0 + new libbar/1.0.0 (required by libbaz) + new libbaz/1.0.0 + EOO + + : fox-baz-foo + : + $clone_cfg; + $* libfox libbaz libfoo >>EOO + new libfox/1.0.0 + new libfoo/1.0.0 + new libbar/1.0.0 (required by libbaz) + new libbaz/1.0.0 + EOO + + : foo-fox-baz + : + $clone_cfg; + $* libfoo libfox libbaz >>EOO + new libfoo/1.0.0 + new libfox/1.0.0 + new libbar/1.0.0 (required by libbaz) + new libbaz/1.0.0 + EOO + + : foo-baz-fox + : + $clone_cfg; + $* libfoo libbaz libfox >>EOO + new libfoo/1.0.0 + new libbar/1.0.0 (required by libbaz) + new libbaz/1.0.0 + new libfox/1.0.0 + EOO + + : baz-fox-foo + : + : This one is contradictory: baz before fox but fox before foo. + : + $clone_cfg; + $* libbaz libfox libfoo >>EOO + new libfox/1.0.0 + new libfoo/1.0.0 + new libbar/1.0.0 (required by libbaz) + new libbaz/1.0.0 + EOO + + : baz-foo-fox + : + $clone_cfg; + $* libbaz libfoo libfox >>EOO + new libfoo/1.0.0 + new libbar/1.0.0 (required by libbaz) + new libbaz/1.0.0 + new libfox/1.0.0 + EOO + + : baz-foo-bar + : + $clone_cfg; + $* libbaz libfoo libbar >>EOO + new libfoo/1.0.0 + new libbar/1.0.0 + new libbaz/1.0.0 + EOO + + : baz-bar-foo + : + $clone_cfg; + $* libbaz libbar libfoo >>EOO + new libfoo/1.0.0 + new libbar/1.0.0 + new libbaz/1.0.0 + EOO + } + } +} + +: libbaz-libfoo-libbar +: +: Test building libbaz that depends on libfoo and libbar; libbar depends on +: libfoo == 1.1.0. +: +{ + test.arguments += --print-only + + : t4c + : + { + +$clone_root_cfg && $rep_add $rep/t4c && $rep_fetch + + : baz + : + $clone_cfg; + $* libbaz >>EOO + new libfoo/1.1.0 (required by libbar libbaz) + new libbar/1.1.0 (required by libbaz) + new libbaz/1.1.0 + EOO + + : foo-baz + : + $clone_cfg; + $* libfoo libbaz >>EOO + new libfoo/1.1.0 + new libbar/1.1.0 (required by libbaz) + new libbaz/1.1.0 + EOO + + : unable-satisfy + : + $clone_cfg; + $* libfoo/1.0.0 libbaz 2>>EOE != 0 + error: unable to satisfy constraints on package libfoo + info: libbar depends on (libfoo == 1.1.0) + info: command line depends on (libfoo == 1.0.0) + info: available libfoo/1.1.0 + info: available libfoo/1.0.0 + info: explicitly specify libfoo version to manually satisfy both constraints + info: while satisfying libbar/1.1.0 + info: while satisfying libbaz/1.1.0 + EOE + + : not-available + : + $clone_cfg; + $* libfoo/1.1.0 libbaz 2>>EOE != 0 + error: libfoo/1.1.0 is not available in source + info: specify sys:libfoo/1.1.0 if it is available from the system + EOE + + : upgrade-warning + : + { + $clone_cfg; + $pkg_fetch -e $src/libfoo-0.0.1.tar.gz && $pkg_unpack libfoo; + $pkg_fetch -e $src/libfix-0.0.1.tar.gz && $pkg_unpack libfix; + + $* libbaz >>EOO 2>>EOE; + upgrade libfoo/1.1.0 (required by libbar libbaz) + new libbar/1.1.0 (required by libbaz) + new libbaz/1.1.0 + EOO + warning: package libbar dependency on (libfoo == 1.1.0) is forcing upgrade of libfoo/0.0.1 to 1.1.0 + EOE + + $pkg_purge libfoo 2>'purged libfoo/0.0.1'; + $pkg_purge libfix 2>'purged libfix/0.0.1' + } + + : downgrade-error + : + { + $clone_cfg; + $pkg_fetch -e $src/libfoo-1.2.0.tar.gz && $pkg_unpack libfoo; + + $* libbaz 2>>EOE != 0; + error: package libbar dependency on (libfoo == 1.1.0) is forcing downgrade of libfoo/1.2.0 to 1.1.0 + info: explicitly request version downgrade to continue + info: while satisfying libbar/1.1.0 + info: while satisfying libbaz/1.1.0 + EOE + + $rep_add $rep/t4a && $rep_fetch; + + $* libfoo/1.1.0 libbaz >>EOO; + downgrade libfoo/1.1.0 + new libbar/1.1.0 (required by libbaz) + new libbaz/1.1.0 + EOO + + $pkg_purge libfoo 2>'purged libfoo/1.2.0' + } + + : unable-downgrade + : + : Test that dependent prevents up/downgrade that would break dependency + : constraints. + : + { + $clone_cfg; + $pkg_fetch libfoo/1.1.0 && $pkg_unpack libfoo && $pkg_configure libfoo; + $pkg_fetch libbar/1.1.0 && $pkg_unpack libbar && $pkg_configure libbar; + + $* libfoo-1.2.0.tar.gz 2>>EOE != 0; + error: unknown package libfoo-1.2.0.tar.gz + EOE + + $* libfoo/1.0.0 2>>EOE != 0; + error: unable to downgrade package libfoo/1.1.0 to 1.0.0 + info: because package libbar depends on (libfoo == 1.1.0) + info: explicitly request up/downgrade of package libbar + info: or explicitly specify package libfoo version to manually satisfy these constraints + EOE + + $* libfoo/1.1.0 --keep-unused >'update libfoo/1.1.0'; + + $pkg_disfigure libbar 2>'disfigured libbar/1.1.0'; + $pkg_purge libbar 2>'purged libbar/1.1.0'; + + $pkg_disfigure libfoo 2>'disfigured libfoo/1.1.0'; + $pkg_purge libfoo 2>'purged libfoo/1.1.0' + } + } + + : dependent-reconfiguration + : + { + test.arguments += --keep-unused + + +$clone_root_cfg + + +$pkg_fetch -e $src/libfoo-1.0.0.tar.gz && $pkg_unpack libfoo + +$pkg_configure libfoo + + +$pkg_fetch -e $src/libbar-1.0.0.tar.gz && $pkg_unpack libbar + +$pkg_configure libbar + + +$pkg_fetch -e $src/libbaz-1.1.0.tar.gz && $pkg_unpack libbaz + +$pkg_configure libbaz + + +$rep_add $rep/t4a && $rep_add $rep/t4b && $rep_fetch + + : bar + : + : Only libbar/1.1.0 (that we are upgrading to) requires libfoo/1.1.0. + : libbaz, that depends on libfoo and libbar, is happy with any version of + : its dependencies. + : + $clone_cfg; + $* libbar >>EOO 2>>EOE + upgrade libfoo/1.1.0 (required by libbar) + upgrade libbar/1.1.0 + reconfigure libbaz (dependent of libbar libfoo) + EOO + warning: package libbar dependency on (libfoo == 1.1.0) is forcing upgrade of libfoo/1.0.0 to 1.1.0 + EOE + + : foo + : + $clone_cfg; + $* libfoo >>EOO + upgrade libfoo/1.1.0 + reconfigure libbar (dependent of libfoo) + reconfigure libbaz (dependent of libbar libfoo) + EOO + + : foo-bar + : + $clone_cfg; + $* libfoo libbar/1.0.0 >>EOO + upgrade libfoo/1.1.0 + reconfigure/update libbar/1.0.0 + reconfigure libbaz (dependent of libbar libfoo) + EOO + + : bar-foo + : + $clone_cfg; + $* libbar/1.0.0 libfoo >>EOO + upgrade libfoo/1.1.0 + reconfigure/update libbar/1.0.0 + reconfigure libbaz (dependent of libbar libfoo) + EOO + + : baz-foo + : + $clone_cfg; + $* libbaz libfoo >>EOO + upgrade libfoo/1.1.0 + reconfigure libbar (dependent of libfoo) + reconfigure/update libbaz/1.1.0 + EOO + + : baz-foo-1.0.0 + : + $clone_cfg; + $* libbaz libfoo/1.0.0 >>EOO + update libfoo/1.0.0 + update libbaz/1.1.0 + EOO + + -$pkg_disfigure libbaz 2>'disfigured libbaz/1.1.0' + -$pkg_purge libbaz 2>'purged libbaz/1.1.0' + + -$pkg_disfigure libbar 2>'disfigured libbar/1.0.0' + -$pkg_purge libbar 2>'purged libbar/1.0.0' + + -$pkg_disfigure libfoo 2>'disfigured libfoo/1.0.0' + -$pkg_purge libfoo 2>'purged libfoo/1.0.0' + } +} + +# Note that when we fetch a package from remote repository the bpkg stderr +# contains fetch program progress output, that comes prior the informational +# message. +# + +: actual-build +: +{ + test.arguments += --yes + + : with-dependencies + : + { + $clone_root_cfg && $rep_add $rep/t4c && $rep_fetch; + + $* libbaz 2>>~%EOE%; + %.* + %.*fetched libfoo/1.1.0% + unpacked libfoo/1.1.0 + configured libfoo/1.1.0 + %.* + %.*fetched libbar/1.1.0% + unpacked libbar/1.1.0 + configured libbar/1.1.0 + %.* + %.*fetched libbaz/1.1.0% + unpacked libbaz/1.1.0 + configured libbaz/1.1.0 + %info: .+ is up to date% + updated libbaz/1.1.0 + EOE + + $pkg_status libfoo/1.1.0 >'libfoo configured 1.1.0'; + $pkg_status libbar/1.1.0 >'libbar configured 1.1.0'; + $pkg_status libbaz/1.1.0 >'!libbaz configured 1.1.0'; + + $pkg_disfigure libbaz 2>'disfigured libbaz/1.1.0'; + $pkg_purge libbaz 2>'purged libbaz/1.1.0'; + + $pkg_disfigure libbar 2>'disfigured libbar/1.1.0'; + $pkg_purge libbar 2>'purged libbar/1.1.0'; + + $pkg_disfigure libfoo 2>'disfigured libfoo/1.1.0'; + $pkg_purge libfoo 2>'purged libfoo/1.1.0' + } + + : hold-fs-fetched + : + { + : direct + : + { + $clone_root_cfg; + + $* $src/libfoo-1.0.0.tar.gz 2>>~%EOE%; + fetched libfoo/1.0.0 + unpacked libfoo/1.0.0 + configured libfoo/1.0.0 + %info: .+ is up to date% + updated libfoo/1.0.0 + EOE + + $pkg_status libfoo >'!libfoo configured !1.0.0'; + + $* $src/libfoo-1.1.0/ 2>>~%EOE%; + disfigured libfoo/1.0.0 + using libfoo/1.1.0 (external) + configured libfoo/1.1.0 + %info: .+ is up to date% + updated libfoo/1.1.0 + EOE + + $pkg_status libfoo >'!libfoo configured !1.1.0'; + + $pkg_disfigure libfoo 2>'disfigured libfoo/1.1.0'; + $pkg_purge libfoo 2>'purged libfoo/1.1.0' + } + + : pre-fetch + : + { + $clone_root_cfg; + $pkg_fetch -e $src/libfoo-1.0.0.tar.gz && $pkg_unpack libfoo; + $pkg_configure libfoo; + + $pkg_status libfoo >'libfoo configured 1.0.0'; + + $* libfoo 2>>~%EOE%; + %info: .+ is up to date% + updated libfoo/1.0.0 + EOE + + $pkg_status libfoo >'!libfoo configured 1.0.0'; + + $pkg_disfigure libfoo 2>'disfigured libfoo/1.0.0'; + $pkg_purge libfoo 2>'purged libfoo/1.0.0' + } + } + + : hold-repo-fetched + : + { + +$clone_root_cfg && $rep_add $rep/t4c && $rep_fetch + + : package-version + : + { + $clone_cfg; + + $* libfoo 2>>~%EOE%; + %.* + %.*fetched libfoo/1.0.0% + unpacked libfoo/1.0.0 + configured libfoo/1.0.0 + %info: .+ is up to date% + updated libfoo/1.0.0 + EOE + + $pkg_status libfoo >'!libfoo configured 1.0.0 available [1.1.0]'; + + $* libfoo/1.0.0 2>>~%EOE%; + %info: .+ is up to date% + updated libfoo/1.0.0 + EOE + + $pkg_status libfoo >'!libfoo configured !1.0.0 available [1.1.0]'; + + $pkg_disfigure libfoo 2>'disfigured libfoo/1.0.0'; + $pkg_purge libfoo 2>'purged libfoo/1.0.0' + } + + : version + : + { + $clone_cfg; + + $* libfoo/1.0.0 2>>~%EOE%; + %.* + %.*fetched libfoo/1.0.0% + unpacked libfoo/1.0.0 + configured libfoo/1.0.0 + %info: .+ is up to date% + updated libfoo/1.0.0 + EOE + + $pkg_status libfoo >'!libfoo configured !1.0.0 available [1.1.0]'; + + $pkg_disfigure libfoo 2>'disfigured libfoo/1.0.0'; + $pkg_purge libfoo 2>'purged libfoo/1.0.0' + } + + : not-held + : + { + $clone_cfg; + + $* libbaz 2>>~%EOE%; + %.* + %.*fetched libfoo/1.1.0% + unpacked libfoo/1.1.0 + configured libfoo/1.1.0 + %.* + %.*fetched libbar/1.1.0% + unpacked libbar/1.1.0 + configured libbar/1.1.0 + %.* + %.*fetched libbaz/1.1.0% + unpacked libbaz/1.1.0 + configured libbaz/1.1.0 + %info: .+ is up to date% + updated libbaz/1.1.0 + EOE + + $pkg_status libfoo >'libfoo configured 1.1.0'; + + $pkg_disfigure libbaz 2>'disfigured libbaz/1.1.0'; + $pkg_purge libbaz 2>'purged libbaz/1.1.0'; + + $pkg_disfigure libbar 2>'disfigured libbar/1.1.0'; + $pkg_purge libbar 2>'purged libbar/1.1.0'; + + $pkg_disfigure libfoo 2>'disfigured libfoo/1.1.0'; + $pkg_purge libfoo 2>'purged libfoo/1.1.0' + } + + : forcing-upgrade-unheld + : + { + $clone_cfg; + + $* libfoo 2>>~%EOE%; + %.* + %.*fetched libfoo/1.0.0% + unpacked libfoo/1.0.0 + configured libfoo/1.0.0 + %info: .+ is up to date% + updated libfoo/1.0.0 + EOE + + $pkg_status libfoo >'!libfoo configured 1.0.0 available [1.1.0]'; + + $* libbaz 2>>~%EOE%; + warning: package libbar dependency on (libfoo == 1.1.0) is forcing upgrade of libfoo/1.0.0 to 1.1.0 + disfigured libfoo/1.0.0 + %.* + %.*fetched libfoo/1.1.0% + unpacked libfoo/1.1.0 + configured libfoo/1.1.0 + %.* + %.*fetched libbar/1.1.0% + unpacked libbar/1.1.0 + configured libbar/1.1.0 + %.* + %.*fetched libbaz/1.1.0% + unpacked libbaz/1.1.0 + configured libbaz/1.1.0 + %info: .+ is up to date% + updated libbaz/1.1.0 + EOE + + $pkg_status libfoo >'!libfoo configured 1.1.0'; + + $pkg_disfigure libbaz 2>'disfigured libbaz/1.1.0'; + $pkg_purge libbaz 2>'purged libbaz/1.1.0'; + + $pkg_disfigure libbar 2>'disfigured libbar/1.1.0'; + $pkg_purge libbar 2>'purged libbar/1.1.0'; + + $pkg_disfigure libfoo 2>'disfigured libfoo/1.1.0'; + $pkg_purge libfoo 2>'purged libfoo/1.1.0' + } + + : forcing-upgrade-held + : + { + $clone_cfg; + + $* libfoo/1.0.0 2>>~%EOE%; + %.* + %.*fetched libfoo/1.0.0% + unpacked libfoo/1.0.0 + configured libfoo/1.0.0 + %info: .+ is up to date% + updated libfoo/1.0.0 + EOE + + $pkg_status libfoo >'!libfoo configured !1.0.0 available [1.1.0]'; + + $* libbaz 2>>EOE != 0; + error: package libbar dependency on (libfoo == 1.1.0) is forcing upgrade of libfoo/1.0.0 to 1.1.0 + info: package version libfoo/1.0.0 is held + info: explicitly request version upgrade to continue + info: while satisfying libbar/1.1.0 + info: while satisfying libbaz/1.1.0 + EOE + + $pkg_disfigure libfoo 2>'disfigured libfoo/1.0.0'; + $pkg_purge libfoo 2>'purged libfoo/1.0.0' + } + } + + : drop-dependencies + : + { + $clone_root_cfg && $rep_add $rep/t2 && $rep_fetch; + + $* libbar 2>>~%EOE%; + %.* + %.*fetched libfoo/1.0.0% + unpacked libfoo/1.0.0 + configured libfoo/1.0.0 + %.* + %.*fetched libbar/1.0.0% + unpacked libbar/1.0.0 + configured libbar/1.0.0 + %info: .+ is up to date% + updated libbar/1.0.0 + EOE + + $pkg_status libfoo >'libfoo configured 1.0.0'; + $pkg_status libbar >'!libbar configured 1.0.0'; + + $rep_add $rep/t5 && $rep_fetch; + + $* libbar 2>>~%EOE%; + disfigured libbar/1.0.0 + disfigured libfoo/1.0.0 + purged libfoo/1.0.0 + %.* + %.*fetched libbar/1.2.0% + unpacked libbar/1.2.0 + configured libbar/1.2.0 + %info: .+ is up to date% + updated libbar/1.2.0 + EOE + + $pkg_status libfoo >'libfoo available 1.0.0'; + $pkg_status libbar >'!libbar configured 1.2.0'; + + $* libbar/1.0.0 libfoo 2>>~%EOE%; + disfigured libbar/1.2.0 + %.* + %.*fetched libfoo/1.0.0% + unpacked libfoo/1.0.0 + configured libfoo/1.0.0 + %.* + %.*fetched libbar/1.0.0% + unpacked libbar/1.0.0 + configured libbar/1.0.0 + %info: .+ is up to date%{2} + updated libfoo/1.0.0 + updated libbar/1.0.0 + EOE + + $pkg_status libfoo >'!libfoo configured 1.0.0'; + $pkg_status libbar >'!libbar configured !1.0.0 available 1.2.0'; + + $* libbar 2>>~%EOE%; + disfigured libbar/1.0.0 + %.* + %.*fetched libbar/1.2.0% + unpacked libbar/1.2.0 + configured libbar/1.2.0 + %info: .+ is up to date% + updated libbar/1.2.0 + EOE + + $pkg_status libfoo >'!libfoo configured 1.0.0'; + $pkg_status libbar >'!libbar configured 1.2.0'; + + $pkg_disfigure libbar 2>'disfigured libbar/1.2.0'; + $pkg_purge libbar 2>'purged libbar/1.2.0'; + + $pkg_disfigure libfoo 2>'disfigured libfoo/1.0.0'; + $pkg_purge libfoo 2>'purged libfoo/1.0.0' + } + + : local-dependency + : + : Test that the local package can be built against the local dependency + : package. + : + { + # Prepare libbar and libbaz (libbaz->libbar) local packages using the + # temporary configuration. + # + $clone_root_cfg; + + $pkg_fetch -e $src/t4b/libbar-1.1.0.tar.gz; + $pkg_unpack libbar &cfg/libbar-1.1.0/***; + + $pkg_fetch -e $src/t4c/libbaz-1.1.0.tar.gz; + $pkg_unpack libbaz &cfg/libbaz-1.1.0/***; + + mv cfg/libbar-1.1.0 libbar; + mv cfg/libbaz-1.1.0 libbaz; + + rm -r cfg && $clone_root_cfg; # Re-clone. + $rep_add $rep/t4a && $rep_fetch; + + $* ./libbar/ 2>>~%EOE%; + %.* + %.*fetched libfoo/1.1.0% + unpacked libfoo/1.1.0 + configured libfoo/1.1.0 + using libbar/1.1.0 (external) + configured libbar/1.1.0 + %info: .+ is up to date% + updated libbar/1.1.0 + EOE + + $* ./libbaz/ 2>>~%EOE%; + using libbaz/1.1.0 (external) + configured libbaz/1.1.0 + %info: .+ is up to date% + updated libbaz/1.1.0 + EOE + + $pkg_disfigure libbaz 2>'disfigured libbaz/1.1.0'; + $pkg_purge libbaz 2>'purged libbaz/1.1.0'; + + $pkg_disfigure libbar 2>'disfigured libbar/1.1.0'; + $pkg_purge libbar 2>'purged libbar/1.1.0'; + + $pkg_disfigure libfoo 2>'disfigured libfoo/1.1.0'; + $pkg_purge libfoo 2>'purged libfoo/1.1.0' + } + + : upgrade-all-held + : + { + $clone_root_cfg && $rep_fetch $rep/t2 $rep/t5; + + $* libbar/1.0 2>>~%EOE%; + %.* + %.*fetched libfoo/1.0.0% + unpacked libfoo/1.0.0 + configured libfoo/1.0.0 + %.* + %.*fetched libbar/1.0.0% + unpacked libbar/1.0.0 + configured libbar/1.0.0 + %info: .+ is up to date% + updated libbar/1.0.0 + EOE + + $* --upgrade 2>>~%EOE%; + disfigured libbar/1.0.0 + disfigured libfoo/1.0.0 + purged libfoo/1.0.0 + %.* + %.*fetched libbar/1.2.0% + unpacked libbar/1.2.0 + configured libbar/1.2.0 + %info: .+ is up to date% + updated libbar/1.2.0 + EOE + + $pkg_status libbar >'!libbar configured 1.2.0'; + + $rep_remove $rep/t2 $rep/t5; + + $* --upgrade 2>>/EOE != 0; + error: libbar is not available + info: configuration cfg/ has no repositories + info: use 'bpkg rep-add' to add a repository + EOE + + $pkg_drop libbar + } +} + +: dependency +: +{ + : unknown + : + { + $clone_root_cfg; + $rep_fetch $rep/t0c; + + $* '?libbux' 2>'error: unknown package libbux' != 0; + $* '?sys:libbux' 2>'error: unknown package sys:libbux' != 0; + $* '?libbar/1.3' 2>'error: unknown package libbar/1.3' != 0 + } + + : unused + : + { + test.arguments += --configure-only + + +$clone_root_cfg + +$rep_fetch $rep/t2 $rep/t5 + + : drop + : + : Test dropping of unused dependencies (default behavior). + : + { + $clone_cfg; + + $* --yes libbar/1.0.0 2>>~%EOE%; + %.* + %.*fetched libfoo/1.0.0% + unpacked libfoo/1.0.0 + configured libfoo/1.0.0 + %.* + %.*fetched libbar/1.0.0% + unpacked libbar/1.0.0 + configured libbar/1.0.0 + EOE + + $* libbar/1.2.0 <'y' 2>>~%EOE%; + drop libfoo/1.0.0 (unused) + upgrade libbar/1.2.0 + continue? [Y/n] disfigured libbar/1.0.0 + disfigured libfoo/1.0.0 + purged libfoo/1.0.0 + %.* + %.*fetched libbar/1.2.0% + unpacked libbar/1.2.0 + configured libbar/1.2.0 + EOE + + $pkg_status libfoo >'libfoo available 1.0.0'; + + $pkg_disfigure libbar 2>'disfigured libbar/1.2.0'; + $pkg_purge libbar 2>'purged libbar/1.2.0' + } + + : keep + : + : Test keeping of unused dependencies (--keep-unused option). + : + { + $clone_cfg; + + $* --yes libbar/1.0.0 2>>~%EOE%; + %.* + %.*fetched libfoo/1.0.0% + unpacked libfoo/1.0.0 + configured libfoo/1.0.0 + %.* + %.*fetched libbar/1.0.0% + unpacked libbar/1.0.0 + configured libbar/1.0.0 + EOE + + $* --keep-unused libbar/1.2.0 <'y' 2>>~%EOE%; + upgrade libbar/1.2.0 + continue? [Y/n] disfigured libbar/1.0.0 + %.* + %.*fetched libbar/1.2.0% + unpacked libbar/1.2.0 + configured libbar/1.2.0 + EOE + + $pkg_status libfoo >'libfoo configured 1.0.0'; + + $pkg_disfigure libbar 2>'disfigured libbar/1.2.0'; + $pkg_purge libbar 2>'purged libbar/1.2.0'; + + $pkg_disfigure libfoo 2>'disfigured libfoo/1.0.0'; + $pkg_purge libfoo 2>'purged libfoo/1.0.0' + } + + : drop-recursive + : + { + test.arguments += --yes + + $clone_root_cfg; + $rep_fetch $rep/t0a $rep/t0c; + + $* libbar/0.0.1 2>!; + + $pkg_status libbaz >'libbaz configured 0.0.1 available 0.1.0 0.0.4 0.0.3'; + $pkg_status libfox >'libfox configured 0.0.1'; + + $* libbar 2>>~%EOE%; + disfigured libbar/0.0.1 + disfigured libbaz/0.0.1 + disfigured libfox/0.0.1 + %.* + %.*fetched libfoo/1.0.0% + unpacked libfoo/1.0.0 + configured libfoo/1.0.0 + purged libfox/0.0.1 + purged libbaz/0.0.1 + %.* + %.*fetched libbar/1.0.0% + unpacked libbar/1.0.0 + configured libbar/1.0.0 + EOE + + $pkg_status libbaz >'libbaz available 0.1.0 0.0.4 0.0.3 0.0.1'; + $pkg_status libfox >'libfox available 0.0.1'; + + $pkg_drop libbar + } + + : drop-unsatisfactory + : + : Test that a dependency (libbaz/0.0.3) that doesn't satisfy its dependent + : (libbar/0.0.1) but get dropped during the plan refinement, doesn't + : prevent the command to succeed. + : + { + test.arguments += --yes + + $clone_root_cfg; + $rep_fetch $rep/t0a $rep/t0c; + + $* libbar/0.0.1 2>!; + + $pkg_status libbaz >'libbaz configured 0.0.1 available 0.1.0 0.0.4 0.0.3'; + $pkg_status libfox >'libfox configured 0.0.1'; + + $* ?libbar ?libbaz/0.0.3 2>>~%EOE%; + disfigured libbar/0.0.1 + disfigured libbaz/0.0.1 + disfigured libfox/0.0.1 + purged libfox/0.0.1 + purged libbaz/0.0.1 + purged libbar/0.0.1 + EOE + + $pkg_status libbar >'libbar available 1.0.0 0.0.3 0.0.1'; + $pkg_status libbaz >'libbaz available 0.1.0 0.0.4 0.0.3 0.0.1'; + $pkg_status libfox >'libfox available 0.0.1' + } + } + + : apply-constraints + : + : Test that the desired dependency version imposes constraint that is taken + : into account during prerequisites collection (see collect_prerequisites() + : for more details). + : + { + test.arguments += --yes --configure-only + + : unable-satisfy + : + { + $clone_root_cfg; + $rep_fetch $rep/t0a $rep/t0b; + + $* libbar/0.0.1 ?libbaz/0.0.2 2>>EOE != 0 + error: unable to satisfy constraints on package libbaz + info: libbar depends on (libbaz == 0.0.1) + info: command line depends on (libbaz == 0.0.2) + info: specify libbaz version to satisfy libbar constraint + info: while satisfying libbar/0.0.1 + EOE + } + + : resolve-conflict + : + { + : satisfy-dependents + : + : Test resolving a conflict when libfix and libbiz have selected such + : versions of their dependency libbaz. that do not satisfy each other + : constraints. We resolve the conflict explicitly specifying + : ?libbaz/0.0.3 on the command line, which satisfies both constraints. + : + { + $clone_root_cfg; + $rep_fetch $rep/t0b $rep/t0c; + + $* libfix libbiz 2>>EOE != 0; + error: unable to satisfy constraints on package libbaz + info: libfix depends on (libbaz >= 0.0.3) + info: libbiz depends on (libbaz <= 0.0.3) + info: available libbaz/0.1.0 + info: available libbaz/0.0.2 + info: explicitly specify libbaz version to manually satisfy both constraints + info: while satisfying libbiz/0.0.2 + EOE + + $* libfix libbiz ?libbaz/0.0.3 2>>~%EOE%; + %.* + %.*fetched libfoo/1.0.0% + unpacked libfoo/1.0.0 + configured libfoo/1.0.0 + %.* + %.*fetched libbaz/0.0.3% + unpacked libbaz/0.0.3 + configured libbaz/0.0.3 + %.* + %.*fetched libfix/0.0.3% + unpacked libfix/0.0.3 + configured libfix/0.0.3 + %.* + %.*fetched libbiz/0.0.2% + unpacked libbiz/0.0.2 + configured libbiz/0.0.2 + EOE + + $pkg_status libbaz >'libbaz configured !0.0.3 available 0.1.0 0.0.4'; + + $pkg_drop libbiz libfix + } + + : postpone + : + : Same as above but with an opposite order of dependents on the command + : line. This would normally fail due the inability to find libbaz/0.0.3 + : in repositories available to libbiz, unless libbaz dependencies + : collection were not postponed (see collect_build_prerequisites() + : function for more details). + : + { + $clone_root_cfg; + $rep_fetch $rep/t0b $rep/t0c; + + $* libbiz libfix ?libbaz/0.0.3 2>>~%EOE%; + %.* + %.*fetched libfoo/1.0.0% + unpacked libfoo/1.0.0 + configured libfoo/1.0.0 + %.* + %.*fetched libbaz/0.0.3% + unpacked libbaz/0.0.3 + configured libbaz/0.0.3 + %.* + %.*fetched libbiz/0.0.2% + unpacked libbiz/0.0.2 + configured libbiz/0.0.2 + %.* + %.*fetched libfix/0.0.3% + unpacked libfix/0.0.3 + configured libfix/0.0.3 + EOE + + $pkg_status libbaz >'libbaz configured !0.0.3 available 0.1.0 0.0.4'; + + $pkg_drop libbiz libfix + } + + : replace-dependent + : + : Test resolving a conflict when libbox and libfox have selected such + : versions of their dependency libfoo, that do not satisfy each other + : constraints. Note that these constraints are incompatible, so we + : resolve the conflict explicitly specifying ?libfox/0.0.1 on the + : command line, to replace one of the conflicting dependents. + : + { + $clone_root_cfg; + $rep_fetch $rep/t0d; + + $* libbiz 2>>EOE != 0; + error: unable to satisfy constraints on package libfoo + info: libbox depends on (libfoo == 1.0.0) + info: libfox depends on (libfoo == 0.0.1) + info: available libfoo/1.0.0 + info: available libfoo/0.0.1 + info: explicitly specify libfoo version to manually satisfy both constraints + info: while satisfying libbox/0.0.2 + info: while satisfying libbiz/0.0.1 + EOE + + $* libbiz ?libfox/0.0.1 2>>~%EOE%; + %.* + %.*fetched libfox/0.0.1% + unpacked libfox/0.0.1 + configured libfox/0.0.1 + %.* + %.*fetched libfoo/1.0.0% + unpacked libfoo/1.0.0 + configured libfoo/1.0.0 + %.* + %.*fetched libbox/0.0.2% + unpacked libbox/0.0.2 + configured libbox/0.0.2 + %.* + %.*fetched libbiz/0.0.1% + unpacked libbiz/0.0.1 + configured libbiz/0.0.1 + EOE + + $pkg_status libfox >'libfox configured !0.0.1 available 0.0.2'; + + $pkg_drop libbiz + } + } + + : selected + : + : Test cases when the selected package (partially) satisfies the + : user-imposed dependency constraint. + : + { + +$clone_root_cfg + +$rep_fetch $rep/t0a $rep/t0b $rep/t0c + + : same + : + { + $clone_cfg; + + $* libbar/0.0.1 2>!; + $* libbar/0.0.2 ?libbaz/0.0.1 2>!; + + $pkg_status libbaz >'libbaz configured !0.0.1 available 0.1.0 0.0.4 0.0.3 0.0.2'; + $pkg_status libfox >'libfox configured 0.0.1'; + + $pkg_drop libbar + } + + : src-to-sys + : + { + $clone_cfg; + + $* libbar/0.0.1 2>!; + $* libbar/0.0.2 '?sys:libbaz/0.0.1' 2>!; + + $pkg_status libbaz >'libbaz configured,system !0.0.1 available 0.1.0 0.0.4 0.0.3 0.0.2'; + $pkg_status libfox >'libfox available 0.0.1'; + + $pkg_drop libbar + } + + : sysver-to-wildcard + : + { + $clone_cfg; + + $* libbar/0.0.1 '?sys:libbaz/0.0.1' 2>!; + $* libbar/0.0.2 '?sys:libbaz' 2>!; + + $pkg_status libbaz >'libbaz configured,system !* available 0.1.0 0.0.4 0.0.3 0.0.2 0.0.1'; + + $pkg_drop libbar + } + + : wildcard-to-sysver + : + { + $clone_cfg; + + $* libbar/0.0.1 '?sys:libbaz' 2>!; + $* libbar/0.0.2 '?sys:libbaz/0.0.1' 2>!; + + $pkg_status libbaz >'libbaz configured,system !0.0.1 available 0.1.0 0.0.4 0.0.3 0.0.2'; + + $pkg_drop libbar + } + } + + : unknown + : + { + $clone_root_cfg; + $rep_fetch $rep/t0a $rep/t0c; + + $* libbar/1.0.0 ?libfoo/0.0.1 2>>EOE != 0 + error: unknown dependency libfoo == 0.0.1 of package libbar + info: while satisfying libbar/1.0.0 + EOE + } + } + + : refine + : + { + test.arguments += --yes --configure-only + + +$clone_root_cfg + +$rep_fetch $rep/t0a $rep/t0c + + : system + : + { + +$clone_cfg + + : wildcard-to-version + : + { + $clone_cfg; + + $* libbar '?sys:libfoo' 2>>~%EOE%; + configured sys:libfoo/* + %.* + %.*fetched libbar/1.0.0% + unpacked libbar/1.0.0 + configured libbar/1.0.0 + EOE + + $* '?sys:libfoo/0.1' 2>>~%EOE%; + disfigured libbar/1.0.0 + purged libfoo/* + configured sys:libfoo/0.1 + configured libbar/1.0.0 + EOE + + $pkg_drop libbar + } + + : wildcard-to-itself + : + { + $clone_cfg; + + $* libbar '?sys:libfoo' 2>>~%EOE%; + configured sys:libfoo/* + %.* + %.*fetched libbar/1.0.0% + unpacked libbar/1.0.0 + configured libbar/1.0.0 + EOE + + $* '?sys:libfoo'; + + $pkg_drop libbar + } + + : wildcard-to-src + : + { + $clone_cfg; + + $* libbar/0.0.1 '?sys:libbaz' 2>>~%EOE%; + configured sys:libbaz/* + %.* + %.*fetched libbar/0.0.1% + unpacked libbar/0.0.1 + configured libbar/0.0.1 + EOE + + $* '?libbaz' 2>>~%EOE%; + disfigured libbar/0.0.1 + purged libbaz/* + %.* + %.*fetched libfox/0.0.1% + unpacked libfox/0.0.1 + configured libfox/0.0.1 + %.* + %.*fetched libbaz/0.0.1% + unpacked libbaz/0.0.1 + configured libbaz/0.0.1 + configured libbar/0.0.1 + EOE + + $pkg_drop libbar + } + + : version-to-wildcard + : + { + $clone_cfg; + + $* libbar '?sys:libfoo/0.1' 2>>~%EOE%; + configured sys:libfoo/0.1 + %.* + %.*fetched libbar/1.0.0% + unpacked libbar/1.0.0 + configured libbar/1.0.0 + EOE + + $* '?sys:libfoo' 2>>~%EOE%; + disfigured libbar/1.0.0 + purged libfoo/0.1 + configured sys:libfoo/* + configured libbar/1.0.0 + EOE + + $pkg_drop libbar + } + + : version-to-itself + : + { + $clone_cfg; + + $* libbar '?sys:libfoo/0.1' 2>>~%EOE%; + configured sys:libfoo/0.1 + %.* + %.*fetched libbar/1.0.0% + unpacked libbar/1.0.0 + configured libbar/1.0.0 + EOE + + $* '?sys:libfoo/0.1'; + + $pkg_drop libbar + } + + : version-to-version + : + { + $clone_cfg; + + $* libbar '?sys:libfoo/0.2' 2>>~%EOE%; + configured sys:libfoo/0.2 + %.* + %.*fetched libbar/1.0.0% + unpacked libbar/1.0.0 + configured libbar/1.0.0 + EOE + + $* '?sys:libfoo/0.1' 2>>~%EOE%; + disfigured libbar/1.0.0 + purged libfoo/0.2 + configured sys:libfoo/0.1 + configured libbar/1.0.0 + EOE + + $pkg_drop libbar + } + + : version-to-src + : + { + $clone_cfg; + + $* libbar/0.0.1 '?sys:libbaz/0.0.1' 2>>~%EOE%; + configured sys:libbaz/0.0.1 + %.* + %.*fetched libbar/0.0.1% + unpacked libbar/0.0.1 + configured libbar/0.0.1 + EOE + + $* '?libbaz/0.0.1' 2>>~%EOE%; + disfigured libbar/0.0.1 + purged libbaz/0.0.1 + %.* + %.*fetched libfox/0.0.1% + unpacked libfox/0.0.1 + configured libfox/0.0.1 + %.* + %.*fetched libbaz/0.0.1% + unpacked libbaz/0.0.1 + configured libbaz/0.0.1 + configured libbar/0.0.1 + EOE + + $pkg_drop libbar + } + + : src-to-wildcard + : + { + $clone_cfg; + + $* libbar/0.0.1 '?libbaz' 2>>~%EOE%; + %.* + %.*fetched libfox/0.0.1% + unpacked libfox/0.0.1 + configured libfox/0.0.1 + %.* + %.*fetched libbaz/0.0.1% + unpacked libbaz/0.0.1 + configured libbaz/0.0.1 + %.* + %.*fetched libbar/0.0.1% + unpacked libbar/0.0.1 + configured libbar/0.0.1 + EOE + + $* '?sys:libbaz' 2>>~%EOE%; + disfigured libbar/0.0.1 + disfigured libbaz/0.0.1 + disfigured libfox/0.0.1 + purged libfox/0.0.1 + purged libbaz/0.0.1 + configured sys:libbaz/* + configured libbar/0.0.1 + EOE + + $pkg_drop libbar + } + + : src-to-version + : + { + $clone_cfg; + + $* libbar/0.0.1 '?libbaz/0.0.1' 2>>~%EOE%; + %.* + %.*fetched libfox/0.0.1% + unpacked libfox/0.0.1 + configured libfox/0.0.1 + %.* + %.*fetched libbaz/0.0.1% + unpacked libbaz/0.0.1 + configured libbaz/0.0.1 + %.* + %.*fetched libbar/0.0.1% + unpacked libbar/0.0.1 + configured libbar/0.0.1 + EOE + + $* '?sys:libbaz/0.0.1' 2>>~%EOE%; + disfigured libbar/0.0.1 + disfigured libbaz/0.0.1 + disfigured libfox/0.0.1 + purged libfox/0.0.1 + purged libbaz/0.0.1 + configured sys:libbaz/0.0.1 + configured libbar/0.0.1 + EOE + + $pkg_drop libbar + } + } + + : source + : + { + +$clone_cfg + + : unavailable + : + { + $clone_cfg; + + $* libbar/1.0.0 2>!; + + $* ?libfoo/0.0.1 2>>EOE != 0; + error: libfoo/0.0.1 is not available from its dependents' repositories + EOE + + $pkg_drop libbar + } + + : satisfy + : + { + $clone_cfg; + $rep_fetch $rep/t0b; + + $* libbar/0.0.1 2>!; + + $pkg_status libbaz >'libbaz configured 0.0.1 available 0.1.0 0.0.4 0.0.3 0.0.2'; + + $* libbar/0.0.2 ?libbaz 2>>~%EOE%; + disfigured libbar/0.0.1 + disfigured libbaz/0.0.1 + disfigured libfox/0.0.1 + purged libfox/0.0.1 + %.* + %.*fetched libfoo/1.0.0% + unpacked libfoo/1.0.0 + configured libfoo/1.0.0 + %.* + %.*fetched libbaz/0.0.2% + unpacked libbaz/0.0.2 + configured libbaz/0.0.2 + %.* + %.*fetched libbar/0.0.2% + unpacked libbar/0.0.2 + configured libbar/0.0.2 + EOE + + $pkg_status libbaz >'libbaz configured 0.0.2 available 0.1.0 0.0.4 0.0.3'; + + $rep_remove $rep/t0b && $rep_fetch; + + # Test that the selected package, that is "better" than the available + # one, is left. + # + $* libbox ?libbaz 2>>~%EOE%; + %.* + %.*fetched libbox/0.0.1% + unpacked libbox/0.0.1 + configured libbox/0.0.1 + EOE + + $pkg_status libbaz >'libbaz configured 0.0.2 available 0.1.0 0.0.4 0.0.3'; + + $rep_remove $rep/t0a && $rep_fetch; + + # Test that the selected package is left as there is no satisfactory + # available package. + # + $* ?libbaz; + + # Test that the above behavior is not triggered for the system package. + # + $* '?sys:libbaz' 2>>~%EOE%; + disfigured libbar/0.0.2 + disfigured libbox/0.0.1 + disfigured libbaz/0.0.2 + disfigured libfoo/1.0.0 + purged libfoo/1.0.0 + purged libbaz/0.0.2 + configured sys:libbaz/* + configured libbox/0.0.1 + configured libbar/0.0.2 + EOE + + $pkg_status libbaz >'libbaz configured,system !* available 0.1.0 0.0.4 0.0.3'; + + $pkg_drop libbar libbox + } + + : unsatisfied + : + { + $clone_cfg; + + $* libbar/0.0.1 2>!; + + $pkg_status libbaz >'libbaz configured 0.0.1 available 0.1.0 0.0.4 0.0.3'; + + $* ?libbaz/0.0.3 2>>EOE != 0; + error: package libbaz doesn't satisfy its dependents + info: libbaz/0.0.3 doesn't satisfy libbar/0.0.1 + EOE + + $pkg_status libbaz >'libbaz configured 0.0.1 available 0.1.0 0.0.4 0.0.3'; + + $pkg_drop libbar + } + } + + : scratch + : + { + $clone_cfg; + + $* libbox 2>!; + + $pkg_status libbaz >'libbaz configured 0.0.3 available 0.1.0 0.0.4'; + $pkg_status libfoo >'libfoo configured 0.0.1 available 1.0.0'; + $pkg_status libfox >'libfox available 0.0.1'; + + # After the first simulation it is discovered that libfoo needs to be + # upgraded to 1.0.0. But after the second simulation, that upgrades + # libfoo, it is discovered that it is now unused (libbaz doesn't need it + # anymore). So we replace libfoo upgrade with drop and start from + # scratch. + # + $* ?libfoo/1.0.0 ?libbaz/0.0.1 2>>~%EOE%; + disfigured libbox/0.0.1 + disfigured libbaz/0.0.3 + disfigured libfoo/0.0.1 + disfigured libfix/0.0.1 + purged libfix/0.0.1 + purged libfoo/0.0.1 + %.* + %.*fetched libfox/0.0.1% + unpacked libfox/0.0.1 + configured libfox/0.0.1 + %.* + %.*fetched libbaz/0.0.1% + unpacked libbaz/0.0.1 + configured libbaz/0.0.1 + configured libbox/0.0.1 + EOE + + $pkg_status libbaz >'libbaz configured !0.0.1 available 0.1.0 0.0.4 0.0.3'; + $pkg_status libfoo >'libfoo available 1.0.0 0.0.1'; + $pkg_status libfox >'libfox configured 0.0.1'; + + $pkg_drop libbox + } + + : reconf-dependent + : + { + $clone_cfg; + $rep_fetch $rep/t0b; + + $* libbar/0.0.2 2>!; + + $pkg_status libbaz >'libbaz configured 0.0.2 available 0.1.0 0.0.4 0.0.3'; + $pkg_status libfoo >'libfoo configured 1.0.0'; + + $* '?sys:libfoo' ?libbaz/0.0.2 2>>EOE; + disfigured libbar/0.0.2 + disfigured libbaz/0.0.2 + disfigured libfoo/1.0.0 + purged libfoo/1.0.0 + configured sys:libfoo/* + configured libbaz/0.0.2 + configured libbar/0.0.2 + EOE + + $pkg_drop libbar + } + } + + : unhold + : + { + test.arguments += --configure-only + + +$clone_root_cfg + +$rep_fetch $rep/t0a + + : drop + : + { + $clone_cfg; + + $* libfox 2>!; + + $* ?libfox --yes 2>>EOE; + disfigured libfox/0.0.1 + purged libfox/0.0.1 + EOE + + $pkg_status libfox >'libfox available 0.0.1' + } + + : silent + : + { + $clone_cfg; + + $* libbar libbaz --yes 2>!; + $pkg_status libbaz >'!libbaz configured 0.0.1 available 0.0.3'; + + $* ?libbaz; + $pkg_status libbaz >'libbaz configured 0.0.1 available 0.0.3'; + + $pkg_drop libbar + } + + : prompt + : + { + $clone_cfg; + + $* libbar libbaz --yes 2>!; + $pkg_status libbaz >'!libbaz configured 0.0.1 available 0.0.3'; + + $* '?sys:libbaz' < 'y' 2>>EOE; + drop libfox/0.0.1 (unused) + reconfigure/unhold sys:libbaz/* + reconfigure libbar (dependent of libbaz) + continue? [Y/n] disfigured libbar/0.0.1 + disfigured libbaz/0.0.1 + disfigured libfox/0.0.1 + purged libfox/0.0.1 + purged libbaz/0.0.1 + configured sys:libbaz/* + configured libbar/0.0.1 + EOE + + $pkg_status libbaz >'libbaz configured,system !* available 0.0.3 0.0.1'; + + $pkg_drop libbar + } + + : unheld + : + { + $clone_cfg; + + $* libbar ?libbaz --yes 2>!; + $pkg_status libbaz >'libbaz configured 0.0.1 available 0.0.3'; + + $* ?libbaz; + $pkg_status libbaz >'libbaz configured 0.0.1 available 0.0.3'; + + $pkg_drop libbar + } + } + + : options + : + { + : keep-out + : + : Test that --keep-out is properly propagated when building libhello + : as a dependency, so it is built incrementally. + : + { + $cfg_create cxx "config.cxx=$config.cxx" -d cfg 2>- &cfg/***; + + # Add libhello as the dir repository. + # + cp -r $src/libhello-1.0.0 ./libhello; + $rep_add libhello --type dir; + + # Add libfoo as the dir repository and make it a dependent of libhello. + # + cp -r $src/libfoo-1.1.0 libfoo; + echo 'depends: libhello' >+libfoo/manifest; + $rep_add libfoo --type dir; + + $rep_fetch; + + # Note that libfoo building doesn't trigger libhello building as it is a + # fake dependent, so build both explicitly. + # + $* libfoo ?libhello 2>!; + + # Move libhello version ahead. + # + sed -i -e 's/(version: 1.0).0/\1.1/' libhello/manifest; + $rep_fetch; + + # Upgrade libhello as a dependency. + # + # Note that despite the fact that we have modified the libhello's + # manifest file after the build, libhello may still be considered up to + # date on filesystems with a low file timestamps resolution (for example + # HFS+). + # + # @@ By some reason the following build occasionally re-links, so the + # test fails (most often reproduced on Windows). We will copy the + # configuration directory preserving file timestamps to research the + # issue when it get reproduced. + # + cp -r cfg cfg-backup; + + $* ?libhello --yes --keep-out 2>>~%EOE% + disfigured libfoo/1.1.0 + disfigured libhello/1.0.0 + using libhello/1.0.1 (external) + configured libhello/1.0.1 + configured libfoo/1.1.0 + %info: .+ is up to date%{1,2} + updated libhello/1.0.1 + updated libfoo/1.1.0 + EOE + } + } + + : dependents + : + { + test.arguments += --yes --configure-only + + : order + : + : Test that libbar that is built but isn't upgraded (and so doesn't order + : itself against dependencies) is still properly reconfigured being + : ordered as (an indirect) dependent of libfoo. + : + { + $clone_root_cfg; + $rep_fetch $rep/t0a $rep/t0b; + + $* libbar libfoo/0.0.1 2>>~%EOE%; + %.* + %.*fetched libfoo/0.0.1% + unpacked libfoo/0.0.1 + configured libfoo/0.0.1 + %.* + %.*fetched libbaz/0.0.2% + unpacked libbaz/0.0.2 + configured libbaz/0.0.2 + %.* + %.*fetched libbar/0.0.2% + unpacked libbar/0.0.2 + configured libbar/0.0.2 + EOE + + $* libbar libfoo 2>>~%EOE%; + disfigured libbar/0.0.2 + disfigured libbaz/0.0.2 + disfigured libfoo/0.0.1 + %.* + %.*fetched libfoo/1.0.0% + unpacked libfoo/1.0.0 + configured libfoo/1.0.0 + configured libbaz/0.0.2 + configured libbar/0.0.2 + EOE + + $pkg_drop libbaz libbar libfoo + } + + : adjust-merge-build + : + : Test that the registered in the map but not ordered package build + : (libfoo) is properly merged into the reconfigure adjustment as a + : dependent of the reconfigured dependency (see collect_order_dependents() + : for more details). + : + { + $clone_root_cfg; + $rep_fetch $rep/t0a; + + $* libfoo 2>>~%EOE%; + %.* + %.*fetched libfix/0.0.1% + unpacked libfix/0.0.1 + configured libfix/0.0.1 + %.* + %.*fetched libfoo/0.0.1% + unpacked libfoo/0.0.1 + configured libfoo/0.0.1 + EOE + + $* libbaz libbar 'sys:libfix' 2>>~%EOE%; + disfigured libfoo/0.0.1 + disfigured libfix/0.0.1 + %.* + %.*fetched libfox/0.0.1% + unpacked libfox/0.0.1 + configured libfox/0.0.1 + %.* + %.*fetched libbaz/0.0.1% + unpacked libbaz/0.0.1 + configured libbaz/0.0.1 + %.* + %.*fetched libbar/0.0.1% + unpacked libbar/0.0.1 + configured libbar/0.0.1 + purged libfix/0.0.1 + configured sys:libfix/* + configured libfoo/0.0.1 + EOE + + $pkg_drop libbaz libbar libfoo + } + } + + : upgrade + : + : Test dependency upgrade using --immediate and --recursive options. + : + { + test.arguments += --configure-only --upgrade + + +$clone_root_cfg + +$rep_fetch $rep/t0a $rep/t0b $rep/t0c + + +$* libbar/0.0.2 libbaz/0.0.2 libfoo/0.0.1 --yes 2>>~%EOE% + %.* + %.*fetched libfix/0.0.1% + unpacked libfix/0.0.1 + configured libfix/0.0.1 + %.* + %.*fetched libfoo/0.0.1% + unpacked libfoo/0.0.1 + configured libfoo/0.0.1 + %.* + %.*fetched libbaz/0.0.2% + unpacked libbaz/0.0.2 + configured libbaz/0.0.2 + %.* + %.*fetched libbar/0.0.2% + unpacked libbar/0.0.2 + configured libbar/0.0.2 + EOE + + clone_cfg = cp --no-cleanup -r ../cfg ./ &cfg/*** + + : immediate + : + { + $clone_cfg; + + $* libbar/0.0.3 --immediate --yes 2>>~%EOE%; + disfigured libbar/0.0.2 + disfigured libbaz/0.0.2 + %.* + %.*fetched libbaz/0.1.0% + unpacked libbaz/0.1.0 + configured libbaz/0.1.0 + %.* + %.*fetched libbar/0.0.3% + unpacked libbar/0.0.3 + configured libbar/0.0.3 + EOE + + $pkg_status libbar >'!libbar configured !0.0.3 available 1.0.0'; + $pkg_status libbaz >'!libbaz configured !0.1.0'; + $pkg_status libfoo >'!libfoo configured !0.0.1 available 1.0.0' + } + + : recursive + : + { + $clone_cfg; + + $* libbar/0.0.3 --recursive --yes 2>>~%EOE%; + disfigured libbar/0.0.2 + disfigured libbaz/0.0.2 + disfigured libfoo/0.0.1 + %.* + %.*fetched libfoo/1.0.0% + unpacked libfoo/1.0.0 + configured libfoo/1.0.0 + %.* + %.*fetched libbaz/0.1.0% + unpacked libbaz/0.1.0 + configured libbaz/0.1.0 + %.* + %.*fetched libbar/0.0.3% + unpacked libbar/0.0.3 + configured libbar/0.0.3 + EOE + + $pkg_status libbar >'!libbar configured !0.0.3 available 1.0.0'; + $pkg_status libbaz >'!libbaz configured !0.1.0'; + $pkg_status libfoo >'!libfoo configured !1.0.0' + } + + : all-held + : + { + $clone_cfg; + + $* ?libfoo/0.0.1 ?libbaz/0.0.2; # Unhold. + + $* --upgrade --recursive <'y' 2>>~%EOE% + drop libfix/0.0.1 (unused) + upgrade libfoo/1.0.0 + drop libbaz/0.0.2 (unused) + upgrade libbar/1.0.0 + continue? [Y/n] disfigured libbar/0.0.2 + disfigured libbaz/0.0.2 + disfigured libfoo/0.0.1 + disfigured libfix/0.0.1 + purged libfix/0.0.1 + %.* + %.*fetched libfoo/1.0.0% + unpacked libfoo/1.0.0 + configured libfoo/1.0.0 + purged libbaz/0.0.2 + %.* + %.*fetched libbar/1.0.0% + unpacked libbar/1.0.0 + configured libbar/1.0.0 + EOE + } + + : prompt + : + { + $clone_cfg; + + $* libbaz/0.0.2 --recursive <'y' 2>>~%EOE% + drop libfix/0.0.1 (unused) + upgrade libfoo/1.0.0 + reconfigure libbaz/0.0.2 + reconfigure libbar (dependent of libbaz) + continue? [Y/n] disfigured libbar/0.0.2 + disfigured libbaz/0.0.2 + disfigured libfoo/0.0.1 + disfigured libfix/0.0.1 + purged libfix/0.0.1 + %.* + %.*fetched libfoo/1.0.0% + unpacked libfoo/1.0.0 + configured libfoo/1.0.0 + configured libbaz/0.0.2 + configured libbar/0.0.2 + EOE + } + + : override + : + { + $clone_cfg; + + $* libbar/0.0.3 ?libbaz/0.0.3 --recursive --yes 2>>~%EOE%; + disfigured libbar/0.0.2 + disfigured libbaz/0.0.2 + disfigured libfoo/0.0.1 + %.* + %.*fetched libfoo/1.0.0% + unpacked libfoo/1.0.0 + configured libfoo/1.0.0 + %.* + %.*fetched libbaz/0.0.3% + unpacked libbaz/0.0.3 + configured libbaz/0.0.3 + %.* + %.*fetched libbar/0.0.3% + unpacked libbar/0.0.3 + configured libbar/0.0.3 + EOE + + $pkg_status libbaz >'libbaz configured !0.0.3 available 0.1.0 0.0.4' + } + + : unhold + : + { + $clone_cfg; + + $* libbar/0.0.3 ?libbaz/0.0.3 ?libfoo --recursive --yes 2>>~%EOE%; + disfigured libbar/0.0.2 + disfigured libbaz/0.0.2 + disfigured libfoo/0.0.1 + %.* + %.*fetched libfoo/1.0.0% + unpacked libfoo/1.0.0 + configured libfoo/1.0.0 + %.* + %.*fetched libbaz/0.0.3% + unpacked libbaz/0.0.3 + configured libbaz/0.0.3 + %.* + %.*fetched libbar/0.0.3% + unpacked libbar/0.0.3 + configured libbar/0.0.3 + EOE + + $pkg_status libbar >'!libbar configured !0.0.3 available 1.0.0'; + $pkg_status libbaz >'libbaz configured !0.0.3 available 0.1.0 0.0.4'; + $pkg_status libfoo >'libfoo configured 1.0.0' + } + + : unavailable + : + : Test that the selected dependency (libfix/0.0.1) is silently left + : unchanged if there is no package available from the dependents + : repositories. + : + { + $clone_cfg; + $rep_remove $rep/t0a $rep/t0b $rep/t0c; + + $* libbar --recursive --yes + } + + -$pkg_drop libbar libbaz libfoo + } +} + +: dependent +: +{ + +$clone_cfg + +$rep_add $rep/t2 && $rep_fetch + + : update + : + : Test --update-dependent option. + : + { + $clone_cfg; + + $* --yes libbar 2>>~%EOE%; + %.* + %.*fetched libfoo/1.0.0% + unpacked libfoo/1.0.0 + configured libfoo/1.0.0 + %.* + %.*fetched libbar/1.0.0% + unpacked libbar/1.0.0 + configured libbar/1.0.0 + %info: .+ is up to date% + updated libbar/1.0.0 + EOE + + $rep_add $rep/t4a && $rep_fetch; + + $* --update-dependent libfoo/1.1.0 <'y' 2>>~%EOE%; + upgrade libfoo/1.1.0 + reconfigure libbar (dependent of libfoo) + continue? [Y/n] disfigured libbar/1.0.0 + disfigured libfoo/1.0.0 + %.* + %.*fetched libfoo/1.1.0% + unpacked libfoo/1.1.0 + configured libfoo/1.1.0 + configured libbar/1.0.0 + %info: .+ is up to date%{2} + updated libfoo/1.1.0 + updated libbar/1.0.0 + EOE + + $pkg_disfigure libbar 2>'disfigured libbar/1.0.0'; + $pkg_purge libbar 2>'purged libbar/1.0.0'; + + $pkg_disfigure libfoo 2>'disfigured libfoo/1.1.0'; + $pkg_purge libfoo 2>'purged libfoo/1.1.0' + } + + : leave + : + : Test --leave-dependent option. + : + { + $clone_cfg; + + $* --yes libbar 2>>~%EOE%; + %.* + %.*fetched libfoo/1.0.0% + unpacked libfoo/1.0.0 + configured libfoo/1.0.0 + %.* + %.*fetched libbar/1.0.0% + unpacked libbar/1.0.0 + configured libbar/1.0.0 + %info: .+ is up to date% + updated libbar/1.0.0 + EOE + + $rep_add $rep/t4a && $rep_fetch; + + $* --leave-dependent libfoo/1.1.0 <'y' 2>>~%EOE%; + upgrade libfoo/1.1.0 + reconfigure libbar (dependent of libfoo) + continue? [Y/n] disfigured libbar/1.0.0 + disfigured libfoo/1.0.0 + %.* + %.*fetched libfoo/1.1.0% + unpacked libfoo/1.1.0 + configured libfoo/1.1.0 + configured libbar/1.0.0 + %info: .+ is up to date% + updated libfoo/1.1.0 + EOE + + $pkg_disfigure libbar 2>'disfigured libbar/1.0.0'; + $pkg_purge libbar 2>'purged libbar/1.0.0'; + + $pkg_disfigure libfoo 2>'disfigured libfoo/1.1.0'; + $pkg_purge libfoo 2>'purged libfoo/1.1.0' + } +} + +: patch +: +{ + test.arguments += --configure-only --yes + + +$clone_root_cfg + + : held + : + { + +$clone_cfg + +$rep_fetch $rep/t0c + + : success + : + { + $clone_cfg; + + $* libbaz/0.0.3 2>!; + + $* libbaz --patch 2>>~%EOE%; + disfigured libbaz/0.0.3 + disfigured libfoo/1.0.0 + purged libfoo/1.0.0 + %.* + %.*fetched libbaz/0.0.4% + unpacked libbaz/0.0.4 + configured libbaz/0.0.4 + EOE + + $pkg_drop libbaz + } + + : ignore + : + { + $clone_cfg; + + $* libbaz/0.0.3 --patch 2>>~%EOE%; + %.* + %.*fetched libfoo/1.0.0% + unpacked libfoo/1.0.0 + configured libfoo/1.0.0 + %.* + %.*fetched libbaz/0.0.3% + unpacked libbaz/0.0.3 + configured libbaz/0.0.3 + EOE + + $* libbaz/0.1.0 --patch 2>>~%EOE%; + disfigured libbaz/0.0.3 + disfigured libfoo/1.0.0 + purged libfoo/1.0.0 + %.* + %.*fetched libbaz/0.1.0% + unpacked libbaz/0.1.0 + configured libbaz/0.1.0 + EOE + + $pkg_drop libbaz + } + + : warn + : + { + $clone_cfg; + + $* 'sys:libbaz/0.0.3-alpha' 2>!; + + $* libbaz --patch 2>>~%EOE%; + warning: unable to patch libbaz/0.0.3-alpha + info: package is not using semantic/standard version + info: nothing to build + EOE + + $pkg_drop libbaz + } + } + + : dependency + : + { + +$clone_cfg + +$rep_fetch $rep/t0c + + +$* libbox libfix ?libbaz/0.0.3 2>>~%EOE% + %.* + %.*fetched libfoo/1.0.0% + unpacked libfoo/1.0.0 + configured libfoo/1.0.0 + %.* + %.*fetched libbaz/0.0.3% + unpacked libbaz/0.0.3 + configured libbaz/0.0.3 + %.* + %.*fetched libbox/0.0.1% + unpacked libbox/0.0.1 + configured libbox/0.0.1 + %.* + %.*fetched libfix/0.0.3% + unpacked libfix/0.0.3 + configured libfix/0.0.3 + EOE + + clone_cfg = cp --no-cleanup -r ../cfg ./ &cfg/*** + + : explicitly + : + : Here we also test that the package --path option overrides the global + : --upgrade option. + : + { + $clone_cfg; + + $* ?libbaz +{ --patch } --upgrade 2>>~%EOE% + disfigured libbox/0.0.1 + disfigured libfix/0.0.3 + disfigured libbaz/0.0.3 + disfigured libfoo/1.0.0 + purged libfoo/1.0.0 + %.* + %.*fetched libbaz/0.0.4% + unpacked libbaz/0.0.4 + configured libbaz/0.0.4 + configured libfix/0.0.3 + configured libbox/0.0.1 + EOE + } + + : warn + : + { + $clone_cfg; + + $* '?sys:libbaz/0.0.4-alpha' 2>!; + + $* ?libbaz --patch 2>>~%EOE% + warning: unable to patch libbaz/0.0.4-alpha + info: package is not using semantic/standard version + EOE + } + + : recursive + : + { + $clone_cfg; + + $* --patch --recursive 2>>~%EOE% + disfigured libfix/0.0.3 + disfigured libbox/0.0.1 + disfigured libbaz/0.0.3 + disfigured libfoo/1.0.0 + purged libfoo/1.0.0 + %.* + %.*fetched libbaz/0.0.4% + unpacked libbaz/0.0.4 + configured libbaz/0.0.4 + configured libbox/0.0.1 + configured libfix/0.0.3 + EOE + } + + : upgrade-wins-patch + : + : Test that --upgrade options wins --patch. + : + { + $clone_cfg; + + $* libbox +{ --upgrade-immediate } libfix +{ --patch-immediate } 2>>~%EOE% + disfigured libfix/0.0.3 + disfigured libbox/0.0.1 + disfigured libbaz/0.0.3 + disfigured libfoo/1.0.0 + purged libfoo/1.0.0 + %.* + %.*fetched libbaz/0.1.0% + unpacked libbaz/0.1.0 + configured libbaz/0.1.0 + configured libbox/0.0.1 + configured libfix/0.0.3 + EOE + } + + : unavailable + : + { + $clone_cfg; + + $* '?sys:libbaz/0.0.3' 2>>EOE; + disfigured libbox/0.0.1 + disfigured libfix/0.0.3 + disfigured libbaz/0.0.3 + disfigured libfoo/1.0.0 + purged libfoo/1.0.0 + purged libbaz/0.0.3 + configured sys:libbaz/0.0.3 + configured libfix/0.0.3 + configured libbox/0.0.1 + EOE + + $rep_remove $rep/t0c; + $rep_fetch $rep/t0b; + + $* ?libbaz --patch --yes 2>>EOE != 0 + error: patch version for sys:libbaz/0.0.3 is not available from its dependents' repositories + EOE + } + + -$pkg_drop libbox libfix libbaz libfoo + } + + : from-repository + : + { + test.arguments += --patch --auth all --trust-yes + + +$clone_cfg + + +$* "libbaz/0.0.3@$rep/t0c" 2>>~%EOE% + added pkg:build2.org/pkg-build/t0c + %.* + %.*fetching pkg:build2.org/pkg-build/t0c% + %.* + %.*fetched libfoo/1.0.0% + unpacked libfoo/1.0.0 + configured libfoo/1.0.0 + %.* + %.*fetched libbaz/0.0.3% + unpacked libbaz/0.0.3 + configured libbaz/0.0.3 + EOE + + clone_cfg = cp --no-cleanup -r ../cfg ./ &cfg/*** + + : explicit + : + { + $clone_cfg; + + $* "libbaz@$rep/t0c" 2>>~%EOE% + fetching pkg:build2.org/pkg-build/t0c + disfigured libbaz/0.0.3 + disfigured libfoo/1.0.0 + purged libfoo/1.0.0 + %.* + %.*fetched libbaz/0.0.4% + unpacked libbaz/0.0.4 + configured libbaz/0.0.4 + EOE + } + + : implicit + : + : Note that libfoo also becomes held. + : + { + $clone_cfg; + + $* "@$rep/t0c" 2>>~%EOE%; + fetching pkg:build2.org/pkg-build/t0c + info: package libbar is not present in configuration + info: package libbox is not present in configuration + info: package libfix is not present in configuration + disfigured libbaz/0.0.3 + %.* + %.*fetched libbaz/0.0.4% + unpacked libbaz/0.0.4 + configured libbaz/0.0.4 + EOE + + $pkg_status libfoo >'!libfoo configured !1.0.0' + } + + -$pkg_drop libbaz libfoo + } +} + +: configure-only +: +: Test --configure-only option. +: +{ + $clone_cfg; + $rep_add $rep/t2 && $rep_fetch; + + $* --configure-only --yes libbar 2>>~%EOE%; + %.* + %.*fetched libfoo/1.0.0% + unpacked libfoo/1.0.0 + configured libfoo/1.0.0 + %.* + %.*fetched libbar/1.0.0% + unpacked libbar/1.0.0 + configured libbar/1.0.0 + EOE + + $pkg_disfigure libbar 2>'disfigured libbar/1.0.0'; + $pkg_purge libbar 2>'purged libbar/1.0.0'; + + $pkg_disfigure libfoo 2>'disfigured libfoo/1.0.0'; + $pkg_purge libfoo 2>'purged libfoo/1.0.0' +} + +: repository-location +: +{ + test.arguments += --yes --auth all --trust-yes + + : all-packages + : + { + : explicit + : + { + $clone_root_cfg; + + $* "@$rep/t4d" 2>>~%EOE%; + %.+ + %info: .+ is up to date%{2} + updated libfox/1.0.0 + updated libbiz/1.0.0 + EOE + + $pkg_disfigure libbiz 2>'disfigured libbiz/1.0.0'; + $pkg_purge libbiz 2>'purged libbiz/1.0.0'; + + $pkg_disfigure libfox 2>'disfigured libfox/1.0.0'; + $pkg_purge libfox 2>'purged libfox/1.0.0'; + + $pkg_disfigure libbaz 2>'disfigured libbaz/1.1.0'; + $pkg_purge libbaz 2>'purged libbaz/1.1.0'; + + $pkg_disfigure libbar 2>'disfigured libbar/1.1.0'; + $pkg_purge libbar 2>'purged libbar/1.1.0'; + + $pkg_disfigure libfoo 2>'disfigured libfoo/1.1.0'; + $pkg_purge libfoo 2>'purged libfoo/1.1.0' + } + + : url-detection + : + { + $clone_root_cfg; + + if ($remote != true) + rep = ($cxx.target.class != 'windows' \ + ? "file:$rep" \ + : "file:/$regex.replace($rep, '\\', '/')") + end; + + $* "$rep/t4d" 2>>~%EOE%; + %.+ + %info: .+ is up to date%{2} + updated libfox/1.0.0 + updated libbiz/1.0.0 + EOE + + $pkg_disfigure libbiz 2>'disfigured libbiz/1.0.0'; + $pkg_purge libbiz 2>'purged libbiz/1.0.0'; + + $pkg_disfigure libfox 2>'disfigured libfox/1.0.0'; + $pkg_purge libfox 2>'purged libfox/1.0.0'; + + $pkg_disfigure libbaz 2>'disfigured libbaz/1.1.0'; + $pkg_purge libbaz 2>'purged libbaz/1.1.0'; + + $pkg_disfigure libbar 2>'disfigured libbar/1.1.0'; + $pkg_purge libbar 2>'purged libbar/1.1.0'; + + $pkg_disfigure libfoo 2>'disfigured libfoo/1.1.0'; + $pkg_purge libfoo 2>'purged libfoo/1.1.0' + } + } + + : multiple-packages + : + { + $clone_root_cfg; + + $* "libfox,libbiz/1.0.0@$rep/t4d" 2>>~%EOE%; + %.+ + %info: .+ is up to date%{2} + updated libfox/1.0.0 + updated libbiz/1.0.0 + EOE + + $pkg_disfigure libbiz 2>'disfigured libbiz/1.0.0'; + $pkg_purge libbiz 2>'purged libbiz/1.0.0'; + + $pkg_disfigure libfox 2>'disfigured libfox/1.0.0'; + $pkg_purge libfox 2>'purged libfox/1.0.0'; + + $pkg_disfigure libbaz 2>'disfigured libbaz/1.1.0'; + $pkg_purge libbaz 2>'purged libbaz/1.1.0'; + + $pkg_disfigure libbar 2>'disfigured libbar/1.1.0'; + $pkg_purge libbar 2>'purged libbar/1.1.0'; + + $pkg_disfigure libfoo 2>'disfigured libfoo/1.1.0'; + $pkg_purge libfoo 2>'purged libfoo/1.1.0' + } + + : version + : + : Test that libfoo/0.0.1 package version is built (repository t0a), rather + : than libfoo/1.0.0 (repository t4a). + : + { + $clone_root_cfg; + + $rep_fetch $rep/t4c 2>!; + + $* "libfoo@$rep/t0a" 2>>~%EOE%; + %.+ + configured libfoo/0.0.1 + %info: .+ is up to date% + updated libfoo/0.0.1 + EOE + + $pkg_drop libfoo + } + + : no-patch + : + : Here we also test that --patch options is ignored if there is no selected + : package in the configuration. + : + { + $clone_root_cfg; + + $* "libfoo@$rep/t1" --patch 2>>~%EOE%; + %.+ + configured libfoo/1.0.0 + %info: .+ is up to date% + updated libfoo/1.0.0 + EOE + + $* "libfoo@$rep/t3" --patch 2>>~%EOE% != 0; + %.+ + error: patch version for libfoo/1.0.0 is not found in pkg:build2.org/pkg-build/t3 + EOE + + $pkg_drop libfoo + } + + : package-in-complement + : + { + $clone_root_cfg; + + $* "libfoo@$rep/t4d" 2>>~%EOE%; + %.+ + %info: .+ is up to date% + updated libfoo/1.0.0 + EOE + + $pkg_disfigure libfoo 2>'disfigured libfoo/1.0.0'; + $pkg_purge libfoo 2>'purged libfoo/1.0.0' + } + + : system + : + { + $clone_root_cfg; + + $* "sys:libbiz/2.0.0@$rep/t4d" 2>>~%EOE%; + %.+ + configured sys:libbiz/2.0.0 + EOE + + $pkg_disfigure libbiz 2>'purged libbiz/2.0.0' + } + + : non-existent-package + : + { + $clone_root_cfg; + + $* "libbar@$rep/t4d" 2>>~%EOE% != 0 + %.+ + error: package libbar is not found in pkg:build2.org/pkg-build/t4d or its complements + EOE + } + + : location-search + : + : Test that the repository location is searched in the database before being + : parsed. The latest would fail as the repository type would be misguessed. + : + { + $clone_root_cfg; + $rep_add $src/libfoo-1.1.0 --type dir && $rep_fetch; + + d = $canonicalize([dir_path] $src/libfoo-1.1.0); + + $* "libfoo@$d" 2>>~"%EOE%"; + fetching dir:$d + using libfoo/1.1.0 \(external\) + configured libfoo/1.1.0 + %info: .+ is up to date% + updated libfoo/1.1.0 + EOE + + $pkg_disfigure libfoo 2>'disfigured libfoo/1.1.0'; + $pkg_purge libfoo 2>'purged libfoo/1.1.0' + } +} + +: dir-rep +: +{ + : preferred + : + : Test that dir (local) repository is preferred over non-dir local repository + : that comes first. + : + { + $clone_root_cfg; + $rep_fetch $rep/t4a; + $rep_add $src/libfoo-1.1.0 --type dir; + $rep_fetch "dir:$canonicalize([dir_path] $src/libfoo-1.1.0)"; + + $* libfoo 2>>~%EOE%; + using libfoo/1.1.0 (external) + configured libfoo/1.1.0 + %info: .+ is up to date% + updated libfoo/1.1.0 + EOE + + $pkg_disfigure libfoo 2>'disfigured libfoo/1.1.0'; + $pkg_purge libfoo 2>'purged libfoo/1.1.0' + } +} + +: keep-out +: +{ + +$cfg_create cxx "config.cxx=$config.cxx" -d cfg 2>- &cfg/*** + + # Build libhello as an external package. + # + +cp -r $src/libhello-1.0.0 ./libhello + +$rep_add libhello --type dir + +$rep_fetch + +$* libhello 2>! + + # Move libhello version ahead. + # + +sed -i -e 's/(version: 1.0).0/\1.1/' libhello/manifest + +$rep_fetch + + test.arguments += --yes # Is a command-specific option. + + : unspecified + : + : Test that libhello is fully rebuilt. + : + { + $clone_cfg; + $rep_fetch; + + $* libhello 2>>~%EOE% + disfigured libhello/1.0.0 + using libhello/1.0.1 (external) + configured libhello/1.0.1 + %(mkdir|c\+\+|ld|ar) .+%{8} + updated libhello/1.0.1 + EOE + } + + : specified + : + { + test.arguments += --keep-out + + +$clone_cfg + + : dir-repo + : + : Test that libhello is built incrementally. May re-link due to the + : configuration copying. + : + { + $clone_cfg; + + $* libhello 2>>~%EOE%; + disfigured libhello/1.0.0 + using libhello/1.0.1 (external) + configured libhello/1.0.1 + %ld .+%? + updated libhello/1.0.1 + EOE + + test -d cfg/libhello/; + test -d cfg/libhello-1.0.1/ == 1 + } + + : directory + : + : Test that libhello is built incrementally. May re-link due to the + : configuration copying. + : + { + +$clone_cfg + + # To avoid 'external package is already available' failure for the + # nested tests. + # + +$rep_remove --all + + : arg + : + { + $clone_cfg; + + $* ../../../libhello/ 2>>~%EOE%; + disfigured libhello/1.0.0 + using libhello/1.0.1 (external) + configured libhello/1.0.1 + %ld .+%? + updated libhello/1.0.1 + EOE + + test -d cfg/libhello/; + test -d cfg/libhello-1.0.1/ == 1 + } + + : unpacked + : + { + $clone_cfg; + $pkg_disfigure libhello --keep-out 2>!; + $pkg_unpack -r -e ../../../libhello; + + $* libhello 2>>~%EOE%; + configured libhello/1.0.1 + %ld .+%? + updated libhello/1.0.1 + EOE + + test -d cfg/libhello/; + test -d cfg/libhello-1.0.1/ == 1 + } + } + + : archive + : + : Test that libhello is fully rebuilt, as the resulted package is not + : external. + { + clone_cfg = cp -p --no-cleanup -r ../../cfg ./ + + +$build 'dist(../../libhello/@./out/)' \ + "config.cxx=$config.cxx" config.dist.root=./ \ + config.dist.archives=tar.gz 2>! \ + &libhello-1.0.1/*** &libhello-1.0.1.tar.gz + + : arg + : + { + $clone_cfg; + + $* ../libhello-1.0.1.tar.gz 2>>~%EOE%; + disfigured libhello/1.0.0 + fetched libhello/1.0.1 + unpacked libhello/1.0.1 + configured libhello/1.0.1 + %(c\+\+|ld|ar) .+%{6} + updated libhello/1.0.1 + EOE + + test -d cfg/libhello-1.0.1/; + test -d cfg/libhello/ == 1; + + $pkg_disfigure libhello 2>'disfigured libhello/1.0.1'; + $pkg_purge libhello 2>'purged libhello/1.0.1'; + + rm -r cfg/ + } + + : unpacked + : + { + $clone_cfg; + + $pkg_disfigure libhello 2>!; + $pkg_fetch -r -e ../libhello-1.0.1.tar.gz; + $pkg_unpack libhello; + + $* libhello 2>>~%EOE%; + configured libhello/1.0.1 + %(c\+\+|ld|ar) .+%{6} + updated libhello/1.0.1 + EOE + + test -d cfg/libhello-1.0.1/; + test -d cfg/libhello/ == 1; + + $pkg_disfigure libhello 2>'disfigured libhello/1.0.1'; + $pkg_purge libhello 2>'purged libhello/1.0.1'; + + rm -r cfg/ + } + } + } + + -$pkg_disfigure libhello 2>'disfigured libhello/1.0.0' + -$pkg_purge libhello 2>'purged libhello/1.0.0' +} + +: iter +: +{ + test.arguments += --yes # Is a command-specific option. + + : already-available + : + { + $clone_root_cfg; + $rep_add $src/libfoo-1.1.0 --type dir && $rep_fetch; + + $* $src/libfoo-1.1.0/ 2>>~%EOE% != 0 + %error: external package libfoo/1.1.0 is already available from dir:.+libfoo-1.1.0% + EOE + } + + : upgrade + : + { + $clone_root_cfg; + + $* $src/libfoo-1.1.0/ 2>>~%EOE%; + using libfoo/1.1.0 (external) + configured libfoo/1.1.0 + %info: .+ is up to date% + updated libfoo/1.1.0 + EOE + + cp -p -r $src/libfoo-1.1.0 libfoo; + + $* libfoo/ 2>>~%EOE%; + disfigured libfoo/1.1.0 + using libfoo/1.1.0#1 (external) + configured libfoo/1.1.0#1 + %info: .+ is up to date% + updated libfoo/1.1.0#1 + EOE + + $rep_add $src/libfoo-1.1.0 --type dir && $rep_fetch; + + $* libfoo 2>>~%EOE%; + disfigured libfoo/1.1.0#1 + using libfoo/1.1.0#2 (external) + configured libfoo/1.1.0#2 + %info: .+ is up to date% + updated libfoo/1.1.0#2 + EOE + + $pkg_disfigure libfoo 2>'disfigured libfoo/1.1.0#2' + } +} + +: ignore-case +: +{ + test.arguments += --yes --auth all --trust-yes + + $clone_cfg; + + $* "libbar@$rep/t5" 2>>~%EOE%; + added pkg:build2.org/pkg-build/t5 + fetching pkg:build2.org/pkg-build/t5 + %.* + %.*fetched libbar/1.2.0% + unpacked libbar/1.2.0 + configured libbar/1.2.0 + %info: .+ is up to date% + updated libbar/1.2.0 + EOE + + $* "libbar@$rep/t6" 2>>~%EOE%; + added pkg:build2.org/pkg-build/t6 + fetching pkg:build2.org/pkg-build/t6 + disfigured libbar/1.2.0 + %.* + %.*fetched libBar/2.0.0% + unpacked libBar/2.0.0 + configured libBar/2.0.0 + %info: .+ is up to date% + updated libBar/2.0.0 + EOE + + $pkg_status libbar >'!libBar configured !2.0.0'; + + test -d cfg/libBar-2.0.0; + + $pkg_drop libbar +} + +: git-rep +: +if ($git_supported != true) +{ + # Skip git repository tests. + # +} +else +{ + rep0 = "$rep_git/state0" + rep1 = "$rep_git/state1" + + test.arguments += --yes + + pkg_disfigure += 2>! + pkg_purge += 2>! + + : prerequisite-repo + : + : Dependency package of the dependent being built is in the prerequisite + : repository. + : + { + $clone_root_cfg; + $rep_add "$rep0/libbar.git#master"; + $rep_add "$rep0/style-basic.git#master"; + $rep_fetch &cfg/.bpkg/repos/*/***; + + $* libmbar 2>>~%EOE%; + %distributing style-basic/.+% + %checked out style-basic/.+% + %configured style-basic/.+% + distributing libmbar/1.0.0 + checked out libmbar/1.0.0 + configured libmbar/1.0.0 + %info: .+ is up to date% + updated libmbar/1.0.0 + EOE + + $pkg_disfigure libmbar; + $pkg_disfigure style-basic; + + $pkg_purge libmbar; + $pkg_purge style-basic + } + + : no-prerequisite-repos + : + : Dependent package repository has no prerequisites nor complements. Its + : dependency is picked up via the root repository that complements its + : repository (see rep_fetch() function implementation for details). + : + { + $clone_root_cfg; + $rep_add "$rep1/libbaz.git#master"; + $rep_add "$rep0/style-basic.git#master"; + $rep_fetch &cfg/.bpkg/repos/*/***; + + $* libbaz 2>>~%EOE%; + %distributing style-basic/.+% + %checked out style-basic/.+% + %configured style-basic/.+% + distributing libbaz/1.0.0 + checked out libbaz/1.0.0 + configured libbaz/1.0.0 + %info: .+ is up to date% + updated libbaz/1.0.0 + EOE + + $pkg_disfigure libbaz; + $pkg_disfigure style-basic; + + $pkg_purge libbaz; + $pkg_purge style-basic + } + + : build-unpacked + : + : Test that the unpacked external package is properly built for the first + : time and is not rebuilt afterwards via the directory argument. + : + if ($remote != true) + { + $clone_root_cfg; + + d = $canonicalize([dir_path] $out_git/state0/style-basic.git); + $pkg_unpack -e $d; + + $* style-basic 2>>~%EOE%; + %configured style-basic/1\.1\.0-a\.0\.\d+\..+% + %info: .+ is up to date% + %updated style-basic/1\.1\.0-a\.0\.\d+\..+% + EOE + + $* $d 2>>~%EOE%; + %info: .+ is up to date% + %updated style-basic/1\.1\.0-a\.0\.\d+\..+% + EOE + + $pkg_disfigure style-basic + } +} diff --git a/tests/pkg-checkout.test b/tests/pkg-checkout.test deleted file mode 100644 index 7203bfb..0000000 --- a/tests/pkg-checkout.test +++ /dev/null @@ -1,105 +0,0 @@ -# file : tests/pkg-checkout.test -# copyright : Copyright (c) 2014-2018 Code Synthesis Ltd -# license : MIT; see accompanying LICENSE file - -.include common.test config.test remote-git.test - -# Source repository: -# -# pkg-checkout -# `-- git -# |-- libbar.git -> style-basic.git (prerequisite) -# `-- style-basic.git - -# Prepare repositories used by tests if running in the local mode. -# -+if ($remote != true) - # Create git repositories. - # - $git_extract $src/git/libbar.tar - $git_extract $src/git/style-basic0.tar &$out_git/state0/*** - $git_extract $src/git/style-basic1.tar &$out_git/state1/*** -end - -: git-rep -: -if ($git_supported != true) -{ - # Skip git repository tests. - # -} -else -{ - rep = "$rep_git/state0" - - rep_add += -d cfg 2>! - rep_fetch += -d cfg 2>! - pkg_configure += -d cfg 2>! - pkg_disfigure += -d cfg 2>! - pkg_purge += -d cfg 2>! - pkg_status += -d cfg - - test.cleanups += &cfg/.bpkg/repos/*/*** - - : unconfigured-dependency - : - $clone_root_cfg; - $rep_add "$rep/libbar.git#master"; - $rep_fetch; - - $* libmbar/1.0.0 2>>EOE != 0 - error: no configured package satisfies dependency on style-basic >= 1.0.0 - EOE - - : configured-dependency - : - $clone_root_cfg; - $rep_add "$rep/libbar.git#master" && $rep_add "$rep/style-basic.git#master"; - $rep_fetch; - - $pkg_status style-basic | sed -n -e 's/style-basic available \[.+\] ([^ ]+)/\1/p' | set v; - - $* "style-basic/$v" 2>>"EOE"; - distributing style-basic/$v - checked out style-basic/$v - EOE - - $pkg_configure style-basic; - - $* libmbar/1.0.0 2>>EOE; - distributing libmbar/1.0.0 - checked out libmbar/1.0.0 - EOE - - $pkg_disfigure style-basic; - - $pkg_purge libmbar; - $pkg_purge style-basic - - : replacement - : - # @@ Reduce to a single repository when multiple revisions can be specified - # in the repository URL fragment. - # - rep0 = "$rep_git/state0"; - rep1 = "$rep_git/state1"; - - $clone_root_cfg; - $rep_add "$rep0/style-basic.git#master"; - $rep_add "$rep1/style-basic.git#stable"; - $rep_fetch; - - $pkg_status style-basic | \ - sed -n -e 's/style-basic available ([^ ]+) +([^ ]+)/\1 \2/p' | set vs; - - echo "$vs" | sed -e 's/([^ ]+).+/\1/' | set v0; - echo "$vs" | sed -e 's/([^ ]+) +([^ ]+)/\2/' | set v1; - - $* "style-basic/$v0" 2>!; - $pkg_status style-basic >~"/style-basic unpacked $v0/"; - - $* --replace "style-basic/$v1" 2>!; - $pkg_status style-basic >~"/style-basic unpacked $v1 .+/"; - - $pkg_purge style-basic -} diff --git a/tests/pkg-checkout.testscript b/tests/pkg-checkout.testscript new file mode 100644 index 0000000..d279eb4 --- /dev/null +++ b/tests/pkg-checkout.testscript @@ -0,0 +1,105 @@ +# file : tests/pkg-checkout.testscript +# copyright : Copyright (c) 2014-2018 Code Synthesis Ltd +# license : MIT; see accompanying LICENSE file + +.include common.testscript config.testscript remote-git.testscript + +# Source repository: +# +# pkg-checkout +# `-- git +# |-- libbar.git -> style-basic.git (prerequisite) +# `-- style-basic.git + +# Prepare repositories used by tests if running in the local mode. +# ++if ($remote != true) + # Create git repositories. + # + $git_extract $src/git/libbar.tar + $git_extract $src/git/style-basic0.tar &$out_git/state0/*** + $git_extract $src/git/style-basic1.tar &$out_git/state1/*** +end + +: git-rep +: +if ($git_supported != true) +{ + # Skip git repository tests. + # +} +else +{ + rep = "$rep_git/state0" + + rep_add += -d cfg 2>! + rep_fetch += -d cfg 2>! + pkg_configure += -d cfg 2>! + pkg_disfigure += -d cfg 2>! + pkg_purge += -d cfg 2>! + pkg_status += -d cfg + + test.cleanups += &cfg/.bpkg/repos/*/*** + + : unconfigured-dependency + : + $clone_root_cfg; + $rep_add "$rep/libbar.git#master"; + $rep_fetch; + + $* libmbar/1.0.0 2>>EOE != 0 + error: no configured package satisfies dependency on style-basic >= 1.0.0 + EOE + + : configured-dependency + : + $clone_root_cfg; + $rep_add "$rep/libbar.git#master" && $rep_add "$rep/style-basic.git#master"; + $rep_fetch; + + $pkg_status style-basic | sed -n -e 's/style-basic available \[.+\] ([^ ]+)/\1/p' | set v; + + $* "style-basic/$v" 2>>"EOE"; + distributing style-basic/$v + checked out style-basic/$v + EOE + + $pkg_configure style-basic; + + $* libmbar/1.0.0 2>>EOE; + distributing libmbar/1.0.0 + checked out libmbar/1.0.0 + EOE + + $pkg_disfigure style-basic; + + $pkg_purge libmbar; + $pkg_purge style-basic + + : replacement + : + # @@ Reduce to a single repository when multiple revisions can be specified + # in the repository URL fragment. + # + rep0 = "$rep_git/state0"; + rep1 = "$rep_git/state1"; + + $clone_root_cfg; + $rep_add "$rep0/style-basic.git#master"; + $rep_add "$rep1/style-basic.git#stable"; + $rep_fetch; + + $pkg_status style-basic | \ + sed -n -e 's/style-basic available ([^ ]+) +([^ ]+)/\1 \2/p' | set vs; + + echo "$vs" | sed -e 's/([^ ]+).+/\1/' | set v0; + echo "$vs" | sed -e 's/([^ ]+) +([^ ]+)/\2/' | set v1; + + $* "style-basic/$v0" 2>!; + $pkg_status style-basic >~"/style-basic unpacked $v0/"; + + $* --replace "style-basic/$v1" 2>!; + $pkg_status style-basic >~"/style-basic unpacked $v1 .+/"; + + $pkg_purge style-basic +} diff --git a/tests/pkg-clean.test b/tests/pkg-clean.test deleted file mode 100644 index 552c82b..0000000 --- a/tests/pkg-clean.test +++ /dev/null @@ -1,136 +0,0 @@ -# file : tests/pkg-clean.test -# copyright : Copyright (c) 2014-2018 Code Synthesis Ltd -# license : MIT; see accompanying LICENSE file - -.include common.test auth.test config.test remote.test - -# Source repository: -# -# pkg-clean -# |-- hello -# | |-- libhello-1.0.0.tar.gz -# | `-- repositories.manifest -# `-- libhello-1.0.0 -# |-- build -# | |-- bootstrap.build -# | |-- export.build -# | `-- root.build -# |-- buildfile -# |-- hello -# | |-- buildfile -# | |-- export -# | |-- hello -# | `-- hello.cxx -# |-- INSTALL -# |-- manifest -# |-- tests -# | |-- build -# | | |-- bootstrap.build -# | | `-- root.build -# | |-- buildfile -# | `-- test -# | |-- buildfile -# | |-- driver.cxx -# | `-- test.out -# `-- version - -# Prepare repositories used by tests if running in the local mode. -# -+if ($remote != true) - rep_create += 2>! - - # Create the signed 'hello' repository. - # - cp -r $src/hello $out/hello - cat <<<$cert_manifest >+$out/hello/repositories.manifest - - $rep_create --key $key $out/hello &$out/hello/packages.manifest \ - &$out/hello/signature.manifest -end - -pkg_configure += -d cfg "config.cxx=$config.cxx" 2>! -pkg_disfigure += -d cfg -pkg_fetch += -d cfg 2>! -pkg_purge += -d cfg -pkg_unpack += -d cfg 2>! -pkg_update += -d cfg 2>! -rep_add += -d cfg 2>! -rep_fetch += -d cfg --auth all 2>! - -: no-name -: -$clone_cfg; -$* 2>>EOE != 0 - error: package name argument expected - info: run 'bpkg help pkg-clean' for more information - EOE - -: fetched -: -{ - +$clone_cfg - +$rep_add $rep/hello - +$rep_fetch --trust $cert_fp &cfg/.bpkg/certs/** - - : no-such-package - : - $clone_cfg; - $* libhello 2>>/EOE != 0 - error: package libhello does not exist in configuration cfg/ - EOE - - : wrong-state - : - { - $clone_cfg && $pkg_fetch libhello/1.0.0; - - $* libhello 2>>EOE != 0; - error: package libhello is fetched - info: expected it to be configured - EOE - - $pkg_purge libhello 2>'purged libhello/1.0.0' - } - - : src-eq-out - : - { - $clone_cfg; - $pkg_fetch libhello/1.0.0 && $pkg_unpack libhello; - $pkg_configure libhello && $pkg_update libhello; - - $* libhello 2>>~%EOE%; - %rm .+%{6} - cleaned libhello/1.0.0 - EOE - - $* libhello 2>>~%EOE%; - %info: .+ is clean% - cleaned libhello/1.0.0 - EOE - - $pkg_disfigure libhello 2>'disfigured libhello/1.0.0'; - $pkg_purge libhello 2>'purged libhello/1.0.0' - } -} - -: src-ne-out -: -{ - $clone_cfg; - $pkg_unpack -e $src/libhello-1.0.0; - $pkg_configure libhello && $pkg_update libhello; - - $* libhello 2>>~%EOE%; - %rm .+%{8} - cleaned libhello/1.0.0 - EOE - - $* libhello 2>>~%EOE%; - %info: .+ is clean% - cleaned libhello/1.0.0 - EOE - - $pkg_disfigure libhello 2>'disfigured libhello/1.0.0'; - $pkg_purge libhello 2>'purged libhello/1.0.0' -} diff --git a/tests/pkg-clean.testscript b/tests/pkg-clean.testscript new file mode 100644 index 0000000..0c05557 --- /dev/null +++ b/tests/pkg-clean.testscript @@ -0,0 +1,136 @@ +# file : tests/pkg-clean.testscript +# copyright : Copyright (c) 2014-2018 Code Synthesis Ltd +# license : MIT; see accompanying LICENSE file + +.include common.testscript auth.testscript config.testscript remote.testscript + +# Source repository: +# +# pkg-clean +# |-- hello +# | |-- libhello-1.0.0.tar.gz +# | `-- repositories.manifest +# `-- libhello-1.0.0 +# |-- build +# | |-- bootstrap.build +# | |-- export.build +# | `-- root.build +# |-- buildfile +# |-- hello +# | |-- buildfile +# | |-- export +# | |-- hello +# | `-- hello.cxx +# |-- INSTALL +# |-- manifest +# |-- tests +# | |-- build +# | | |-- bootstrap.build +# | | `-- root.build +# | |-- buildfile +# | `-- test +# | |-- buildfile +# | |-- driver.cxx +# | `-- test.out +# `-- version + +# Prepare repositories used by tests if running in the local mode. +# ++if ($remote != true) + rep_create += 2>! + + # Create the signed 'hello' repository. + # + cp -r $src/hello $out/hello + cat <<<$cert_manifest >+$out/hello/repositories.manifest + + $rep_create --key $key $out/hello &$out/hello/packages.manifest \ + &$out/hello/signature.manifest +end + +pkg_configure += -d cfg "config.cxx=$config.cxx" 2>! +pkg_disfigure += -d cfg +pkg_fetch += -d cfg 2>! +pkg_purge += -d cfg +pkg_unpack += -d cfg 2>! +pkg_update += -d cfg 2>! +rep_add += -d cfg 2>! +rep_fetch += -d cfg --auth all 2>! + +: no-name +: +$clone_cfg; +$* 2>>EOE != 0 + error: package name argument expected + info: run 'bpkg help pkg-clean' for more information + EOE + +: fetched +: +{ + +$clone_cfg + +$rep_add $rep/hello + +$rep_fetch --trust $cert_fp &cfg/.bpkg/certs/** + + : no-such-package + : + $clone_cfg; + $* libhello 2>>/EOE != 0 + error: package libhello does not exist in configuration cfg/ + EOE + + : wrong-state + : + { + $clone_cfg && $pkg_fetch libhello/1.0.0; + + $* libhello 2>>EOE != 0; + error: package libhello is fetched + info: expected it to be configured + EOE + + $pkg_purge libhello 2>'purged libhello/1.0.0' + } + + : src-eq-out + : + { + $clone_cfg; + $pkg_fetch libhello/1.0.0 && $pkg_unpack libhello; + $pkg_configure libhello && $pkg_update libhello; + + $* libhello 2>>~%EOE%; + %rm .+%{6} + cleaned libhello/1.0.0 + EOE + + $* libhello 2>>~%EOE%; + %info: .+ is clean% + cleaned libhello/1.0.0 + EOE + + $pkg_disfigure libhello 2>'disfigured libhello/1.0.0'; + $pkg_purge libhello 2>'purged libhello/1.0.0' + } +} + +: src-ne-out +: +{ + $clone_cfg; + $pkg_unpack -e $src/libhello-1.0.0; + $pkg_configure libhello && $pkg_update libhello; + + $* libhello 2>>~%EOE%; + %rm .+%{8} + cleaned libhello/1.0.0 + EOE + + $* libhello 2>>~%EOE%; + %info: .+ is clean% + cleaned libhello/1.0.0 + EOE + + $pkg_disfigure libhello 2>'disfigured libhello/1.0.0'; + $pkg_purge libhello 2>'purged libhello/1.0.0' +} diff --git a/tests/pkg-configure.test b/tests/pkg-configure.test deleted file mode 100644 index 0813084..0000000 --- a/tests/pkg-configure.test +++ /dev/null @@ -1,408 +0,0 @@ -# file : tests/pkg-configure.test -# copyright : Copyright (c) 2014-2018 Code Synthesis Ltd -# license : MIT; see accompanying LICENSE file - -# Here we test both pkg-configure and pkg-disfigure commands. -# - -.include common.test auth.test config.test remote.test - -# Source repository: -# -# pkg-configure -# |-- hello -# | |-- libhello-1.0.0.tar.gz -# | `-- repositories.manifest -# |-- libhello-1.0.0 -# | |-- build -# | | |-- bootstrap.build -# | | |-- export.build -# | | `-- root.build -# | |-- buildfile -# | |-- hello -# | | |-- buildfile -# | | |-- export -# | | |-- hello -# | | `-- hello.cxx -# | |-- INSTALL -# | |-- manifest -# | |-- tests -# | | |-- build -# | | | |-- bootstrap.build -# | | | `-- root.build -# | | |-- buildfile -# | | `-- test -# | | |-- buildfile -# | | |-- driver.cxx -# | | `-- test.out -# | `-- version -# `-- stable -# |-- libbar-1.0.0.tar.gz -> libfoo -# |-- libbar-1.1.0.tar.gz -> libfoo >= 1.1.0 -# |-- libbar-1.2.0.tar.gz -> libfoo >= 1.1.0, libfox | libfoo >= 1.2.0 -# |-- libbar-1.3.0.tar.gz -> libfox | libfoo <= 1.1.0, -# | libfix | libfoo >= 1.1.0 -# |-- libfoo-1.0.0.tar.gz -# |-- libfoo-1.1.0.tar.gz -# |-- libfoo-1.2.0.tar.gz -# `-- repositories.manifest - -# Prepare repositories used by tests if running in the local mode. -# -+if ($remote != true) - rep_create += 2>! - - # Create the signed 'hello' repository. - # - cp -r $src/hello $out/hello - cat <<<$cert_manifest >+$out/hello/repositories.manifest - - $rep_create --key $key $out/hello &$out/hello/packages.manifest \ - &$out/hello/signature.manifest - - # Create the 'stable' repository. - # - cp -r $src/stable $out/stable - $rep_create $out/stable &$out/stable/packages.manifest -end - -test.arguments += "config.cxx=$config.cxx" - -pkg_disfigure += -d cfg -pkg_fetch += -d cfg 2>! -pkg_purge += -d cfg -pkg_status += -d cfg -pkg_unpack += -d cfg 2>! -rep_add += -d cfg 2>! -rep_fetch += -d cfg --auth all 2>! - -: no-name -: -$clone_cfg; -$* 2>>EOE != 0 - error: package name argument expected - info: run 'bpkg help pkg-configure' for more information - EOE - -: var-no-name -: -$clone_cfg; -$* "config.dist.root=$~/opt" 2>>EOE != 0 - error: package name argument expected - info: run 'bpkg help pkg-configure' for more information - EOE - -: unexpected-arg -: -$clone_cfg; -$* libhello libhello 2>>EOE != 0 - error: unexpected argument 'libhello' - EOE - -: fetched -: -{ - +$clone_cfg - +$rep_add $rep/hello - +$rep_fetch --trust $cert_fp &cfg/.bpkg/certs/** - - : no-such-package - : - $clone_cfg; - $* libhello1 2>>/EOE != 0 - error: package libhello1 does not exist in configuration cfg/ - EOE - - : disfigure - { - : no-name - : - $clone_root_cfg; - $pkg_disfigure 2>>EOE != 0 - error: package name argument expected - info: run 'bpkg help pkg-disfigure' for more information - EOE - - : no-such-package - : - $clone_root_cfg; - $pkg_disfigure libhello1 2>>/EOE != 0 - error: package libhello1 does not exist in configuration cfg/ - EOE - } - - : wrong-state - : - { - $clone_cfg && $pkg_fetch libhello/1.0.0; - - $* libhello 2>>EOE != 0; - error: package libhello is fetched - info: expected it to be unpacked - EOE - - $pkg_disfigure libhello 2>>EOE != 0; - error: package libhello is fetched - info: expected it to be configured - EOE - - $pkg_purge libhello 2>'purged libhello/1.0.0' - } - - : src-eq-out - : - { - $clone_cfg; - $pkg_fetch libhello/1.0.0 && $pkg_unpack libhello; - - $* libhello 2>'configured libhello/1.0.0'; - $pkg_status libhello 1>'libhello configured 1.0.0'; - $pkg_disfigure libhello 2>'disfigured libhello/1.0.0'; - $pkg_status libhello 1>'libhello unpacked 1.0.0'; - - $pkg_purge libhello 2>'purged libhello/1.0.0'; - $pkg_status libhello/1.0.0 1>'libhello available 1.0.0' - } -} - -: src-ne-out -: -{ - $clone_cfg && $pkg_unpack -e $src/libhello-1.0.0; - - $* libhello 2>'configured libhello/1.0.0'; - $pkg_status libhello 1>'libhello configured 1.0.0'; - $pkg_disfigure libhello 2>'disfigured libhello/1.0.0'; - $pkg_status libhello 1>'libhello unpacked 1.0.0'; - - $pkg_purge libhello 2>'purged libhello/1.0.0'; - $pkg_status libhello 1>'libhello unknown'; - test -d cfg/libhello-1.0.0 == 1 -} - -: out-exists-disfigure -: -{ - $clone_cfg && $pkg_unpack -e $src/libhello-1.0.0; - - $* libhello 2>'configured libhello/1.0.0'; - touch cfg/libhello/stray &!cfg/libhello/stray; - - $pkg_disfigure libhello 2>'disfigured libhello/1.0.0'; - - $pkg_status libhello/1.0.0 >'libhello unpacked 1.0.0'; - - $pkg_purge -f libhello 2>'purged libhello/1.0.0'; - $pkg_status libhello/1.0.0 1>'libhello unknown 1.0.0' -} - -: broken -: -if ($cxx.target.class != 'windows') -{ - : disfigure-failed - : - { - $clone_root_cfg && $pkg_unpack -e $src/libhello-1.0.0; - - $* libhello 2>'configured libhello/1.0.0'; - chmod 555 cfg/libhello; - - $pkg_disfigure libhello 2>>/~%EOE% != 0; - %error: unable to remove directory cfg/libhello/.+% - info: package libhello is now broken; use 'pkg-purge' to remove - EOE - - $pkg_status libhello >'libhello broken 1.0.0'; - - chmod 755 cfg/libhello; - rm -r cfg/libhello; - $pkg_purge -f libhello 2>'purged libhello/1.0.0'; - $pkg_status libhello >'libhello unknown' - } - - : configure-failed - : - : Note that pkg-configure in case of build2 process failure implicitly - : performs pkg-disfigure, that succeeds. - : - { - $clone_root_cfg && $pkg_unpack -e $src/libhello-1.0.0; - mkdir -p cfg/libhello/build &!cfg/libhello/ &!cfg/libhello/build/; - chmod 555 cfg/libhello/build; - - $* libhello 2>>/~%EOE% != 0; - %error: unable to create directory cfg/libhello/build/.+% - EOE - - $pkg_status libhello >'libhello unpacked 1.0.0' - } - - : configure-disfigure-failed - : - : Note that pkg-configure in case of build2 process failure implicitly - : performs pkg-disfigure, that also fails. - : - { - $clone_root_cfg && $pkg_unpack -e $src/libhello-1.0.0; - mkdir -p cfg/libhello/build &!cfg/libhello/ &!cfg/libhello/build/; - chmod 555 cfg/libhello cfg/libhello/build; - - $* libhello 2>>/~%EOE% != 0; - %error: unable to create directory cfg/libhello/build/.+% - %error: unable to remove directory cfg/libhello/.+% - info: package libhello is now broken; use 'pkg-purge' to remove - EOE - - $pkg_status libhello >'libhello broken 1.0.0'; - - chmod 755 cfg/libhello cfg/libhello/build; - rm -r cfg/libhello; - $pkg_purge -f libhello 2>'purged libhello/1.0.0'; - $pkg_status libhello >'libhello unknown' - } -} - -: dependency-management -: -{ - +$clone_cfg && $rep_add $rep/stable && $rep_fetch --trust-yes - - : still-has-deps - : - { - $clone_cfg; - $pkg_fetch libbar/1.0.0 && $pkg_unpack libbar; - - $* libbar 2>>EOE != 0; - error: no configured package satisfies dependency on libfoo - EOE - - $pkg_status libbar/1.0.0 1>'libbar unpacked 1.0.0'; - $pkg_fetch libfoo/1.0.0; - $pkg_unpack libfoo; - - $* libbar 2>>EOE != 0; - error: no configured package satisfies dependency on libfoo - EOE - - $* libfoo 2>'configured libfoo/1.0.0'; - $* libbar 2>'configured libbar/1.0.0'; - - $pkg_disfigure libfoo 2>>EOE != 0; - error: package libfoo still has dependencies: - info: package libbar - EOE - - $pkg_disfigure libbar 2>'disfigured libbar/1.0.0'; - $pkg_disfigure libfoo 2>'disfigured libfoo/1.0.0'; - - $pkg_purge libbar 2>'purged libbar/1.0.0'; - $pkg_purge libfoo 2>'purged libfoo/1.0.0' - } - - : no-package-satisfy - : - { - $clone_cfg; - $pkg_fetch libfoo/1.0.0 && $pkg_unpack libfoo; - - $* libfoo 2>'configured libfoo/1.0.0'; - $pkg_fetch libbar/1.1.0; - $pkg_unpack libbar; - - $* libbar 2>>EOE != 0; - error: no configured package satisfies dependency on libfoo >= 1.1.0 - EOE - - $pkg_disfigure libfoo 2>'disfigured libfoo/1.0.0'; - $pkg_purge libfoo 2>'purged libfoo/1.0.0'; - $pkg_fetch libfoo/1.1.0; - $pkg_unpack libfoo; - $* libfoo 2>'configured libfoo/1.1.0'; - $* libbar 2>'configured libbar/1.1.0'; - $pkg_disfigure libbar 2>'disfigured libbar/1.1.0'; - $pkg_disfigure libfoo 2>'disfigured libfoo/1.1.0'; - - $pkg_purge libfoo 2>'purged libfoo/1.1.0'; - $pkg_purge libbar 2>'purged libbar/1.1.0' - } - - : no-package-satisfy-alt - : - { - $clone_cfg; - $pkg_fetch libfoo/1.1.0 && $pkg_unpack libfoo; - - $* libfoo 2>'configured libfoo/1.1.0'; - $pkg_fetch libbar/1.2.0; - $pkg_unpack libbar; - - $* libbar 2>>EOE != 0; - error: no configured package satisfies dependency on libfox | libfoo >= 1.2.0 - EOE - - $pkg_disfigure libfoo 2>'disfigured libfoo/1.1.0'; - $pkg_purge libfoo 2>'purged libfoo/1.1.0'; - $pkg_fetch libfoo/1.2.0; - $pkg_unpack libfoo; - $* libfoo 2>'configured libfoo/1.2.0'; - $* libbar 2>'configured libbar/1.2.0'; - - $pkg_disfigure libfoo 2>>EOE != 0; - error: package libfoo still has dependencies: - info: package libbar on libfoo >= 1.2.0 - EOE - - $pkg_disfigure libbar 2>'disfigured libbar/1.2.0'; - $pkg_disfigure libfoo 2>'disfigured libfoo/1.2.0'; - - $pkg_purge libfoo 2>'purged libfoo/1.2.0'; - $pkg_purge libbar 2>'purged libbar/1.2.0' - } - - : incompatible-constraints - : - { - $clone_cfg; - $pkg_fetch libfoo/1.1.0 && $pkg_unpack libfoo; - - $* libfoo 2>'configured libfoo/1.1.0'; - $pkg_fetch libbar/1.3.0; - $pkg_unpack libbar; - - $* libbar 2>>EOE != 0; - error: multiple dependencies on package libfoo - info: libfoo <= 1.1.0 - info: libfoo >= 1.1.0 - EOE - - $pkg_disfigure libfoo 2>'disfigured libfoo/1.1.0'; - - $pkg_purge libfoo 2>'purged libfoo/1.1.0'; - $pkg_purge libbar 2>'purged libbar/1.3.0' - } -} - -: keep-out -: -{ - : fallback - : - : Test that pkg-disfigure falls back to the external package output directory - : removal if the source directory have gone. - : - { - $clone_root_cfg; - - # Configure libhello as an external package. - # - cp --no-cleanup -r $src/libhello-1.0.0 ./libhello; - $pkg_unpack -e ./libhello; - $* libhello 2>!; - - rm -r ./libhello; - $pkg_disfigure --keep-out libhello 2>'disfigured libhello/1.0.0'; - test -d cfg/libhello != 0 - } -} diff --git a/tests/pkg-configure.testscript b/tests/pkg-configure.testscript new file mode 100644 index 0000000..a61bb27 --- /dev/null +++ b/tests/pkg-configure.testscript @@ -0,0 +1,408 @@ +# file : tests/pkg-configure.testscript +# copyright : Copyright (c) 2014-2018 Code Synthesis Ltd +# license : MIT; see accompanying LICENSE file + +# Here we test both pkg-configure and pkg-disfigure commands. +# + +.include common.testscript auth.testscript config.testscript remote.testscript + +# Source repository: +# +# pkg-configure +# |-- hello +# | |-- libhello-1.0.0.tar.gz +# | `-- repositories.manifest +# |-- libhello-1.0.0 +# | |-- build +# | | |-- bootstrap.build +# | | |-- export.build +# | | `-- root.build +# | |-- buildfile +# | |-- hello +# | | |-- buildfile +# | | |-- export +# | | |-- hello +# | | `-- hello.cxx +# | |-- INSTALL +# | |-- manifest +# | |-- tests +# | | |-- build +# | | | |-- bootstrap.build +# | | | `-- root.build +# | | |-- buildfile +# | | `-- test +# | | |-- buildfile +# | | |-- driver.cxx +# | | `-- test.out +# | `-- version +# `-- stable +# |-- libbar-1.0.0.tar.gz -> libfoo +# |-- libbar-1.1.0.tar.gz -> libfoo >= 1.1.0 +# |-- libbar-1.2.0.tar.gz -> libfoo >= 1.1.0, libfox | libfoo >= 1.2.0 +# |-- libbar-1.3.0.tar.gz -> libfox | libfoo <= 1.1.0, +# | libfix | libfoo >= 1.1.0 +# |-- libfoo-1.0.0.tar.gz +# |-- libfoo-1.1.0.tar.gz +# |-- libfoo-1.2.0.tar.gz +# `-- repositories.manifest + +# Prepare repositories used by tests if running in the local mode. +# ++if ($remote != true) + rep_create += 2>! + + # Create the signed 'hello' repository. + # + cp -r $src/hello $out/hello + cat <<<$cert_manifest >+$out/hello/repositories.manifest + + $rep_create --key $key $out/hello &$out/hello/packages.manifest \ + &$out/hello/signature.manifest + + # Create the 'stable' repository. + # + cp -r $src/stable $out/stable + $rep_create $out/stable &$out/stable/packages.manifest +end + +test.arguments += "config.cxx=$config.cxx" + +pkg_disfigure += -d cfg +pkg_fetch += -d cfg 2>! +pkg_purge += -d cfg +pkg_status += -d cfg +pkg_unpack += -d cfg 2>! +rep_add += -d cfg 2>! +rep_fetch += -d cfg --auth all 2>! + +: no-name +: +$clone_cfg; +$* 2>>EOE != 0 + error: package name argument expected + info: run 'bpkg help pkg-configure' for more information + EOE + +: var-no-name +: +$clone_cfg; +$* "config.dist.root=$~/opt" 2>>EOE != 0 + error: package name argument expected + info: run 'bpkg help pkg-configure' for more information + EOE + +: unexpected-arg +: +$clone_cfg; +$* libhello libhello 2>>EOE != 0 + error: unexpected argument 'libhello' + EOE + +: fetched +: +{ + +$clone_cfg + +$rep_add $rep/hello + +$rep_fetch --trust $cert_fp &cfg/.bpkg/certs/** + + : no-such-package + : + $clone_cfg; + $* libhello1 2>>/EOE != 0 + error: package libhello1 does not exist in configuration cfg/ + EOE + + : disfigure + { + : no-name + : + $clone_root_cfg; + $pkg_disfigure 2>>EOE != 0 + error: package name argument expected + info: run 'bpkg help pkg-disfigure' for more information + EOE + + : no-such-package + : + $clone_root_cfg; + $pkg_disfigure libhello1 2>>/EOE != 0 + error: package libhello1 does not exist in configuration cfg/ + EOE + } + + : wrong-state + : + { + $clone_cfg && $pkg_fetch libhello/1.0.0; + + $* libhello 2>>EOE != 0; + error: package libhello is fetched + info: expected it to be unpacked + EOE + + $pkg_disfigure libhello 2>>EOE != 0; + error: package libhello is fetched + info: expected it to be configured + EOE + + $pkg_purge libhello 2>'purged libhello/1.0.0' + } + + : src-eq-out + : + { + $clone_cfg; + $pkg_fetch libhello/1.0.0 && $pkg_unpack libhello; + + $* libhello 2>'configured libhello/1.0.0'; + $pkg_status libhello 1>'libhello configured 1.0.0'; + $pkg_disfigure libhello 2>'disfigured libhello/1.0.0'; + $pkg_status libhello 1>'libhello unpacked 1.0.0'; + + $pkg_purge libhello 2>'purged libhello/1.0.0'; + $pkg_status libhello/1.0.0 1>'libhello available 1.0.0' + } +} + +: src-ne-out +: +{ + $clone_cfg && $pkg_unpack -e $src/libhello-1.0.0; + + $* libhello 2>'configured libhello/1.0.0'; + $pkg_status libhello 1>'libhello configured 1.0.0'; + $pkg_disfigure libhello 2>'disfigured libhello/1.0.0'; + $pkg_status libhello 1>'libhello unpacked 1.0.0'; + + $pkg_purge libhello 2>'purged libhello/1.0.0'; + $pkg_status libhello 1>'libhello unknown'; + test -d cfg/libhello-1.0.0 == 1 +} + +: out-exists-disfigure +: +{ + $clone_cfg && $pkg_unpack -e $src/libhello-1.0.0; + + $* libhello 2>'configured libhello/1.0.0'; + touch cfg/libhello/stray &!cfg/libhello/stray; + + $pkg_disfigure libhello 2>'disfigured libhello/1.0.0'; + + $pkg_status libhello/1.0.0 >'libhello unpacked 1.0.0'; + + $pkg_purge -f libhello 2>'purged libhello/1.0.0'; + $pkg_status libhello/1.0.0 1>'libhello unknown 1.0.0' +} + +: broken +: +if ($cxx.target.class != 'windows') +{ + : disfigure-failed + : + { + $clone_root_cfg && $pkg_unpack -e $src/libhello-1.0.0; + + $* libhello 2>'configured libhello/1.0.0'; + chmod 555 cfg/libhello; + + $pkg_disfigure libhello 2>>/~%EOE% != 0; + %error: unable to remove directory cfg/libhello/.+% + info: package libhello is now broken; use 'pkg-purge' to remove + EOE + + $pkg_status libhello >'libhello broken 1.0.0'; + + chmod 755 cfg/libhello; + rm -r cfg/libhello; + $pkg_purge -f libhello 2>'purged libhello/1.0.0'; + $pkg_status libhello >'libhello unknown' + } + + : configure-failed + : + : Note that pkg-configure in case of build2 process failure implicitly + : performs pkg-disfigure, that succeeds. + : + { + $clone_root_cfg && $pkg_unpack -e $src/libhello-1.0.0; + mkdir -p cfg/libhello/build &!cfg/libhello/ &!cfg/libhello/build/; + chmod 555 cfg/libhello/build; + + $* libhello 2>>/~%EOE% != 0; + %error: unable to create directory cfg/libhello/build/.+% + EOE + + $pkg_status libhello >'libhello unpacked 1.0.0' + } + + : configure-disfigure-failed + : + : Note that pkg-configure in case of build2 process failure implicitly + : performs pkg-disfigure, that also fails. + : + { + $clone_root_cfg && $pkg_unpack -e $src/libhello-1.0.0; + mkdir -p cfg/libhello/build &!cfg/libhello/ &!cfg/libhello/build/; + chmod 555 cfg/libhello cfg/libhello/build; + + $* libhello 2>>/~%EOE% != 0; + %error: unable to create directory cfg/libhello/build/.+% + %error: unable to remove directory cfg/libhello/.+% + info: package libhello is now broken; use 'pkg-purge' to remove + EOE + + $pkg_status libhello >'libhello broken 1.0.0'; + + chmod 755 cfg/libhello cfg/libhello/build; + rm -r cfg/libhello; + $pkg_purge -f libhello 2>'purged libhello/1.0.0'; + $pkg_status libhello >'libhello unknown' + } +} + +: dependency-management +: +{ + +$clone_cfg && $rep_add $rep/stable && $rep_fetch --trust-yes + + : still-has-deps + : + { + $clone_cfg; + $pkg_fetch libbar/1.0.0 && $pkg_unpack libbar; + + $* libbar 2>>EOE != 0; + error: no configured package satisfies dependency on libfoo + EOE + + $pkg_status libbar/1.0.0 1>'libbar unpacked 1.0.0'; + $pkg_fetch libfoo/1.0.0; + $pkg_unpack libfoo; + + $* libbar 2>>EOE != 0; + error: no configured package satisfies dependency on libfoo + EOE + + $* libfoo 2>'configured libfoo/1.0.0'; + $* libbar 2>'configured libbar/1.0.0'; + + $pkg_disfigure libfoo 2>>EOE != 0; + error: package libfoo still has dependencies: + info: package libbar + EOE + + $pkg_disfigure libbar 2>'disfigured libbar/1.0.0'; + $pkg_disfigure libfoo 2>'disfigured libfoo/1.0.0'; + + $pkg_purge libbar 2>'purged libbar/1.0.0'; + $pkg_purge libfoo 2>'purged libfoo/1.0.0' + } + + : no-package-satisfy + : + { + $clone_cfg; + $pkg_fetch libfoo/1.0.0 && $pkg_unpack libfoo; + + $* libfoo 2>'configured libfoo/1.0.0'; + $pkg_fetch libbar/1.1.0; + $pkg_unpack libbar; + + $* libbar 2>>EOE != 0; + error: no configured package satisfies dependency on libfoo >= 1.1.0 + EOE + + $pkg_disfigure libfoo 2>'disfigured libfoo/1.0.0'; + $pkg_purge libfoo 2>'purged libfoo/1.0.0'; + $pkg_fetch libfoo/1.1.0; + $pkg_unpack libfoo; + $* libfoo 2>'configured libfoo/1.1.0'; + $* libbar 2>'configured libbar/1.1.0'; + $pkg_disfigure libbar 2>'disfigured libbar/1.1.0'; + $pkg_disfigure libfoo 2>'disfigured libfoo/1.1.0'; + + $pkg_purge libfoo 2>'purged libfoo/1.1.0'; + $pkg_purge libbar 2>'purged libbar/1.1.0' + } + + : no-package-satisfy-alt + : + { + $clone_cfg; + $pkg_fetch libfoo/1.1.0 && $pkg_unpack libfoo; + + $* libfoo 2>'configured libfoo/1.1.0'; + $pkg_fetch libbar/1.2.0; + $pkg_unpack libbar; + + $* libbar 2>>EOE != 0; + error: no configured package satisfies dependency on libfox | libfoo >= 1.2.0 + EOE + + $pkg_disfigure libfoo 2>'disfigured libfoo/1.1.0'; + $pkg_purge libfoo 2>'purged libfoo/1.1.0'; + $pkg_fetch libfoo/1.2.0; + $pkg_unpack libfoo; + $* libfoo 2>'configured libfoo/1.2.0'; + $* libbar 2>'configured libbar/1.2.0'; + + $pkg_disfigure libfoo 2>>EOE != 0; + error: package libfoo still has dependencies: + info: package libbar on libfoo >= 1.2.0 + EOE + + $pkg_disfigure libbar 2>'disfigured libbar/1.2.0'; + $pkg_disfigure libfoo 2>'disfigured libfoo/1.2.0'; + + $pkg_purge libfoo 2>'purged libfoo/1.2.0'; + $pkg_purge libbar 2>'purged libbar/1.2.0' + } + + : incompatible-constraints + : + { + $clone_cfg; + $pkg_fetch libfoo/1.1.0 && $pkg_unpack libfoo; + + $* libfoo 2>'configured libfoo/1.1.0'; + $pkg_fetch libbar/1.3.0; + $pkg_unpack libbar; + + $* libbar 2>>EOE != 0; + error: multiple dependencies on package libfoo + info: libfoo <= 1.1.0 + info: libfoo >= 1.1.0 + EOE + + $pkg_disfigure libfoo 2>'disfigured libfoo/1.1.0'; + + $pkg_purge libfoo 2>'purged libfoo/1.1.0'; + $pkg_purge libbar 2>'purged libbar/1.3.0' + } +} + +: keep-out +: +{ + : fallback + : + : Test that pkg-disfigure falls back to the external package output directory + : removal if the source directory have gone. + : + { + $clone_root_cfg; + + # Configure libhello as an external package. + # + cp --no-cleanup -r $src/libhello-1.0.0 ./libhello; + $pkg_unpack -e ./libhello; + $* libhello 2>!; + + rm -r ./libhello; + $pkg_disfigure --keep-out libhello 2>'disfigured libhello/1.0.0'; + test -d cfg/libhello != 0 + } +} diff --git a/tests/pkg-drop.test b/tests/pkg-drop.test deleted file mode 100644 index f0ff50f..0000000 --- a/tests/pkg-drop.test +++ /dev/null @@ -1,447 +0,0 @@ -# file : tests/pkg-drop.test -# copyright : Copyright (c) 2014-2018 Code Synthesis Ltd -# license : MIT; see accompanying LICENSE file - -.include common.test config.test remote.test - -# Source repository: -# -# 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 - -# Prepare repositories used by tests if running in the local mode. -# -+if ($remote != true) - rep_create += 2>! - - cp -r $src/t4a $out/t4a && $rep_create $out/t4a &$out/t4a/packages.manifest - cp -r $src/t4b $out/t4b && $rep_create $out/t4b &$out/t4b/packages.manifest - 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 -end - -pkg_build += -d cfg --yes 2>! -pkg_status += -d cfg -rep_add += -d cfg 2>! -rep_fetch += -d cfg --auth all --trust-yes 2>! - -: no-name -: -$clone_cfg; -$* 2>>EOE != 0 - error: package name argument expected - info: run 'bpkg help pkg-drop' for more information - EOE - -: unknown-package -: -$clone_cfg; -$* libfoo 2>>/EOE != 0 - error: package libfoo does not exist in configuration cfg/ - EOE - -: invalid-name -: -$clone_cfg; -$* libfoo/1.0.0 2>>~%EOE% != 0 - %error: invalid package name 'libfoo/1.0.0': illegal character% - EOE - -: dependencies-or-dependents -: -{ - +$clone_cfg && $rep_add $rep/t4c && $rep_fetch - +$pkg_build libbaz - - test.arguments += --print-only - - : foo-baz-bar - : - $clone_cfg; - $* -y libfoo libbaz libbar >>EOO - drop libbaz - drop libbar - drop libfoo - EOO - - : dependents - : - { - # Prepare the nested tests to use configuration from the enclosing - # 'dependencies-or-dependents' group scope. - # - clone_cfg = cp -r $~/../cfg ./ - - : unconfirmed - : - { - test.arguments += --yes - - : libfoo - : - $clone_cfg; - $* libfoo 2>>EOE != 0 - following dependent packages will have to be dropped as well: - libbar (requires libfoo) - libbaz (requires libbar) - error: refusing to drop dependent packages with just --yes - info: specify --drop-dependent to confirm - EOE - - : libfoo-libbar - : - $clone_cfg; - $* libfoo libbar 2>>EOE != 0 - following dependent packages will have to be dropped as well: - libbaz (requires libbar) - error: refusing to drop dependent packages with just --yes - info: specify --drop-dependent to confirm - EOE - - : libfoo-libbaz - : - $clone_cfg; - $* libfoo libbaz 2>>EOE != 0 - following dependent packages will have to be dropped as well: - libbar (requires libfoo) - error: refusing to drop dependent packages with just --yes - info: specify --drop-dependent to confirm - EOE - } - - : confirmed - : - { - test.arguments += --drop-dependent - - : libfoo - : - $clone_cfg; - $* libfoo >>EOO - drop libbaz - drop libbar - drop libfoo - EOO - - : libfoo-libbaz - : - $clone_cfg; - $* libfoo libbaz >>EOO - drop libbaz - drop libbar - drop libfoo - EOO - - : libbaz-libfoo - : - $clone_cfg; - $* libbaz libfoo >>EOO - drop libbaz - drop libbar - drop libfoo - EOO - } - } - - : dependencies - : - { - # Prepare the nested tests to use configuration from the enclosing - # 'dependencies-or-dependents' group scope. - # - clone_cfg = cp -r $~/../cfg ./ - - : libbaz - : - $clone_cfg; - $* -y libbaz >>EOO - drop libbaz - drop libbar - drop libfoo - EOO - - : libbaz-only - : - $clone_cfg; - $* -n libbaz >>EOO - drop libbaz - EOO - - : libbar-libbaz - : - $clone_cfg; - $* -n libbar libbaz >>EOO - drop libbaz - drop libbar - EOO - - : libbaz-libbar - : - $clone_cfg; - $* -n libbaz libbar >>EOO - drop libbaz - drop libbar - EOO - - : dependencies - : - : Note that we do not move this test to the dependencies-and-dependents - : group as the configuration repository set would be different. - : - $clone_cfg; - $* -y --drop-dependent libbar >>EOO - drop libbaz - drop libbar - drop libfoo - EOO - } - - # Here we combine the test group teardown and the "actual drop" test. - # - -$pkg_drop -d cfg --yes libbaz 2>>EOE - disfigured libbaz - disfigured libbar - disfigured libfoo - purged libbaz - purged libbar - purged libfoo - EOE - - -$pkg_status libbar/1.1.0 >'libbar available [1.1.0]' - -$pkg_status libbaz/1.1.0 >'libbaz available 1.1.0' - -$pkg_status libfoo/1.1.0 >'libfoo available [1.1.0]' -} - -: dependencies-and-dependents -: -{ - +$clone_cfg && $rep_add $rep/t4d && $rep_fetch - +$pkg_build libbiz - - clone_cfg = cp -r ../../cfg ./ - test.arguments += --print-only - - : drop-dependencies-no-dependents - : - { - test.arguments += --yes - - : libbiz - : - $clone_cfg; - $* libbiz >>EOO - drop libbiz - drop libbaz - drop libbar - drop libfoo - drop libfox - EOO - - : libfox-libbiz - : - $clone_cfg; - $* libfox libbiz >>EOO - drop libbiz - drop libfox - drop libbaz - drop libbar - drop libfoo - EOO - } - - : drop-dependencies - : - { - test.arguments += --yes --drop-dependent - - : libfox - : - $clone_cfg; - $* libfox >>EOO - drop libbiz - drop libfox - drop libbaz - drop libbar - drop libfoo - EOO - - : libbaz - : - $clone_cfg; - $* libbaz >>EOO - drop libbiz - drop libbaz - drop libbar - drop libfoo - drop libfox - EOO - - : libbar - : - $clone_cfg; - $* libbar >>EOO - drop libbiz - drop libbaz - drop libbar - drop libfoo - drop libfox - EOO - - : libfoo - : - $clone_cfg; - $* libfoo >>EOO - drop libbiz - drop libbaz - drop libbar - drop libfoo - drop libfox - EOO - } - - : keep-dependencies - { - test.arguments += --no --drop-dependent - - : fox-baz - : - $clone_cfg; - $* libfox libbaz >>EOO - drop libbiz - drop libfox - drop libbaz - EOO - - : libbaz-libfox - : - $clone_cfg; - $* libbaz libfox >>EOO - drop libbiz - drop libbaz - drop libfox - EOO - - : libfox-libbar - : - $clone_cfg; - $* libfox libbar >>EOO - drop libbiz - drop libfox - drop libbaz - drop libbar - EOO - - : libbar-libfox - : - $clone_cfg; - $* libbar libfox >>EOO - drop libbiz - drop libbaz - drop libbar - drop libfox - EOO - } - - -$pkg_drop -d cfg --yes --drop-dependent libbar 2>>EOE - disfigured libbiz - disfigured libbaz - disfigured libbar - disfigured libfoo - disfigured libfox - purged libbiz - purged libbaz - purged libbar - purged libfoo - purged libfox - EOE - - -$pkg_status libfox/1.0.0 >'libfox available 1.0.0' - -$pkg_status libfoo/1.1.0 >'libfoo available [1.1.0]' - -$pkg_status libbar/1.1.0 >'libbar available [1.1.0]' - -$pkg_status libbaz/1.1.0 >'libbaz available 1.1.0' - -$pkg_status libbiz/1.0.0 >'libbiz available 1.0.0' -} - -: keep-drop-options -: -: Test --drop-dependent, --keep-dependent, --keep-unused, option. -: -{ - +$clone_cfg && $rep_add $rep/t4b && $rep_fetch - - : keep-drop-dependent - : - { - $clone_cfg && $pkg_build libbar; - - $* --keep-dependent libfoo 2>>EOE != 0; - error: following dependent packages will have to be dropped as well: - libbar (requires libfoo) - EOE - - $* --drop-dependent libfoo 2>>EOE - disfigured libbar - disfigured libfoo - purged libbar - purged libfoo - EOE - } - - : drop-dependency - : - { - $clone_cfg && $pkg_build libbar; - - $* libbar --yes 2>>EOE - disfigured libbar - disfigured libfoo - purged libbar - purged libfoo - EOE - } - - : keep-dependency - : - { - $clone_cfg && $pkg_build libbar; - - $* --keep-unused libbar 2>>EOE; - disfigured libbar - purged libbar - EOE - - $pkg_status libfoo >'libfoo configured 1.1.0'; - - $* libfoo 2>>EOE - disfigured libfoo - purged libfoo - EOE - } -} - -: disfigure-only -: -: Test --disfigure-only option. -: -{ - $clone_cfg && $rep_add $rep/t4a && $rep_fetch; - $pkg_build libfoo; - - $* --disfigure-only libfoo 2>'disfigured libfoo'; - $pkg_status libfoo >'!libfoo unpacked 1.1.0'; - - $* libfoo 2>'purged libfoo' -} diff --git a/tests/pkg-drop.testscript b/tests/pkg-drop.testscript new file mode 100644 index 0000000..8750f80 --- /dev/null +++ b/tests/pkg-drop.testscript @@ -0,0 +1,447 @@ +# file : tests/pkg-drop.testscript +# copyright : Copyright (c) 2014-2018 Code Synthesis Ltd +# license : MIT; see accompanying LICENSE file + +.include common.testscript config.testscript remote.testscript + +# Source repository: +# +# 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 + +# Prepare repositories used by tests if running in the local mode. +# ++if ($remote != true) + rep_create += 2>! + + cp -r $src/t4a $out/t4a && $rep_create $out/t4a &$out/t4a/packages.manifest + cp -r $src/t4b $out/t4b && $rep_create $out/t4b &$out/t4b/packages.manifest + 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 +end + +pkg_build += -d cfg --yes 2>! +pkg_status += -d cfg +rep_add += -d cfg 2>! +rep_fetch += -d cfg --auth all --trust-yes 2>! + +: no-name +: +$clone_cfg; +$* 2>>EOE != 0 + error: package name argument expected + info: run 'bpkg help pkg-drop' for more information + EOE + +: unknown-package +: +$clone_cfg; +$* libfoo 2>>/EOE != 0 + error: package libfoo does not exist in configuration cfg/ + EOE + +: invalid-name +: +$clone_cfg; +$* libfoo/1.0.0 2>>~%EOE% != 0 + %error: invalid package name 'libfoo/1.0.0': illegal character% + EOE + +: dependencies-or-dependents +: +{ + +$clone_cfg && $rep_add $rep/t4c && $rep_fetch + +$pkg_build libbaz + + test.arguments += --print-only + + : foo-baz-bar + : + $clone_cfg; + $* -y libfoo libbaz libbar >>EOO + drop libbaz + drop libbar + drop libfoo + EOO + + : dependents + : + { + # Prepare the nested tests to use configuration from the enclosing + # 'dependencies-or-dependents' group scope. + # + clone_cfg = cp -r $~/../cfg ./ + + : unconfirmed + : + { + test.arguments += --yes + + : libfoo + : + $clone_cfg; + $* libfoo 2>>EOE != 0 + following dependent packages will have to be dropped as well: + libbar (requires libfoo) + libbaz (requires libbar) + error: refusing to drop dependent packages with just --yes + info: specify --drop-dependent to confirm + EOE + + : libfoo-libbar + : + $clone_cfg; + $* libfoo libbar 2>>EOE != 0 + following dependent packages will have to be dropped as well: + libbaz (requires libbar) + error: refusing to drop dependent packages with just --yes + info: specify --drop-dependent to confirm + EOE + + : libfoo-libbaz + : + $clone_cfg; + $* libfoo libbaz 2>>EOE != 0 + following dependent packages will have to be dropped as well: + libbar (requires libfoo) + error: refusing to drop dependent packages with just --yes + info: specify --drop-dependent to confirm + EOE + } + + : confirmed + : + { + test.arguments += --drop-dependent + + : libfoo + : + $clone_cfg; + $* libfoo >>EOO + drop libbaz + drop libbar + drop libfoo + EOO + + : libfoo-libbaz + : + $clone_cfg; + $* libfoo libbaz >>EOO + drop libbaz + drop libbar + drop libfoo + EOO + + : libbaz-libfoo + : + $clone_cfg; + $* libbaz libfoo >>EOO + drop libbaz + drop libbar + drop libfoo + EOO + } + } + + : dependencies + : + { + # Prepare the nested tests to use configuration from the enclosing + # 'dependencies-or-dependents' group scope. + # + clone_cfg = cp -r $~/../cfg ./ + + : libbaz + : + $clone_cfg; + $* -y libbaz >>EOO + drop libbaz + drop libbar + drop libfoo + EOO + + : libbaz-only + : + $clone_cfg; + $* -n libbaz >>EOO + drop libbaz + EOO + + : libbar-libbaz + : + $clone_cfg; + $* -n libbar libbaz >>EOO + drop libbaz + drop libbar + EOO + + : libbaz-libbar + : + $clone_cfg; + $* -n libbaz libbar >>EOO + drop libbaz + drop libbar + EOO + + : dependencies + : + : Note that we do not move this test to the dependencies-and-dependents + : group as the configuration repository set would be different. + : + $clone_cfg; + $* -y --drop-dependent libbar >>EOO + drop libbaz + drop libbar + drop libfoo + EOO + } + + # Here we combine the test group teardown and the "actual drop" test. + # + -$pkg_drop -d cfg --yes libbaz 2>>EOE + disfigured libbaz + disfigured libbar + disfigured libfoo + purged libbaz + purged libbar + purged libfoo + EOE + + -$pkg_status libbar/1.1.0 >'libbar available [1.1.0]' + -$pkg_status libbaz/1.1.0 >'libbaz available 1.1.0' + -$pkg_status libfoo/1.1.0 >'libfoo available [1.1.0]' +} + +: dependencies-and-dependents +: +{ + +$clone_cfg && $rep_add $rep/t4d && $rep_fetch + +$pkg_build libbiz + + clone_cfg = cp -r ../../cfg ./ + test.arguments += --print-only + + : drop-dependencies-no-dependents + : + { + test.arguments += --yes + + : libbiz + : + $clone_cfg; + $* libbiz >>EOO + drop libbiz + drop libbaz + drop libbar + drop libfoo + drop libfox + EOO + + : libfox-libbiz + : + $clone_cfg; + $* libfox libbiz >>EOO + drop libbiz + drop libfox + drop libbaz + drop libbar + drop libfoo + EOO + } + + : drop-dependencies + : + { + test.arguments += --yes --drop-dependent + + : libfox + : + $clone_cfg; + $* libfox >>EOO + drop libbiz + drop libfox + drop libbaz + drop libbar + drop libfoo + EOO + + : libbaz + : + $clone_cfg; + $* libbaz >>EOO + drop libbiz + drop libbaz + drop libbar + drop libfoo + drop libfox + EOO + + : libbar + : + $clone_cfg; + $* libbar >>EOO + drop libbiz + drop libbaz + drop libbar + drop libfoo + drop libfox + EOO + + : libfoo + : + $clone_cfg; + $* libfoo >>EOO + drop libbiz + drop libbaz + drop libbar + drop libfoo + drop libfox + EOO + } + + : keep-dependencies + { + test.arguments += --no --drop-dependent + + : fox-baz + : + $clone_cfg; + $* libfox libbaz >>EOO + drop libbiz + drop libfox + drop libbaz + EOO + + : libbaz-libfox + : + $clone_cfg; + $* libbaz libfox >>EOO + drop libbiz + drop libbaz + drop libfox + EOO + + : libfox-libbar + : + $clone_cfg; + $* libfox libbar >>EOO + drop libbiz + drop libfox + drop libbaz + drop libbar + EOO + + : libbar-libfox + : + $clone_cfg; + $* libbar libfox >>EOO + drop libbiz + drop libbaz + drop libbar + drop libfox + EOO + } + + -$pkg_drop -d cfg --yes --drop-dependent libbar 2>>EOE + disfigured libbiz + disfigured libbaz + disfigured libbar + disfigured libfoo + disfigured libfox + purged libbiz + purged libbaz + purged libbar + purged libfoo + purged libfox + EOE + + -$pkg_status libfox/1.0.0 >'libfox available 1.0.0' + -$pkg_status libfoo/1.1.0 >'libfoo available [1.1.0]' + -$pkg_status libbar/1.1.0 >'libbar available [1.1.0]' + -$pkg_status libbaz/1.1.0 >'libbaz available 1.1.0' + -$pkg_status libbiz/1.0.0 >'libbiz available 1.0.0' +} + +: keep-drop-options +: +: Test --drop-dependent, --keep-dependent, --keep-unused, option. +: +{ + +$clone_cfg && $rep_add $rep/t4b && $rep_fetch + + : keep-drop-dependent + : + { + $clone_cfg && $pkg_build libbar; + + $* --keep-dependent libfoo 2>>EOE != 0; + error: following dependent packages will have to be dropped as well: + libbar (requires libfoo) + EOE + + $* --drop-dependent libfoo 2>>EOE + disfigured libbar + disfigured libfoo + purged libbar + purged libfoo + EOE + } + + : drop-dependency + : + { + $clone_cfg && $pkg_build libbar; + + $* libbar --yes 2>>EOE + disfigured libbar + disfigured libfoo + purged libbar + purged libfoo + EOE + } + + : keep-dependency + : + { + $clone_cfg && $pkg_build libbar; + + $* --keep-unused libbar 2>>EOE; + disfigured libbar + purged libbar + EOE + + $pkg_status libfoo >'libfoo configured 1.1.0'; + + $* libfoo 2>>EOE + disfigured libfoo + purged libfoo + EOE + } +} + +: disfigure-only +: +: Test --disfigure-only option. +: +{ + $clone_cfg && $rep_add $rep/t4a && $rep_fetch; + $pkg_build libfoo; + + $* --disfigure-only libfoo 2>'disfigured libfoo'; + $pkg_status libfoo >'!libfoo unpacked 1.1.0'; + + $* libfoo 2>'purged libfoo' +} diff --git a/tests/pkg-fetch.test b/tests/pkg-fetch.test deleted file mode 100644 index dfc2ff0..0000000 --- a/tests/pkg-fetch.test +++ /dev/null @@ -1,203 +0,0 @@ -# file : tests/pkg-fetch.test -# copyright : Copyright (c) 2014-2018 Code Synthesis Ltd -# license : MIT; see accompanying LICENSE file - -.include common.test auth.test config.test remote.test - -# Source repository: -# -# pkg-fetch -# |-- hello -# | |-- libhello-1.0.0.tar.gz -# | `-- repositories.manifest -# `-- t1 -# |-- libfoo-1.0.0.tar.gz -# |-- libfoo-1.1.0.tar.gz -# `-- repositories.manifest - -# Prepare repositories used by tests if running in the local mode. -# -+if ($remote != true) - rep_create += 2>! - - # Create the signed 'hello' repository. - # - cp -r $src/hello $out/hello - cat <<<$cert_manifest >+$out/hello/repositories.manifest - - $rep_create --key $key $out/hello &$out/hello/packages.manifest \ - &$out/hello/signature.manifest - - # Create the 't1' repository. - # - cp -r $src/t1 $out/t1 && $rep_create $out/t1 &$out/t1/packages.manifest -end - -pkg_purge += -d cfg -pkg_status += -d cfg -pkg_unpack += -d cfg -rep_add += -d cfg 2>! -rep_fetch += -d cfg --auth all 2>! - -: no-archive -: -$clone_cfg; -$* -e 2>>EOE != 0 - error: archive path argument expected - info: run 'bpkg help pkg-fetch' for more information - EOE - -: archive-not-exist -: -$clone_cfg; -$* -e ./no-such-file 2>>/EOE != 0 - error: archive file './no-such-file' does not exist - EOE - -: no-name -: -$clone_cfg; -$* 2>>EOE != 0 - error: package name/version argument expected - info: run 'bpkg help pkg-fetch' for more information - EOE - -: no-version -: -$clone_cfg; -$* libfoo 2>>EOE != 0 - error: package version expected - info: run 'bpkg help pkg-fetch' for more information - EOE - -: invalid-version -: -$clone_cfg; -$* libfoo/1/2/3 2>>EOE != 0 - error: invalid package version '1/2/3': alpha-numeric characters expected in a component - EOE - -: no-repositories -: -$clone_cfg; -$* libfoo/1.0.0 2>>/EOE != 0 - error: configuration cfg/ has no repositories - info: use 'bpkg rep-add' to add a repository - EOE - -: no-packages -: -{ - $clone_cfg && $rep_add $rep/t1; - - $* libfoo/1.0.0 2>>/EOE != 0 - error: configuration cfg/ has no available packages - info: use 'bpkg rep-fetch' to fetch available packages list - EOE -} - -# Note that when we fetch a package from remote repository the bpkg stderr -# contains fetch program progress output, that comes prior the informational -# message. -# - -: fetched-rep -: -{ - +$clone_cfg && $rep_add $rep/t1 && $rep_fetch --trust-yes - - : package-not-available - : - $clone_cfg; - $* libfoo/2.0.0+1 2>>/EOE != 0 - error: package libfoo 2.0.0+1 is not available - EOE - - : package-available - : - { - $clone_cfg; - - $* libfoo/1.0.0 2>>~%EOE%; - %.* - %.*fetched libfoo/1.0.0% - EOE - - $pkg_status libfoo/1.0.0 1>'libfoo fetched 1.0.0'; - - $* libfoo/1.0.0 2>>/EOE != 0; - error: package libfoo already exists in configuration cfg/ - info: version: 1.0.0, state: fetched, substate: none - info: use 'pkg-fetch --replace|-r' to replace - EOE - - $* -e $src/t1/libfoo-1.0.0.tar.gz 2>>/EOE != 0; - error: package libfoo already exists in configuration cfg/ - info: version: 1.0.0, state: fetched, substate: none - info: use 'pkg-fetch --replace|-r' to replace - EOE - - $pkg_purge libfoo 2>'purged libfoo/1.0.0' - } - - : package-replace - : - { - $clone_cfg; - - $* -e $src/t1/libfoo-1.0.0.tar.gz 2>'using libfoo/1.0.0 (external)'; - $pkg_status libfoo/1.0.0 1>'libfoo fetched 1.0.0'; - $pkg_unpack libfoo 2>'unpacked libfoo/1.0.0'; - - test.arguments += --replace; # Replace existing package. - - $* libfoo/1.1.0 2>>~%EOE%; - %.* - %.*fetched libfoo/1.1.0% - EOE - - $pkg_status libfoo/1.1.0 1>'libfoo fetched 1.1.0'; - $pkg_unpack libfoo 2>'unpacked libfoo/1.1.0'; - $* -e $src/t1/libfoo-1.0.0.tar.gz 2>'using libfoo/1.0.0 (external)'; - $pkg_status libfoo/1.0.0 1>'libfoo fetched 1.0.0'; - - $* libfoo/1.1.0 2>>~%EOE%; - %.* - %.*fetched libfoo/1.1.0% - EOE - - $pkg_status libfoo/1.1.0 1>'libfoo fetched 1.1.0'; - $* -e $src/t1/libfoo-1.0.0.tar.gz 2>'using libfoo/1.0.0 (external)'; - $pkg_status libfoo/1.0.0 1>'libfoo fetched 1.0.0'; - - $pkg_purge libfoo 2>'purged libfoo/1.0.0' - } - - : purge-existing - : - { - $clone_cfg; - cp --no-cleanup $src/t1/libfoo-1.0.0.tar.gz ./; - - $* -p -e libfoo-1.0.0.tar.gz 2>'using libfoo/1.0.0 (external)'; - - $pkg_purge libfoo 2>'purged libfoo/1.0.0' - } -} - -: hello -: -{ - $clone_cfg; - $rep_add $rep/hello; - $rep_fetch --trust $cert_fp &cfg/.bpkg/certs/**; - - $* libhello/1.0.0 2>>~%EOE%; - %.* - %.*fetched libhello/1.0.0% - EOE - - $pkg_status libhello/1.0.0 1>'libhello fetched 1.0.0'; - - $pkg_purge libhello 2>'purged libhello/1.0.0' -} diff --git a/tests/pkg-fetch.testscript b/tests/pkg-fetch.testscript new file mode 100644 index 0000000..9fc8847 --- /dev/null +++ b/tests/pkg-fetch.testscript @@ -0,0 +1,203 @@ +# file : tests/pkg-fetch.testscript +# copyright : Copyright (c) 2014-2018 Code Synthesis Ltd +# license : MIT; see accompanying LICENSE file + +.include common.testscript auth.testscript config.testscript remote.testscript + +# Source repository: +# +# pkg-fetch +# |-- hello +# | |-- libhello-1.0.0.tar.gz +# | `-- repositories.manifest +# `-- t1 +# |-- libfoo-1.0.0.tar.gz +# |-- libfoo-1.1.0.tar.gz +# `-- repositories.manifest + +# Prepare repositories used by tests if running in the local mode. +# ++if ($remote != true) + rep_create += 2>! + + # Create the signed 'hello' repository. + # + cp -r $src/hello $out/hello + cat <<<$cert_manifest >+$out/hello/repositories.manifest + + $rep_create --key $key $out/hello &$out/hello/packages.manifest \ + &$out/hello/signature.manifest + + # Create the 't1' repository. + # + cp -r $src/t1 $out/t1 && $rep_create $out/t1 &$out/t1/packages.manifest +end + +pkg_purge += -d cfg +pkg_status += -d cfg +pkg_unpack += -d cfg +rep_add += -d cfg 2>! +rep_fetch += -d cfg --auth all 2>! + +: no-archive +: +$clone_cfg; +$* -e 2>>EOE != 0 + error: archive path argument expected + info: run 'bpkg help pkg-fetch' for more information + EOE + +: archive-not-exist +: +$clone_cfg; +$* -e ./no-such-file 2>>/EOE != 0 + error: archive file './no-such-file' does not exist + EOE + +: no-name +: +$clone_cfg; +$* 2>>EOE != 0 + error: package name/version argument expected + info: run 'bpkg help pkg-fetch' for more information + EOE + +: no-version +: +$clone_cfg; +$* libfoo 2>>EOE != 0 + error: package version expected + info: run 'bpkg help pkg-fetch' for more information + EOE + +: invalid-version +: +$clone_cfg; +$* libfoo/1/2/3 2>>EOE != 0 + error: invalid package version '1/2/3': alpha-numeric characters expected in a component + EOE + +: no-repositories +: +$clone_cfg; +$* libfoo/1.0.0 2>>/EOE != 0 + error: configuration cfg/ has no repositories + info: use 'bpkg rep-add' to add a repository + EOE + +: no-packages +: +{ + $clone_cfg && $rep_add $rep/t1; + + $* libfoo/1.0.0 2>>/EOE != 0 + error: configuration cfg/ has no available packages + info: use 'bpkg rep-fetch' to fetch available packages list + EOE +} + +# Note that when we fetch a package from remote repository the bpkg stderr +# contains fetch program progress output, that comes prior the informational +# message. +# + +: fetched-rep +: +{ + +$clone_cfg && $rep_add $rep/t1 && $rep_fetch --trust-yes + + : package-not-available + : + $clone_cfg; + $* libfoo/2.0.0+1 2>>/EOE != 0 + error: package libfoo 2.0.0+1 is not available + EOE + + : package-available + : + { + $clone_cfg; + + $* libfoo/1.0.0 2>>~%EOE%; + %.* + %.*fetched libfoo/1.0.0% + EOE + + $pkg_status libfoo/1.0.0 1>'libfoo fetched 1.0.0'; + + $* libfoo/1.0.0 2>>/EOE != 0; + error: package libfoo already exists in configuration cfg/ + info: version: 1.0.0, state: fetched, substate: none + info: use 'pkg-fetch --replace|-r' to replace + EOE + + $* -e $src/t1/libfoo-1.0.0.tar.gz 2>>/EOE != 0; + error: package libfoo already exists in configuration cfg/ + info: version: 1.0.0, state: fetched, substate: none + info: use 'pkg-fetch --replace|-r' to replace + EOE + + $pkg_purge libfoo 2>'purged libfoo/1.0.0' + } + + : package-replace + : + { + $clone_cfg; + + $* -e $src/t1/libfoo-1.0.0.tar.gz 2>'using libfoo/1.0.0 (external)'; + $pkg_status libfoo/1.0.0 1>'libfoo fetched 1.0.0'; + $pkg_unpack libfoo 2>'unpacked libfoo/1.0.0'; + + test.arguments += --replace; # Replace existing package. + + $* libfoo/1.1.0 2>>~%EOE%; + %.* + %.*fetched libfoo/1.1.0% + EOE + + $pkg_status libfoo/1.1.0 1>'libfoo fetched 1.1.0'; + $pkg_unpack libfoo 2>'unpacked libfoo/1.1.0'; + $* -e $src/t1/libfoo-1.0.0.tar.gz 2>'using libfoo/1.0.0 (external)'; + $pkg_status libfoo/1.0.0 1>'libfoo fetched 1.0.0'; + + $* libfoo/1.1.0 2>>~%EOE%; + %.* + %.*fetched libfoo/1.1.0% + EOE + + $pkg_status libfoo/1.1.0 1>'libfoo fetched 1.1.0'; + $* -e $src/t1/libfoo-1.0.0.tar.gz 2>'using libfoo/1.0.0 (external)'; + $pkg_status libfoo/1.0.0 1>'libfoo fetched 1.0.0'; + + $pkg_purge libfoo 2>'purged libfoo/1.0.0' + } + + : purge-existing + : + { + $clone_cfg; + cp --no-cleanup $src/t1/libfoo-1.0.0.tar.gz ./; + + $* -p -e libfoo-1.0.0.tar.gz 2>'using libfoo/1.0.0 (external)'; + + $pkg_purge libfoo 2>'purged libfoo/1.0.0' + } +} + +: hello +: +{ + $clone_cfg; + $rep_add $rep/hello; + $rep_fetch --trust $cert_fp &cfg/.bpkg/certs/**; + + $* libhello/1.0.0 2>>~%EOE%; + %.* + %.*fetched libhello/1.0.0% + EOE + + $pkg_status libhello/1.0.0 1>'libhello fetched 1.0.0'; + + $pkg_purge libhello 2>'purged libhello/1.0.0' +} diff --git a/tests/pkg-purge.test b/tests/pkg-purge.test deleted file mode 100644 index 8bbd3a8..0000000 --- a/tests/pkg-purge.test +++ /dev/null @@ -1,177 +0,0 @@ -# file : tests/pkg-purge.test -# copyright : Copyright (c) 2014-2018 Code Synthesis Ltd -# license : MIT; see accompanying LICENSE file - -.include common.test config.test - -# 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' -} 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' +} diff --git a/tests/pkg-status.test b/tests/pkg-status.test deleted file mode 100644 index 2845e55..0000000 --- a/tests/pkg-status.test +++ /dev/null @@ -1,212 +0,0 @@ -# file : tests/pkg-status.test -# copyright : Copyright (c) 2014-2018 Code Synthesis Ltd -# license : MIT; see accompanying LICENSE file - -.include common.test config.test remote.test remote-git.test - -# Source repository: -# -# pkg-status -# |-- extra -> stable (prerequisite) -# | |-- libbar-1.1.0+1.tar.gz -# | `-- repositories.manifest -# | -# |-- stable -# | |-- libbar-1.0.0.tar.gz -# | |-- libfoo-1.0.0.tar.gz -# | `-- repositories.manifest -# | -# |-- testing -> stable (complement), extra (prerequisite) -# | |-- libbar-1.0.0+1.tar.gz -# | |-- libbar-1.1.0.tar.gz -# | `-- repositories.manifest -# | -# |-- unstable -> testing (complement) -# | |-- libbar-2.0.0.tar.gz -# | `-- repositories.manifest -# | -# `-- git -# |-- libbar.git -> style-basic.git (prerequisite) -# |-- style-basic.git -# `-- style.git - -# Prepare repositories used by tests if running in the local mode. -# -+if ($remote != true) - cp -r $src/extra $out/extra - cp -r $src/stable $out/stable - cp -r $src/testing $out/testing - cp -r $src/unstable $out/unstable - - c = $rep_create 2>! - - $c $out/extra &$out/extra/packages.manifest - $c $out/stable &$out/stable/packages.manifest - $c $out/testing &$out/testing/packages.manifest - $c $out/unstable &$out/unstable/packages.manifest - - # Create git repositories. - # - $git_extract $src/git/style.tar - $git_extract $src/git/libbar.tar - $git_extract $src/git/style-basic.tar &$out_git/state0/*** -end - -pkg_fetch += 2>! -pkg_purge += -d cfg 2>! -rep_add += -d cfg 2>! -rep_fetch += -d cfg --auth all --trust-yes 2>! - -: basics -: -{ - +$clone_cfg - - : not-fetched - : - { - +$clone_cfg - - : libfoo-1.0.0 - : - $clone_cfg; - $* libfoo/1.0.0 >'libfoo unknown 1.0.0' - - : libfoo - : - $clone_cfg; - $* libfoo >'libfoo unknown' - } - - : rep-fetched - : - { - +$clone_cfg && $rep_add $rep/stable && $rep_fetch - - +cp -r cfg ./fetched - +$pkg_fetch libfoo/1.0.0 -d fetched &fetched/libfoo-1.0.0.tar.gz - - : libfoo-1.0.0 - : - $clone_cfg; - $* libfoo/1.0.0 >'libfoo available 1.0.0' - - : libfoo - : - $clone_cfg; - $* libfoo >'libfoo available 1.0.0' - - : pkg-fetched - : - { - clone_cfg = cp -r ../../fetched cfg - - : libfoo-1.0.0 - : - $clone_cfg; - $* libfoo/1.0.0 >'libfoo fetched 1.0.0' - - : libfoo - : - $clone_cfg; - $* libfoo >'libfoo fetched 1.0.0' - } - } -} - -: multiple-versions -{ - # Prepare the nested tests to copy the root configuration. Note that they - # must provide the destination directory name as an argument. - # - clone_cfg = cp -r $~/../cfg - - : extra - : - { - # Here we, first, prepare 2 configurations that derive from each other, and - # then spawn 2 tests on them. - # - +$clone_cfg extra && $rep_add -d extra $rep/extra && $rep_fetch -d extra - - +cp -r extra extra-stable - +$rep_add -d extra-stable $rep/stable && $rep_fetch -d extra-stable - - : libbar - : - $* -d ../extra libbar >'libbar available 1.1.0+1 [1.0.0]' - - : libbar-stable - : - $* -d ../extra-stable libbar >'libbar available 1.1.0+1 1.0.0' - } - - : testing - : - { - $clone_cfg ./ && $rep_add $rep/testing && $rep_fetch; - - $* libbar >'libbar available [1.1.0+1] 1.1.0 1.0.0+1 1.0.0' - } - - : unstable - : - { - # Here we, first, prepare 3 configurations that derive from each other, and - # then spawn 3 tests on them. - # - +$clone_cfg ./ && $rep_add $rep/unstable && $rep_fetch - - +cp -r cfg fetched1 - +$pkg_fetch libbar/1.0.0+1 -d fetched1 &fetched1/libbar-1.0.0+1.tar.gz - - +cp -r fetched1 fetched2 - +$pkg_purge -d fetched2 libbar &!fetched2/libbar-1.0.0+1.tar.gz - +$pkg_fetch libbar/2.0.0 -d fetched2 &fetched2/libbar-2.0.0.tar.gz - - : not-fetched - : - $* -d ../cfg libbar >'libbar available 2.0.0 [1.1.0+1] 1.1.0 1.0.0+1 1.0.0' - - : fetched-1 - : - $* -d ../fetched1 libbar >'libbar fetched 1.0.0+1 available 2.0.0 [1.1.0+1] 1.1.0' - - : fetched-2 - : - $* -d ../fetched2 libbar >'libbar fetched 2.0.0' - } -} - -: git-rep -: -if ($git_supported != true) -{ - # Skip git repository tests. - # -} -else -{ - rep = "$rep_git/state0" - test.cleanups += &cfg/.bpkg/repos/*/*** - - : complement-cycle - : - : Make sure that we properly handle the root<->style repository dependency - : cycle while searching for the style-basic package, that is an available - : package but not from the user-added repository (or its complement), and so - : is not detected as buildable by the status command. Note that the root - : repository is the default complement for git repositories (see rep_fetch() - : implementation for the reasoning). - : - $clone_root_cfg; - $rep_add "$rep/libbar.git#master" && $rep_add "$rep/style.git#master"; - - # Convert specific warnings to infos as we expect them to appear. This, in - # particular, prevents bbot workers to set task result status to warning. - # - $rep_fetch 2>&1 | \ - sed -e 's/warning: (fetching (over|whole) .*)/info: \1/' >&2 2>!; - - $* style-basic >~'%style-basic available \[1\.1\.0-a\.0\..+\]%' -} diff --git a/tests/pkg-status.testscript b/tests/pkg-status.testscript new file mode 100644 index 0000000..b539f05 --- /dev/null +++ b/tests/pkg-status.testscript @@ -0,0 +1,215 @@ +# file : tests/pkg-status.testscript +# copyright : Copyright (c) 2014-2018 Code Synthesis Ltd +# license : MIT; see accompanying LICENSE file + +.include common.testscript \ + config.testscript \ + remote.testscript \ + remote-git.testscript + +# Source repository: +# +# pkg-status +# |-- extra -> stable (prerequisite) +# | |-- libbar-1.1.0+1.tar.gz +# | `-- repositories.manifest +# | +# |-- stable +# | |-- libbar-1.0.0.tar.gz +# | |-- libfoo-1.0.0.tar.gz +# | `-- repositories.manifest +# | +# |-- testing -> stable (complement), extra (prerequisite) +# | |-- libbar-1.0.0+1.tar.gz +# | |-- libbar-1.1.0.tar.gz +# | `-- repositories.manifest +# | +# |-- unstable -> testing (complement) +# | |-- libbar-2.0.0.tar.gz +# | `-- repositories.manifest +# | +# `-- git +# |-- libbar.git -> style-basic.git (prerequisite) +# |-- style-basic.git +# `-- style.git + +# Prepare repositories used by tests if running in the local mode. +# ++if ($remote != true) + cp -r $src/extra $out/extra + cp -r $src/stable $out/stable + cp -r $src/testing $out/testing + cp -r $src/unstable $out/unstable + + c = $rep_create 2>! + + $c $out/extra &$out/extra/packages.manifest + $c $out/stable &$out/stable/packages.manifest + $c $out/testing &$out/testing/packages.manifest + $c $out/unstable &$out/unstable/packages.manifest + + # Create git repositories. + # + $git_extract $src/git/style.tar + $git_extract $src/git/libbar.tar + $git_extract $src/git/style-basic.tar &$out_git/state0/*** +end + +pkg_fetch += 2>! +pkg_purge += -d cfg 2>! +rep_add += -d cfg 2>! +rep_fetch += -d cfg --auth all --trust-yes 2>! + +: basics +: +{ + +$clone_cfg + + : not-fetched + : + { + +$clone_cfg + + : libfoo-1.0.0 + : + $clone_cfg; + $* libfoo/1.0.0 >'libfoo unknown 1.0.0' + + : libfoo + : + $clone_cfg; + $* libfoo >'libfoo unknown' + } + + : rep-fetched + : + { + +$clone_cfg && $rep_add $rep/stable && $rep_fetch + + +cp -r cfg ./fetched + +$pkg_fetch libfoo/1.0.0 -d fetched &fetched/libfoo-1.0.0.tar.gz + + : libfoo-1.0.0 + : + $clone_cfg; + $* libfoo/1.0.0 >'libfoo available 1.0.0' + + : libfoo + : + $clone_cfg; + $* libfoo >'libfoo available 1.0.0' + + : pkg-fetched + : + { + clone_cfg = cp -r ../../fetched cfg + + : libfoo-1.0.0 + : + $clone_cfg; + $* libfoo/1.0.0 >'libfoo fetched 1.0.0' + + : libfoo + : + $clone_cfg; + $* libfoo >'libfoo fetched 1.0.0' + } + } +} + +: multiple-versions +{ + # Prepare the nested tests to copy the root configuration. Note that they + # must provide the destination directory name as an argument. + # + clone_cfg = cp -r $~/../cfg + + : extra + : + { + # Here we, first, prepare 2 configurations that derive from each other, and + # then spawn 2 tests on them. + # + +$clone_cfg extra && $rep_add -d extra $rep/extra && $rep_fetch -d extra + + +cp -r extra extra-stable + +$rep_add -d extra-stable $rep/stable && $rep_fetch -d extra-stable + + : libbar + : + $* -d ../extra libbar >'libbar available 1.1.0+1 [1.0.0]' + + : libbar-stable + : + $* -d ../extra-stable libbar >'libbar available 1.1.0+1 1.0.0' + } + + : testing + : + { + $clone_cfg ./ && $rep_add $rep/testing && $rep_fetch; + + $* libbar >'libbar available [1.1.0+1] 1.1.0 1.0.0+1 1.0.0' + } + + : unstable + : + { + # Here we, first, prepare 3 configurations that derive from each other, and + # then spawn 3 tests on them. + # + +$clone_cfg ./ && $rep_add $rep/unstable && $rep_fetch + + +cp -r cfg fetched1 + +$pkg_fetch libbar/1.0.0+1 -d fetched1 &fetched1/libbar-1.0.0+1.tar.gz + + +cp -r fetched1 fetched2 + +$pkg_purge -d fetched2 libbar &!fetched2/libbar-1.0.0+1.tar.gz + +$pkg_fetch libbar/2.0.0 -d fetched2 &fetched2/libbar-2.0.0.tar.gz + + : not-fetched + : + $* -d ../cfg libbar >'libbar available 2.0.0 [1.1.0+1] 1.1.0 1.0.0+1 1.0.0' + + : fetched-1 + : + $* -d ../fetched1 libbar >'libbar fetched 1.0.0+1 available 2.0.0 [1.1.0+1] 1.1.0' + + : fetched-2 + : + $* -d ../fetched2 libbar >'libbar fetched 2.0.0' + } +} + +: git-rep +: +if ($git_supported != true) +{ + # Skip git repository tests. + # +} +else +{ + rep = "$rep_git/state0" + test.cleanups += &cfg/.bpkg/repos/*/*** + + : complement-cycle + : + : Make sure that we properly handle the root<->style repository dependency + : cycle while searching for the style-basic package, that is an available + : package but not from the user-added repository (or its complement), and so + : is not detected as buildable by the status command. Note that the root + : repository is the default complement for git repositories (see rep_fetch() + : implementation for the reasoning). + : + $clone_root_cfg; + $rep_add "$rep/libbar.git#master" && $rep_add "$rep/style.git#master"; + + # Convert specific warnings to infos as we expect them to appear. This, in + # particular, prevents bbot workers to set task result status to warning. + # + $rep_fetch 2>&1 | \ + sed -e 's/warning: (fetching (over|whole) .*)/info: \1/' >&2 2>!; + + $* style-basic >~'%style-basic available \[1\.1\.0-a\.0\..+\]%' +} diff --git a/tests/pkg-system.test b/tests/pkg-system.test deleted file mode 100644 index a681127..0000000 --- a/tests/pkg-system.test +++ /dev/null @@ -1,911 +0,0 @@ -# file : tests/pkg-system.test -# copyright : Copyright (c) 2014-2018 Code Synthesis Ltd -# license : MIT; see accompanying LICENSE file - -.include common.test auth.test config.test remote.test - -# There is no pkg-system command, and this testscript contains tests for -# various building scenarios that involves system packages. Note that by that -# reason usage of $* is meaningless. -# - -# Source repository: -# -# pkg-system -# |-- foo-2.tar.gz -> libbar >= 2 -# |-- libbar-0+1.tar.gz -# |-- libbar-1.tar.gz -> libbaz == 2 -# |-- libbar-2.tar.gz -> libbaz == 2 -# |-- libbaz-2.tar.gz -# |-- t1 -# | |-- foo-2.tar.gz -> libbar >= 2 -# | |-- libbar-1.tar.gz -> libbaz == 2 -# | |-- libbar-2.tar.gz -> libbaz == 2 -# | |-- libbaz-2.tar.gz -# | `-- repositories.manifest -# |-- t2 -# | |-- foo-2.tar.gz -> libbar >= 2 -# | |-- libbar-0+1.tar.gz -# | `-- repositories.manifest -# `-- t3 -> t2 (prerequisite) -# |-- foo-2.tar.gz -> libbar >= 2 -# `-- repositories.manifest - -# Prepare repositories used by tests if running in the local mode. -# -+if ($remote != true) - rep_create += 2>! - - cp -r $src/t1 $out/t1 && $rep_create $out/t1 &$out/t1/packages.manifest - cp -r $src/t2 $out/t2 && $rep_create $out/t2 &$out/t2/packages.manifest - cp -r $src/t3 $out/t3 && $rep_create $out/t3 &$out/t3/packages.manifest -end - -pkg_build += -d cfg --yes -pkg_drop += -d cfg --yes 2>! -pkg_status += -d cfg -rep_add += -d cfg 2>! -rep_fetch += -d cfg --auth all --trust-yes 2>! -rep_remove += -d cfg 2>! - -# Note that when we fetch a package from remote repository the bpkg stderr -# contains fetch program progress output, that comes prior the informational -# message. -# -: t1 -: -{ - +$clone_cfg && $rep_add $rep/t1 && $rep_fetch - - : dup - : - : Test that passing package duplicates on the command line expectedly fails. - : Note that we unite all such tests into a single one for the sake of code - : (and not to think of too many ids for almost identical tests :-)). - : - { - $clone_cfg; - - $pkg_build 'sys:libbar' '?sys:libbar' 2>>EOE != 0; - error: duplicate package libbar - info: first mentioned as sys:libbar - info: second mentioned as ?sys:libbar - EOE - - $pkg_build '?sys:libbar' 'sys:libbar' 2>>EOE != 0; - error: duplicate package libbar - info: first mentioned as ?sys:libbar - info: second mentioned as sys:libbar - EOE - - $pkg_build '?sys:libbar' libbar 2>>EOE != 0; - error: duplicate package libbar - info: first mentioned as ?sys:libbar - info: second mentioned as libbar - EOE - - $pkg_build libbar '?sys:libbar' 2>>EOE != 0; - error: duplicate package libbar - info: first mentioned as libbar - info: second mentioned as ?sys:libbar - EOE - - $pkg_build 'sys:libbar' libbar 2>>EOE != 0; - error: duplicate package libbar - info: first mentioned as sys:libbar - info: second mentioned as libbar - EOE - - $pkg_build libbar 'sys:libbar' 2>>EOE != 0 - error: duplicate package libbar - info: first mentioned as libbar - info: second mentioned as sys:libbar - EOE - } - - : syslibbar-foo-syslibbar2-libbar2 - : - : The overall plan is to build sys:libbar/*, foo, then reconfigure - : sys:libbar/* to sys:libbar/2 and afterwards to libbar/2. - : - { - $clone_cfg; - - # Build sys:libbar/*. - # - $pkg_build 'sys:libbar' 2>'configured sys:libbar/*'; - $pkg_status libbar 1>'!libbar configured,system !* available 2 1'; - $pkg_status libbaz 1>'libbaz available 2'; - - # Build foo with preconfigured sys:libbar/*. - # - $pkg_build foo 2>>~%EOE%; - %.* - %.*fetched foo/2% - unpacked foo/2 - configured foo/2 - %info: .+ is up to date% - updated foo/2 - EOE - - $pkg_status foo >'!foo configured 2'; - $pkg_status libbar >'!libbar configured,system !* available 2 1'; - $pkg_status libbaz >'libbaz available 2'; - - # Reconfigure sys:libbar/* to 2. - # - $pkg_build 'sys:libbar/2' 2>>~%EOE%; - disfigured foo/2 - purged libbar/* - configured sys:libbar/2 - configured foo/2 - %info: .+ is up to date% - updated foo/2 - EOE - - $pkg_status foo >'!foo configured 2'; - $pkg_status libbar >'!libbar configured,system !2'; - $pkg_status libbaz >'libbaz available 2'; - - # Reconfigure sys:libbar/2 to libbar/2. - # - $pkg_build libbar/2 2>>~%EOE%; - disfigured foo/2 - purged libbar/2 - %.* - %.*fetched libbaz/2% - unpacked libbaz/2 - configured libbaz/2 - %.* - %.*fetched libbar/2% - unpacked libbar/2 - configured libbar/2 - configured foo/2 - %info: .+ is up to date%{2} - updated libbar/2 - updated foo/2 - EOE - - $pkg_status foo >'!foo configured 2'; - $pkg_status libbar >'!libbar configured !2'; - $pkg_status libbaz >'libbaz configured 2'; - - $pkg_drop foo libbar - } - - : foo-syslibbar2 - : - : Build foo and sys:libbar/2. - : - { - $clone_cfg; - - $pkg_build foo 'sys:libbar/2' 2>>~%EOE%; - configured sys:libbar/2 - %.* - %.*fetched foo/2% - unpacked foo/2 - configured foo/2 - %info: .+ is up to date% - updated foo/2 - EOE - - $pkg_status foo >'!foo configured 2'; - $pkg_status libbar >'!libbar configured,system !2'; - $pkg_status libbaz >'libbaz available 2'; - - $pkg_drop foo libbar - } - - : syslibbar2-foo - : - : Build sys:libbar/2 and foo. - : - { - $clone_cfg; - - $pkg_build 'sys:libbar/2' foo 2>>~%EOE%; - configured sys:libbar/2 - %.* - %.*fetched foo/2% - unpacked foo/2 - configured foo/2 - %info: .+ is up to date% - updated foo/2 - EOE - - $pkg_status foo >'!foo configured 2'; - $pkg_status libbar >'!libbar configured,system !2'; - $pkg_status libbaz >'libbaz available 2'; - - $pkg_drop foo libbar - } - - : libbar2-foo-syslibbar2 - : - : The overall plan is to build libbar/2, then foo and sys:libbar/2. - : - { - $clone_cfg; - - # Build libbar/2. - # - $pkg_build libbar/2 2>>~%EOE%; - %.* - %.*fetched libbaz/2% - unpacked libbaz/2 - configured libbaz/2 - %.* - %.*fetched libbar/2% - unpacked libbar/2 - configured libbar/2 - %info: .+ is up to date% - updated libbar/2 - EOE - - $pkg_status libbar >'!libbar configured !2'; - $pkg_status libbaz >'libbaz configured 2'; - - # Build foo and sys:libbar/2. - # - $pkg_build foo 'sys:libbar/2' 2>>~%EOE%; - disfigured libbar/2 - disfigured libbaz/2 - purged libbaz/2 - purged libbar/2 - configured sys:libbar/2 - %.* - %.*fetched foo/2% - unpacked foo/2 - configured foo/2 - %info: .+ is up to date% - updated foo/2 - EOE - - $pkg_status foo >'!foo configured 2'; - $pkg_status libbar >'!libbar configured,system !2'; - $pkg_status libbaz >'libbaz available 2'; - - $pkg_drop foo libbar - } - - : libbar2-foo-syslibbar - : - : The overall plan is to build libbar/2, then foo and sys:libbar. - : - { - $clone_cfg; - - # Build libbar/2. - # - $pkg_build libbar/2 2>>~%EOE%; - %.* - %.*fetched libbaz/2% - unpacked libbaz/2 - configured libbaz/2 - %.* - %.*fetched libbar/2% - unpacked libbar/2 - configured libbar/2 - %info: .+ is up to date% - updated libbar/2 - EOE - - $pkg_status libbar >'!libbar configured !2'; - $pkg_status libbaz >'libbaz configured 2'; - - # Build foo and sys:libbar. - # - $pkg_build foo 'sys:libbar' 2>>~%EOE%; - disfigured libbar/2 - disfigured libbaz/2 - purged libbaz/2 - purged libbar/2 - configured sys:libbar/* - %.* - %.*fetched foo/2% - unpacked foo/2 - configured foo/2 - %info: .+ is up to date% - updated foo/2 - EOE - - $pkg_status foo >'!foo configured 2'; - $pkg_status libbar >'!libbar configured,system !* available 2 1'; - $pkg_status libbaz >'libbaz available 2'; - - $pkg_drop foo libbar - } - - : syslibbar2-foo-libbar2-syslibbar2-libbar2 - : - : The overall plan is to build sys:libbar/2, then foo and libbar/2, then - : reconfigure to sys:libbar/2 and afterwards to libbar/2. - : - { - $clone_cfg; - - # Build sys:libbar/2. - # - $pkg_build 'sys:libbar/2' 2>'configured sys:libbar/2'; - $pkg_status libbar >'!libbar configured,system !2'; - - # Build foo and libbar/2. - # - $pkg_build foo libbar/2 2>>~%EOE%; - purged libbar/2 - %.* - %.*fetched libbaz/2% - unpacked libbaz/2 - configured libbaz/2 - %.* - %.*fetched libbar/2% - unpacked libbar/2 - configured libbar/2 - %.* - %.*fetched foo/2% - unpacked foo/2 - configured foo/2 - %info: .+ is up to date%{2} - updated libbar/2 - updated foo/2 - EOE - - $pkg_status foo >'!foo configured 2'; - $pkg_status libbar >'!libbar configured !2'; - $pkg_status libbaz >'libbaz configured 2'; - - # Build sys:libbar/2. - # - $pkg_build 'sys:libbar/2' 2>>~%EOE%; - disfigured foo/2 - disfigured libbar/2 - disfigured libbaz/2 - purged libbaz/2 - purged libbar/2 - configured sys:libbar/2 - configured foo/2 - %info: .+ is up to date% - updated foo/2 - EOE - - $pkg_status foo >'!foo configured 2'; - $pkg_status libbar >'!libbar configured,system !2'; - $pkg_status libbaz >'libbaz available 2'; - - # Build libbar/2. - # - $pkg_build libbar/2 2>>~%EOE%; - disfigured foo/2 - purged libbar/2 - %.* - %.*fetched libbaz/2% - unpacked libbaz/2 - configured libbaz/2 - %.* - %.*fetched libbar/2% - unpacked libbar/2 - configured libbar/2 - configured foo/2 - %info: .+ is up to date%{2} - updated libbar/2 - updated foo/2 - EOE - - $pkg_status foo >'!foo configured 2'; - $pkg_status libbar >'!libbar configured !2'; - $pkg_status libbaz >'libbaz configured 2'; - - $pkg_drop foo libbar - } - - : syslibbar1-foo-libbar - : - : The overall plan is to configure sys:libbar/1, then fail to build foo but - : succeed to build foo libbar. - : - { - $clone_cfg; - - # Build sys:libbar/1. - # - $pkg_build 'sys:libbar/1' 2>'configured sys:libbar/1'; - $pkg_status libbar 1>'!libbar configured,system !1 available 2'; - $pkg_status libbaz 1>'libbaz available 2'; - - # Fail to build foo. - # - $pkg_build foo 2>>EOE != 0; - error: package foo dependency on (libbar >= 2) is forcing upgrade of sys:libbar/1 to libbar/2 - info: package version sys:libbar/1 is held - info: explicitly request version upgrade to continue - info: while satisfying foo/2 - EOE - - # Build foo and libbar. - # - $pkg_build foo libbar 2>>~%EOE%; - purged libbar/1 - %.* - %.*fetched libbaz/2% - unpacked libbaz/2 - configured libbaz/2 - %.* - %.*fetched libbar/2% - unpacked libbar/2 - configured libbar/2 - %.* - %.*fetched foo/2% - unpacked foo/2 - configured foo/2 - %info: .+ is up to date%{2} - updated libbar/2 - updated foo/2 - EOE - - $pkg_status foo >'!foo configured 2'; - $pkg_status libbar >'!libbar configured 2'; - $pkg_status libbaz >'libbaz configured 2'; - - $pkg_drop foo libbar - } - - : foo-syslibbar - : - : Build foo and ?sys:libbar. - : - { - $clone_cfg; - - $pkg_build foo '?sys:libbar' 2>>~%EOE%; - configured sys:libbar/* - %.* - %.*fetched foo/2% - unpacked foo/2 - configured foo/2 - %info: .+ is up to date% - updated foo/2 - EOE - - $pkg_status foo >'!foo configured 2'; - $pkg_status libbar >'libbar configured,system !* available 2 1'; - $pkg_status libbaz >'libbaz available 2'; - - $pkg_drop foo libbar - } - - : libbar1-foo-syslibbar2 - : - : The overall plan is to configure libbar/1, then fail to build foo but - : succeed to build foo ?sys:libbar/2, and then foo sys:libbar/2. - : - { - $clone_cfg; - - # Build libbar/1. - # - $pkg_build libbar/1 2>>~%EOE%; - %.* - %.*fetched libbaz/2% - unpacked libbaz/2 - configured libbaz/2 - %.* - %.*fetched libbar/1% - unpacked libbar/1 - configured libbar/1 - %info: .+ is up to date% - updated libbar/1 - EOE - - $pkg_status libbar >'!libbar configured !1 available 2'; - $pkg_status libbaz >'libbaz configured 2'; - - # Fail to build foo. - # - $pkg_build foo 2>>EOE != 0; - error: package foo dependency on (libbar >= 2) is forcing upgrade of libbar/1 to 2 - info: package version libbar/1 is held - info: explicitly request version upgrade to continue - info: while satisfying foo/2 - EOE - - # Build foo and ?sys:libbar/2. - # - $pkg_build foo '?sys:libbar/2' 2>>~%EOE%; - disfigured libbar/1 - disfigured libbaz/2 - purged libbaz/2 - purged libbar/1 - configured sys:libbar/2 - %.* - %.*fetched foo/2% - unpacked foo/2 - configured foo/2 - %info: .+ is up to date% - updated foo/2 - EOE - - $pkg_status foo >'!foo configured 2'; - $pkg_status libbar >'libbar configured,system !2'; - $pkg_status libbaz >'libbaz available 2'; - - # Build foo and sys:libbar/2. - # - $pkg_build foo 'sys:libbar/2' 2>>~%EOE%; - %info: .+ is up to date% - updated foo/2 - EOE - - $pkg_status foo >'!foo configured 2'; - $pkg_status libbar >'!libbar configured,system !2'; - $pkg_status libbaz >'libbaz available 2'; - - $pkg_drop foo libbar - } - - : upgrade-held - : - { - $clone_cfg; - - $pkg_build libbar 2>!; - - $rep_remove $rep/t1 && $rep_fetch $rep/t2; - - $pkg_build --upgrade 2>>EOE != 0; - error: libbar is not available in source - info: consider building it as sys:libbar if it is available from the system - EOE - - $pkg_build 'sys:libbar' 2>>EOE; - disfigured libbar/2 - disfigured libbaz/2 - purged libbaz/2 - purged libbar/2 - configured sys:libbar/* - EOE - - $pkg_build --upgrade 2>'info: nothing to build'; - - $pkg_drop libbar - } -} - -: t2 -: -{ - +$clone_cfg && $rep_add $rep/t2 && $rep_fetch - - : no-libbar - : - : Test that the following builds expectedly fails having no libbar available - : in source. - : - { - $clone_cfg; - - $pkg_build foo 2>>EOE != 0; - error: dependency libbar >= 2 of package foo is not available in source - info: specify ?sys:libbar if it is available from the system - info: while satisfying foo/2 - EOE - - $pkg_build foo libbar 2>>EOE != 0; - error: libbar is not available in source - info: specify sys:libbar if it is available from the system - EOE - - $pkg_status foo >'foo available 2'; - $pkg_status libbar >'libbar unknown' - } - - : foo-syslibbar - : - : Build foo configuring sys:libbar. - : - { - $clone_cfg; - - $pkg_build foo 'sys:libbar' 2>>~%EOE%; - configured sys:libbar/* - %.* - %.*fetched foo/2% - unpacked foo/2 - configured foo/2 - %info: .+ is up to date% - updated foo/2 - EOE - - $pkg_status foo >'!foo configured 2'; - $pkg_status libbar >'!libbar configured,system !*'; - - $pkg_drop foo libbar - } - - : libbar1-foo-syslibbar2 - : - : The overall plan is to configure sys:libbar/1, then fail to build foo, but - : succeed to build foo sys:libbar/2. - : - { - $clone_cfg; - - # Build sys:libbar/1. - # - $pkg_build 'sys:libbar/1' 2>'configured sys:libbar/1'; - $pkg_status libbar 1>'!libbar configured,system !1'; - - # Fail to build foo. - # - $pkg_build foo 2>>EOE != 0; - error: dependency libbar >= 2 of package foo is not available in source - info: sys:libbar/1 does not satisfy the constrains - info: while satisfying foo/2 - EOE - - # Build foo and sys:libbar/2. - # - $pkg_build foo 'sys:libbar/2' 2>>~%EOE%; - purged libbar/1 - configured sys:libbar/2 - %.* - %.*fetched foo/2% - unpacked foo/2 - configured foo/2 - %info: .+ is up to date% - updated foo/2 - EOE - - $pkg_status foo >'!foo configured 2'; - $pkg_status libbar >'!libbar configured,system !2'; - - $pkg_drop foo libbar - } - - : syslibbar2 - : - : The overall plan is to fail to build foo sys:libbar/1, then configure - : sys:libbar/2 but still fail to build foo sys:libbar/1. - : - { - $clone_cfg; - - # Fail to build foo and sys:libbar/1. - # - $pkg_build foo 'sys:libbar/1' 2>>EOE != 0; - error: dependency libbar >= 2 of package foo is not available in source - info: sys:libbar/1 does not satisfy the constrains - info: while satisfying foo/2 - EOE - - # Build sys:libbar/2. - # - $pkg_build 'sys:libbar/2' 2>'configured sys:libbar/2'; - $pkg_status libbar 1>'!libbar configured,system !2'; - - # Still fail to build foo and sys:libbar/1. - # - $pkg_build foo 'sys:libbar/1' 2>>EOE != 0; - error: unable to satisfy constraints on package libbar - info: foo depends on (libbar >= 2) - info: command line depends on (libbar == 1) - info: available sys:libbar/2 - info: available sys:libbar/1 - info: explicitly specify libbar version to manually satisfy both constraints - info: while satisfying foo/2 - EOE - - $pkg_drop libbar - } - - : syslibbar1 - : - : The overall plan is to configure sys:libbar/1, then fail to build - : sys:libbar/1.1 foo. - : - { - $clone_cfg; - - # Build sys:libbar/2. - # - $pkg_build 'sys:libbar/1' 2>'configured sys:libbar/1'; - $pkg_status libbar 1>'!libbar configured,system !1'; - - # Fail to build sys:libbar/1.1 and foo. - # - $pkg_build 'sys:libbar/1.1' foo 2>>EOE != 0; - error: dependency libbar >= 2 of package foo is not available in source - info: sys:libbar/1.1 does not satisfy the constrains - info: while satisfying foo/2 - EOE - - $pkg_drop libbar - } - - : foo-syslibbar-drop-foo - : - : The overall plan is to build foo ?sys:libbar, then drop foo and make sure - : libbar is purged as well. - : - { - $clone_cfg; - - # Build foo and ?sys:libbar. - # - $pkg_build foo '?sys:libbar' 2>>~%EOE%; - configured sys:libbar/* - %.* - %.*fetched foo/2% - unpacked foo/2 - configured foo/2 - %info: .+ is up to date% - updated foo/2 - EOE - - $pkg_status foo >'!foo configured 2'; - $pkg_status libbar >'libbar configured,system !*'; - - # Drop foo. - # - $pkg_drop foo 2>>EOE; - disfigured foo - purged libbar - purged foo - EOE - - $pkg_status foo >'foo available 2'; - $pkg_status libbar --system >'libbar available sys:?' - } - - : syslibbar1-foo-syslibbar-drop-foo - : - : The overall plan is to build sys:libbar/1, then fail to build foo but - : succeed to build foo ?sys:libbar, then drop foo and make sure libbar stays. - : - { - $clone_cfg; - - # Build sys:libbar/1. - # - $pkg_build 'sys:libbar/1' 2>'configured sys:libbar/1'; - $pkg_status libbar 1>'!libbar configured,system !1'; - - # Fail to build foo. - # - $pkg_build foo 2>>EOE != 0; - error: dependency libbar >= 2 of package foo is not available in source - info: sys:libbar/1 does not satisfy the constrains - info: while satisfying foo/2 - EOE - - # Build foo and '?sys:libbar/2'. - # - $pkg_build foo '?sys:libbar/2' 2>>~%EOE%; - purged libbar/1 - configured sys:libbar/2 - %.* - %.*fetched foo/2% - unpacked foo/2 - configured foo/2 - %info: .+ is up to date% - updated foo/2 - EOE - - $pkg_status foo >'!foo configured 2'; - $pkg_status libbar >'libbar configured,system !2'; - - # Drop foo. - # - $pkg_drop foo 2>>EOE; - disfigured foo - purged libbar - purged foo - EOE - - $pkg_status foo >'foo available 2'; - $pkg_status libbar --system >'libbar available sys:?' - } -} - -: t3 -: -{ - +$clone_cfg && $rep_add $rep/t3 && $rep_fetch - - : no-libbar - : - : Test that the following builds expectedly fails having no libbar available - : in source. - : - { - $clone_cfg; - - $pkg_build foo 2>>EOE != 0; - error: dependency libbar >= 2 of package foo is not available in source - info: specify ?sys:libbar if it is available from the system - info: while satisfying foo/2 - EOE - - $pkg_build 'sys:libbar/1' 2>>EOE != 0; - error: unknown package libbar - EOE - - $pkg_build foo 'sys:libbar/1' 2>>EOE != 0; - error: unknown package libbar - EOE - - $pkg_build foo '?sys:libbar/1' 2>>EOE != 0; - error: unable to satisfy constraints on package libbar - info: foo depends on (libbar >= 2) - info: command line depends on (libbar == 1) - info: specify libbar version to satisfy foo constraint - info: while satisfying foo/2 - EOE - - $pkg_status foo >'foo available 2'; - $pkg_status libbar >'libbar unknown' - } - - : syslibbar1-foo-syslibbar-drop-foo - : - : The overall plan is to build foo ?sys:libbar/2, fail to build sys:libbar - : and foo 'sys:libbar', but succeed to build foo ?sys:libbar/3 and foo - : ?sys:libbar. - : - { - $clone_cfg; - - # Build foo '?sys:libbar/2'. - # - $pkg_build foo '?sys:libbar/2' 2>>~%EOE%; - configured sys:libbar/2 - %.* - %.*fetched foo/2% - unpacked foo/2 - configured foo/2 - %info: .+ is up to date% - updated foo/2 - EOE - - $pkg_status foo >'!foo configured 2'; - $pkg_status libbar >'libbar configured,system !2'; - - # Fail as libbar while being selected is still unknown (not present in t3 - # repo). - # - $pkg_build 'sys:libbar' 2>'error: unknown package libbar' != 0; - $pkg_build foo 'sys:libbar' 2>'error: unknown package libbar' != 0; - $pkg_status foo 1>'!foo configured 2'; - $pkg_status libbar 1>'libbar configured,system !2'; - - # Build foo and ?sys:libbar/3. - # - $pkg_build foo '?sys:libbar/3' 2>>~%EOE%; - disfigured foo/2 - purged libbar/2 - configured sys:libbar/3 - configured foo/2 - %info: .+ is up to date% - updated foo/2 - EOE - - $pkg_status foo >'!foo configured 2'; - $pkg_status libbar >'libbar configured,system !3'; - - # Build foo and ?sys:libbar. - # - $pkg_build foo '?sys:libbar' 2>>~%EOE%; - disfigured foo/2 - purged libbar/3 - configured sys:libbar/* - configured foo/2 - %info: .+ is up to date% - updated foo/2 - EOE - - $pkg_status foo >'!foo configured 2'; - $pkg_status libbar >'libbar configured,system !*'; - - $pkg_drop foo - } -} diff --git a/tests/pkg-system.testscript b/tests/pkg-system.testscript new file mode 100644 index 0000000..e8ad676 --- /dev/null +++ b/tests/pkg-system.testscript @@ -0,0 +1,911 @@ +# file : tests/pkg-system.testscript +# copyright : Copyright (c) 2014-2018 Code Synthesis Ltd +# license : MIT; see accompanying LICENSE file + +.include common.testscript auth.testscript config.testscript remote.testscript + +# There is no pkg-system command, and this testscript contains tests for +# various building scenarios that involves system packages. Note that by that +# reason usage of $* is meaningless. +# + +# Source repository: +# +# pkg-system +# |-- foo-2.tar.gz -> libbar >= 2 +# |-- libbar-0+1.tar.gz +# |-- libbar-1.tar.gz -> libbaz == 2 +# |-- libbar-2.tar.gz -> libbaz == 2 +# |-- libbaz-2.tar.gz +# |-- t1 +# | |-- foo-2.tar.gz -> libbar >= 2 +# | |-- libbar-1.tar.gz -> libbaz == 2 +# | |-- libbar-2.tar.gz -> libbaz == 2 +# | |-- libbaz-2.tar.gz +# | `-- repositories.manifest +# |-- t2 +# | |-- foo-2.tar.gz -> libbar >= 2 +# | |-- libbar-0+1.tar.gz +# | `-- repositories.manifest +# `-- t3 -> t2 (prerequisite) +# |-- foo-2.tar.gz -> libbar >= 2 +# `-- repositories.manifest + +# Prepare repositories used by tests if running in the local mode. +# ++if ($remote != true) + rep_create += 2>! + + cp -r $src/t1 $out/t1 && $rep_create $out/t1 &$out/t1/packages.manifest + cp -r $src/t2 $out/t2 && $rep_create $out/t2 &$out/t2/packages.manifest + cp -r $src/t3 $out/t3 && $rep_create $out/t3 &$out/t3/packages.manifest +end + +pkg_build += -d cfg --yes +pkg_drop += -d cfg --yes 2>! +pkg_status += -d cfg +rep_add += -d cfg 2>! +rep_fetch += -d cfg --auth all --trust-yes 2>! +rep_remove += -d cfg 2>! + +# Note that when we fetch a package from remote repository the bpkg stderr +# contains fetch program progress output, that comes prior the informational +# message. +# +: t1 +: +{ + +$clone_cfg && $rep_add $rep/t1 && $rep_fetch + + : dup + : + : Test that passing package duplicates on the command line expectedly fails. + : Note that we unite all such tests into a single one for the sake of code + : (and not to think of too many ids for almost identical tests :-)). + : + { + $clone_cfg; + + $pkg_build 'sys:libbar' '?sys:libbar' 2>>EOE != 0; + error: duplicate package libbar + info: first mentioned as sys:libbar + info: second mentioned as ?sys:libbar + EOE + + $pkg_build '?sys:libbar' 'sys:libbar' 2>>EOE != 0; + error: duplicate package libbar + info: first mentioned as ?sys:libbar + info: second mentioned as sys:libbar + EOE + + $pkg_build '?sys:libbar' libbar 2>>EOE != 0; + error: duplicate package libbar + info: first mentioned as ?sys:libbar + info: second mentioned as libbar + EOE + + $pkg_build libbar '?sys:libbar' 2>>EOE != 0; + error: duplicate package libbar + info: first mentioned as libbar + info: second mentioned as ?sys:libbar + EOE + + $pkg_build 'sys:libbar' libbar 2>>EOE != 0; + error: duplicate package libbar + info: first mentioned as sys:libbar + info: second mentioned as libbar + EOE + + $pkg_build libbar 'sys:libbar' 2>>EOE != 0 + error: duplicate package libbar + info: first mentioned as libbar + info: second mentioned as sys:libbar + EOE + } + + : syslibbar-foo-syslibbar2-libbar2 + : + : The overall plan is to build sys:libbar/*, foo, then reconfigure + : sys:libbar/* to sys:libbar/2 and afterwards to libbar/2. + : + { + $clone_cfg; + + # Build sys:libbar/*. + # + $pkg_build 'sys:libbar' 2>'configured sys:libbar/*'; + $pkg_status libbar 1>'!libbar configured,system !* available 2 1'; + $pkg_status libbaz 1>'libbaz available 2'; + + # Build foo with preconfigured sys:libbar/*. + # + $pkg_build foo 2>>~%EOE%; + %.* + %.*fetched foo/2% + unpacked foo/2 + configured foo/2 + %info: .+ is up to date% + updated foo/2 + EOE + + $pkg_status foo >'!foo configured 2'; + $pkg_status libbar >'!libbar configured,system !* available 2 1'; + $pkg_status libbaz >'libbaz available 2'; + + # Reconfigure sys:libbar/* to 2. + # + $pkg_build 'sys:libbar/2' 2>>~%EOE%; + disfigured foo/2 + purged libbar/* + configured sys:libbar/2 + configured foo/2 + %info: .+ is up to date% + updated foo/2 + EOE + + $pkg_status foo >'!foo configured 2'; + $pkg_status libbar >'!libbar configured,system !2'; + $pkg_status libbaz >'libbaz available 2'; + + # Reconfigure sys:libbar/2 to libbar/2. + # + $pkg_build libbar/2 2>>~%EOE%; + disfigured foo/2 + purged libbar/2 + %.* + %.*fetched libbaz/2% + unpacked libbaz/2 + configured libbaz/2 + %.* + %.*fetched libbar/2% + unpacked libbar/2 + configured libbar/2 + configured foo/2 + %info: .+ is up to date%{2} + updated libbar/2 + updated foo/2 + EOE + + $pkg_status foo >'!foo configured 2'; + $pkg_status libbar >'!libbar configured !2'; + $pkg_status libbaz >'libbaz configured 2'; + + $pkg_drop foo libbar + } + + : foo-syslibbar2 + : + : Build foo and sys:libbar/2. + : + { + $clone_cfg; + + $pkg_build foo 'sys:libbar/2' 2>>~%EOE%; + configured sys:libbar/2 + %.* + %.*fetched foo/2% + unpacked foo/2 + configured foo/2 + %info: .+ is up to date% + updated foo/2 + EOE + + $pkg_status foo >'!foo configured 2'; + $pkg_status libbar >'!libbar configured,system !2'; + $pkg_status libbaz >'libbaz available 2'; + + $pkg_drop foo libbar + } + + : syslibbar2-foo + : + : Build sys:libbar/2 and foo. + : + { + $clone_cfg; + + $pkg_build 'sys:libbar/2' foo 2>>~%EOE%; + configured sys:libbar/2 + %.* + %.*fetched foo/2% + unpacked foo/2 + configured foo/2 + %info: .+ is up to date% + updated foo/2 + EOE + + $pkg_status foo >'!foo configured 2'; + $pkg_status libbar >'!libbar configured,system !2'; + $pkg_status libbaz >'libbaz available 2'; + + $pkg_drop foo libbar + } + + : libbar2-foo-syslibbar2 + : + : The overall plan is to build libbar/2, then foo and sys:libbar/2. + : + { + $clone_cfg; + + # Build libbar/2. + # + $pkg_build libbar/2 2>>~%EOE%; + %.* + %.*fetched libbaz/2% + unpacked libbaz/2 + configured libbaz/2 + %.* + %.*fetched libbar/2% + unpacked libbar/2 + configured libbar/2 + %info: .+ is up to date% + updated libbar/2 + EOE + + $pkg_status libbar >'!libbar configured !2'; + $pkg_status libbaz >'libbaz configured 2'; + + # Build foo and sys:libbar/2. + # + $pkg_build foo 'sys:libbar/2' 2>>~%EOE%; + disfigured libbar/2 + disfigured libbaz/2 + purged libbaz/2 + purged libbar/2 + configured sys:libbar/2 + %.* + %.*fetched foo/2% + unpacked foo/2 + configured foo/2 + %info: .+ is up to date% + updated foo/2 + EOE + + $pkg_status foo >'!foo configured 2'; + $pkg_status libbar >'!libbar configured,system !2'; + $pkg_status libbaz >'libbaz available 2'; + + $pkg_drop foo libbar + } + + : libbar2-foo-syslibbar + : + : The overall plan is to build libbar/2, then foo and sys:libbar. + : + { + $clone_cfg; + + # Build libbar/2. + # + $pkg_build libbar/2 2>>~%EOE%; + %.* + %.*fetched libbaz/2% + unpacked libbaz/2 + configured libbaz/2 + %.* + %.*fetched libbar/2% + unpacked libbar/2 + configured libbar/2 + %info: .+ is up to date% + updated libbar/2 + EOE + + $pkg_status libbar >'!libbar configured !2'; + $pkg_status libbaz >'libbaz configured 2'; + + # Build foo and sys:libbar. + # + $pkg_build foo 'sys:libbar' 2>>~%EOE%; + disfigured libbar/2 + disfigured libbaz/2 + purged libbaz/2 + purged libbar/2 + configured sys:libbar/* + %.* + %.*fetched foo/2% + unpacked foo/2 + configured foo/2 + %info: .+ is up to date% + updated foo/2 + EOE + + $pkg_status foo >'!foo configured 2'; + $pkg_status libbar >'!libbar configured,system !* available 2 1'; + $pkg_status libbaz >'libbaz available 2'; + + $pkg_drop foo libbar + } + + : syslibbar2-foo-libbar2-syslibbar2-libbar2 + : + : The overall plan is to build sys:libbar/2, then foo and libbar/2, then + : reconfigure to sys:libbar/2 and afterwards to libbar/2. + : + { + $clone_cfg; + + # Build sys:libbar/2. + # + $pkg_build 'sys:libbar/2' 2>'configured sys:libbar/2'; + $pkg_status libbar >'!libbar configured,system !2'; + + # Build foo and libbar/2. + # + $pkg_build foo libbar/2 2>>~%EOE%; + purged libbar/2 + %.* + %.*fetched libbaz/2% + unpacked libbaz/2 + configured libbaz/2 + %.* + %.*fetched libbar/2% + unpacked libbar/2 + configured libbar/2 + %.* + %.*fetched foo/2% + unpacked foo/2 + configured foo/2 + %info: .+ is up to date%{2} + updated libbar/2 + updated foo/2 + EOE + + $pkg_status foo >'!foo configured 2'; + $pkg_status libbar >'!libbar configured !2'; + $pkg_status libbaz >'libbaz configured 2'; + + # Build sys:libbar/2. + # + $pkg_build 'sys:libbar/2' 2>>~%EOE%; + disfigured foo/2 + disfigured libbar/2 + disfigured libbaz/2 + purged libbaz/2 + purged libbar/2 + configured sys:libbar/2 + configured foo/2 + %info: .+ is up to date% + updated foo/2 + EOE + + $pkg_status foo >'!foo configured 2'; + $pkg_status libbar >'!libbar configured,system !2'; + $pkg_status libbaz >'libbaz available 2'; + + # Build libbar/2. + # + $pkg_build libbar/2 2>>~%EOE%; + disfigured foo/2 + purged libbar/2 + %.* + %.*fetched libbaz/2% + unpacked libbaz/2 + configured libbaz/2 + %.* + %.*fetched libbar/2% + unpacked libbar/2 + configured libbar/2 + configured foo/2 + %info: .+ is up to date%{2} + updated libbar/2 + updated foo/2 + EOE + + $pkg_status foo >'!foo configured 2'; + $pkg_status libbar >'!libbar configured !2'; + $pkg_status libbaz >'libbaz configured 2'; + + $pkg_drop foo libbar + } + + : syslibbar1-foo-libbar + : + : The overall plan is to configure sys:libbar/1, then fail to build foo but + : succeed to build foo libbar. + : + { + $clone_cfg; + + # Build sys:libbar/1. + # + $pkg_build 'sys:libbar/1' 2>'configured sys:libbar/1'; + $pkg_status libbar 1>'!libbar configured,system !1 available 2'; + $pkg_status libbaz 1>'libbaz available 2'; + + # Fail to build foo. + # + $pkg_build foo 2>>EOE != 0; + error: package foo dependency on (libbar >= 2) is forcing upgrade of sys:libbar/1 to libbar/2 + info: package version sys:libbar/1 is held + info: explicitly request version upgrade to continue + info: while satisfying foo/2 + EOE + + # Build foo and libbar. + # + $pkg_build foo libbar 2>>~%EOE%; + purged libbar/1 + %.* + %.*fetched libbaz/2% + unpacked libbaz/2 + configured libbaz/2 + %.* + %.*fetched libbar/2% + unpacked libbar/2 + configured libbar/2 + %.* + %.*fetched foo/2% + unpacked foo/2 + configured foo/2 + %info: .+ is up to date%{2} + updated libbar/2 + updated foo/2 + EOE + + $pkg_status foo >'!foo configured 2'; + $pkg_status libbar >'!libbar configured 2'; + $pkg_status libbaz >'libbaz configured 2'; + + $pkg_drop foo libbar + } + + : foo-syslibbar + : + : Build foo and ?sys:libbar. + : + { + $clone_cfg; + + $pkg_build foo '?sys:libbar' 2>>~%EOE%; + configured sys:libbar/* + %.* + %.*fetched foo/2% + unpacked foo/2 + configured foo/2 + %info: .+ is up to date% + updated foo/2 + EOE + + $pkg_status foo >'!foo configured 2'; + $pkg_status libbar >'libbar configured,system !* available 2 1'; + $pkg_status libbaz >'libbaz available 2'; + + $pkg_drop foo libbar + } + + : libbar1-foo-syslibbar2 + : + : The overall plan is to configure libbar/1, then fail to build foo but + : succeed to build foo ?sys:libbar/2, and then foo sys:libbar/2. + : + { + $clone_cfg; + + # Build libbar/1. + # + $pkg_build libbar/1 2>>~%EOE%; + %.* + %.*fetched libbaz/2% + unpacked libbaz/2 + configured libbaz/2 + %.* + %.*fetched libbar/1% + unpacked libbar/1 + configured libbar/1 + %info: .+ is up to date% + updated libbar/1 + EOE + + $pkg_status libbar >'!libbar configured !1 available 2'; + $pkg_status libbaz >'libbaz configured 2'; + + # Fail to build foo. + # + $pkg_build foo 2>>EOE != 0; + error: package foo dependency on (libbar >= 2) is forcing upgrade of libbar/1 to 2 + info: package version libbar/1 is held + info: explicitly request version upgrade to continue + info: while satisfying foo/2 + EOE + + # Build foo and ?sys:libbar/2. + # + $pkg_build foo '?sys:libbar/2' 2>>~%EOE%; + disfigured libbar/1 + disfigured libbaz/2 + purged libbaz/2 + purged libbar/1 + configured sys:libbar/2 + %.* + %.*fetched foo/2% + unpacked foo/2 + configured foo/2 + %info: .+ is up to date% + updated foo/2 + EOE + + $pkg_status foo >'!foo configured 2'; + $pkg_status libbar >'libbar configured,system !2'; + $pkg_status libbaz >'libbaz available 2'; + + # Build foo and sys:libbar/2. + # + $pkg_build foo 'sys:libbar/2' 2>>~%EOE%; + %info: .+ is up to date% + updated foo/2 + EOE + + $pkg_status foo >'!foo configured 2'; + $pkg_status libbar >'!libbar configured,system !2'; + $pkg_status libbaz >'libbaz available 2'; + + $pkg_drop foo libbar + } + + : upgrade-held + : + { + $clone_cfg; + + $pkg_build libbar 2>!; + + $rep_remove $rep/t1 && $rep_fetch $rep/t2; + + $pkg_build --upgrade 2>>EOE != 0; + error: libbar is not available in source + info: consider building it as sys:libbar if it is available from the system + EOE + + $pkg_build 'sys:libbar' 2>>EOE; + disfigured libbar/2 + disfigured libbaz/2 + purged libbaz/2 + purged libbar/2 + configured sys:libbar/* + EOE + + $pkg_build --upgrade 2>'info: nothing to build'; + + $pkg_drop libbar + } +} + +: t2 +: +{ + +$clone_cfg && $rep_add $rep/t2 && $rep_fetch + + : no-libbar + : + : Test that the following builds expectedly fails having no libbar available + : in source. + : + { + $clone_cfg; + + $pkg_build foo 2>>EOE != 0; + error: dependency libbar >= 2 of package foo is not available in source + info: specify ?sys:libbar if it is available from the system + info: while satisfying foo/2 + EOE + + $pkg_build foo libbar 2>>EOE != 0; + error: libbar is not available in source + info: specify sys:libbar if it is available from the system + EOE + + $pkg_status foo >'foo available 2'; + $pkg_status libbar >'libbar unknown' + } + + : foo-syslibbar + : + : Build foo configuring sys:libbar. + : + { + $clone_cfg; + + $pkg_build foo 'sys:libbar' 2>>~%EOE%; + configured sys:libbar/* + %.* + %.*fetched foo/2% + unpacked foo/2 + configured foo/2 + %info: .+ is up to date% + updated foo/2 + EOE + + $pkg_status foo >'!foo configured 2'; + $pkg_status libbar >'!libbar configured,system !*'; + + $pkg_drop foo libbar + } + + : libbar1-foo-syslibbar2 + : + : The overall plan is to configure sys:libbar/1, then fail to build foo, but + : succeed to build foo sys:libbar/2. + : + { + $clone_cfg; + + # Build sys:libbar/1. + # + $pkg_build 'sys:libbar/1' 2>'configured sys:libbar/1'; + $pkg_status libbar 1>'!libbar configured,system !1'; + + # Fail to build foo. + # + $pkg_build foo 2>>EOE != 0; + error: dependency libbar >= 2 of package foo is not available in source + info: sys:libbar/1 does not satisfy the constrains + info: while satisfying foo/2 + EOE + + # Build foo and sys:libbar/2. + # + $pkg_build foo 'sys:libbar/2' 2>>~%EOE%; + purged libbar/1 + configured sys:libbar/2 + %.* + %.*fetched foo/2% + unpacked foo/2 + configured foo/2 + %info: .+ is up to date% + updated foo/2 + EOE + + $pkg_status foo >'!foo configured 2'; + $pkg_status libbar >'!libbar configured,system !2'; + + $pkg_drop foo libbar + } + + : syslibbar2 + : + : The overall plan is to fail to build foo sys:libbar/1, then configure + : sys:libbar/2 but still fail to build foo sys:libbar/1. + : + { + $clone_cfg; + + # Fail to build foo and sys:libbar/1. + # + $pkg_build foo 'sys:libbar/1' 2>>EOE != 0; + error: dependency libbar >= 2 of package foo is not available in source + info: sys:libbar/1 does not satisfy the constrains + info: while satisfying foo/2 + EOE + + # Build sys:libbar/2. + # + $pkg_build 'sys:libbar/2' 2>'configured sys:libbar/2'; + $pkg_status libbar 1>'!libbar configured,system !2'; + + # Still fail to build foo and sys:libbar/1. + # + $pkg_build foo 'sys:libbar/1' 2>>EOE != 0; + error: unable to satisfy constraints on package libbar + info: foo depends on (libbar >= 2) + info: command line depends on (libbar == 1) + info: available sys:libbar/2 + info: available sys:libbar/1 + info: explicitly specify libbar version to manually satisfy both constraints + info: while satisfying foo/2 + EOE + + $pkg_drop libbar + } + + : syslibbar1 + : + : The overall plan is to configure sys:libbar/1, then fail to build + : sys:libbar/1.1 foo. + : + { + $clone_cfg; + + # Build sys:libbar/2. + # + $pkg_build 'sys:libbar/1' 2>'configured sys:libbar/1'; + $pkg_status libbar 1>'!libbar configured,system !1'; + + # Fail to build sys:libbar/1.1 and foo. + # + $pkg_build 'sys:libbar/1.1' foo 2>>EOE != 0; + error: dependency libbar >= 2 of package foo is not available in source + info: sys:libbar/1.1 does not satisfy the constrains + info: while satisfying foo/2 + EOE + + $pkg_drop libbar + } + + : foo-syslibbar-drop-foo + : + : The overall plan is to build foo ?sys:libbar, then drop foo and make sure + : libbar is purged as well. + : + { + $clone_cfg; + + # Build foo and ?sys:libbar. + # + $pkg_build foo '?sys:libbar' 2>>~%EOE%; + configured sys:libbar/* + %.* + %.*fetched foo/2% + unpacked foo/2 + configured foo/2 + %info: .+ is up to date% + updated foo/2 + EOE + + $pkg_status foo >'!foo configured 2'; + $pkg_status libbar >'libbar configured,system !*'; + + # Drop foo. + # + $pkg_drop foo 2>>EOE; + disfigured foo + purged libbar + purged foo + EOE + + $pkg_status foo >'foo available 2'; + $pkg_status libbar --system >'libbar available sys:?' + } + + : syslibbar1-foo-syslibbar-drop-foo + : + : The overall plan is to build sys:libbar/1, then fail to build foo but + : succeed to build foo ?sys:libbar, then drop foo and make sure libbar stays. + : + { + $clone_cfg; + + # Build sys:libbar/1. + # + $pkg_build 'sys:libbar/1' 2>'configured sys:libbar/1'; + $pkg_status libbar 1>'!libbar configured,system !1'; + + # Fail to build foo. + # + $pkg_build foo 2>>EOE != 0; + error: dependency libbar >= 2 of package foo is not available in source + info: sys:libbar/1 does not satisfy the constrains + info: while satisfying foo/2 + EOE + + # Build foo and '?sys:libbar/2'. + # + $pkg_build foo '?sys:libbar/2' 2>>~%EOE%; + purged libbar/1 + configured sys:libbar/2 + %.* + %.*fetched foo/2% + unpacked foo/2 + configured foo/2 + %info: .+ is up to date% + updated foo/2 + EOE + + $pkg_status foo >'!foo configured 2'; + $pkg_status libbar >'libbar configured,system !2'; + + # Drop foo. + # + $pkg_drop foo 2>>EOE; + disfigured foo + purged libbar + purged foo + EOE + + $pkg_status foo >'foo available 2'; + $pkg_status libbar --system >'libbar available sys:?' + } +} + +: t3 +: +{ + +$clone_cfg && $rep_add $rep/t3 && $rep_fetch + + : no-libbar + : + : Test that the following builds expectedly fails having no libbar available + : in source. + : + { + $clone_cfg; + + $pkg_build foo 2>>EOE != 0; + error: dependency libbar >= 2 of package foo is not available in source + info: specify ?sys:libbar if it is available from the system + info: while satisfying foo/2 + EOE + + $pkg_build 'sys:libbar/1' 2>>EOE != 0; + error: unknown package libbar + EOE + + $pkg_build foo 'sys:libbar/1' 2>>EOE != 0; + error: unknown package libbar + EOE + + $pkg_build foo '?sys:libbar/1' 2>>EOE != 0; + error: unable to satisfy constraints on package libbar + info: foo depends on (libbar >= 2) + info: command line depends on (libbar == 1) + info: specify libbar version to satisfy foo constraint + info: while satisfying foo/2 + EOE + + $pkg_status foo >'foo available 2'; + $pkg_status libbar >'libbar unknown' + } + + : syslibbar1-foo-syslibbar-drop-foo + : + : The overall plan is to build foo ?sys:libbar/2, fail to build sys:libbar + : and foo 'sys:libbar', but succeed to build foo ?sys:libbar/3 and foo + : ?sys:libbar. + : + { + $clone_cfg; + + # Build foo '?sys:libbar/2'. + # + $pkg_build foo '?sys:libbar/2' 2>>~%EOE%; + configured sys:libbar/2 + %.* + %.*fetched foo/2% + unpacked foo/2 + configured foo/2 + %info: .+ is up to date% + updated foo/2 + EOE + + $pkg_status foo >'!foo configured 2'; + $pkg_status libbar >'libbar configured,system !2'; + + # Fail as libbar while being selected is still unknown (not present in t3 + # repo). + # + $pkg_build 'sys:libbar' 2>'error: unknown package libbar' != 0; + $pkg_build foo 'sys:libbar' 2>'error: unknown package libbar' != 0; + $pkg_status foo 1>'!foo configured 2'; + $pkg_status libbar 1>'libbar configured,system !2'; + + # Build foo and ?sys:libbar/3. + # + $pkg_build foo '?sys:libbar/3' 2>>~%EOE%; + disfigured foo/2 + purged libbar/2 + configured sys:libbar/3 + configured foo/2 + %info: .+ is up to date% + updated foo/2 + EOE + + $pkg_status foo >'!foo configured 2'; + $pkg_status libbar >'libbar configured,system !3'; + + # Build foo and ?sys:libbar. + # + $pkg_build foo '?sys:libbar' 2>>~%EOE%; + disfigured foo/2 + purged libbar/3 + configured sys:libbar/* + configured foo/2 + %info: .+ is up to date% + updated foo/2 + EOE + + $pkg_status foo >'!foo configured 2'; + $pkg_status libbar >'libbar configured,system !*'; + + $pkg_drop foo + } +} diff --git a/tests/pkg-test.test b/tests/pkg-test.test deleted file mode 100644 index 6e36ffe..0000000 --- a/tests/pkg-test.test +++ /dev/null @@ -1,119 +0,0 @@ -# file : tests/pkg-test.test -# copyright : Copyright (c) 2014-2018 Code Synthesis Ltd -# license : MIT; see accompanying LICENSE file - -.include common.test config.test remote.test - -# Source repository: -# -# pkg-build -# | -# `-- t0a -# |-- libbar-0.0.1.tar.gz -> libbaz == 0.0.1 -# |-- libbaz-0.0.1.tar.gz -> libfox -# |-- libbaz-0.0.3.tar.gz -> libfoo -# |-- libbox-0.0.1.tar.gz -> libbaz -# |-- libfix-0.0.1.tar.gz -# |-- libfoo-0.0.1.tar.gz -> libfix -# |-- libfox-0.0.1.tar.gz -# `-- repositories.manifest - -# Prepare repositories used by tests if running in the local mode. -# -+if ($remote != true) - rep_create += 2>! - - cp -r $src/t0a $out/t0a && $rep_create $out/t0a &$out/t0a/packages.manifest -end - -cfg_create += -d cfg 2>! &cfg/*** -pkg_build += -d cfg --yes --auth all --trust-yes 2>! - -+$pkg_build "libbaz@$rep/t0a" - -test.options += --build-option -s - -: args -: -{ - : no-name - : - $* 2>>EOE != 0 - error: package name argument expected - info: run 'bpkg help pkg-test' for more information - EOE - - : all-name - : - $* --all libbaz 2>>EOE != 0 - error: both --all|-a and package argument specified - info: run 'bpkg help pkg-test' for more information - EOE - - : recursive-immediate - : - $* libbaz --recursive --immediate 2>>~%EOE% != 0 - error: both --immediate|-i and --recursive|-r specified - info: run 'bpkg help pkg-test' for more information - EOE -} - -: package -: -{ - $clone_cfg; - - $* libbaz 2>>~%EOE% - %info: .+ has nothing to test% - tested libbaz/0.0.3 - EOE -} - -: all -: -{ - : src - : - { - $clone_root_cfg; - - $* --all 2>>~%EOE% - %info: .+ has nothing to test% - tested libbaz/0.0.3 - EOE - } - - : sys - : - { - $cfg_create; - $pkg_build "sys:libbaz@$rep/t0a"; - - $* --all 2>'info: nothing to test' - } -} - -: immediate -: -{ - $clone_cfg; - - $* libbaz --immediate 2>>~%EOE% - %info: .+ has nothing to test%{2} - tested libbaz/0.0.3 - tested libfoo/0.0.1 - EOE -} - -: recursive -: -{ - $clone_cfg; - - $* libbaz --recursive 2>>~%EOE% - %info: .+ has nothing to test%{3} - tested libbaz/0.0.3 - tested libfoo/0.0.1 - tested libfix/0.0.1 - EOE -} diff --git a/tests/pkg-test.testscript b/tests/pkg-test.testscript new file mode 100644 index 0000000..17f9b25 --- /dev/null +++ b/tests/pkg-test.testscript @@ -0,0 +1,119 @@ +# file : tests/pkg-test.testscript +# copyright : Copyright (c) 2014-2018 Code Synthesis Ltd +# license : MIT; see accompanying LICENSE file + +.include common.testscript config.testscript remote.testscript + +# Source repository: +# +# pkg-build +# | +# `-- t0a +# |-- libbar-0.0.1.tar.gz -> libbaz == 0.0.1 +# |-- libbaz-0.0.1.tar.gz -> libfox +# |-- libbaz-0.0.3.tar.gz -> libfoo +# |-- libbox-0.0.1.tar.gz -> libbaz +# |-- libfix-0.0.1.tar.gz +# |-- libfoo-0.0.1.tar.gz -> libfix +# |-- libfox-0.0.1.tar.gz +# `-- repositories.manifest + +# Prepare repositories used by tests if running in the local mode. +# ++if ($remote != true) + rep_create += 2>! + + cp -r $src/t0a $out/t0a && $rep_create $out/t0a &$out/t0a/packages.manifest +end + +cfg_create += -d cfg 2>! &cfg/*** +pkg_build += -d cfg --yes --auth all --trust-yes 2>! + ++$pkg_build "libbaz@$rep/t0a" + +test.options += --build-option -s + +: args +: +{ + : no-name + : + $* 2>>EOE != 0 + error: package name argument expected + info: run 'bpkg help pkg-test' for more information + EOE + + : all-name + : + $* --all libbaz 2>>EOE != 0 + error: both --all|-a and package argument specified + info: run 'bpkg help pkg-test' for more information + EOE + + : recursive-immediate + : + $* libbaz --recursive --immediate 2>>~%EOE% != 0 + error: both --immediate|-i and --recursive|-r specified + info: run 'bpkg help pkg-test' for more information + EOE +} + +: package +: +{ + $clone_cfg; + + $* libbaz 2>>~%EOE% + %info: .+ has nothing to test% + tested libbaz/0.0.3 + EOE +} + +: all +: +{ + : src + : + { + $clone_root_cfg; + + $* --all 2>>~%EOE% + %info: .+ has nothing to test% + tested libbaz/0.0.3 + EOE + } + + : sys + : + { + $cfg_create; + $pkg_build "sys:libbaz@$rep/t0a"; + + $* --all 2>'info: nothing to test' + } +} + +: immediate +: +{ + $clone_cfg; + + $* libbaz --immediate 2>>~%EOE% + %info: .+ has nothing to test%{2} + tested libbaz/0.0.3 + tested libfoo/0.0.1 + EOE +} + +: recursive +: +{ + $clone_cfg; + + $* libbaz --recursive 2>>~%EOE% + %info: .+ has nothing to test%{3} + tested libbaz/0.0.3 + tested libfoo/0.0.1 + tested libfix/0.0.1 + EOE +} diff --git a/tests/pkg-unpack.test b/tests/pkg-unpack.test deleted file mode 100644 index 1e20b22..0000000 --- a/tests/pkg-unpack.test +++ /dev/null @@ -1,297 +0,0 @@ -# file : tests/pkg-unpack.test -# copyright : Copyright (c) 2014-2018 Code Synthesis Ltd -# license : MIT; see accompanying LICENSE file - -.include common.test auth.test config.test remote.test remote-git.test - -# Source repository: -# -# pkg-unpack -# |-- hello -# | |-- libhello-1.0.0.tar.gz -# | `-- repositories.manifest -# |-- libfoo-1.1.0 -# | |-- build -# | | `-- bootstrap.build -# | |-- buildfile -# | `-- manifest -# |-- t1 -# | |-- libfoo-1.0.0.tar.gz -# | |-- libfoo-1.1.0.tar.gz -# | `-- repositories.manifest -# | -# `-- git -# `-- style-basic.git - -# Prepare repositories used by tests if running in the local mode. -# -+if ($remote != true) - rep_create += 2>! - - # Create the signed 'hello' repository. - # - cp -r $src/hello $out/hello - cat <<<$cert_manifest >+$out/hello/repositories.manifest - - $rep_create --key $key $out/hello &$out/hello/packages.manifest \ - &$out/hello/signature.manifest - - # Create the 't1' repository. - # - cp -r $src/t1 $out/t1 && $rep_create $out/t1 &$out/t1/packages.manifest - - # Create git repositories. - # - $git_extract $src/git/style-basic.tar &$out_git/state0/*** -end - -pkg_fetch += -d cfg 2>! -pkg_purge += -d cfg -pkg_status += -d cfg -rep_add += -d cfg 2>! -rep_fetch += -d cfg --auth all 2>! -pkg_configure += -d cfg -pkg_disfigure += -d cfg - -: replace-with-existing -: -$clone_cfg; -$* foo -r 2>>EOE != 0 - error: --replace|-r can only be specified with external package - EOE - -: no-dir -: -$clone_cfg; -$* -e 2>>EOE != 0 - error: package directory argument expected - info: run 'bpkg help pkg-unpack' for more information - EOE - -: not-package-dir -: -$clone_cfg; -$* -e ./ 2>>/EOE != 0 - error: no manifest file in package directory ./ - EOE - -: dir-not-exist -: -$clone_cfg; -$* -e ./no-such-dir 2>>/EOE != 0 - error: package directory ./no-such-dir/ does not exist - EOE - -: no-name -: -$clone_cfg; -$* 2>>EOE != 0 - error: package name argument expected - info: run 'bpkg help pkg-unpack' for more information - EOE - -: fetched-rep -: -{ - +$clone_cfg && $rep_add $rep/t1 && $rep_fetch --trust-yes - - : package-exists - : - { - $clone_cfg && $pkg_fetch libfoo/1.0.0; - - $* -e $src/libfoo-1.1.0 2>>/EOE != 0; - error: package libfoo already exists in configuration cfg/ - info: version: 1.0.0, state: fetched, substate: none - info: use 'pkg-unpack --replace|-r' to replace - EOE - - $pkg_purge libfoo 2>'purged libfoo/1.0.0'; - $* -e $src/libfoo-1.1.0 2>'using libfoo/1.1.0 (external)'; - $pkg_status libfoo/1.1.0 1>'libfoo unpacked 1.1.0'; - - $pkg_configure libfoo 2>'configured libfoo/1.1.0'; - test -d cfg/libfoo; - $pkg_disfigure libfoo 2>'disfigured libfoo/1.1.0'; - - $pkg_purge libfoo 2>'purged libfoo/1.1.0' - } - - : replace-fetched - : - { - $clone_cfg && $pkg_fetch libfoo/1.0.0; - - $* -e $src/libfoo-1.1.0 2>>/EOE != 0; - error: package libfoo already exists in configuration cfg/ - info: version: 1.0.0, state: fetched, substate: none - info: use 'pkg-unpack --replace|-r' to replace - EOE - - $* -r -e $src/libfoo-1.1.0 2>'using libfoo/1.1.0 (external)'; - $pkg_status libfoo/1.1.0 1>'libfoo unpacked 1.1.0'; - - $pkg_purge libfoo 2>'purged libfoo/1.1.0' - } - - : replace-unpacked - : - { - $clone_cfg && $pkg_fetch libfoo/1.0.0; - - $* libfoo 2>'unpacked libfoo/1.0.0'; - - $* -e $src/libfoo-1.1.0 2>>/EOE != 0; - error: package libfoo already exists in configuration cfg/ - info: version: 1.0.0, state: unpacked, substate: none - info: use 'pkg-unpack --replace|-r' to replace - EOE - - $* -r -e $src/libfoo-1.1.0 2>'using libfoo/1.1.0 (external)'; - $pkg_status libfoo/1.1.0 1>'libfoo unpacked 1.1.0'; - - $pkg_purge libfoo 2>'purged libfoo/1.1.0' - } - - : wrong-state - : - { - $clone_cfg; - - $* libfoo 2>>/EOE != 0; - error: package libfoo does not exist in configuration cfg/ - EOE - - $* -e $src/libfoo-1.1.0 2>'using libfoo/1.1.0 (external)'; - - $* libfoo 2>>EOE != 0; - error: package libfoo is unpacked - info: expected it to be fetched - EOE - - $pkg_purge libfoo 2>'purged libfoo/1.1.0' - } - - : right-state - : - { - $clone_cfg && $pkg_fetch libfoo/1.0.0; - - $pkg_status libfoo/1.0.0 1>'libfoo fetched 1.0.0'; - $* libfoo 2>'unpacked libfoo/1.0.0'; - $pkg_status libfoo/1.0.0 1>'libfoo unpacked 1.0.0'; - - $pkg_configure libfoo 2>'configured libfoo/1.0.0'; - test -d cfg/libfoo-1.0.0; - $pkg_disfigure libfoo 2>'disfigured libfoo/1.0.0'; - - $pkg_purge libfoo 2>'purged libfoo/1.0.0' - } - - : purge-existing - : - { - $clone_cfg; - cp --no-cleanup -r $src/libfoo-1.1.0 ./; - - $* -p -e libfoo-1.1.0 2>'using libfoo/1.1.0 (external)'; - - $pkg_purge libfoo 2>'purged libfoo/1.1.0' - } -} - -: dir-rep -: -{ - rep_add += --type dir - - : no-repos - : - { - $clone_root_cfg; - - $* libfoo/1.1.0 2>>/EOE != 0 - error: configuration cfg/ has no repositories - info: use 'bpkg rep-add' to add a repository - EOE - } - - : unfetched - : - { - $clone_root_cfg && $rep_add $src/libfoo-1.1.0; - - $* libfoo/1.1.0 2>>/EOE != 0 - error: configuration cfg/ has no available packages - info: use 'bpkg rep-fetch' to fetch available packages list - EOE - } - - : unavailable - : - { - $clone_root_cfg && $rep_add $src/libfoo-1.1.0 && $rep_fetch; - - $* libfoo/1.0.0 2>>EOE != 0 - error: package libfoo 1.0.0 is not available - EOE - } - - : unavailable-dir-based - : - { - $clone_root_cfg && $rep_add $rep/t1 --type pkg && $rep_fetch --trust-yes; - - $* libfoo/1.0.0 2>>EOE != 0 - error: package libfoo 1.0.0 is not available from a directory-based repository - EOE - } - - : available - : - { - $clone_root_cfg && $rep_add $src/libfoo-1.1.0 && $rep_fetch; - - $* libfoo/1.1.0 2>>EOE; - using libfoo/1.1.0 (external) - EOE - - $pkg_status libfoo 1>'libfoo unpacked 1.1.0'; - - $pkg_configure libfoo 2>'configured libfoo/1.1.0'; - test -d cfg/libfoo; - $pkg_disfigure libfoo 2>'disfigured libfoo/1.1.0' - } -} - -: existing -: -{ - : version-fixup - : - : Test that the version is populated with the snapshot information for the - : package directory that is under the version control. - : - if ($remote != true) - { - $clone_root_cfg; - - rep = $canonicalize([dir_path] $out_git/state0); - - $* -e $rep/style-basic.git 2>>~%EOE% - %using style-basic/1\.1\.0-a\.0\.\d+\..+ \(external\)% - EOE - } -} - -: hello -: -{ - $clone_cfg; - $rep_add $rep/hello && $rep_fetch --trust $cert_fp &cfg/.bpkg/certs/**; - $pkg_fetch libhello/1.0.0; - - $* libhello 2>'unpacked libhello/1.0.0'; - - $pkg_purge libhello 2>'purged libhello/1.0.0' -} diff --git a/tests/pkg-unpack.testscript b/tests/pkg-unpack.testscript new file mode 100644 index 0000000..f866fd2 --- /dev/null +++ b/tests/pkg-unpack.testscript @@ -0,0 +1,301 @@ +# file : tests/pkg-unpack.testscript +# copyright : Copyright (c) 2014-2018 Code Synthesis Ltd +# license : MIT; see accompanying LICENSE file + +.include common.testscript \ + auth.testscript \ + config.testscript \ + remote.testscript \ + remote-git.testscript + +# Source repository: +# +# pkg-unpack +# |-- hello +# | |-- libhello-1.0.0.tar.gz +# | `-- repositories.manifest +# |-- libfoo-1.1.0 +# | |-- build +# | | `-- bootstrap.build +# | |-- buildfile +# | `-- manifest +# |-- t1 +# | |-- libfoo-1.0.0.tar.gz +# | |-- libfoo-1.1.0.tar.gz +# | `-- repositories.manifest +# | +# `-- git +# `-- style-basic.git + +# Prepare repositories used by tests if running in the local mode. +# ++if ($remote != true) + rep_create += 2>! + + # Create the signed 'hello' repository. + # + cp -r $src/hello $out/hello + cat <<<$cert_manifest >+$out/hello/repositories.manifest + + $rep_create --key $key $out/hello &$out/hello/packages.manifest \ + &$out/hello/signature.manifest + + # Create the 't1' repository. + # + cp -r $src/t1 $out/t1 && $rep_create $out/t1 &$out/t1/packages.manifest + + # Create git repositories. + # + $git_extract $src/git/style-basic.tar &$out_git/state0/*** +end + +pkg_fetch += -d cfg 2>! +pkg_purge += -d cfg +pkg_status += -d cfg +rep_add += -d cfg 2>! +rep_fetch += -d cfg --auth all 2>! +pkg_configure += -d cfg +pkg_disfigure += -d cfg + +: replace-with-existing +: +$clone_cfg; +$* foo -r 2>>EOE != 0 + error: --replace|-r can only be specified with external package + EOE + +: no-dir +: +$clone_cfg; +$* -e 2>>EOE != 0 + error: package directory argument expected + info: run 'bpkg help pkg-unpack' for more information + EOE + +: not-package-dir +: +$clone_cfg; +$* -e ./ 2>>/EOE != 0 + error: no manifest file in package directory ./ + EOE + +: dir-not-exist +: +$clone_cfg; +$* -e ./no-such-dir 2>>/EOE != 0 + error: package directory ./no-such-dir/ does not exist + EOE + +: no-name +: +$clone_cfg; +$* 2>>EOE != 0 + error: package name argument expected + info: run 'bpkg help pkg-unpack' for more information + EOE + +: fetched-rep +: +{ + +$clone_cfg && $rep_add $rep/t1 && $rep_fetch --trust-yes + + : package-exists + : + { + $clone_cfg && $pkg_fetch libfoo/1.0.0; + + $* -e $src/libfoo-1.1.0 2>>/EOE != 0; + error: package libfoo already exists in configuration cfg/ + info: version: 1.0.0, state: fetched, substate: none + info: use 'pkg-unpack --replace|-r' to replace + EOE + + $pkg_purge libfoo 2>'purged libfoo/1.0.0'; + $* -e $src/libfoo-1.1.0 2>'using libfoo/1.1.0 (external)'; + $pkg_status libfoo/1.1.0 1>'libfoo unpacked 1.1.0'; + + $pkg_configure libfoo 2>'configured libfoo/1.1.0'; + test -d cfg/libfoo; + $pkg_disfigure libfoo 2>'disfigured libfoo/1.1.0'; + + $pkg_purge libfoo 2>'purged libfoo/1.1.0' + } + + : replace-fetched + : + { + $clone_cfg && $pkg_fetch libfoo/1.0.0; + + $* -e $src/libfoo-1.1.0 2>>/EOE != 0; + error: package libfoo already exists in configuration cfg/ + info: version: 1.0.0, state: fetched, substate: none + info: use 'pkg-unpack --replace|-r' to replace + EOE + + $* -r -e $src/libfoo-1.1.0 2>'using libfoo/1.1.0 (external)'; + $pkg_status libfoo/1.1.0 1>'libfoo unpacked 1.1.0'; + + $pkg_purge libfoo 2>'purged libfoo/1.1.0' + } + + : replace-unpacked + : + { + $clone_cfg && $pkg_fetch libfoo/1.0.0; + + $* libfoo 2>'unpacked libfoo/1.0.0'; + + $* -e $src/libfoo-1.1.0 2>>/EOE != 0; + error: package libfoo already exists in configuration cfg/ + info: version: 1.0.0, state: unpacked, substate: none + info: use 'pkg-unpack --replace|-r' to replace + EOE + + $* -r -e $src/libfoo-1.1.0 2>'using libfoo/1.1.0 (external)'; + $pkg_status libfoo/1.1.0 1>'libfoo unpacked 1.1.0'; + + $pkg_purge libfoo 2>'purged libfoo/1.1.0' + } + + : wrong-state + : + { + $clone_cfg; + + $* libfoo 2>>/EOE != 0; + error: package libfoo does not exist in configuration cfg/ + EOE + + $* -e $src/libfoo-1.1.0 2>'using libfoo/1.1.0 (external)'; + + $* libfoo 2>>EOE != 0; + error: package libfoo is unpacked + info: expected it to be fetched + EOE + + $pkg_purge libfoo 2>'purged libfoo/1.1.0' + } + + : right-state + : + { + $clone_cfg && $pkg_fetch libfoo/1.0.0; + + $pkg_status libfoo/1.0.0 1>'libfoo fetched 1.0.0'; + $* libfoo 2>'unpacked libfoo/1.0.0'; + $pkg_status libfoo/1.0.0 1>'libfoo unpacked 1.0.0'; + + $pkg_configure libfoo 2>'configured libfoo/1.0.0'; + test -d cfg/libfoo-1.0.0; + $pkg_disfigure libfoo 2>'disfigured libfoo/1.0.0'; + + $pkg_purge libfoo 2>'purged libfoo/1.0.0' + } + + : purge-existing + : + { + $clone_cfg; + cp --no-cleanup -r $src/libfoo-1.1.0 ./; + + $* -p -e libfoo-1.1.0 2>'using libfoo/1.1.0 (external)'; + + $pkg_purge libfoo 2>'purged libfoo/1.1.0' + } +} + +: dir-rep +: +{ + rep_add += --type dir + + : no-repos + : + { + $clone_root_cfg; + + $* libfoo/1.1.0 2>>/EOE != 0 + error: configuration cfg/ has no repositories + info: use 'bpkg rep-add' to add a repository + EOE + } + + : unfetched + : + { + $clone_root_cfg && $rep_add $src/libfoo-1.1.0; + + $* libfoo/1.1.0 2>>/EOE != 0 + error: configuration cfg/ has no available packages + info: use 'bpkg rep-fetch' to fetch available packages list + EOE + } + + : unavailable + : + { + $clone_root_cfg && $rep_add $src/libfoo-1.1.0 && $rep_fetch; + + $* libfoo/1.0.0 2>>EOE != 0 + error: package libfoo 1.0.0 is not available + EOE + } + + : unavailable-dir-based + : + { + $clone_root_cfg && $rep_add $rep/t1 --type pkg && $rep_fetch --trust-yes; + + $* libfoo/1.0.0 2>>EOE != 0 + error: package libfoo 1.0.0 is not available from a directory-based repository + EOE + } + + : available + : + { + $clone_root_cfg && $rep_add $src/libfoo-1.1.0 && $rep_fetch; + + $* libfoo/1.1.0 2>>EOE; + using libfoo/1.1.0 (external) + EOE + + $pkg_status libfoo 1>'libfoo unpacked 1.1.0'; + + $pkg_configure libfoo 2>'configured libfoo/1.1.0'; + test -d cfg/libfoo; + $pkg_disfigure libfoo 2>'disfigured libfoo/1.1.0' + } +} + +: existing +: +{ + : version-fixup + : + : Test that the version is populated with the snapshot information for the + : package directory that is under the version control. + : + if ($remote != true) + { + $clone_root_cfg; + + rep = $canonicalize([dir_path] $out_git/state0); + + $* -e $rep/style-basic.git 2>>~%EOE% + %using style-basic/1\.1\.0-a\.0\.\d+\..+ \(external\)% + EOE + } +} + +: hello +: +{ + $clone_cfg; + $rep_add $rep/hello && $rep_fetch --trust $cert_fp &cfg/.bpkg/certs/**; + $pkg_fetch libhello/1.0.0; + + $* libhello 2>'unpacked libhello/1.0.0'; + + $pkg_purge libhello 2>'purged libhello/1.0.0' +} diff --git a/tests/pkg-update.test b/tests/pkg-update.test deleted file mode 100644 index 73e1221..0000000 --- a/tests/pkg-update.test +++ /dev/null @@ -1,139 +0,0 @@ -# file : tests/pkg-update.test -# copyright : Copyright (c) 2014-2018 Code Synthesis Ltd -# license : MIT; see accompanying LICENSE file - -.include common.test auth.test config.test remote.test - -# Source repository: -# -# pkg-update -# |-- hello -# | |-- libhello-1.0.0.tar.gz -# | `-- repositories.manifest -# `-- libhello-1.0.0 -# |-- build -# | |-- bootstrap.build -# | |-- export.build -# | `-- root.build -# |-- buildfile -# |-- hello -# | |-- buildfile -# | |-- export -# | |-- hello -# | `-- hello.cxx -# |-- INSTALL -# |-- manifest -# |-- tests -# | |-- build -# | | |-- bootstrap.build -# | | `-- root.build -# | |-- buildfile -# | `-- test -# | |-- buildfile -# | |-- driver.cxx -# | `-- test.out -# `-- version - -# Prepare repositories used by tests if running in the local mode. -# -+if ($remote != true) - rep_create += 2>! - - # Create the signed 'hello' repository. - # - cp -r $src/hello $out/hello - cat <<<$cert_manifest >+$out/hello/repositories.manifest - - $rep_create --key $key $out/hello &$out/hello/packages.manifest \ - &$out/hello/signature.manifest -end - -pkg_configure += -d cfg "config.cxx=$config.cxx" 2>! -pkg_disfigure += -d cfg -pkg_fetch += -d cfg 2>! -pkg_purge += -d cfg -pkg_unpack += -d cfg 2>! -rep_add += -d cfg 2>! -rep_fetch += -d cfg --auth all 2>! - -# Sometimes we need to run underlying build update operation with -j 1 options -# to have an output that we can match reliably. -# -j1 = --build-option -j --build-option 1 - -: no-name -: -$clone_cfg; -$* 2>>EOE != 0 - error: package name argument expected - info: run 'bpkg help pkg-update' for more information - EOE - -: fetched -: -{ - +$clone_cfg - +$rep_add $rep/hello - +$rep_fetch --trust $cert_fp &cfg/.bpkg/certs/** - - : no-such-package - : - $clone_cfg; - $* libhello 2>>/EOE != 0 - error: package libhello does not exist in configuration cfg/ - EOE - - : wrong-state - : - { - $clone_cfg && $pkg_fetch libhello/1.0.0; - - $* libhello 2>>EOE != 0; - error: package libhello is fetched - info: expected it to be configured - EOE - - $pkg_purge libhello 2>'purged libhello/1.0.0' - } - - : src-eq-out - : - { - $clone_cfg; - $pkg_fetch libhello/1.0.0 && $pkg_unpack libhello; - $pkg_configure libhello; - - $* $j1 libhello 2>>~%EOE%; - %(c\+\+|ar|ld) .+%{6} - updated libhello/1.0.0 - EOE - - $* libhello 2>>~%EOE%; - %info: .+ is up to date% - updated libhello/1.0.0 - EOE - - $pkg_disfigure libhello 2>'disfigured libhello/1.0.0'; - $pkg_purge libhello 2>'purged libhello/1.0.0' - } -} - -: src-ne-out -: -{ - $clone_cfg; - $pkg_unpack -e $src/libhello-1.0.0 && $pkg_configure libhello; - - $* $j1 libhello 2>>~%EOE%; - %(mkdir|c\+\+|ar|ld) .+%{8} - updated libhello/1.0.0 - EOE - - $* libhello 2>>~%EOE%; - %info: .+ is up to date% - updated libhello/1.0.0 - EOE - - $pkg_disfigure libhello 2>'disfigured libhello/1.0.0'; - $pkg_purge libhello 2>'purged libhello/1.0.0' -} diff --git a/tests/pkg-update.testscript b/tests/pkg-update.testscript new file mode 100644 index 0000000..02a1a3d --- /dev/null +++ b/tests/pkg-update.testscript @@ -0,0 +1,139 @@ +# file : tests/pkg-update.testscript +# copyright : Copyright (c) 2014-2018 Code Synthesis Ltd +# license : MIT; see accompanying LICENSE file + +.include common.testscript auth.testscript config.testscript remote.testscript + +# Source repository: +# +# pkg-update +# |-- hello +# | |-- libhello-1.0.0.tar.gz +# | `-- repositories.manifest +# `-- libhello-1.0.0 +# |-- build +# | |-- bootstrap.build +# | |-- export.build +# | `-- root.build +# |-- buildfile +# |-- hello +# | |-- buildfile +# | |-- export +# | |-- hello +# | `-- hello.cxx +# |-- INSTALL +# |-- manifest +# |-- tests +# | |-- build +# | | |-- bootstrap.build +# | | `-- root.build +# | |-- buildfile +# | `-- test +# | |-- buildfile +# | |-- driver.cxx +# | `-- test.out +# `-- version + +# Prepare repositories used by tests if running in the local mode. +# ++if ($remote != true) + rep_create += 2>! + + # Create the signed 'hello' repository. + # + cp -r $src/hello $out/hello + cat <<<$cert_manifest >+$out/hello/repositories.manifest + + $rep_create --key $key $out/hello &$out/hello/packages.manifest \ + &$out/hello/signature.manifest +end + +pkg_configure += -d cfg "config.cxx=$config.cxx" 2>! +pkg_disfigure += -d cfg +pkg_fetch += -d cfg 2>! +pkg_purge += -d cfg +pkg_unpack += -d cfg 2>! +rep_add += -d cfg 2>! +rep_fetch += -d cfg --auth all 2>! + +# Sometimes we need to run underlying build update operation with -j 1 options +# to have an output that we can match reliably. +# +j1 = --build-option -j --build-option 1 + +: no-name +: +$clone_cfg; +$* 2>>EOE != 0 + error: package name argument expected + info: run 'bpkg help pkg-update' for more information + EOE + +: fetched +: +{ + +$clone_cfg + +$rep_add $rep/hello + +$rep_fetch --trust $cert_fp &cfg/.bpkg/certs/** + + : no-such-package + : + $clone_cfg; + $* libhello 2>>/EOE != 0 + error: package libhello does not exist in configuration cfg/ + EOE + + : wrong-state + : + { + $clone_cfg && $pkg_fetch libhello/1.0.0; + + $* libhello 2>>EOE != 0; + error: package libhello is fetched + info: expected it to be configured + EOE + + $pkg_purge libhello 2>'purged libhello/1.0.0' + } + + : src-eq-out + : + { + $clone_cfg; + $pkg_fetch libhello/1.0.0 && $pkg_unpack libhello; + $pkg_configure libhello; + + $* $j1 libhello 2>>~%EOE%; + %(c\+\+|ar|ld) .+%{6} + updated libhello/1.0.0 + EOE + + $* libhello 2>>~%EOE%; + %info: .+ is up to date% + updated libhello/1.0.0 + EOE + + $pkg_disfigure libhello 2>'disfigured libhello/1.0.0'; + $pkg_purge libhello 2>'purged libhello/1.0.0' + } +} + +: src-ne-out +: +{ + $clone_cfg; + $pkg_unpack -e $src/libhello-1.0.0 && $pkg_configure libhello; + + $* $j1 libhello 2>>~%EOE%; + %(mkdir|c\+\+|ar|ld) .+%{8} + updated libhello/1.0.0 + EOE + + $* libhello 2>>~%EOE%; + %info: .+ is up to date% + updated libhello/1.0.0 + EOE + + $pkg_disfigure libhello 2>'disfigured libhello/1.0.0'; + $pkg_purge libhello 2>'purged libhello/1.0.0' +} diff --git a/tests/pkg-verify.test b/tests/pkg-verify.test deleted file mode 100644 index d438524..0000000 --- a/tests/pkg-verify.test +++ /dev/null @@ -1,71 +0,0 @@ -# file : tests/pkg-verify.test -# copyright : Copyright (c) 2014-2018 Code Synthesis Ltd -# license : MIT; see accompanying LICENSE file - -.include common.test - -# Source repository: -# -# pkg-verify -# |-- foo-1.tar.gz -# |-- foo-2.tar.gz (manifest with unknown name) -# `-- not-a-package.tar.gz - -: valid-package -: -$* $src/foo-1.tar.gz 2>'valid package foo 1' - -: manifest -: -$* --manifest $src/foo-1.tar.gz >>EOO - : 1 - name: foo - version: 1 - summary: The "Foo" utility - license: MIT - url: http://www.example.org/foo - email: foo-users@example.org - EOO - -: no-package -: -$* 2>>EOE != 0 -error: archive path argument expected - info: run 'bpkg help pkg-verify' for more information -EOE - -: not-a-package -: -{ - : verbose - : - $* $src/not-a-package.tar.gz 2>>/~%EOE% != 0 - %.+ - %error: .+/not-a-package.tar.gz does not appear to be a bpkg package% - EOE - - : silent - : - $* --silent $src/not-a-package.tar.gz != 0 -} - -: unknown-name -: -: Test that package manifest that contains an unknown name is properly handled. -: -{ - : verbose - : - $* $src/foo-2.tar.gz 2>>/~%EOE% != 0 - foo-2/manifest:8:1: error: unknown name 'color' in package manifest - % info: package archive .+/foo-2.tar.gz% - EOE - - : silent - : - $* --silent $src/foo-2.tar.gz != 0 - - : ignore - : - $* --ignore-unknown $src/foo-2.tar.gz 2>'valid package foo 2' -} diff --git a/tests/pkg-verify.testscript b/tests/pkg-verify.testscript new file mode 100644 index 0000000..559b612 --- /dev/null +++ b/tests/pkg-verify.testscript @@ -0,0 +1,71 @@ +# file : tests/pkg-verify.testscript +# copyright : Copyright (c) 2014-2018 Code Synthesis Ltd +# license : MIT; see accompanying LICENSE file + +.include common.testscript + +# Source repository: +# +# pkg-verify +# |-- foo-1.tar.gz +# |-- foo-2.tar.gz (manifest with unknown name) +# `-- not-a-package.tar.gz + +: valid-package +: +$* $src/foo-1.tar.gz 2>'valid package foo 1' + +: manifest +: +$* --manifest $src/foo-1.tar.gz >>EOO + : 1 + name: foo + version: 1 + summary: The "Foo" utility + license: MIT + url: http://www.example.org/foo + email: foo-users@example.org + EOO + +: no-package +: +$* 2>>EOE != 0 +error: archive path argument expected + info: run 'bpkg help pkg-verify' for more information +EOE + +: not-a-package +: +{ + : verbose + : + $* $src/not-a-package.tar.gz 2>>/~%EOE% != 0 + %.+ + %error: .+/not-a-package.tar.gz does not appear to be a bpkg package% + EOE + + : silent + : + $* --silent $src/not-a-package.tar.gz != 0 +} + +: unknown-name +: +: Test that package manifest that contains an unknown name is properly handled. +: +{ + : verbose + : + $* $src/foo-2.tar.gz 2>>/~%EOE% != 0 + foo-2/manifest:8:1: error: unknown name 'color' in package manifest + % info: package archive .+/foo-2.tar.gz% + EOE + + : silent + : + $* --silent $src/foo-2.tar.gz != 0 + + : ignore + : + $* --ignore-unknown $src/foo-2.tar.gz 2>'valid package foo 2' +} diff --git a/tests/remote-git.test b/tests/remote-git.test deleted file mode 100644 index 878f297..0000000 --- a/tests/remote-git.test +++ /dev/null @@ -1,69 +0,0 @@ -# file : tests/remote-git.test -# copyright : Copyright (c) 2014-2018 Code Synthesis Ltd -# license : MIT; see accompanying LICENSE file - -# Tests for commands that accept git repository location must be able to run -# regardless whether the repository is local or remote. They also must be able -# to create the repository used for testing at the specified path, so being -# published to build2.org it can be used for the remote testing. Note that -# prior to publishing repositories tests must be performed with the -# config.test.output=keep variable override, so their working directories (that -# contain repositories produced) are not cleaned up. -# - -# Check that git version is the minimum supported one (2.12.0) or above. -# -+git --version | set git_version_out - -+echo "$git_version_out" | sed -n -e 's/git version (\d+\.\d+\.\d+).*/\1/p' | \ - set git_version - -+if ("$git_version" == "") - exit "unable to obtain git version from '$git_version_out'" -end - -+echo "$git_version" | sed -e 's/(\d+).*/\1/' | set git_version_major -+echo "$git_version" | sed -e 's/\d+\.(\d+).*/\1/' | set git_version_minor - -# This flag must be used by testscripts to decide if they should skip git -# repository-related tests. -# -git_supported = ($git_version_major > 2 || \ - $git_version_major == 2 && $git_version_minor >= 12) - -# Output directory path that testscripts must use to prepare repositories -# required by tests they contain. -# -out_git = $canonicalize([dir_path] $~/git/$cmd) - -# If $remote is true then remote repository locations must be used for tests. -# -remote = $config.bpkg.test.remote - -+if ($remote != true) - rep_git_local = ($cxx.target.class != 'windows' \ - ? "file://$out_git" \ - : "file:/$regex.replace($out_git, '\\', '/')") - - rep_git = $rep_git_local # Default local repository URL. - - mkdir -p $out_git -else - rep_git_https_dumb = "https://build2.org/bpkg/git/$cmd" - rep_git_https_smart = "https://git.build2.org/testing/bpkg/advonly/$cmd" - rep_git_https_smart_unadv = "https://git.build2.org/testing/bpkg/unadv/$cmd" - rep_git_git = "git://git.build2.org/testing/bpkg/unadv/$cmd" - - rep_git = $rep_git_https_dumb # Default remote repository URL. -end - -# Command for extracting the git repository from a tarball into the output -# directory (see above). -# -# Note that we can expect that the tar program is present on the platform. We -# will use the same options as we do for unpacking of package archives (see -# pkg-unpack.cxx). -# -git_extract = ($cxx.target.class != 'windows' \ - ? tar -C $out_git -xf \ - : tar -C $regex.replace($out_git, '\\', '/') --force-local -xf) diff --git a/tests/remote-git.testscript b/tests/remote-git.testscript new file mode 100644 index 0000000..6724473 --- /dev/null +++ b/tests/remote-git.testscript @@ -0,0 +1,69 @@ +# file : tests/remote-git.testscript +# copyright : Copyright (c) 2014-2018 Code Synthesis Ltd +# license : MIT; see accompanying LICENSE file + +# Tests for commands that accept git repository location must be able to run +# regardless whether the repository is local or remote. They also must be able +# to create the repository used for testing at the specified path, so being +# published to build2.org it can be used for the remote testing. Note that +# prior to publishing repositories tests must be performed with the +# config.test.output=keep variable override, so their working directories (that +# contain repositories produced) are not cleaned up. +# + +# Check that git version is the minimum supported one (2.12.0) or above. +# ++git --version | set git_version_out + ++echo "$git_version_out" | sed -n -e 's/git version (\d+\.\d+\.\d+).*/\1/p' | \ + set git_version + ++if ("$git_version" == "") + exit "unable to obtain git version from '$git_version_out'" +end + ++echo "$git_version" | sed -e 's/(\d+).*/\1/' | set git_version_major ++echo "$git_version" | sed -e 's/\d+\.(\d+).*/\1/' | set git_version_minor + +# This flag must be used by testscripts to decide if they should skip git +# repository-related tests. +# +git_supported = ($git_version_major > 2 || \ + $git_version_major == 2 && $git_version_minor >= 12) + +# Output directory path that testscripts must use to prepare repositories +# required by tests they contain. +# +out_git = $canonicalize([dir_path] $~/git/$cmd) + +# If $remote is true then remote repository locations must be used for tests. +# +remote = $config.bpkg.test.remote + ++if ($remote != true) + rep_git_local = ($cxx.target.class != 'windows' \ + ? "file://$out_git" \ + : "file:/$regex.replace($out_git, '\\', '/')") + + rep_git = $rep_git_local # Default local repository URL. + + mkdir -p $out_git +else + rep_git_https_dumb = "https://build2.org/bpkg/git/$cmd" + rep_git_https_smart = "https://git.build2.org/testing/bpkg/advonly/$cmd" + rep_git_https_smart_unadv = "https://git.build2.org/testing/bpkg/unadv/$cmd" + rep_git_git = "git://git.build2.org/testing/bpkg/unadv/$cmd" + + rep_git = $rep_git_https_dumb # Default remote repository URL. +end + +# Command for extracting the git repository from a tarball into the output +# directory (see above). +# +# Note that we can expect that the tar program is present on the platform. We +# will use the same options as we do for unpacking of package archives (see +# pkg-unpack.cxx). +# +git_extract = ($cxx.target.class != 'windows' \ + ? tar -C $out_git -xf \ + : tar -C $regex.replace($out_git, '\\', '/') --force-local -xf) diff --git a/tests/remote.test b/tests/remote.test deleted file mode 100644 index 51a52bc..0000000 --- a/tests/remote.test +++ /dev/null @@ -1,37 +0,0 @@ -# file : tests/remote.test -# copyright : Copyright (c) 2014-2018 Code Synthesis Ltd -# license : MIT; see accompanying LICENSE file - -# Tests for commands that accept pkg repository location must be able to run -# regardless whether the repository is local or remote. They also must be able -# to create the repository used for testing at the specified path, so being -# published to build2.org it can be used for the remote testing. Note that -# prior to publishing repositories tests must be performed with the -# config.test.output=keep variable override, so their working directories (that -# contain repositories produced) are not cleaned up. -# - -# Output directory path that testscripts must use to prepare repositories -# required by tests they contain. -# -# Note that the local path is carefully crafted so that we end up with the -# same repository names in both (local and remote) cases. This is necessary -# for the authentication to work properly in both cases. -# -out = $canonicalize([dir_path] $~/pkg/1/build2.org/) - -# If $remote is true then remote repositories locations must be used for -# tests. Variables rep_root and rep refer to the root and the command- -# specific repositories respectively. Note that the variables type is dir_path -# for local repositories (rather than string for the remote ones), that allows -# to portably obtain sub-repositories locations representations. -# -remote = $config.bpkg.test.remote -rep_root = ($remote == true ? [string] "https://build2.org/bpkg/1" : $out) - -out += [dir_path] $cmd -rep = ($remote == true ? [string] "$rep_root/$cmd" : $out) - -+if ($remote != true) - mkdir -p $out -end diff --git a/tests/remote.testscript b/tests/remote.testscript new file mode 100644 index 0000000..aa0ffbf --- /dev/null +++ b/tests/remote.testscript @@ -0,0 +1,37 @@ +# file : tests/remote.testscript +# copyright : Copyright (c) 2014-2018 Code Synthesis Ltd +# license : MIT; see accompanying LICENSE file + +# Tests for commands that accept pkg repository location must be able to run +# regardless whether the repository is local or remote. They also must be able +# to create the repository used for testing at the specified path, so being +# published to build2.org it can be used for the remote testing. Note that +# prior to publishing repositories tests must be performed with the +# config.test.output=keep variable override, so their working directories (that +# contain repositories produced) are not cleaned up. +# + +# Output directory path that testscripts must use to prepare repositories +# required by tests they contain. +# +# Note that the local path is carefully crafted so that we end up with the +# same repository names in both (local and remote) cases. This is necessary +# for the authentication to work properly in both cases. +# +out = $canonicalize([dir_path] $~/pkg/1/build2.org/) + +# If $remote is true then remote repositories locations must be used for +# tests. Variables rep_root and rep refer to the root and the command- +# specific repositories respectively. Note that the variables type is dir_path +# for local repositories (rather than string for the remote ones), that allows +# to portably obtain sub-repositories locations representations. +# +remote = $config.bpkg.test.remote +rep_root = ($remote == true ? [string] "https://build2.org/bpkg/1" : $out) + +out += [dir_path] $cmd +rep = ($remote == true ? [string] "$rep_root/$cmd" : $out) + ++if ($remote != true) + mkdir -p $out +end diff --git a/tests/rep-add.test b/tests/rep-add.test deleted file mode 100644 index 8c4b9f9..0000000 --- a/tests/rep-add.test +++ /dev/null @@ -1,205 +0,0 @@ -# file : tests/rep-add.test -# copyright : Copyright (c) 2014-2018 Code Synthesis Ltd -# license : MIT; see accompanying LICENSE file - -.include common.test config.test - -rep_list += -d cfg - -: location -: -{ - +$clone_cfg - - : none - : - $* 2>>EOE != 0 - error: repository location argument expected - info: run 'bpkg help rep-add' for more information - EOE - - : empty - : - { - $clone_cfg; - - $* '' 2>>EOE != 0 - error: invalid repository location '': empty URL - EOE - } - - : unknown-type - : - $* 'repo' --type unknown 2>>EOE != 0 - error: invalid value 'unknown' for option '--type' - EOE - - : no-version - : - { - $clone_cfg; - - $* 'stable' 2>>/~%EOE% != 0 - %error: invalid pkg repository location '.+/no-version/stable': missing repository version% - info: consider using --type to specify repository type - EOE - } - - : git-invalid-fragment - : - { - $clone_cfg; - - $* 'git://example.org/repo#' 2>>EOE != 0 - error: invalid git repository location 'git://example.org/repo#': missing refname or commit id for git repository - EOE - } - - : pkg-git-scheme - : - { - $clone_cfg; - - $* 'git://example.org/repo' --type pkg 2>>EOE != 0 - error: invalid pkg repository location 'git://example.org/repo': unsupported scheme for pkg repository - EOE - } - - : invalid-path - : - { - s="../../../../../../../../../../../../../../../../../../../../../../../" - s="$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s" - - $clone_cfg; - - $* "$s" 2>>~%EOE% != 0 - %error: invalid repository path '.+/': invalid filesystem path% - EOE - } - - : type-detection - : - { - +$clone_cfg - - : git-scheme - : - $clone_cfg; - $* 'git://example.org/repo#master' 2>>EOE - added git:example.org/repo#master - EOE - - : http-git - : - $clone_cfg; - $* 'http://example.org/repo.git#master' 2>>EOE - added git:example.org/repo#master - EOE - - : http-pkg - : - $clone_cfg; - $* 'http://example.org/1/repo' 2>>EOE - added pkg:example.org/repo - EOE - - : file-git - : - $clone_cfg && mkdir -p repo/.git; - - $* 'repo' 2>>/~%EOE% - %added git:.+/repo% - EOE - - : file-pkg - : - $clone_cfg; - - $* '1/repo' 2>>/~%EOE% - %added .+/repo% - EOE - } -} - -: relative-path -: -{ - $clone_cfg; - - $* ./1/bar/stable 2>>/~%EOE%; - %added pkg:.+/relative-path/bar/stable% - EOE - - $* ./1/../1/bar/stable 2>>/~%EOE% - %unchanged pkg:.+/relative-path/bar/stable% - EOE -} - -: absolute-path -: -{ - $clone_cfg; - - $* $~/1/foo/stable 2>>/~%EOE%; - %added pkg:.+/absolute-path/foo/stable% - EOE - - $* $~/1/../1/foo/stable 2>>/~%EOE% - %unchanged pkg:.+/absolute-path/foo/stable% - EOE -} - -: remote-url -: -{ - +$clone_cfg - - : pkg - : - $clone_cfg; - - $* 'http://pkg.example.org/1/testing' 2>>EOE; - added pkg:example.org/testing - EOE - - $* 'https://www.example.org/1/testing' 2>>EOE; - updated pkg:example.org/testing - EOE - - $rep_list >>EOO - pkg:example.org/testing https://www.example.org/1/testing - EOO - - : git - : - $clone_cfg; - - $* 'git://example.org/testing.git#master' 2>>~%EOE%; - %added git:example.org/testing#master% - EOE - - $* 'https://www.example.org/testing.git#master' 2>>EOE; - updated git:example.org/testing#master - EOE - - $rep_list >>EOO - git:example.org/testing#master https://www.example.org/testing.git#master - EOO -} - -: multiple-locations -: -{ - $clone_cfg; - - $* 'http://pkg.example.org/1/alpha' 'http://pkg.example.org/1/beta' 2>>EOE; - added pkg:example.org/alpha - added pkg:example.org/beta - EOE - - $rep_list >>EOO - pkg:example.org/alpha http://pkg.example.org/1/alpha - pkg:example.org/beta http://pkg.example.org/1/beta - EOO -} diff --git a/tests/rep-add.testscript b/tests/rep-add.testscript new file mode 100644 index 0000000..b57eb68 --- /dev/null +++ b/tests/rep-add.testscript @@ -0,0 +1,205 @@ +# file : tests/rep-add.testscript +# copyright : Copyright (c) 2014-2018 Code Synthesis Ltd +# license : MIT; see accompanying LICENSE file + +.include common.testscript config.testscript + +rep_list += -d cfg + +: location +: +{ + +$clone_cfg + + : none + : + $* 2>>EOE != 0 + error: repository location argument expected + info: run 'bpkg help rep-add' for more information + EOE + + : empty + : + { + $clone_cfg; + + $* '' 2>>EOE != 0 + error: invalid repository location '': empty URL + EOE + } + + : unknown-type + : + $* 'repo' --type unknown 2>>EOE != 0 + error: invalid value 'unknown' for option '--type' + EOE + + : no-version + : + { + $clone_cfg; + + $* 'stable' 2>>/~%EOE% != 0 + %error: invalid pkg repository location '.+/no-version/stable': missing repository version% + info: consider using --type to specify repository type + EOE + } + + : git-invalid-fragment + : + { + $clone_cfg; + + $* 'git://example.org/repo#' 2>>EOE != 0 + error: invalid git repository location 'git://example.org/repo#': missing refname or commit id for git repository + EOE + } + + : pkg-git-scheme + : + { + $clone_cfg; + + $* 'git://example.org/repo' --type pkg 2>>EOE != 0 + error: invalid pkg repository location 'git://example.org/repo': unsupported scheme for pkg repository + EOE + } + + : invalid-path + : + { + s="../../../../../../../../../../../../../../../../../../../../../../../" + s="$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s" + + $clone_cfg; + + $* "$s" 2>>~%EOE% != 0 + %error: invalid repository path '.+/': invalid filesystem path% + EOE + } + + : type-detection + : + { + +$clone_cfg + + : git-scheme + : + $clone_cfg; + $* 'git://example.org/repo#master' 2>>EOE + added git:example.org/repo#master + EOE + + : http-git + : + $clone_cfg; + $* 'http://example.org/repo.git#master' 2>>EOE + added git:example.org/repo#master + EOE + + : http-pkg + : + $clone_cfg; + $* 'http://example.org/1/repo' 2>>EOE + added pkg:example.org/repo + EOE + + : file-git + : + $clone_cfg && mkdir -p repo/.git; + + $* 'repo' 2>>/~%EOE% + %added git:.+/repo% + EOE + + : file-pkg + : + $clone_cfg; + + $* '1/repo' 2>>/~%EOE% + %added .+/repo% + EOE + } +} + +: relative-path +: +{ + $clone_cfg; + + $* ./1/bar/stable 2>>/~%EOE%; + %added pkg:.+/relative-path/bar/stable% + EOE + + $* ./1/../1/bar/stable 2>>/~%EOE% + %unchanged pkg:.+/relative-path/bar/stable% + EOE +} + +: absolute-path +: +{ + $clone_cfg; + + $* $~/1/foo/stable 2>>/~%EOE%; + %added pkg:.+/absolute-path/foo/stable% + EOE + + $* $~/1/../1/foo/stable 2>>/~%EOE% + %unchanged pkg:.+/absolute-path/foo/stable% + EOE +} + +: remote-url +: +{ + +$clone_cfg + + : pkg + : + $clone_cfg; + + $* 'http://pkg.example.org/1/testing' 2>>EOE; + added pkg:example.org/testing + EOE + + $* 'https://www.example.org/1/testing' 2>>EOE; + updated pkg:example.org/testing + EOE + + $rep_list >>EOO + pkg:example.org/testing https://www.example.org/1/testing + EOO + + : git + : + $clone_cfg; + + $* 'git://example.org/testing.git#master' 2>>~%EOE%; + %added git:example.org/testing#master% + EOE + + $* 'https://www.example.org/testing.git#master' 2>>EOE; + updated git:example.org/testing#master + EOE + + $rep_list >>EOO + git:example.org/testing#master https://www.example.org/testing.git#master + EOO +} + +: multiple-locations +: +{ + $clone_cfg; + + $* 'http://pkg.example.org/1/alpha' 'http://pkg.example.org/1/beta' 2>>EOE; + added pkg:example.org/alpha + added pkg:example.org/beta + EOE + + $rep_list >>EOO + pkg:example.org/alpha http://pkg.example.org/1/alpha + pkg:example.org/beta http://pkg.example.org/1/beta + EOO +} diff --git a/tests/rep-auth.test b/tests/rep-auth.test deleted file mode 100644 index 640f828..0000000 --- a/tests/rep-auth.test +++ /dev/null @@ -1,634 +0,0 @@ -# file : tests/rep-auth.test -# copyright : Copyright (c) 2014-2018 Code Synthesis Ltd -# license : MIT; see accompanying LICENSE file - -.include common.test auth.test config.test remote.test - -# There is no rep-auth command, and this testscript contains tests for various -# authentication scenarios throughout different stages of repositories -# preparation and consumption. Note that by that reason usage of $* is -# meaningless. -# - -# Source repository: -# -# rep-auth -# |-- expired -# | |-- foo-1.tar.gz -# | |-- packages.manifest -# | |-- repositories.manifest -# | `-- signature.manifest -# `-- unsigned -# |-- foo-1.tar.gz -# `-- repositories.manifest - -# Prepare repositories used by tests if running in the local mode. -# -+if ($remote != true) - rc = $rep_create 2>! - - # Create the 'unsigned1' repository. - # - cp -r $src/unsigned $out/unsigned1 - $rc $out/unsigned1 &$out/unsigned1/packages.manifest - - # Create the 'unsigned2' repository. This is a copy of the just created - # 'unsigned1' repository. - # - cp -r $out/unsigned1 $out/unsigned2 - - # Create the 'signed' repository. - # - cp -r $src/unsigned $out/signed - cat <<<$cert_manifest >+$out/signed/repositories.manifest - - $rc --key $key $out/signed &$out/signed/packages.manifest \ - &$out/signed/signature.manifest - - # Create the 'self-match' repository. Note that its certificate name is - # the '*build2.org' wildcard (matches build2.org and any single-level - # subdomain). - # - cp -r $src/unsigned $out/self-match - - echo 'certificate: \' >+$out/self-match/repositories.manifest - cat <<<$src_base/auth/self-cert.pem >+$out/self-match/repositories.manifest - echo '\' >+$out/self-match/repositories.manifest - - $rc --key $key $out/self-match &$out/self-match/packages.manifest \ - &$out/self-match/signature.manifest - - # Create the 'self-any-match' repository. Note that its certificate name is - # the '**build2.org' wildcard (matches build2.org and any subdomain). - # - cp -r $src/unsigned $out/self-any-match - - echo 'certificate: \' >+$out/self-any-match/repositories.manifest - cat <<<$src_base/auth/self-any-cert.pem >+$out/self-any-match/repositories.manifest - echo '\' >+$out/self-any-match/repositories.manifest - - $rc --key $key $out/self-any-match &$out/self-any-match/packages.manifest \ - &$out/self-any-match/signature.manifest - - # Create the 'subdomain-match' repository. Note that its certificate name is - # the '*.build2.org' wildcard (matches any single-level subdomain of - # build2.org). - # - cp -r $src/unsigned $out/subdomain-match - - echo 'certificate: \' >+$out/subdomain-match/repositories.manifest - cat <<<$src_base/auth/subdomain-cert.pem >+$out/subdomain-match/repositories.manifest - echo '\' >+$out/subdomain-match/repositories.manifest - - $rc --key $key $out/subdomain-match &$out/subdomain-match/packages.manifest \ - &$out/subdomain-match/signature.manifest - - # Create the 'name-mismatch' repository. Note that its certificate name - # mismatches the repository location. - # - cp -r $src/unsigned $out/name-mismatch - - echo 'certificate: \' >+$out/name-mismatch/repositories.manifest - cat <<<$src_base/auth/mismatch-cert.pem >+$out/name-mismatch/repositories.manifest - echo '\' >+$out/name-mismatch/repositories.manifest - - $rc --key $key $out/name-mismatch &$out/name-mismatch/packages.manifest \ - &$out/name-mismatch/signature.manifest - - # Create the 'expired' repository. This repository is "pre-created" and its - # certificate is expired by now. So we just copy it from the source - # directory. - # - cp -r $src/expired $out/expired - - # Create the 'sha256sum-mismatch' repository. This is a copy of the just - # created 'signed' repository that has the sha256sum manifest value tampered. - # - cp -r $out/signed $out/sha256sum-mismatch - - v = 'd374c59b36fdbdbd0d4468665061d94fda9c6c687863dfe72b0bcc34ff9d5fb4' - - sed -i -e "s/^\(sha256sum: \).*\$/\\1$v/" \ - $out/sha256sum-mismatch/signature.manifest - - # Create the 'signature-mismatch' repository. This is a copy of the just - # created 'signed' repository that has the signature manifest value tampered. - # - cp -r $out/signed $out/signature-mismatch - - # Here we tamper the last signature line (the one of 76 chars length, without - # spaces and terminated with '='). - # - v = 'mnBAsS529NUdNIQy8EB4si/UK26ICaMywbLeHDVvWOB+AsqZ5rj8VjGDamLbmUrDr3ru7BU1gJU=' - sed -i -e "s%^[^ ]{75}=\$%$v%" $out/signature-mismatch/signature.manifest -end - -pkg_status += -d cfg -rep_add += -d cfg 2>! -rep_fetch += -d cfg - -# Check if rep-fetch command was successfull or not. -# -fetched = $pkg_status foo >'foo available 1' -not_fetched = $pkg_status foo >'foo unknown' - -sc = " " # Space character to append to here-document line when required. - -: no-auth -: -: Test that local repositories do not require authentication by default. -: -{ - r = 1/signed - +mkdir 1/ - +cp -r $src/unsigned $r - +cat <<<$cert_manifest >+$r/repositories.manifest - +$rep_create --key $key $r &$r/packages.manifest &$r/signature.manifest 2>! - - : rep-fetch - : - { - $clone_root_cfg && $rep_add ../$r; - - $rep_fetch 2>>/~%EOE% - %fetching .+/no-auth/signed% - 1 package(s) in 1 repository(s) - EOE - } - - : rep-info - : - $clone_root_cfg; - $rep_info --cert-name ../$r >'name:build2.org' -} - -: signed -: -{ - : rep-fetch - : - { - +$clone_root_cfg && $rep_add $rep/signed - rep_fetch += --auth all &?cfg/.bpkg/certs/** - - : no-auth - : - { - $clone_cfg; - - $rep_fetch 2>>"EOE" != 0; - fetching pkg:build2.org/rep-auth/signed - warning: authenticity of the certificate for repository pkg:build2.org/rep-auth/signed cannot be established - certificate is for build2.org, "Code Synthesis" - certificate SHA256 fingerprint: - $cert_fp - trust this certificate? [y/n]$sc - error: unable to read y/n answer from stdin - EOE - - $not_fetched - } - - : trust-fp - : - { - $clone_cfg; - - $rep_fetch --trust $cert_fp 2>>EOE; - fetching pkg:build2.org/rep-auth/signed - 1 package(s) in 1 repository(s) - EOE - - $fetched - } - - : trust-fp-no - : - { - $clone_cfg; - - $rep_fetch --trust-no --trust $cert_fp 2>>EOE; - fetching pkg:build2.org/rep-auth/signed - 1 package(s) in 1 repository(s) - EOE - - $fetched - } - - : trust-yes - : - { - $clone_cfg; - - $rep_fetch --trust-yes 2>>EOE; - fetching pkg:build2.org/rep-auth/signed - 1 package(s) in 1 repository(s) - EOE - - $fetched - } - - : trust-no - : - { - $clone_cfg; - - $rep_fetch --trust-no 2>>EOE != 0; - fetching pkg:build2.org/rep-auth/signed - error: authenticity of the certificate for repository pkg:build2.org/rep-auth/signed cannot be established - EOE - - $not_fetched - } - - : trust-yes-no - : - { - $clone_cfg; - - $rep_fetch --trust-yes --trust-no 2>>EOE != 0; - fetching pkg:build2.org/rep-auth/signed - error: --trust-yes and --trust-no are mutually exclusive - EOE - - $not_fetched - } - - : already-trusted - : - { - $clone_cfg; - - $rep_fetch --trust-yes 2>>EOE; - fetching pkg:build2.org/rep-auth/signed - 1 package(s) in 1 repository(s) - EOE - - $rep_fetch 2>>EOE; - fetching pkg:build2.org/rep-auth/signed - 1 package(s) in 1 repository(s) - EOE - - $fetched; - - $rep_fetch --trust-no 2>>EOE; - fetching pkg:build2.org/rep-auth/signed - 1 package(s) in 1 repository(s) - EOE - - $fetched - } - } - - : rep-info - : - { - rep_info += --cert-name --auth all $rep/signed - - : no-auth - : - $rep_info 2>>"EOE" != 0 - warning: authenticity of the certificate for repository pkg:build2.org/rep-auth/signed cannot be established - certificate is for build2.org, "Code Synthesis" - certificate SHA256 fingerprint: - $cert_fp - trust this certificate? [y/n]$sc - error: unable to read y/n answer from stdin - EOE - - : trust-fp - : - $rep_info --trust $cert_fp >'name:build2.org' - - : trust-yes - : - $rep_info --trust-yes >'name:build2.org' - - : trust-no - : - $rep_info --trust-no 2>>EOE != 0 - error: authenticity of the certificate for repository pkg:build2.org/rep-auth/signed cannot be established - EOE - - : already-trusted - : - { - $clone_root_cfg; - rep_info += -d cfg; - - $rep_info --trust "$cert_fp" &cfg/.bpkg/certs/** >>EOO; - name:build2.org - EOO - - $rep_info >'name:build2.org' - } - } - - : subdomain-wildcard - : - { - rep_info += --auth all --trust-yes --cert-name - - : self - : - { - : exact - : - $rep_info $rep/self-match >'name:*build2.org' - - : subdomain - : - if ($remote != true) - { - : first-level - : - { - r = $canonicalize([dir_path] $~/pkg/1/a.build2.org/); - mkdir -p $r; - cp -r $rep/self-match $r; - - $rep_info $r/self-match >'name:*build2.org' - } - - : second-level - : - { - r = $canonicalize([dir_path] $~/pkg/1/b.a.build2.org/); - mkdir -p $r; - cp -r $rep/self-match $r; - - $rep_info $r/self-match 2>>EOE != 0 - error: certificate name mismatch for repository pkg:b.a.build2.org/self-match - info: certificate name is *build2.org - EOE - } - } - } - - : self-any - : - { - : exact - : - $rep_info $rep/self-any-match >'name:**build2.org' - - : subdomain - : - if ($remote != true) - { - : first-level - : - { - r = $canonicalize([dir_path] $~/pkg/1/a.build2.org/); - mkdir -p $r; - cp -r $rep/self-any-match $r; - - $rep_info $r/self-any-match >'name:**build2.org' - } - - : second-level - : - { - r = $canonicalize([dir_path] $~/pkg/1/b.a.build2.org/); - mkdir -p $r; - cp -r $rep/self-any-match $r; - - $rep_info $r/self-any-match >'name:**build2.org' - } - } - } - - : subdomain - : - { - : exact - : - $rep_info $rep/subdomain-match 2>>EOE != 0 - error: certificate name mismatch for repository pkg:build2.org/rep-auth/subdomain-match - info: certificate name is *.build2.org - EOE - - : subdomain - : - if ($remote != true) - { - : first-level - : - { - r = $canonicalize([dir_path] $~/pkg/1/a.build2.org/); - mkdir -p $r; - cp -r $rep/subdomain-match $r; - - $rep_info $r/subdomain-match >'name:*.build2.org' - } - - : second-level - : - { - r = $canonicalize([dir_path] $~/pkg/1/b.a.build2.org/); - mkdir -p $r; - cp -r $rep/subdomain-match $r; - - $rep_info $r/subdomain-match 2>>EOE != 0 - error: certificate name mismatch for repository pkg:b.a.build2.org/subdomain-match - info: certificate name is *.build2.org - EOE - } - } - } - } -} - -: unsigned -: -{ - : rep-fetch - : - { - +$clone_root_cfg && $rep_add $rep/unsigned1 - rep_fetch += --auth all - - : no-auth - : - { - $clone_cfg; - - $rep_fetch 2>>~%EOE% != 0; - fetching pkg:build2.org/rep-auth/unsigned1 - warning: repository pkg:build2.org/rep-auth/unsigned1 is unsigned - %continue without authenticating repositories at .+\? \[y/n\] % - error: unable to read y/n answer from stdin - EOE - - $not_fetched - } - - : trust-yes - : - { - $clone_cfg; - - $rep_fetch --trust-yes 2>>EOE; - fetching pkg:build2.org/rep-auth/unsigned1 - 1 package(s) in 1 repository(s) - EOE - - $fetched - } - - : trust-no - : - { - $clone_cfg; - - $rep_fetch --trust-no 2>>EOE != 0; - fetching pkg:build2.org/rep-auth/unsigned1 - error: repository pkg:build2.org/rep-auth/unsigned1 is unsigned - EOE - - $not_fetched - } - - : already-trusted - : - { - $clone_cfg; - - $rep_fetch --trust-yes 2>>EOE; - fetching pkg:build2.org/rep-auth/unsigned1 - 1 package(s) in 1 repository(s) - EOE - - $rep_fetch 2>>EOE; - fetching pkg:build2.org/rep-auth/unsigned1 - 1 package(s) in 1 repository(s) - EOE - - $fetched; - - $rep_fetch --trust-no 2>>EOE; - fetching pkg:build2.org/rep-auth/unsigned1 - 1 package(s) in 1 repository(s) - EOE - - $fetched; - - $rep_add $rep/unsigned2; - - $rep_fetch 2>>EOE; - fetching pkg:build2.org/rep-auth/unsigned1 - fetching pkg:build2.org/rep-auth/unsigned2 - 1 package(s) in 2 repository(s) - EOE - - $fetched - } - } - - : rep-info - : - { - rep_info += --name --auth all $rep/unsigned1 - - : no-auth - : - $rep_info 2>>~%EOE% != 0 - warning: repository pkg:build2.org/rep-auth/unsigned1 is unsigned - %continue without authenticating repositories at .+\? \[y/n\] % - error: unable to read y/n answer from stdin - EOE - - : trust-yes - : - $rep_info --trust-yes >>"EOO" - pkg:build2.org/rep-auth/unsigned1 ($rep/unsigned1) - EOO - - : trust-no - : - $rep_info --trust-no 2>>EOE != 0 - error: repository pkg:build2.org/rep-auth/unsigned1 is unsigned - EOE - - : already-trusted - : - { - $clone_root_cfg; - rep_info += -d cfg; - - $rep_info --trust-yes >>"EOO"; - pkg:build2.org/rep-auth/unsigned1 ($rep/unsigned1) - EOO - $rep_info >>"EOO" - pkg:build2.org/rep-auth/unsigned1 ($rep/unsigned1) - EOO - } - } -} - -: faulty -: -{ - rep_info += --auth all --trust-yes - - : name-mismatch - : - $rep_info $rep/name-mismatch 2>>EOE != 0 - error: certificate name mismatch for repository pkg:build2.org/rep-auth/name-mismatch - info: certificate name is build2.org/mismatched/name - EOE - - : expired - : - $rep_info $rep/expired 2>>EOE != 0 - error: certificate for repository pkg:build2.org/rep-auth/expired has expired - EOE - - : sha256sum-mismatch - : - $rep_info $rep/sha256sum-mismatch 2>>EOE != 0 - error: packages manifest file checksum mismatch for pkg:build2.org/rep-auth/sha256sum-mismatch - info: try again - EOE - - : signature-mismatch - : - $rep_info $rep/signature-mismatch 2>>~%EOE% != 0 - %.* - %error: unable to authenticate repository pkg:build2.org/rep-auth/signature-mismatch: .*% - EOE - - : create-rep - : - { - : no-email - : - { - cp -r $src/unsigned rep; - - echo 'certificate: \' >+rep/repositories.manifest; - cat <<<$src_base/auth/noemail-cert.pem >+rep/repositories.manifest; - echo '\' >+rep/repositories.manifest; - - $rep_create --key $key rep &rep/packages.manifest 2>>/EOE != 0 - added foo 1 - error: invalid certificate for rep/: no email - EOE - } - - : expired - : - { - cp -r $src/unsigned rep; - - echo 'certificate: \' >+rep/repositories.manifest; - cat <<<$src_base/auth/expired-cert.pem >+rep/repositories.manifest; - echo '\' >+rep/repositories.manifest; - - $rep_create --key $key rep &rep/packages.manifest 2>>/EOE != 0 - added foo 1 - error: certificate for repository rep/ has expired - EOE - } - } -} diff --git a/tests/rep-auth.testscript b/tests/rep-auth.testscript new file mode 100644 index 0000000..ede815b --- /dev/null +++ b/tests/rep-auth.testscript @@ -0,0 +1,634 @@ +# file : tests/rep-auth.testscript +# copyright : Copyright (c) 2014-2018 Code Synthesis Ltd +# license : MIT; see accompanying LICENSE file + +.include common.testscript auth.testscript config.testscript remote.testscript + +# There is no rep-auth command, and this testscript contains tests for various +# authentication scenarios throughout different stages of repositories +# preparation and consumption. Note that by that reason usage of $* is +# meaningless. +# + +# Source repository: +# +# rep-auth +# |-- expired +# | |-- foo-1.tar.gz +# | |-- packages.manifest +# | |-- repositories.manifest +# | `-- signature.manifest +# `-- unsigned +# |-- foo-1.tar.gz +# `-- repositories.manifest + +# Prepare repositories used by tests if running in the local mode. +# ++if ($remote != true) + rc = $rep_create 2>! + + # Create the 'unsigned1' repository. + # + cp -r $src/unsigned $out/unsigned1 + $rc $out/unsigned1 &$out/unsigned1/packages.manifest + + # Create the 'unsigned2' repository. This is a copy of the just created + # 'unsigned1' repository. + # + cp -r $out/unsigned1 $out/unsigned2 + + # Create the 'signed' repository. + # + cp -r $src/unsigned $out/signed + cat <<<$cert_manifest >+$out/signed/repositories.manifest + + $rc --key $key $out/signed &$out/signed/packages.manifest \ + &$out/signed/signature.manifest + + # Create the 'self-match' repository. Note that its certificate name is + # the '*build2.org' wildcard (matches build2.org and any single-level + # subdomain). + # + cp -r $src/unsigned $out/self-match + + echo 'certificate: \' >+$out/self-match/repositories.manifest + cat <<<$src_base/auth/self-cert.pem >+$out/self-match/repositories.manifest + echo '\' >+$out/self-match/repositories.manifest + + $rc --key $key $out/self-match &$out/self-match/packages.manifest \ + &$out/self-match/signature.manifest + + # Create the 'self-any-match' repository. Note that its certificate name is + # the '**build2.org' wildcard (matches build2.org and any subdomain). + # + cp -r $src/unsigned $out/self-any-match + + echo 'certificate: \' >+$out/self-any-match/repositories.manifest + cat <<<$src_base/auth/self-any-cert.pem >+$out/self-any-match/repositories.manifest + echo '\' >+$out/self-any-match/repositories.manifest + + $rc --key $key $out/self-any-match &$out/self-any-match/packages.manifest \ + &$out/self-any-match/signature.manifest + + # Create the 'subdomain-match' repository. Note that its certificate name is + # the '*.build2.org' wildcard (matches any single-level subdomain of + # build2.org). + # + cp -r $src/unsigned $out/subdomain-match + + echo 'certificate: \' >+$out/subdomain-match/repositories.manifest + cat <<<$src_base/auth/subdomain-cert.pem >+$out/subdomain-match/repositories.manifest + echo '\' >+$out/subdomain-match/repositories.manifest + + $rc --key $key $out/subdomain-match &$out/subdomain-match/packages.manifest \ + &$out/subdomain-match/signature.manifest + + # Create the 'name-mismatch' repository. Note that its certificate name + # mismatches the repository location. + # + cp -r $src/unsigned $out/name-mismatch + + echo 'certificate: \' >+$out/name-mismatch/repositories.manifest + cat <<<$src_base/auth/mismatch-cert.pem >+$out/name-mismatch/repositories.manifest + echo '\' >+$out/name-mismatch/repositories.manifest + + $rc --key $key $out/name-mismatch &$out/name-mismatch/packages.manifest \ + &$out/name-mismatch/signature.manifest + + # Create the 'expired' repository. This repository is "pre-created" and its + # certificate is expired by now. So we just copy it from the source + # directory. + # + cp -r $src/expired $out/expired + + # Create the 'sha256sum-mismatch' repository. This is a copy of the just + # created 'signed' repository that has the sha256sum manifest value tampered. + # + cp -r $out/signed $out/sha256sum-mismatch + + v = 'd374c59b36fdbdbd0d4468665061d94fda9c6c687863dfe72b0bcc34ff9d5fb4' + + sed -i -e "s/^\(sha256sum: \).*\$/\\1$v/" \ + $out/sha256sum-mismatch/signature.manifest + + # Create the 'signature-mismatch' repository. This is a copy of the just + # created 'signed' repository that has the signature manifest value tampered. + # + cp -r $out/signed $out/signature-mismatch + + # Here we tamper the last signature line (the one of 76 chars length, without + # spaces and terminated with '='). + # + v = 'mnBAsS529NUdNIQy8EB4si/UK26ICaMywbLeHDVvWOB+AsqZ5rj8VjGDamLbmUrDr3ru7BU1gJU=' + sed -i -e "s%^[^ ]{75}=\$%$v%" $out/signature-mismatch/signature.manifest +end + +pkg_status += -d cfg +rep_add += -d cfg 2>! +rep_fetch += -d cfg + +# Check if rep-fetch command was successfull or not. +# +fetched = $pkg_status foo >'foo available 1' +not_fetched = $pkg_status foo >'foo unknown' + +sc = " " # Space character to append to here-document line when required. + +: no-auth +: +: Test that local repositories do not require authentication by default. +: +{ + r = 1/signed + +mkdir 1/ + +cp -r $src/unsigned $r + +cat <<<$cert_manifest >+$r/repositories.manifest + +$rep_create --key $key $r &$r/packages.manifest &$r/signature.manifest 2>! + + : rep-fetch + : + { + $clone_root_cfg && $rep_add ../$r; + + $rep_fetch 2>>/~%EOE% + %fetching .+/no-auth/signed% + 1 package(s) in 1 repository(s) + EOE + } + + : rep-info + : + $clone_root_cfg; + $rep_info --cert-name ../$r >'name:build2.org' +} + +: signed +: +{ + : rep-fetch + : + { + +$clone_root_cfg && $rep_add $rep/signed + rep_fetch += --auth all &?cfg/.bpkg/certs/** + + : no-auth + : + { + $clone_cfg; + + $rep_fetch 2>>"EOE" != 0; + fetching pkg:build2.org/rep-auth/signed + warning: authenticity of the certificate for repository pkg:build2.org/rep-auth/signed cannot be established + certificate is for build2.org, "Code Synthesis" + certificate SHA256 fingerprint: + $cert_fp + trust this certificate? [y/n]$sc + error: unable to read y/n answer from stdin + EOE + + $not_fetched + } + + : trust-fp + : + { + $clone_cfg; + + $rep_fetch --trust $cert_fp 2>>EOE; + fetching pkg:build2.org/rep-auth/signed + 1 package(s) in 1 repository(s) + EOE + + $fetched + } + + : trust-fp-no + : + { + $clone_cfg; + + $rep_fetch --trust-no --trust $cert_fp 2>>EOE; + fetching pkg:build2.org/rep-auth/signed + 1 package(s) in 1 repository(s) + EOE + + $fetched + } + + : trust-yes + : + { + $clone_cfg; + + $rep_fetch --trust-yes 2>>EOE; + fetching pkg:build2.org/rep-auth/signed + 1 package(s) in 1 repository(s) + EOE + + $fetched + } + + : trust-no + : + { + $clone_cfg; + + $rep_fetch --trust-no 2>>EOE != 0; + fetching pkg:build2.org/rep-auth/signed + error: authenticity of the certificate for repository pkg:build2.org/rep-auth/signed cannot be established + EOE + + $not_fetched + } + + : trust-yes-no + : + { + $clone_cfg; + + $rep_fetch --trust-yes --trust-no 2>>EOE != 0; + fetching pkg:build2.org/rep-auth/signed + error: --trust-yes and --trust-no are mutually exclusive + EOE + + $not_fetched + } + + : already-trusted + : + { + $clone_cfg; + + $rep_fetch --trust-yes 2>>EOE; + fetching pkg:build2.org/rep-auth/signed + 1 package(s) in 1 repository(s) + EOE + + $rep_fetch 2>>EOE; + fetching pkg:build2.org/rep-auth/signed + 1 package(s) in 1 repository(s) + EOE + + $fetched; + + $rep_fetch --trust-no 2>>EOE; + fetching pkg:build2.org/rep-auth/signed + 1 package(s) in 1 repository(s) + EOE + + $fetched + } + } + + : rep-info + : + { + rep_info += --cert-name --auth all $rep/signed + + : no-auth + : + $rep_info 2>>"EOE" != 0 + warning: authenticity of the certificate for repository pkg:build2.org/rep-auth/signed cannot be established + certificate is for build2.org, "Code Synthesis" + certificate SHA256 fingerprint: + $cert_fp + trust this certificate? [y/n]$sc + error: unable to read y/n answer from stdin + EOE + + : trust-fp + : + $rep_info --trust $cert_fp >'name:build2.org' + + : trust-yes + : + $rep_info --trust-yes >'name:build2.org' + + : trust-no + : + $rep_info --trust-no 2>>EOE != 0 + error: authenticity of the certificate for repository pkg:build2.org/rep-auth/signed cannot be established + EOE + + : already-trusted + : + { + $clone_root_cfg; + rep_info += -d cfg; + + $rep_info --trust "$cert_fp" &cfg/.bpkg/certs/** >>EOO; + name:build2.org + EOO + + $rep_info >'name:build2.org' + } + } + + : subdomain-wildcard + : + { + rep_info += --auth all --trust-yes --cert-name + + : self + : + { + : exact + : + $rep_info $rep/self-match >'name:*build2.org' + + : subdomain + : + if ($remote != true) + { + : first-level + : + { + r = $canonicalize([dir_path] $~/pkg/1/a.build2.org/); + mkdir -p $r; + cp -r $rep/self-match $r; + + $rep_info $r/self-match >'name:*build2.org' + } + + : second-level + : + { + r = $canonicalize([dir_path] $~/pkg/1/b.a.build2.org/); + mkdir -p $r; + cp -r $rep/self-match $r; + + $rep_info $r/self-match 2>>EOE != 0 + error: certificate name mismatch for repository pkg:b.a.build2.org/self-match + info: certificate name is *build2.org + EOE + } + } + } + + : self-any + : + { + : exact + : + $rep_info $rep/self-any-match >'name:**build2.org' + + : subdomain + : + if ($remote != true) + { + : first-level + : + { + r = $canonicalize([dir_path] $~/pkg/1/a.build2.org/); + mkdir -p $r; + cp -r $rep/self-any-match $r; + + $rep_info $r/self-any-match >'name:**build2.org' + } + + : second-level + : + { + r = $canonicalize([dir_path] $~/pkg/1/b.a.build2.org/); + mkdir -p $r; + cp -r $rep/self-any-match $r; + + $rep_info $r/self-any-match >'name:**build2.org' + } + } + } + + : subdomain + : + { + : exact + : + $rep_info $rep/subdomain-match 2>>EOE != 0 + error: certificate name mismatch for repository pkg:build2.org/rep-auth/subdomain-match + info: certificate name is *.build2.org + EOE + + : subdomain + : + if ($remote != true) + { + : first-level + : + { + r = $canonicalize([dir_path] $~/pkg/1/a.build2.org/); + mkdir -p $r; + cp -r $rep/subdomain-match $r; + + $rep_info $r/subdomain-match >'name:*.build2.org' + } + + : second-level + : + { + r = $canonicalize([dir_path] $~/pkg/1/b.a.build2.org/); + mkdir -p $r; + cp -r $rep/subdomain-match $r; + + $rep_info $r/subdomain-match 2>>EOE != 0 + error: certificate name mismatch for repository pkg:b.a.build2.org/subdomain-match + info: certificate name is *.build2.org + EOE + } + } + } + } +} + +: unsigned +: +{ + : rep-fetch + : + { + +$clone_root_cfg && $rep_add $rep/unsigned1 + rep_fetch += --auth all + + : no-auth + : + { + $clone_cfg; + + $rep_fetch 2>>~%EOE% != 0; + fetching pkg:build2.org/rep-auth/unsigned1 + warning: repository pkg:build2.org/rep-auth/unsigned1 is unsigned + %continue without authenticating repositories at .+\? \[y/n\] % + error: unable to read y/n answer from stdin + EOE + + $not_fetched + } + + : trust-yes + : + { + $clone_cfg; + + $rep_fetch --trust-yes 2>>EOE; + fetching pkg:build2.org/rep-auth/unsigned1 + 1 package(s) in 1 repository(s) + EOE + + $fetched + } + + : trust-no + : + { + $clone_cfg; + + $rep_fetch --trust-no 2>>EOE != 0; + fetching pkg:build2.org/rep-auth/unsigned1 + error: repository pkg:build2.org/rep-auth/unsigned1 is unsigned + EOE + + $not_fetched + } + + : already-trusted + : + { + $clone_cfg; + + $rep_fetch --trust-yes 2>>EOE; + fetching pkg:build2.org/rep-auth/unsigned1 + 1 package(s) in 1 repository(s) + EOE + + $rep_fetch 2>>EOE; + fetching pkg:build2.org/rep-auth/unsigned1 + 1 package(s) in 1 repository(s) + EOE + + $fetched; + + $rep_fetch --trust-no 2>>EOE; + fetching pkg:build2.org/rep-auth/unsigned1 + 1 package(s) in 1 repository(s) + EOE + + $fetched; + + $rep_add $rep/unsigned2; + + $rep_fetch 2>>EOE; + fetching pkg:build2.org/rep-auth/unsigned1 + fetching pkg:build2.org/rep-auth/unsigned2 + 1 package(s) in 2 repository(s) + EOE + + $fetched + } + } + + : rep-info + : + { + rep_info += --name --auth all $rep/unsigned1 + + : no-auth + : + $rep_info 2>>~%EOE% != 0 + warning: repository pkg:build2.org/rep-auth/unsigned1 is unsigned + %continue without authenticating repositories at .+\? \[y/n\] % + error: unable to read y/n answer from stdin + EOE + + : trust-yes + : + $rep_info --trust-yes >>"EOO" + pkg:build2.org/rep-auth/unsigned1 ($rep/unsigned1) + EOO + + : trust-no + : + $rep_info --trust-no 2>>EOE != 0 + error: repository pkg:build2.org/rep-auth/unsigned1 is unsigned + EOE + + : already-trusted + : + { + $clone_root_cfg; + rep_info += -d cfg; + + $rep_info --trust-yes >>"EOO"; + pkg:build2.org/rep-auth/unsigned1 ($rep/unsigned1) + EOO + $rep_info >>"EOO" + pkg:build2.org/rep-auth/unsigned1 ($rep/unsigned1) + EOO + } + } +} + +: faulty +: +{ + rep_info += --auth all --trust-yes + + : name-mismatch + : + $rep_info $rep/name-mismatch 2>>EOE != 0 + error: certificate name mismatch for repository pkg:build2.org/rep-auth/name-mismatch + info: certificate name is build2.org/mismatched/name + EOE + + : expired + : + $rep_info $rep/expired 2>>EOE != 0 + error: certificate for repository pkg:build2.org/rep-auth/expired has expired + EOE + + : sha256sum-mismatch + : + $rep_info $rep/sha256sum-mismatch 2>>EOE != 0 + error: packages manifest file checksum mismatch for pkg:build2.org/rep-auth/sha256sum-mismatch + info: try again + EOE + + : signature-mismatch + : + $rep_info $rep/signature-mismatch 2>>~%EOE% != 0 + %.* + %error: unable to authenticate repository pkg:build2.org/rep-auth/signature-mismatch: .*% + EOE + + : create-rep + : + { + : no-email + : + { + cp -r $src/unsigned rep; + + echo 'certificate: \' >+rep/repositories.manifest; + cat <<<$src_base/auth/noemail-cert.pem >+rep/repositories.manifest; + echo '\' >+rep/repositories.manifest; + + $rep_create --key $key rep &rep/packages.manifest 2>>/EOE != 0 + added foo 1 + error: invalid certificate for rep/: no email + EOE + } + + : expired + : + { + cp -r $src/unsigned rep; + + echo 'certificate: \' >+rep/repositories.manifest; + cat <<<$src_base/auth/expired-cert.pem >+rep/repositories.manifest; + echo '\' >+rep/repositories.manifest; + + $rep_create --key $key rep &rep/packages.manifest 2>>/EOE != 0 + added foo 1 + error: certificate for repository rep/ has expired + EOE + } + } +} diff --git a/tests/rep-create.test b/tests/rep-create.test deleted file mode 100644 index 09aeb7f..0000000 --- a/tests/rep-create.test +++ /dev/null @@ -1,178 +0,0 @@ -# file : tests/rep-create.test -# copyright : Copyright (c) 2014-2018 Code Synthesis Ltd -# license : MIT; see accompanying LICENSE file - -.include common.test auth.test - -# Source repository: -# -# rep-create -# |-- stable -# | |-- foo-1.tar.gz -# | `-- repositories.manifest -# `-- testing -> stable (complement) -# |-- foo-2.tar.gz (manifest with unknown name) -# `-- repositories.manifest - -: unsigned -: -{ - # Make sure the cloned repository has a valid location, so we can use - # rep-info command to validate the repository info. - # - clone_rep = mkdir 1/ && cp -r $src/stable 1/ - - : without-key - : - { - $clone_rep; - - $* 1/stable/ 2>>/~%EOE% &1/stable/packages.manifest; - added foo 1 - %1 package\(s\) in .+/stable/% - EOE - - $rep_info -p --manifest 1/stable/ >>EOO - : 1 - name: foo - version: 1 - summary: The "Foo" utility - license: MIT - url: http://www.example.org/foo - email: foo-users@example.org - location: foo-1.tar.gz - sha256sum: fee330a362a4f87ff42a954aa305b6446d541b7b60000ebcd2fbf68f2b1ae58e - EOO - } - - : with-key - : - { - $clone_rep; - - $* --key $key 1/stable/ 2>>/~%EOE% &1/stable/packages.manifest; - added foo 1 - warning: --key option ignored - info: repository manifest contains no certificate - info: run 'bpkg help rep-create' for more information - %1 package\(s\) in .+/stable/% - EOE - - $rep_info -p --manifest 1/stable/ >>EOO - : 1 - name: foo - version: 1 - summary: The "Foo" utility - license: MIT - url: http://www.example.org/foo - email: foo-users@example.org - location: foo-1.tar.gz - sha256sum: fee330a362a4f87ff42a954aa305b6446d541b7b60000ebcd2fbf68f2b1ae58e - EOO - } -} - -: signed -: -: Here we sign the 'stable' repository with the certificate prior to running -: tests. -: -{ - +cp -r $src/stable ./ && cat <<<$cert_manifest >+stable/repositories.manifest - - # Make sure the cloned repository has a valid location, so we can use - # rep-info command to validate the repository info. - # - clone_rep = mkdir 1/ && cp -r ../stable 1/ - - : with-key - : - : Note that as we re-create the repositories.manifest file on the fly (see - : above) its sha256sum can vary due to CRs mix-in on Windows. That explains - : why we do not match it exactly. - : - { - $clone_rep; - - $* --key $key 1/stable/ 2>>/~%EOE% &1/stable/packages.manifest \ - &1/stable/signature.manifest; - added foo 1 - %1 package\(s\) in .+/stable/% - EOE - - $rep_info --cert-fingerprint -p --manifest 1/stable/ >>~"%EOO%" - $cert_fp - : 1 - name: foo - version: 1 - summary: The "Foo" utility - license: MIT - url: http://www.example.org/foo - email: foo-users@example.org - location: foo-1.tar.gz - sha256sum: fee330a362a4f87ff42a954aa305b6446d541b7b60000ebcd2fbf68f2b1ae58e - EOO - } - - : without-key - : - $clone_rep; - $* 1/stable/ 2>>EOE &1/stable/packages.manifest != 0 - added foo 1 - error: --key option required - info: repository manifest contains a certificate - info: run 'bpkg help rep-create' for more information - EOE -} - -: unknown-name -: -: Test that package manifest that contains an unknown name is properly handled. -: -{ - clone_rep = cp -r $src/testing ./ - - : fail - : - $clone_rep; - $* testing/ 2>>/EOE != 0 - foo-2/manifest:8:1: error: unknown name 'color' in package manifest - info: package archive testing/foo-2.tar.gz - EOE - - : ignore - : - $clone_rep; - $* --ignore-unknown testing/ 2>>/~%EOE% &testing/packages.manifest - added foo 2 - %1 package\(s\) in .+/testing/% - EOE -} - -: broken-repo -: -: Here we break the 'stable' repository prior to running a test. -: -{ - clone_rep = cp -r $src/stable ./ - - : no-repositories-manifest - : - { - $clone_rep &!stable/repositories.manifest; - rm stable/repositories.manifest; - - $* stable/ 2>/'error: file stable/repositories.manifest does not exist' != 0 - } - - : unexpected-file - : - { - $clone_rep; - touch stable/foo; - - $* stable/ 2>>/EOE != 0 - error: unknown compression method in stable/foo - EOE - } -} diff --git a/tests/rep-create.testscript b/tests/rep-create.testscript new file mode 100644 index 0000000..053902d --- /dev/null +++ b/tests/rep-create.testscript @@ -0,0 +1,178 @@ +# file : tests/rep-create.testscript +# copyright : Copyright (c) 2014-2018 Code Synthesis Ltd +# license : MIT; see accompanying LICENSE file + +.include common.testscript auth.testscript + +# Source repository: +# +# rep-create +# |-- stable +# | |-- foo-1.tar.gz +# | `-- repositories.manifest +# `-- testing -> stable (complement) +# |-- foo-2.tar.gz (manifest with unknown name) +# `-- repositories.manifest + +: unsigned +: +{ + # Make sure the cloned repository has a valid location, so we can use + # rep-info command to validate the repository info. + # + clone_rep = mkdir 1/ && cp -r $src/stable 1/ + + : without-key + : + { + $clone_rep; + + $* 1/stable/ 2>>/~%EOE% &1/stable/packages.manifest; + added foo 1 + %1 package\(s\) in .+/stable/% + EOE + + $rep_info -p --manifest 1/stable/ >>EOO + : 1 + name: foo + version: 1 + summary: The "Foo" utility + license: MIT + url: http://www.example.org/foo + email: foo-users@example.org + location: foo-1.tar.gz + sha256sum: fee330a362a4f87ff42a954aa305b6446d541b7b60000ebcd2fbf68f2b1ae58e + EOO + } + + : with-key + : + { + $clone_rep; + + $* --key $key 1/stable/ 2>>/~%EOE% &1/stable/packages.manifest; + added foo 1 + warning: --key option ignored + info: repository manifest contains no certificate + info: run 'bpkg help rep-create' for more information + %1 package\(s\) in .+/stable/% + EOE + + $rep_info -p --manifest 1/stable/ >>EOO + : 1 + name: foo + version: 1 + summary: The "Foo" utility + license: MIT + url: http://www.example.org/foo + email: foo-users@example.org + location: foo-1.tar.gz + sha256sum: fee330a362a4f87ff42a954aa305b6446d541b7b60000ebcd2fbf68f2b1ae58e + EOO + } +} + +: signed +: +: Here we sign the 'stable' repository with the certificate prior to running +: tests. +: +{ + +cp -r $src/stable ./ && cat <<<$cert_manifest >+stable/repositories.manifest + + # Make sure the cloned repository has a valid location, so we can use + # rep-info command to validate the repository info. + # + clone_rep = mkdir 1/ && cp -r ../stable 1/ + + : with-key + : + : Note that as we re-create the repositories.manifest file on the fly (see + : above) its sha256sum can vary due to CRs mix-in on Windows. That explains + : why we do not match it exactly. + : + { + $clone_rep; + + $* --key $key 1/stable/ 2>>/~%EOE% &1/stable/packages.manifest \ + &1/stable/signature.manifest; + added foo 1 + %1 package\(s\) in .+/stable/% + EOE + + $rep_info --cert-fingerprint -p --manifest 1/stable/ >>~"%EOO%" + $cert_fp + : 1 + name: foo + version: 1 + summary: The "Foo" utility + license: MIT + url: http://www.example.org/foo + email: foo-users@example.org + location: foo-1.tar.gz + sha256sum: fee330a362a4f87ff42a954aa305b6446d541b7b60000ebcd2fbf68f2b1ae58e + EOO + } + + : without-key + : + $clone_rep; + $* 1/stable/ 2>>EOE &1/stable/packages.manifest != 0 + added foo 1 + error: --key option required + info: repository manifest contains a certificate + info: run 'bpkg help rep-create' for more information + EOE +} + +: unknown-name +: +: Test that package manifest that contains an unknown name is properly handled. +: +{ + clone_rep = cp -r $src/testing ./ + + : fail + : + $clone_rep; + $* testing/ 2>>/EOE != 0 + foo-2/manifest:8:1: error: unknown name 'color' in package manifest + info: package archive testing/foo-2.tar.gz + EOE + + : ignore + : + $clone_rep; + $* --ignore-unknown testing/ 2>>/~%EOE% &testing/packages.manifest + added foo 2 + %1 package\(s\) in .+/testing/% + EOE +} + +: broken-repo +: +: Here we break the 'stable' repository prior to running a test. +: +{ + clone_rep = cp -r $src/stable ./ + + : no-repositories-manifest + : + { + $clone_rep &!stable/repositories.manifest; + rm stable/repositories.manifest; + + $* stable/ 2>/'error: file stable/repositories.manifest does not exist' != 0 + } + + : unexpected-file + : + { + $clone_rep; + touch stable/foo; + + $* stable/ 2>>/EOE != 0 + error: unknown compression method in stable/foo + EOE + } +} diff --git a/tests/rep-fetch-git-commit.test b/tests/rep-fetch-git-commit.test deleted file mode 100644 index 58c9ffe..0000000 --- a/tests/rep-fetch-git-commit.test +++ /dev/null @@ -1,93 +0,0 @@ -# file : tests/rep-fetch-git-commit.test -# copyright : Copyright (c) 2014-2018 Code Synthesis Ltd -# license : MIT; see accompanying LICENSE file - -+git clone "$rep_git/state0/style-basic.git" 2>! &style-basic/*** - -: unadvertised -: -{ - +git -C ../style-basic log '--pretty=format:%H' --all --grep='README' | \ - set commit - - : no-refname - : - : Here we also test that a commit can be specified without leading '@'. - : - { - $clone_root_cfg && $rep_add "$rep/state0/style-basic.git#$commit"; - - if ($git_protocol == 'https-dumb') - warn = "$warn_repo_hist$reason_dumb$warn_dumb" - elif ($git_protocol != 'https-smart-unadv') - warn = "$warn_repo_hist$reason_unadv" - end; - - $* 2>>~"%EOE%" - %fetching git:.+style-basic#$commit% - %querying .+style-basic\.git%? - %fetching from .+style-basic\.git% - $warn - 1 package\(s\) in 1 repository\(s\) - EOE - } - - : refname - : - { - $clone_root_cfg && $rep_add "$rep/state0/style-basic.git#stable@$commit"; - - if ($git_protocol == 'https-dumb') - warn = "$warn_ref_hist$reason_dumb$warn_dumb" - elif ($git_protocol != 'https-smart-unadv') - warn = "$warn_ref_hist$reason_unadv" - end; - - $* 2>>~"%EOE%" - %fetching git:.+style-basic#stable@$commit% - %querying .+style-basic\.git%? - %fetching from .+style-basic\.git% - $warn - 1 package\(s\) in 1 repository\(s\) - EOE - } -} - -: advertised -: -{ - +git -C ../style-basic log '--pretty=format:%H' --all --grep='INSTALL' | \ - set commit - - +if ($git_protocol == 'https-dumb') - warn = "$warn_ref_hist$reason_dumb$warn_dumb" - end - - : no-refname - : - { - $clone_root_cfg && $rep_add "$rep/state0/style-basic.git#@$commit"; - - $* 2>>~"%EOE%" - %fetching git:.+style-basic#@$commit% - %querying .+style-basic\.git%? - %fetching from .+style-basic.\git% - $warn - 1 package\(s\) in 1 repository\(s\) - EOE - } - - : refname - : - { - $clone_root_cfg && $rep_add "$rep/state0/style-basic.git#stable@$commit"; - - $* 2>>~"%EOE%" - %fetching git:.+style-basic#stable@$commit% - %querying .+style-basic\.git%? - %fetching from .+style-basic\.git% - $warn - 1 package\(s\) in 1 repository\(s\) - EOE - } -} diff --git a/tests/rep-fetch-git-commit.testscript b/tests/rep-fetch-git-commit.testscript new file mode 100644 index 0000000..ff6c7a3 --- /dev/null +++ b/tests/rep-fetch-git-commit.testscript @@ -0,0 +1,93 @@ +# file : tests/rep-fetch-git-commit.testscript +# copyright : Copyright (c) 2014-2018 Code Synthesis Ltd +# license : MIT; see accompanying LICENSE file + ++git clone "$rep_git/state0/style-basic.git" 2>! &style-basic/*** + +: unadvertised +: +{ + +git -C ../style-basic log '--pretty=format:%H' --all --grep='README' | \ + set commit + + : no-refname + : + : Here we also test that a commit can be specified without leading '@'. + : + { + $clone_root_cfg && $rep_add "$rep/state0/style-basic.git#$commit"; + + if ($git_protocol == 'https-dumb') + warn = "$warn_repo_hist$reason_dumb$warn_dumb" + elif ($git_protocol != 'https-smart-unadv') + warn = "$warn_repo_hist$reason_unadv" + end; + + $* 2>>~"%EOE%" + %fetching git:.+style-basic#$commit% + %querying .+style-basic\.git%? + %fetching from .+style-basic\.git% + $warn + 1 package\(s\) in 1 repository\(s\) + EOE + } + + : refname + : + { + $clone_root_cfg && $rep_add "$rep/state0/style-basic.git#stable@$commit"; + + if ($git_protocol == 'https-dumb') + warn = "$warn_ref_hist$reason_dumb$warn_dumb" + elif ($git_protocol != 'https-smart-unadv') + warn = "$warn_ref_hist$reason_unadv" + end; + + $* 2>>~"%EOE%" + %fetching git:.+style-basic#stable@$commit% + %querying .+style-basic\.git%? + %fetching from .+style-basic\.git% + $warn + 1 package\(s\) in 1 repository\(s\) + EOE + } +} + +: advertised +: +{ + +git -C ../style-basic log '--pretty=format:%H' --all --grep='INSTALL' | \ + set commit + + +if ($git_protocol == 'https-dumb') + warn = "$warn_ref_hist$reason_dumb$warn_dumb" + end + + : no-refname + : + { + $clone_root_cfg && $rep_add "$rep/state0/style-basic.git#@$commit"; + + $* 2>>~"%EOE%" + %fetching git:.+style-basic#@$commit% + %querying .+style-basic\.git%? + %fetching from .+style-basic.\git% + $warn + 1 package\(s\) in 1 repository\(s\) + EOE + } + + : refname + : + { + $clone_root_cfg && $rep_add "$rep/state0/style-basic.git#stable@$commit"; + + $* 2>>~"%EOE%" + %fetching git:.+style-basic#stable@$commit% + %querying .+style-basic\.git%? + %fetching from .+style-basic\.git% + $warn + 1 package\(s\) in 1 repository\(s\) + EOE + } +} diff --git a/tests/rep-fetch-git-refname.test b/tests/rep-fetch-git-refname.test deleted file mode 100644 index a6f9065..0000000 --- a/tests/rep-fetch-git-refname.test +++ /dev/null @@ -1,148 +0,0 @@ -# file : tests/rep-fetch-git-refname.test -# copyright : Copyright (c) 2014-2018 Code Synthesis Ltd -# license : MIT; see accompanying LICENSE file - -: fetch -: -{ - $clone_root_cfg && $rep_add "$rep/state0/libfoo.git$fragment"; - - if ($git_protocol == 'https-dumb') - warn = "$warn_ref_hist$reason_dumb$warn_dumb" - end; - - $* 2>>~"%EOE%" - %fetching git:.+libfoo$fragment% - %querying .+libfoo\.git% - %fetching from .+libfoo\.git% - $warn - 1 package\(s\) in 1 repository\(s\) - EOE -} - -: re-fetch -: -{ - : unchanged - : - { - $clone_root_cfg && $rep_add "$rep/state0/libfoo.git$fragment"; - - $* 2>!; - - $* 2>>~"%EOE%" - %fetching git:.+libfoo$fragment% - %querying .+libfoo\.git% - 1 package\(s\) in 1 repository\(s\) - EOE - } - - : changed - : - { - g = git -C - u = "$rep_git/state1" - d = cfg/libfoo-1.0.0 - - $clone_root_cfg && $rep_add "$rep/state0/libfoo.git$fragment"; - - # Extract the repository path from the output line like this: - # - # fetching from in 'cfg/.bpkg/tmp/4bde15f59461'... - # - $* --verbose 2 2>&1 | \ - sed -n -e "s/fetching from .+ in '\(.+\)'/\$1/p" | \ - sed -n -e 's%(.+[\\/])tmp([\\/].+)%$1repos$2%p' | \ - set r; - - # Note that the commit for doc/style/basic submodule is not at the branch - # tip and so is not advertised. - # - warn1 = '%.{0}'; - warn2 = '%.{0}'; - warn3 = '%.{0}'; - - if ($git_protocol == 'local' || \ - $git_protocol == 'https-smart' || \ - $git_protocol == 'git') - warn2 = "$warn_repo_hist for submodule 'doc/style/basic'$reason_unadv" - elif ($git_protocol == 'https-dumb') - warn1 = "$warn_ref_hist for submodule 'doc/style'$reason_dumb$warn_dumb" - warn2 = "$warn_repo_hist for submodule 'doc/style/basic'$reason_dumb$warn_dumb" - warn3 = "$warn_ref_hist for submodule 'libbar'$reason_dumb$warn_dumb" - end; - - $pkg_checkout libfoo/1.0.0 2>>~"%EOE%"; - checking out libfoo/1.0.0 - %querying .+style\.git%? - %fetching submodule 'doc/style' from .+style\.git% - $warn1 - %submodule path 'doc/style': checked out .+% - %querying .+style-basic\.git%? - %fetching submodule 'doc/style/basic' from .+style-basic\.git% - $warn2 - %submodule path 'doc/style/basic': checked out .+% - %querying .+libbar\.git%? - %fetching submodule 'libbar' from .+libbar\.git% - $warn3 - %submodule path 'libbar': checked out .+% - distributing libfoo/1.0.0 - checked out libfoo/1.0.0 - EOE - - $g "$r" config remote.origin.url "$u/libfoo.git"; - - # Preconditions. - # - test -f $d/tests/TODO; - test -f $d/libbar/libbar/manifest; - test -f $d/doc/style/README != 0; - test -d $d/libbaz != 0; - - if ($git_protocol == 'https-dumb') - warn = "$warn_ref_hist$reason_dumb$warn_dumb" - end; - - $* 2>>~"%EOE%" 1>&2; - %fetching git:.+libfoo$fragment% - %querying .+libfoo\.git% - %fetching from .+libfoo\.git% - $warn - %warning: unable to rmdir .?libbar.?: .+% - 1 package\(s\) in 1 repository\(s\) - EOE - - $pkg_drop libfoo; - - warn1 = '%.{0}'; - warn2 = '%.{0}'; - - if ($git_protocol == 'https-dumb') - warn1 = "$warn_ref_hist for submodule 'doc/style'$reason_dumb$warn_dumb" - warn2 = "$warn_ref_hist for submodule 'libbaz'$reason_dumb$warn_dumb" - end; - - $pkg_checkout libfoo/1.0.0 2>>~"%EOE%"; - checking out libfoo/1.0.0 - %querying .+style\.git%? - %fetching submodule 'doc/style' from .+style\.git% - $warn1 - %submodule path 'doc/style': checked out .+% - %querying .+libbaz\.git%? - %fetching submodule 'libbaz' from .+libbaz\.git% - $warn2 - %submodule path 'libbaz': checked out .+% - distributing libfoo/1.0.0 - checked out libfoo/1.0.0 - EOE - - # Postconditions. - # - test -d $d/tests != 0; - test -d $d/libbar != 0; - test -f $d/doc/style/README; - test -f $d/libbaz/manifest; - - $pkg_drop libfoo - } -} diff --git a/tests/rep-fetch-git-refname.testscript b/tests/rep-fetch-git-refname.testscript new file mode 100644 index 0000000..fe5b330 --- /dev/null +++ b/tests/rep-fetch-git-refname.testscript @@ -0,0 +1,148 @@ +# file : tests/rep-fetch-git-refname.testscript +# copyright : Copyright (c) 2014-2018 Code Synthesis Ltd +# license : MIT; see accompanying LICENSE file + +: fetch +: +{ + $clone_root_cfg && $rep_add "$rep/state0/libfoo.git$fragment"; + + if ($git_protocol == 'https-dumb') + warn = "$warn_ref_hist$reason_dumb$warn_dumb" + end; + + $* 2>>~"%EOE%" + %fetching git:.+libfoo$fragment% + %querying .+libfoo\.git% + %fetching from .+libfoo\.git% + $warn + 1 package\(s\) in 1 repository\(s\) + EOE +} + +: re-fetch +: +{ + : unchanged + : + { + $clone_root_cfg && $rep_add "$rep/state0/libfoo.git$fragment"; + + $* 2>!; + + $* 2>>~"%EOE%" + %fetching git:.+libfoo$fragment% + %querying .+libfoo\.git% + 1 package\(s\) in 1 repository\(s\) + EOE + } + + : changed + : + { + g = git -C + u = "$rep_git/state1" + d = cfg/libfoo-1.0.0 + + $clone_root_cfg && $rep_add "$rep/state0/libfoo.git$fragment"; + + # Extract the repository path from the output line like this: + # + # fetching from in 'cfg/.bpkg/tmp/4bde15f59461'... + # + $* --verbose 2 2>&1 | \ + sed -n -e "s/fetching from .+ in '\(.+\)'/\$1/p" | \ + sed -n -e 's%(.+[\\/])tmp([\\/].+)%$1repos$2%p' | \ + set r; + + # Note that the commit for doc/style/basic submodule is not at the branch + # tip and so is not advertised. + # + warn1 = '%.{0}'; + warn2 = '%.{0}'; + warn3 = '%.{0}'; + + if ($git_protocol == 'local' || \ + $git_protocol == 'https-smart' || \ + $git_protocol == 'git') + warn2 = "$warn_repo_hist for submodule 'doc/style/basic'$reason_unadv" + elif ($git_protocol == 'https-dumb') + warn1 = "$warn_ref_hist for submodule 'doc/style'$reason_dumb$warn_dumb" + warn2 = "$warn_repo_hist for submodule 'doc/style/basic'$reason_dumb$warn_dumb" + warn3 = "$warn_ref_hist for submodule 'libbar'$reason_dumb$warn_dumb" + end; + + $pkg_checkout libfoo/1.0.0 2>>~"%EOE%"; + checking out libfoo/1.0.0 + %querying .+style\.git%? + %fetching submodule 'doc/style' from .+style\.git% + $warn1 + %submodule path 'doc/style': checked out .+% + %querying .+style-basic\.git%? + %fetching submodule 'doc/style/basic' from .+style-basic\.git% + $warn2 + %submodule path 'doc/style/basic': checked out .+% + %querying .+libbar\.git%? + %fetching submodule 'libbar' from .+libbar\.git% + $warn3 + %submodule path 'libbar': checked out .+% + distributing libfoo/1.0.0 + checked out libfoo/1.0.0 + EOE + + $g "$r" config remote.origin.url "$u/libfoo.git"; + + # Preconditions. + # + test -f $d/tests/TODO; + test -f $d/libbar/libbar/manifest; + test -f $d/doc/style/README != 0; + test -d $d/libbaz != 0; + + if ($git_protocol == 'https-dumb') + warn = "$warn_ref_hist$reason_dumb$warn_dumb" + end; + + $* 2>>~"%EOE%" 1>&2; + %fetching git:.+libfoo$fragment% + %querying .+libfoo\.git% + %fetching from .+libfoo\.git% + $warn + %warning: unable to rmdir .?libbar.?: .+% + 1 package\(s\) in 1 repository\(s\) + EOE + + $pkg_drop libfoo; + + warn1 = '%.{0}'; + warn2 = '%.{0}'; + + if ($git_protocol == 'https-dumb') + warn1 = "$warn_ref_hist for submodule 'doc/style'$reason_dumb$warn_dumb" + warn2 = "$warn_ref_hist for submodule 'libbaz'$reason_dumb$warn_dumb" + end; + + $pkg_checkout libfoo/1.0.0 2>>~"%EOE%"; + checking out libfoo/1.0.0 + %querying .+style\.git%? + %fetching submodule 'doc/style' from .+style\.git% + $warn1 + %submodule path 'doc/style': checked out .+% + %querying .+libbaz\.git%? + %fetching submodule 'libbaz' from .+libbaz\.git% + $warn2 + %submodule path 'libbaz': checked out .+% + distributing libfoo/1.0.0 + checked out libfoo/1.0.0 + EOE + + # Postconditions. + # + test -d $d/tests != 0; + test -d $d/libbar != 0; + test -f $d/doc/style/README; + test -f $d/libbaz/manifest; + + $pkg_drop libfoo + } +} diff --git a/tests/rep-fetch-git.test b/tests/rep-fetch-git.test deleted file mode 100644 index 804fefc..0000000 --- a/tests/rep-fetch-git.test +++ /dev/null @@ -1,79 +0,0 @@ -# file : tests/rep-fetch-git.test -# copyright : Copyright (c) 2014-2018 Code Synthesis Ltd -# license : MIT; see accompanying LICENSE file - -# All tests use the same repository infrastructure present in the initial and -# the final states. See tests/common/git/init script for more details. -# - -reason_dumb = ' (dumb HTTP)' -reason_unadv = ' (unadvertised commit)' - -warn_dumb=' -warning: no progress will be shown (dumb HTTP)' - -warn_repo_hist = "warning: fetching whole repository history" -warn_ref_hist = "warning: fetching whole reference history" - -warn = '%.{0}' # None. - -test.cleanups += &cfg/.bpkg/repos/*/*** - -+if ($git_protocol == 'local') - rep = "$rep_git_local" -elif ($git_protocol == 'https-dumb') - rep = "$rep_git_https_dumb" -elif ($git_protocol == 'https-smart') - rep = "$rep_git_https_smart" -elif ($git_protocol == 'https-smart-unadv') - rep = "$rep_git_https_smart_unadv" -elif ($git_protocol == 'git') - rep = "$rep_git_git" -else - exit "unexpected git protocol '$git_protocol'" -end - -# Repository URL prefix for use with git commands. -# -# Note that git supports none of the standard 'file:' URL notations on Windows, -# so we produce one that is acceptable for git. -# -+if ($git_protocol == 'local' && $cxx.target.class == 'windows') - rep_git = "$regex.replace($rep, '^file:/', 'file://')" -else - rep_git = "$rep" -end - -: branch -: -{ - fragment = '#master' - .include rep-fetch-git-refname.test -} - -: ltag -: -{ - fragment = '#ltag' - .include rep-fetch-git-refname.test -} - -: atag -: -{ - fragment = '#atag' - .include rep-fetch-git-refname.test -} - -: list -: -{ - fragment = '#master,ltag,atag' - .include rep-fetch-git-refname.test -} - -: commit -: -{ - .include rep-fetch-git-commit.test -} diff --git a/tests/rep-fetch-git.testscript b/tests/rep-fetch-git.testscript new file mode 100644 index 0000000..3fe0287 --- /dev/null +++ b/tests/rep-fetch-git.testscript @@ -0,0 +1,79 @@ +# file : tests/rep-fetch-git.testscript +# copyright : Copyright (c) 2014-2018 Code Synthesis Ltd +# license : MIT; see accompanying LICENSE file + +# All tests use the same repository infrastructure present in the initial and +# the final states. See tests/common/git/init script for more details. +# + +reason_dumb = ' (dumb HTTP)' +reason_unadv = ' (unadvertised commit)' + +warn_dumb=' +warning: no progress will be shown (dumb HTTP)' + +warn_repo_hist = "warning: fetching whole repository history" +warn_ref_hist = "warning: fetching whole reference history" + +warn = '%.{0}' # None. + +test.cleanups += &cfg/.bpkg/repos/*/*** + ++if ($git_protocol == 'local') + rep = "$rep_git_local" +elif ($git_protocol == 'https-dumb') + rep = "$rep_git_https_dumb" +elif ($git_protocol == 'https-smart') + rep = "$rep_git_https_smart" +elif ($git_protocol == 'https-smart-unadv') + rep = "$rep_git_https_smart_unadv" +elif ($git_protocol == 'git') + rep = "$rep_git_git" +else + exit "unexpected git protocol '$git_protocol'" +end + +# Repository URL prefix for use with git commands. +# +# Note that git supports none of the standard 'file:' URL notations on Windows, +# so we produce one that is acceptable for git. +# ++if ($git_protocol == 'local' && $cxx.target.class == 'windows') + rep_git = "$regex.replace($rep, '^file:/', 'file://')" +else + rep_git = "$rep" +end + +: branch +: +{ + fragment = '#master' + .include rep-fetch-git-refname.testscript +} + +: ltag +: +{ + fragment = '#ltag' + .include rep-fetch-git-refname.testscript +} + +: atag +: +{ + fragment = '#atag' + .include rep-fetch-git-refname.testscript +} + +: list +: +{ + fragment = '#master,ltag,atag' + .include rep-fetch-git-refname.testscript +} + +: commit +: +{ + .include rep-fetch-git-commit.testscript +} diff --git a/tests/rep-fetch.test b/tests/rep-fetch.test deleted file mode 100644 index c7e9e0f..0000000 --- a/tests/rep-fetch.test +++ /dev/null @@ -1,977 +0,0 @@ -# file : tests/rep-fetch.test -# copyright : Copyright (c) 2014-2018 Code Synthesis Ltd -# license : MIT; see accompanying LICENSE file - -.include common.test auth.test config.test remote.test remote-git.test - -# Source repository: -# -# rep-fetch -# |-- bar -# | |-- stable -> ../foo/stable (prerequisite) -# | | |-- libbar-1.0.0.tar.gz -> libfoo >= 1.0.0 -# | | `-- repositories.manifest -# | |-- testing -> stable (complement), -# | | | ../foo/testing (prerequisite) -# | | |-- libbar-1.1.0.tar.gz -> libfoo >= 1.1.0 -# | | `-- repositories.manifest -# | `-- unstable -> testing (complement), -# | | ../foo/testing (prerequisite) -# | |-- libbar-1.1.1.tar.gz -> libfoo >= 1.1.0 -# | `-- repositories.manifest -# | -# |-- foo -# | |-- stable -# | | |-- libfoo-1.0.0.tar.gz -# | | `-- repositories.manifest -# | `-- testing -> stable (complement) -# | |-- libfoo-1.1.0.tar.gz -# | `-- repositories.manifest -# | -# `-- hello -# | |-- libhello-1.0.0.tar.gz -# | `-- repositories.manifest -# | -# |-- libhello-1.0.0 -# | |-- build -# | | |-- bootstrap.build -# | | |-- export.build -# | | `-- root.build -# | `-- * -# | -# |-- cycle -# | |-- extra -> stable (prerequisite) -# | | |-- libbar-1.1.0+1.tar.gz -# | | `-- repositories.manifest -# | |-- math -> extra (prerequisite) -# | | |-- libbar-1.0.0.tar.gz -# | | `-- repositories.manifest -# | `-- stable -> math (prerequisite) -# | |-- libfoo-1.0.0.tar.gz -# | `-- repositories.manifest -# | -# |-- no-cycle -# | |-- extra -# | | |-- libbar-1.1.0+1.tar.gz -# | | `-- repositories.manifest -# | |-- math -# | | |-- libbar-1.0.0.tar.gz -# | | `-- repositories.manifest -# | `-- stable -> extra (prerequisite) -# | |-- libfoo-1.0.0.tar.gz -# | `-- repositories.manifest -# | -# `-- git/* (see rep-fetch-git.test) - -# Prepare repositories used by tests if running in the local mode. -# -+if ($remote != true) - rep_create += 2>! - - # Create the signed 'hello' repository. - # - cp -r $src/hello $out/hello - cat <<<$cert_manifest >+$out/hello/repositories.manifest - - $rep_create --key $key $out/hello &$out/hello/packages.manifest \ - &$out/hello/signature.manifest - - # Create 'foo/*' repositories. - # - cp -r $src/foo $out/foo - - # Sign foo/stable repository. - # - cat <<<$cert_manifest >+$out/foo/stable/repositories.manifest - $rep_create --key $key $out/foo/stable &$out/foo/stable/packages.manifest \ - &$out/foo/stable/signature.manifest - - # Add dependent trust to foo complement repository into the foo/testing - # repository manifest. - # - tv = "trust: $cert_fp -:" - - sed -i -e "s/^\(:\)\$/$tv/" $out/foo/testing/repositories.manifest - - $rep_create $out/foo/testing &$out/foo/testing/packages.manifest - - # Create 'bar/*' repositories. - # - cp -r $src/bar $out/bar - $rep_create $out/bar/stable &$out/bar/stable/packages.manifest - $rep_create $out/bar/testing &$out/bar/testing/packages.manifest - $rep_create $out/bar/unstable &$out/bar/unstable/packages.manifest - - # Create 'cycle/*' repositories. - # - cp -r $src/cycle $out/cycle - $rep_create $out/cycle/extra &$out/cycle/extra/packages.manifest - $rep_create $out/cycle/math &$out/cycle/math/packages.manifest - $rep_create $out/cycle/stable &$out/cycle/stable/packages.manifest - - # Create git repositories. - # - $git_extract $src/git/state0/libfoo.tar - $git_extract $src/git/state0/libfox.tar - $git_extract $src/git/state0/libbar.tar - $git_extract $src/git/state0/style.tar - $git_extract $src/git/state0/style-basic.tar &$out_git/state0/*** - - $git_extract $src/git/state1/libfoo.tar - $git_extract $src/git/state1/libbaz.tar - $git_extract $src/git/state1/style.tar - $git_extract $src/git/state1/style-basic.tar &$out_git/state1/*** -end - -rep_add += -d cfg 2>! -rep_list += -d cfg --prerequisites --complements -rep_remove += -d cfg 2>! -pkg_status += -d cfg -pkg_fetch += -d cfg 2>! -pkg_unpack += -d cfg 2>! -pkg_checkout += -d cfg -pkg_purge += -d cfg -pkg_drop += -d cfg --yes 2>! - -: no-repos -: -$clone_cfg; -$* 2>>/EOE != 0 - error: configuration cfg/ has no repositories - info: use 'bpkg rep-add' to add a repository - EOE - -: pkg-rep -: -{ - test.options += --auth all - - : hello - : - { - $clone_root_cfg && $rep_add $rep/hello; - - $* --trust $cert_fp 2>>EOE &cfg/.bpkg/certs/**; - fetching pkg:build2.org/rep-fetch/hello - 1 package(s) in 1 repository(s) - EOE - - $* 2>>EOE - fetching pkg:build2.org/rep-fetch/hello - 1 package(s) in 1 repository(s) - EOE - } - - : bar-unstable - : - { - $clone_root_cfg && $rep_add $rep/bar/unstable; - - $* --trust-yes 2>>EOE &cfg/.bpkg/certs/**; - fetching pkg:build2.org/rep-fetch/bar/unstable - fetching pkg:build2.org/rep-fetch/bar/testing (complements pkg:build2.org/rep-fetch/bar/unstable) - fetching pkg:build2.org/rep-fetch/bar/stable (complements pkg:build2.org/rep-fetch/bar/testing) - fetching pkg:build2.org/rep-fetch/foo/stable (prerequisite of pkg:build2.org/rep-fetch/bar/stable) - fetching pkg:build2.org/rep-fetch/foo/testing (prerequisite of pkg:build2.org/rep-fetch/bar/testing) - 5 package(s) in 5 repository(s) - EOE - - $* 2>>EOE - fetching pkg:build2.org/rep-fetch/bar/unstable - fetching pkg:build2.org/rep-fetch/bar/testing (complements pkg:build2.org/rep-fetch/bar/unstable) - fetching pkg:build2.org/rep-fetch/bar/stable (complements pkg:build2.org/rep-fetch/bar/testing) - fetching pkg:build2.org/rep-fetch/foo/stable (prerequisite of pkg:build2.org/rep-fetch/bar/stable) - fetching pkg:build2.org/rep-fetch/foo/testing (prerequisite of pkg:build2.org/rep-fetch/bar/testing) - 5 package(s) in 5 repository(s) - EOE - } - - : both - : - { - $clone_root_cfg && $rep_add $rep/hello $rep/bar/unstable; - - $* --trust-yes 2>>EOE &cfg/.bpkg/certs/**; - fetching pkg:build2.org/rep-fetch/bar/unstable - fetching pkg:build2.org/rep-fetch/bar/testing (complements pkg:build2.org/rep-fetch/bar/unstable) - fetching pkg:build2.org/rep-fetch/bar/stable (complements pkg:build2.org/rep-fetch/bar/testing) - fetching pkg:build2.org/rep-fetch/foo/stable (prerequisite of pkg:build2.org/rep-fetch/bar/stable) - fetching pkg:build2.org/rep-fetch/foo/testing (prerequisite of pkg:build2.org/rep-fetch/bar/testing) - fetching pkg:build2.org/rep-fetch/hello - 6 package(s) in 6 repository(s) - EOE - - $* 2>>EOE - fetching pkg:build2.org/rep-fetch/bar/unstable - fetching pkg:build2.org/rep-fetch/bar/testing (complements pkg:build2.org/rep-fetch/bar/unstable) - fetching pkg:build2.org/rep-fetch/bar/stable (complements pkg:build2.org/rep-fetch/bar/testing) - fetching pkg:build2.org/rep-fetch/foo/stable (prerequisite of pkg:build2.org/rep-fetch/bar/stable) - fetching pkg:build2.org/rep-fetch/foo/testing (prerequisite of pkg:build2.org/rep-fetch/bar/testing) - fetching pkg:build2.org/rep-fetch/hello - 6 package(s) in 6 repository(s) - EOE - } - - : location-args - : - { - $clone_root_cfg; - - $* --trust-yes $rep/bar/unstable 2>>EOE &cfg/.bpkg/certs/**; - added pkg:build2.org/rep-fetch/bar/unstable - fetching pkg:build2.org/rep-fetch/bar/testing (complements pkg:build2.org/rep-fetch/bar/unstable) - fetching pkg:build2.org/rep-fetch/bar/stable (complements pkg:build2.org/rep-fetch/bar/testing) - fetching pkg:build2.org/rep-fetch/foo/stable (prerequisite of pkg:build2.org/rep-fetch/bar/stable) - fetching pkg:build2.org/rep-fetch/foo/testing (prerequisite of pkg:build2.org/rep-fetch/bar/testing) - 5 package(s) in 5 repository(s) - EOE - - $* 'pkg:build2.org/rep-fetch/bar/unstable' 2>>EOE; - fetching pkg:build2.org/rep-fetch/bar/testing (complements pkg:build2.org/rep-fetch/bar/unstable) - fetching pkg:build2.org/rep-fetch/bar/stable (complements pkg:build2.org/rep-fetch/bar/testing) - fetching pkg:build2.org/rep-fetch/foo/stable (prerequisite of pkg:build2.org/rep-fetch/bar/stable) - fetching pkg:build2.org/rep-fetch/foo/testing (prerequisite of pkg:build2.org/rep-fetch/bar/testing) - 5 package(s) in 5 repository(s) - EOE - - $rep_list >>"EOO" - pkg:build2.org/rep-fetch/bar/unstable ($rep/bar/unstable) - complement pkg:build2.org/rep-fetch/bar/testing ($rep/bar/testing) - complement pkg:build2.org/rep-fetch/bar/stable ($rep/bar/stable) - prerequisite pkg:build2.org/rep-fetch/foo/stable ($rep/foo/stable) - prerequisite pkg:build2.org/rep-fetch/foo/testing ($rep/foo/testing) - complement pkg:build2.org/rep-fetch/foo/stable ($rep/foo/stable) - prerequisite pkg:build2.org/rep-fetch/foo/testing ($rep/foo/testing) - complement pkg:build2.org/rep-fetch/foo/stable ($rep/foo/stable) - EOO - } - - : prerequisites-cycle - : - { - $clone_root_cfg; - - $* --trust-yes $rep/cycle/stable 2>>EOE; - added pkg:build2.org/rep-fetch/cycle/stable - fetching pkg:build2.org/rep-fetch/cycle/math (prerequisite of pkg:build2.org/rep-fetch/cycle/stable) - fetching pkg:build2.org/rep-fetch/cycle/extra (prerequisite of pkg:build2.org/rep-fetch/cycle/math) - 3 package(s) in 3 repository(s) - EOE - - $rep_list >>"EOO" - pkg:build2.org/rep-fetch/cycle/stable ($rep/cycle/stable) - prerequisite pkg:build2.org/rep-fetch/cycle/math ($rep/cycle/math) - prerequisite pkg:build2.org/rep-fetch/cycle/extra ($rep/cycle/extra) - prerequisite pkg:build2.org/rep-fetch/cycle/stable ($rep/cycle/stable) - EOO - } - - : unreferenced-prerequisite - : - { - +$clone_root_cfg - - # Create the no-cycle repository as the new state of the cycle repository. - # The cycle dependency is now broken (extra/ doesn't depend on stable/ - # anymore) and the extra/ prerequisite is moved from math/ to stable/. - # - nc_rep = [dir_path] $~/pkg/1/build2.org/rep-fetch/cycle/ - +mkdir -p $path.directory($nc_rep) - +cp -r $src/no-cycle "$nc_rep" # Strip trailing slash. - - +$rep_create $nc_rep/extra 2>! &$nc_rep/extra/packages.manifest - +$rep_create $nc_rep/math 2>! &$nc_rep/math/packages.manifest - +$rep_create $nc_rep/stable 2>! &$nc_rep/stable/packages.manifest - - math_rep = $nc_rep/math - stable_rep = $nc_rep/stable - - : remove - : - { - $clone_cfg; - - $* --trust-yes $rep/cycle/stable 2>>EOE; - added pkg:build2.org/rep-fetch/cycle/stable - fetching pkg:build2.org/rep-fetch/cycle/math (prerequisite of pkg:build2.org/rep-fetch/cycle/stable) - fetching pkg:build2.org/rep-fetch/cycle/extra (prerequisite of pkg:build2.org/rep-fetch/cycle/math) - 3 package(s) in 3 repository(s) - EOE - - $* --trust-yes $stable_rep 2>>EOE; - updated pkg:build2.org/rep-fetch/cycle/stable - fetching pkg:build2.org/rep-fetch/cycle/extra (prerequisite of pkg:build2.org/rep-fetch/cycle/stable) - 2 package(s) in 2 repository(s) - EOE - - $rep_list >>"EOO" - pkg:build2.org/rep-fetch/cycle/stable ($nc_rep/stable) - prerequisite pkg:build2.org/rep-fetch/cycle/extra ($nc_rep/extra) - EOO - } - - : no-remove - : - { - $clone_cfg; - - $* --trust-yes $rep/cycle/stable 2>>EOE; - added pkg:build2.org/rep-fetch/cycle/stable - fetching pkg:build2.org/rep-fetch/cycle/math (prerequisite of pkg:build2.org/rep-fetch/cycle/stable) - fetching pkg:build2.org/rep-fetch/cycle/extra (prerequisite of pkg:build2.org/rep-fetch/cycle/math) - 3 package(s) in 3 repository(s) - EOE - - $* --trust-yes $math_rep $stable_rep 2>>EOE; - added pkg:build2.org/rep-fetch/cycle/math - updated pkg:build2.org/rep-fetch/cycle/stable - fetching pkg:build2.org/rep-fetch/cycle/math - fetching pkg:build2.org/rep-fetch/cycle/stable - fetching pkg:build2.org/rep-fetch/cycle/extra (prerequisite of pkg:build2.org/rep-fetch/cycle/stable) - 3 package(s) in 3 repository(s) - EOE - - $rep_list >>"EOO" - pkg:build2.org/rep-fetch/cycle/math ($nc_rep/math) - pkg:build2.org/rep-fetch/cycle/stable ($nc_rep/stable) - prerequisite pkg:build2.org/rep-fetch/cycle/extra ($nc_rep/extra) - EOO - } - } - - : use-auth - : - { - : dependent-trust - : - : Test that the certificate of foo/stable complement repository is - : silently authenticated for use by the dependent foo/testing repository. - : In this case the certificate is not saved into the database (see the - : subsequent 'rep-fetch $rep/foo/stable' test) and certificate file is not - : persisted (otherwise cleanup of non-empty cfg/ directory would fail). - : - { - $clone_root_cfg; - - $* --verbose 2 $rep/foo/testing <'y' 2>>~%EOE%; - added pkg:build2.org/rep-fetch/foo/testing - %.* - warning: repository pkg:build2.org/rep-fetch/foo/testing is unsigned - %continue without authenticating repositories at .+\? \[y/n\] .+% - %.+ - info: certificate for repository pkg:build2.org/rep-fetch/foo/stable authenticated by dependent trust - %.+ - 2 package(s) in 2 repository(s) - EOE - - $* $rep/foo/stable 2>>~%EOE% != 0 - %.+ - warning: authenticity of the certificate for repository pkg:build2.org/rep-fetch/foo/stable cannot be established - %.+ - EOE - } - - : dependent-command-line - : - : Test that the certificate of foo/stable complement repository is - : authenticated for use by the command line (persisted into the database - : and the filesystem) rather than dependent trust. - : - { - $clone_root_cfg; - - $* --trust $cert_fp --verbose 2 $rep/foo/testing <'y' 2>>~%EOE% &cfg/.bpkg/certs/** - added pkg:build2.org/rep-fetch/foo/testing - %.* - warning: repository pkg:build2.org/rep-fetch/foo/testing is unsigned - %continue without authenticating repositories at .+\? \[y/n\] .+% - %.+ - info: certificate for repository pkg:build2.org/rep-fetch/foo/stable authenticated by command line - %.+ - 2 package(s) in 2 repository(s) - EOE - } - - : dependent-trust-prompt - : - : Test that the certificate of foo/stable repository is first authenticated - : for use by the dependent foo/test repository and then by the user (via - : the prompt) as a top-level repository during a single rep-fetch - : operation. - : - { - yy = 'y -y' - $clone_root_cfg; - - $* --verbose 2 $rep/foo/testing $rep/foo/stable <$yy 2>>~%EOE% &cfg/.bpkg/certs/** - added pkg:build2.org/rep-fetch/foo/testing - added pkg:build2.org/rep-fetch/foo/stable - fetching pkg:build2.org/rep-fetch/foo/testing - %.* - warning: repository pkg:build2.org/rep-fetch/foo/testing is unsigned - %continue without authenticating repositories at .+\? \[y/n\] .+% - %.+ - info: certificate for repository pkg:build2.org/rep-fetch/foo/stable authenticated by dependent trust - %.+ - warning: authenticity of the certificate for repository pkg:build2.org/rep-fetch/foo/stable cannot be established - certificate is for build2.org, "Code Synthesis" - %.+ - %.+2 package\(s\) in 2 repository\(s\)% - EOE - } - - : command-line-dependent-noop - : - : Test that the certificate of foo/stable repository is first authenticated - : by the user (via the command line) as a top-level repository and so - : authentication for use by the dependent foo/test is noop. - : - { - $clone_root_cfg; - - $* --trust $cert_fp --verbose 2 $rep/foo/stable $rep/foo/testing <'y' 2>>~%EOE% &cfg/.bpkg/certs/** - added pkg:build2.org/rep-fetch/foo/stable - added pkg:build2.org/rep-fetch/foo/testing - fetching pkg:build2.org/rep-fetch/foo/stable - %.+ - info: certificate for repository pkg:build2.org/rep-fetch/foo/stable authenticated by command line - %.+ - fetching pkg:build2.org/rep-fetch/foo/testing - %.* - warning: repository pkg:build2.org/rep-fetch/foo/testing is unsigned - %continue without authenticating repositories at .+\? \[y/n\] .+% - %.* - 2 package(s) in 2 repository(s) - EOE - } - } -} - -: dir-rep -: -: For dir repository tests we will reuse local git repositories, that have the -: same repository structure. -: -if ($remote != true) -{ - rep_add += --type dir - - +cp -r $out_git/state0 $~/state0 - - rep = $canonicalize([dir_path] $~/state0) - - +cat <= $rep/libbar.git/repositories.manifest - : 1 - role: prerequisite - type: dir - location: ../style-basic.git - EOI - - +$clone_cfg && $rep_add $rep/libbar.git - - : prerequisites - : - { - $clone_cfg; - - $* 2>>"EOE"; - fetching dir:($rep/libbar.git) - fetching dir:($rep/style-basic.git) \(prerequisite of dir:($rep/libbar.git)\) - 3 package\(s\) in 2 repository\(s\) - EOE - - $rep_list >>"EOO" - dir:($rep/libbar.git) ($rep/libbar.git) - prerequisite dir:($rep/style-basic.git) ($rep/style-basic.git) - EOO - } - - : by-name - : - : Here we, in particular, test that the local repository canonical name - : (dir:/...) is not confused with the repository URL. - : - { - $clone_cfg; - $* 2>!; - - $* "dir:($rep/libbar.git)" 2>>"EOE"; - fetching dir:($rep/style-basic.git) \(prerequisite of dir:($rep/libbar.git)\) - 3 package\(s\) in 2 repository\(s\) - EOE - - $rep_list >>"EOO" - dir:($rep/libbar.git) ($rep/libbar.git) - prerequisite dir:($rep/style-basic.git) ($rep/style-basic.git) - EOO - } - - : shallow - : - { - +$clone_cfg - - : respected - : - { - $clone_cfg; - $* 2>!; - - $* --shallow "dir:($rep/libbar.git)" 2>>"EOE"; - 3 package\(s\) in 2 repository\(s\) - EOE - - $rep_list >>"EOO" - dir:($rep/libbar.git) ($rep/libbar.git) - prerequisite dir:($rep/style-basic.git) ($rep/style-basic.git) - EOO - } - - : ignored - : - { - $clone_cfg; - - $* --shallow 2>>"EOE"; - fetching dir:($rep/libbar.git) - fetching dir:($rep/style-basic.git) \(prerequisite of dir:($rep/libbar.git)\) - 3 package\(s\) in 2 repository\(s\) - EOE - - $rep_list >>"EOO" - dir:($rep/libbar.git) ($rep/libbar.git) - prerequisite dir:($rep/style-basic.git) ($rep/style-basic.git) - EOO - } - } -} - -: iter -: -{ - rep_add += --type dir - - : multiple-repos - : - { - cp -r $src/libhello-1.0.0 libhello1; - cp -r $src/libhello-1.0.0 libhello2; - - $clone_root_cfg && $rep_add libhello1 libhello2; - - $* 2>>~%EOE% != 0 - %fetching dir:.+libhello1% - %fetching dir:.+libhello2% - error: external package libhello/1.0.0 is available from two repositories - % info: repository .+libhello1% - % info: repository .+libhello2% - EOE - } - - : inc - : - { - : path-changed - : - { - $clone_root_cfg && $rep_add $src/libhello-1.0.0; - - $* 2>!; - $pkg_unpack libhello/1.0.0; - - $rep_remove --all; - - cp -r $src/libhello-1.0.0 libhello; - $rep_add libhello; - - $* 2>!; - - $pkg_status libhello >'libhello unpacked 1.0.0 available 1.0.0#1' - } - - : manifest-changed - : - { - cp -r $src/libhello-1.0.0 libhello; - - $clone_root_cfg && $rep_add libhello; - - $* 2>!; - $pkg_unpack libhello/1.0.0; - - echo "" >+ libhello/manifest; - $* 2>!; - - $pkg_status libhello >'libhello unpacked 1.0.0 available 1.0.0#1' - } - - : pkg-rep - { - +$clone_root_cfg - - +$* --auth all --trust-yes $rep/hello &cfg/.bpkg/certs/** 2>! - +$pkg_fetch libhello/1.0.0 - +$pkg_unpack libhello - - : unchanged-external - : - { - $clone_cfg && $rep_add $src/libhello-1.0.0; - $* 2>!; - - $pkg_status libhello >'libhello unpacked 1.0.0' - } - - : changed-external - : - { - cp -r $src/libhello-1.0.0 libhello; - echo "" >+ libhello/manifest; - - $clone_cfg && $rep_add libhello; - $* 2>!; - - $pkg_status libhello >'libhello unpacked 1.0.0 available 1.0.0#1' - } - - -$pkg_purge libhello 2>'purged libhello/1.0.0' - } - - : git-rep - : - if ($git_supported == true && $remote != true) - { - rep = $canonicalize([dir_path] $out_git/state0); - - $clone_root_cfg; - - $* "$rep/style.git#master" 2>! &cfg/.bpkg/repos/*/***; - - # Convert specific warnings to infos as we expect them to appear. This, - # in particular, prevents bbot workers to set task result status to - # warning. - # - $pkg_checkout "style/1.0.0" 2>&1 | \ - sed -e 's/warning: (fetching (over|whole) .*)/info: \1/' >&2 2>!; - - $rep_add $rep/style.git; - $* 2>!; - - $pkg_status style >"style unpacked 1.0.0"; - - $pkg_purge style 2>"purged style/1.0.0" - } - } - - : no-inc - : - { - $clone_root_cfg; - - $pkg_unpack -e $src/libhello-1.0.0; - - $rep_add $src/libhello-1.0.0; - - $* 2>>~%EOE%; - %fetching dir:.+libhello-1.0.0% - 1 package(s) in 1 repository(s) - EOE - - $pkg_status libhello >'libhello unpacked 1.0.0' - } -} - -: git-rep -: -if ($git_supported != true) -{ - # Skip git repository tests. - # -} -else -{ - : proto - : - if ($remote != true) - { - git_protocol = 'local' - .include rep-fetch-git.test - } - else - { - : https-dumb - : - { - git_protocol = 'https-dumb' - .include rep-fetch-git.test - } - - : https-smart - : - { - git_protocol = 'https-smart' - .include rep-fetch-git.test - } - - : https-smart-unadv - : - { - git_protocol = 'https-smart-unadv' - .include rep-fetch-git.test - } - - : git - : - { - git_protocol = 'git' - .include rep-fetch-git.test - } - } - - : strip-ext - : - : Test that if the local prerequisite git repository having the .git - : extension does not exist but the one without the extension does, then - : it is picked up by rep-fetch. - : - if ($remote != true) - { - cp -r $out_git/state0/libbar.git libbar.git; - cp -r $out_git/state0/style-basic.git style-basic; - - $clone_root_cfg; - - rep = ($cxx.target.class != 'windows' \ - ? "file:$~" \ - : "file:/$regex.replace($~, '\\', '/')"); - - $* "$rep/libbar.git#master" 2>>~%EOE% &cfg/.bpkg/repos/*/***; - %added git:.+libbar#master% - %querying .+libbar\.git% - %fetching from .+libbar\.git% - %fetching git:.+style-basic#stable \(prerequisite of git:.+libbar#master\)% - %querying .+style-basic% - %fetching from .+style-basic% - 3 package(s) in 2 repository(s) - EOE - - $rep_list >>~%EOO% - %git:.+libbar#master file:.+libbar\.git#master% - % prerequisite git:.+style-basic#stable file:.+style-basic#stable \(heads/master\)% - EOO - } - - : checkout-submodules - : - : Test that if some of the packages are located in the repository - : submodules directory, then rep-fetch checks out submoodules. - : - { - $clone_root_cfg && $rep_add "$rep_git/state0/libfox.git#master"; - - $* 2>>~%EOE% &cfg/.bpkg/repos/*/*** - %fetching git:.+libfox#master% - %querying .+libfox\.git% - %fetching from .+libfox\.git% - %warning: .+%{0,2} - %querying .+libbar\.git%? - %fetching submodule 'libbar' from .+libbar\.git% - %warning: .+%{0,2} - %submodule path 'libbar': checked out '.+'% - 2 package(s) in 1 repository(s) - EOE - } - - : re-fetching - : - : Test that repository is re-fetched on the location change. Here it happens - : due to the scheme change. - : - if ($remote == true) - { - $clone_root_cfg && $rep_add "$rep_git_git/state0/libfoo.git#master"; - $* 2>! &cfg/.bpkg/repos/*/***; - $rep_add "$rep_git_https_smart_unadv/state0/libfoo.git#master"; - - $* 2>>~%EOE% - %fetching git:.+libfoo#master% - %info: location changed for git:.+libfoo#master% - % info: new location https://.+libfoo\.git#master% - % info: old location git://.+libfoo\.git#master% - %querying .+libfoo\.git% - 1 package(s) in 1 repository(s) - EOE - } - - : cleanup-failed - : - : Test that configuration is cleaned up if fetch fails after the repository - : filesystem state is changed. - : - { - $clone_root_cfg && $rep_add "$rep_git/state0/libfoo.git#master"; - - # Extract the repository path from the output line like this: - # - # fetching from in 'cfg/.bpkg/tmp/4bde15f59461'... - # - $* --verbose 2 2>&1 | \ - sed -n -e "s/fetching from .+ in '\(.+\)'/\$1/p" | \ - sed -n -e 's%(.+[\\/])tmp([\\/].+)%$1repos$2%p' | \ - set r; - - # Break the repo (drop the remote repository URL) and try to re-fetch. - # - rm "$r/.git/config"; - - $* 2>>~%EOE% != 0; - %.+ - warning: repository state is now broken and will be cleaned up - info: run 'bpkg rep-fetch' to update - EOE - - $pkg_status libfoo >'libfoo unknown' - } - - : ref-filters - : - { - test.cleanups += &?cfg/.bpkg/repos/*/*** - - : pattern - : - { - : matching - : - { - $clone_root_cfg; - - $* "$rep_git/state0/libfoo.git#v**" 2>>~%EOE% - %added .+libfoo#v\*\*% - %querying .+libfoo\.git% - %fetching from .+libfoo\.git% - %warning: .+%{0,2} - 2 package(s) in 1 repository(s) - EOE - } - - : non-matching - : - { - $clone_root_cfg; - - $* "$rep_git/state0/libfoo.git#tags/mast*" 2>>~%EOE% - %added .+libfoo#tags/mast\*% - %querying .+libfoo\.git% - 0 package(s) in 1 repository(s) - EOE - } - } - - : name - : - { - : non-matching - : - { - $clone_root_cfg; - - $* "$rep_git/state0/libfoo.git#foo" 2>>~%EOE% != 0 - %added .+libfoo#foo% - %querying .+libfoo\.git% - error: reference 'foo' is not found - EOE - } - } - - : commit - : - { - : non-matching-pattern - : - { - $clone_root_cfg; - - $* "$rep_git/state0/libfoo.git#foo*@9ab039761936802d61b8e591d6812a4dd4605029" 2>>~%EOE% != 0 - %added .+libfoo#foo\*@9ab039761936802d61b8e591d6812a4dd4605029% - %querying .+libfoo\.git% - error: no names match pattern 'foo*' - EOE - } - - : unexisting - : - { - $clone_root_cfg; - - $* "$rep_git/state0/libfoo.git#9ab039761936802d61b8e591d6812a4dd4605029" 2>>~%EOE% != 0 - %added .+libfoo#9ab039761936802d61b8e591d6812a4dd4605029% - %querying .+libfoo\.git% - %fetching from .+libfoo\.git% - %warning: .+%{0,2} - error: unable to fetch commit 9ab039761936802d61b8e591d6812a4dd4605029 - EOE - } - } - - : exclusion - : - { - $clone_root_cfg; - - $* "$rep_git/state0/libfoo.git#mast*,-master" 2>>~%EOE% - %added .+libfoo#mast\*,-master% - %querying .+libfoo\.git% - 0 package(s) in 1 repository(s) - EOE - } - - : inclusion - : - { - $clone_root_cfg; - - $* "$rep_git/state0/libfoo.git#tags/mast*,+master" 2>>~%EOE% - %added .+libfoo#tags/mast\*,\+master% - %querying .+libfoo\.git% - %fetching from .+libfoo\.git% - %warning: .+%{0,2} - 1 package(s) in 1 repository(s) - EOE - } - - : default - : - { - : no-fragment - : - { - $clone_root_cfg; - - $* "$rep_git/state0/libfoo.git" 2>>~%EOE% - %added .+libfoo% - %querying .+libfoo\.git% - %fetching from .+libfoo\.git% - %warning: .+%{0,2} - 2 package(s) in 1 repository(s) - EOE - } - - : with-exclusion - : - { - $clone_root_cfg; - - $* "$rep_git/state0/libfoo.git##-/tags/v1*" 2>>~%EOE% - %added .+libfoo##-/tags/v1\*% - %querying .+libfoo\.git% - %fetching from .+libfoo\.git% - %warning: .+%{0,2} - 1 package(s) in 1 repository(s) - EOE - } - } - } -} diff --git a/tests/rep-fetch.testscript b/tests/rep-fetch.testscript new file mode 100644 index 0000000..c1828a8 --- /dev/null +++ b/tests/rep-fetch.testscript @@ -0,0 +1,981 @@ +# file : tests/rep-fetch.testscript +# copyright : Copyright (c) 2014-2018 Code Synthesis Ltd +# license : MIT; see accompanying LICENSE file + +.include common.testscript \ + auth.testscript \ + config.testscript \ + remote.testscript \ + remote-git.testscript + +# Source repository: +# +# rep-fetch +# |-- bar +# | |-- stable -> ../foo/stable (prerequisite) +# | | |-- libbar-1.0.0.tar.gz -> libfoo >= 1.0.0 +# | | `-- repositories.manifest +# | |-- testing -> stable (complement), +# | | | ../foo/testing (prerequisite) +# | | |-- libbar-1.1.0.tar.gz -> libfoo >= 1.1.0 +# | | `-- repositories.manifest +# | `-- unstable -> testing (complement), +# | | ../foo/testing (prerequisite) +# | |-- libbar-1.1.1.tar.gz -> libfoo >= 1.1.0 +# | `-- repositories.manifest +# | +# |-- foo +# | |-- stable +# | | |-- libfoo-1.0.0.tar.gz +# | | `-- repositories.manifest +# | `-- testing -> stable (complement) +# | |-- libfoo-1.1.0.tar.gz +# | `-- repositories.manifest +# | +# `-- hello +# | |-- libhello-1.0.0.tar.gz +# | `-- repositories.manifest +# | +# |-- libhello-1.0.0 +# | |-- build +# | | |-- bootstrap.build +# | | |-- export.build +# | | `-- root.build +# | `-- * +# | +# |-- cycle +# | |-- extra -> stable (prerequisite) +# | | |-- libbar-1.1.0+1.tar.gz +# | | `-- repositories.manifest +# | |-- math -> extra (prerequisite) +# | | |-- libbar-1.0.0.tar.gz +# | | `-- repositories.manifest +# | `-- stable -> math (prerequisite) +# | |-- libfoo-1.0.0.tar.gz +# | `-- repositories.manifest +# | +# |-- no-cycle +# | |-- extra +# | | |-- libbar-1.1.0+1.tar.gz +# | | `-- repositories.manifest +# | |-- math +# | | |-- libbar-1.0.0.tar.gz +# | | `-- repositories.manifest +# | `-- stable -> extra (prerequisite) +# | |-- libfoo-1.0.0.tar.gz +# | `-- repositories.manifest +# | +# `-- git/* (see rep-fetch-git.testscript) + +# Prepare repositories used by tests if running in the local mode. +# ++if ($remote != true) + rep_create += 2>! + + # Create the signed 'hello' repository. + # + cp -r $src/hello $out/hello + cat <<<$cert_manifest >+$out/hello/repositories.manifest + + $rep_create --key $key $out/hello &$out/hello/packages.manifest \ + &$out/hello/signature.manifest + + # Create 'foo/*' repositories. + # + cp -r $src/foo $out/foo + + # Sign foo/stable repository. + # + cat <<<$cert_manifest >+$out/foo/stable/repositories.manifest + $rep_create --key $key $out/foo/stable &$out/foo/stable/packages.manifest \ + &$out/foo/stable/signature.manifest + + # Add dependent trust to foo complement repository into the foo/testing + # repository manifest. + # + tv = "trust: $cert_fp +:" + + sed -i -e "s/^\(:\)\$/$tv/" $out/foo/testing/repositories.manifest + + $rep_create $out/foo/testing &$out/foo/testing/packages.manifest + + # Create 'bar/*' repositories. + # + cp -r $src/bar $out/bar + $rep_create $out/bar/stable &$out/bar/stable/packages.manifest + $rep_create $out/bar/testing &$out/bar/testing/packages.manifest + $rep_create $out/bar/unstable &$out/bar/unstable/packages.manifest + + # Create 'cycle/*' repositories. + # + cp -r $src/cycle $out/cycle + $rep_create $out/cycle/extra &$out/cycle/extra/packages.manifest + $rep_create $out/cycle/math &$out/cycle/math/packages.manifest + $rep_create $out/cycle/stable &$out/cycle/stable/packages.manifest + + # Create git repositories. + # + $git_extract $src/git/state0/libfoo.tar + $git_extract $src/git/state0/libfox.tar + $git_extract $src/git/state0/libbar.tar + $git_extract $src/git/state0/style.tar + $git_extract $src/git/state0/style-basic.tar &$out_git/state0/*** + + $git_extract $src/git/state1/libfoo.tar + $git_extract $src/git/state1/libbaz.tar + $git_extract $src/git/state1/style.tar + $git_extract $src/git/state1/style-basic.tar &$out_git/state1/*** +end + +rep_add += -d cfg 2>! +rep_list += -d cfg --prerequisites --complements +rep_remove += -d cfg 2>! +pkg_status += -d cfg +pkg_fetch += -d cfg 2>! +pkg_unpack += -d cfg 2>! +pkg_checkout += -d cfg +pkg_purge += -d cfg +pkg_drop += -d cfg --yes 2>! + +: no-repos +: +$clone_cfg; +$* 2>>/EOE != 0 + error: configuration cfg/ has no repositories + info: use 'bpkg rep-add' to add a repository + EOE + +: pkg-rep +: +{ + test.options += --auth all + + : hello + : + { + $clone_root_cfg && $rep_add $rep/hello; + + $* --trust $cert_fp 2>>EOE &cfg/.bpkg/certs/**; + fetching pkg:build2.org/rep-fetch/hello + 1 package(s) in 1 repository(s) + EOE + + $* 2>>EOE + fetching pkg:build2.org/rep-fetch/hello + 1 package(s) in 1 repository(s) + EOE + } + + : bar-unstable + : + { + $clone_root_cfg && $rep_add $rep/bar/unstable; + + $* --trust-yes 2>>EOE &cfg/.bpkg/certs/**; + fetching pkg:build2.org/rep-fetch/bar/unstable + fetching pkg:build2.org/rep-fetch/bar/testing (complements pkg:build2.org/rep-fetch/bar/unstable) + fetching pkg:build2.org/rep-fetch/bar/stable (complements pkg:build2.org/rep-fetch/bar/testing) + fetching pkg:build2.org/rep-fetch/foo/stable (prerequisite of pkg:build2.org/rep-fetch/bar/stable) + fetching pkg:build2.org/rep-fetch/foo/testing (prerequisite of pkg:build2.org/rep-fetch/bar/testing) + 5 package(s) in 5 repository(s) + EOE + + $* 2>>EOE + fetching pkg:build2.org/rep-fetch/bar/unstable + fetching pkg:build2.org/rep-fetch/bar/testing (complements pkg:build2.org/rep-fetch/bar/unstable) + fetching pkg:build2.org/rep-fetch/bar/stable (complements pkg:build2.org/rep-fetch/bar/testing) + fetching pkg:build2.org/rep-fetch/foo/stable (prerequisite of pkg:build2.org/rep-fetch/bar/stable) + fetching pkg:build2.org/rep-fetch/foo/testing (prerequisite of pkg:build2.org/rep-fetch/bar/testing) + 5 package(s) in 5 repository(s) + EOE + } + + : both + : + { + $clone_root_cfg && $rep_add $rep/hello $rep/bar/unstable; + + $* --trust-yes 2>>EOE &cfg/.bpkg/certs/**; + fetching pkg:build2.org/rep-fetch/bar/unstable + fetching pkg:build2.org/rep-fetch/bar/testing (complements pkg:build2.org/rep-fetch/bar/unstable) + fetching pkg:build2.org/rep-fetch/bar/stable (complements pkg:build2.org/rep-fetch/bar/testing) + fetching pkg:build2.org/rep-fetch/foo/stable (prerequisite of pkg:build2.org/rep-fetch/bar/stable) + fetching pkg:build2.org/rep-fetch/foo/testing (prerequisite of pkg:build2.org/rep-fetch/bar/testing) + fetching pkg:build2.org/rep-fetch/hello + 6 package(s) in 6 repository(s) + EOE + + $* 2>>EOE + fetching pkg:build2.org/rep-fetch/bar/unstable + fetching pkg:build2.org/rep-fetch/bar/testing (complements pkg:build2.org/rep-fetch/bar/unstable) + fetching pkg:build2.org/rep-fetch/bar/stable (complements pkg:build2.org/rep-fetch/bar/testing) + fetching pkg:build2.org/rep-fetch/foo/stable (prerequisite of pkg:build2.org/rep-fetch/bar/stable) + fetching pkg:build2.org/rep-fetch/foo/testing (prerequisite of pkg:build2.org/rep-fetch/bar/testing) + fetching pkg:build2.org/rep-fetch/hello + 6 package(s) in 6 repository(s) + EOE + } + + : location-args + : + { + $clone_root_cfg; + + $* --trust-yes $rep/bar/unstable 2>>EOE &cfg/.bpkg/certs/**; + added pkg:build2.org/rep-fetch/bar/unstable + fetching pkg:build2.org/rep-fetch/bar/testing (complements pkg:build2.org/rep-fetch/bar/unstable) + fetching pkg:build2.org/rep-fetch/bar/stable (complements pkg:build2.org/rep-fetch/bar/testing) + fetching pkg:build2.org/rep-fetch/foo/stable (prerequisite of pkg:build2.org/rep-fetch/bar/stable) + fetching pkg:build2.org/rep-fetch/foo/testing (prerequisite of pkg:build2.org/rep-fetch/bar/testing) + 5 package(s) in 5 repository(s) + EOE + + $* 'pkg:build2.org/rep-fetch/bar/unstable' 2>>EOE; + fetching pkg:build2.org/rep-fetch/bar/testing (complements pkg:build2.org/rep-fetch/bar/unstable) + fetching pkg:build2.org/rep-fetch/bar/stable (complements pkg:build2.org/rep-fetch/bar/testing) + fetching pkg:build2.org/rep-fetch/foo/stable (prerequisite of pkg:build2.org/rep-fetch/bar/stable) + fetching pkg:build2.org/rep-fetch/foo/testing (prerequisite of pkg:build2.org/rep-fetch/bar/testing) + 5 package(s) in 5 repository(s) + EOE + + $rep_list >>"EOO" + pkg:build2.org/rep-fetch/bar/unstable ($rep/bar/unstable) + complement pkg:build2.org/rep-fetch/bar/testing ($rep/bar/testing) + complement pkg:build2.org/rep-fetch/bar/stable ($rep/bar/stable) + prerequisite pkg:build2.org/rep-fetch/foo/stable ($rep/foo/stable) + prerequisite pkg:build2.org/rep-fetch/foo/testing ($rep/foo/testing) + complement pkg:build2.org/rep-fetch/foo/stable ($rep/foo/stable) + prerequisite pkg:build2.org/rep-fetch/foo/testing ($rep/foo/testing) + complement pkg:build2.org/rep-fetch/foo/stable ($rep/foo/stable) + EOO + } + + : prerequisites-cycle + : + { + $clone_root_cfg; + + $* --trust-yes $rep/cycle/stable 2>>EOE; + added pkg:build2.org/rep-fetch/cycle/stable + fetching pkg:build2.org/rep-fetch/cycle/math (prerequisite of pkg:build2.org/rep-fetch/cycle/stable) + fetching pkg:build2.org/rep-fetch/cycle/extra (prerequisite of pkg:build2.org/rep-fetch/cycle/math) + 3 package(s) in 3 repository(s) + EOE + + $rep_list >>"EOO" + pkg:build2.org/rep-fetch/cycle/stable ($rep/cycle/stable) + prerequisite pkg:build2.org/rep-fetch/cycle/math ($rep/cycle/math) + prerequisite pkg:build2.org/rep-fetch/cycle/extra ($rep/cycle/extra) + prerequisite pkg:build2.org/rep-fetch/cycle/stable ($rep/cycle/stable) + EOO + } + + : unreferenced-prerequisite + : + { + +$clone_root_cfg + + # Create the no-cycle repository as the new state of the cycle repository. + # The cycle dependency is now broken (extra/ doesn't depend on stable/ + # anymore) and the extra/ prerequisite is moved from math/ to stable/. + # + nc_rep = [dir_path] $~/pkg/1/build2.org/rep-fetch/cycle/ + +mkdir -p $path.directory($nc_rep) + +cp -r $src/no-cycle "$nc_rep" # Strip trailing slash. + + +$rep_create $nc_rep/extra 2>! &$nc_rep/extra/packages.manifest + +$rep_create $nc_rep/math 2>! &$nc_rep/math/packages.manifest + +$rep_create $nc_rep/stable 2>! &$nc_rep/stable/packages.manifest + + math_rep = $nc_rep/math + stable_rep = $nc_rep/stable + + : remove + : + { + $clone_cfg; + + $* --trust-yes $rep/cycle/stable 2>>EOE; + added pkg:build2.org/rep-fetch/cycle/stable + fetching pkg:build2.org/rep-fetch/cycle/math (prerequisite of pkg:build2.org/rep-fetch/cycle/stable) + fetching pkg:build2.org/rep-fetch/cycle/extra (prerequisite of pkg:build2.org/rep-fetch/cycle/math) + 3 package(s) in 3 repository(s) + EOE + + $* --trust-yes $stable_rep 2>>EOE; + updated pkg:build2.org/rep-fetch/cycle/stable + fetching pkg:build2.org/rep-fetch/cycle/extra (prerequisite of pkg:build2.org/rep-fetch/cycle/stable) + 2 package(s) in 2 repository(s) + EOE + + $rep_list >>"EOO" + pkg:build2.org/rep-fetch/cycle/stable ($nc_rep/stable) + prerequisite pkg:build2.org/rep-fetch/cycle/extra ($nc_rep/extra) + EOO + } + + : no-remove + : + { + $clone_cfg; + + $* --trust-yes $rep/cycle/stable 2>>EOE; + added pkg:build2.org/rep-fetch/cycle/stable + fetching pkg:build2.org/rep-fetch/cycle/math (prerequisite of pkg:build2.org/rep-fetch/cycle/stable) + fetching pkg:build2.org/rep-fetch/cycle/extra (prerequisite of pkg:build2.org/rep-fetch/cycle/math) + 3 package(s) in 3 repository(s) + EOE + + $* --trust-yes $math_rep $stable_rep 2>>EOE; + added pkg:build2.org/rep-fetch/cycle/math + updated pkg:build2.org/rep-fetch/cycle/stable + fetching pkg:build2.org/rep-fetch/cycle/math + fetching pkg:build2.org/rep-fetch/cycle/stable + fetching pkg:build2.org/rep-fetch/cycle/extra (prerequisite of pkg:build2.org/rep-fetch/cycle/stable) + 3 package(s) in 3 repository(s) + EOE + + $rep_list >>"EOO" + pkg:build2.org/rep-fetch/cycle/math ($nc_rep/math) + pkg:build2.org/rep-fetch/cycle/stable ($nc_rep/stable) + prerequisite pkg:build2.org/rep-fetch/cycle/extra ($nc_rep/extra) + EOO + } + } + + : use-auth + : + { + : dependent-trust + : + : Test that the certificate of foo/stable complement repository is + : silently authenticated for use by the dependent foo/testing repository. + : In this case the certificate is not saved into the database (see the + : subsequent 'rep-fetch $rep/foo/stable' test) and certificate file is not + : persisted (otherwise cleanup of non-empty cfg/ directory would fail). + : + { + $clone_root_cfg; + + $* --verbose 2 $rep/foo/testing <'y' 2>>~%EOE%; + added pkg:build2.org/rep-fetch/foo/testing + %.* + warning: repository pkg:build2.org/rep-fetch/foo/testing is unsigned + %continue without authenticating repositories at .+\? \[y/n\] .+% + %.+ + info: certificate for repository pkg:build2.org/rep-fetch/foo/stable authenticated by dependent trust + %.+ + 2 package(s) in 2 repository(s) + EOE + + $* $rep/foo/stable 2>>~%EOE% != 0 + %.+ + warning: authenticity of the certificate for repository pkg:build2.org/rep-fetch/foo/stable cannot be established + %.+ + EOE + } + + : dependent-command-line + : + : Test that the certificate of foo/stable complement repository is + : authenticated for use by the command line (persisted into the database + : and the filesystem) rather than dependent trust. + : + { + $clone_root_cfg; + + $* --trust $cert_fp --verbose 2 $rep/foo/testing <'y' 2>>~%EOE% &cfg/.bpkg/certs/** + added pkg:build2.org/rep-fetch/foo/testing + %.* + warning: repository pkg:build2.org/rep-fetch/foo/testing is unsigned + %continue without authenticating repositories at .+\? \[y/n\] .+% + %.+ + info: certificate for repository pkg:build2.org/rep-fetch/foo/stable authenticated by command line + %.+ + 2 package(s) in 2 repository(s) + EOE + } + + : dependent-trust-prompt + : + : Test that the certificate of foo/stable repository is first authenticated + : for use by the dependent foo/test repository and then by the user (via + : the prompt) as a top-level repository during a single rep-fetch + : operation. + : + { + yy = 'y +y' + $clone_root_cfg; + + $* --verbose 2 $rep/foo/testing $rep/foo/stable <$yy 2>>~%EOE% &cfg/.bpkg/certs/** + added pkg:build2.org/rep-fetch/foo/testing + added pkg:build2.org/rep-fetch/foo/stable + fetching pkg:build2.org/rep-fetch/foo/testing + %.* + warning: repository pkg:build2.org/rep-fetch/foo/testing is unsigned + %continue without authenticating repositories at .+\? \[y/n\] .+% + %.+ + info: certificate for repository pkg:build2.org/rep-fetch/foo/stable authenticated by dependent trust + %.+ + warning: authenticity of the certificate for repository pkg:build2.org/rep-fetch/foo/stable cannot be established + certificate is for build2.org, "Code Synthesis" + %.+ + %.+2 package\(s\) in 2 repository\(s\)% + EOE + } + + : command-line-dependent-noop + : + : Test that the certificate of foo/stable repository is first authenticated + : by the user (via the command line) as a top-level repository and so + : authentication for use by the dependent foo/test is noop. + : + { + $clone_root_cfg; + + $* --trust $cert_fp --verbose 2 $rep/foo/stable $rep/foo/testing <'y' 2>>~%EOE% &cfg/.bpkg/certs/** + added pkg:build2.org/rep-fetch/foo/stable + added pkg:build2.org/rep-fetch/foo/testing + fetching pkg:build2.org/rep-fetch/foo/stable + %.+ + info: certificate for repository pkg:build2.org/rep-fetch/foo/stable authenticated by command line + %.+ + fetching pkg:build2.org/rep-fetch/foo/testing + %.* + warning: repository pkg:build2.org/rep-fetch/foo/testing is unsigned + %continue without authenticating repositories at .+\? \[y/n\] .+% + %.* + 2 package(s) in 2 repository(s) + EOE + } + } +} + +: dir-rep +: +: For dir repository tests we will reuse local git repositories, that have the +: same repository structure. +: +if ($remote != true) +{ + rep_add += --type dir + + +cp -r $out_git/state0 $~/state0 + + rep = $canonicalize([dir_path] $~/state0) + + +cat <= $rep/libbar.git/repositories.manifest + : 1 + role: prerequisite + type: dir + location: ../style-basic.git + EOI + + +$clone_cfg && $rep_add $rep/libbar.git + + : prerequisites + : + { + $clone_cfg; + + $* 2>>"EOE"; + fetching dir:($rep/libbar.git) + fetching dir:($rep/style-basic.git) \(prerequisite of dir:($rep/libbar.git)\) + 3 package\(s\) in 2 repository\(s\) + EOE + + $rep_list >>"EOO" + dir:($rep/libbar.git) ($rep/libbar.git) + prerequisite dir:($rep/style-basic.git) ($rep/style-basic.git) + EOO + } + + : by-name + : + : Here we, in particular, test that the local repository canonical name + : (dir:/...) is not confused with the repository URL. + : + { + $clone_cfg; + $* 2>!; + + $* "dir:($rep/libbar.git)" 2>>"EOE"; + fetching dir:($rep/style-basic.git) \(prerequisite of dir:($rep/libbar.git)\) + 3 package\(s\) in 2 repository\(s\) + EOE + + $rep_list >>"EOO" + dir:($rep/libbar.git) ($rep/libbar.git) + prerequisite dir:($rep/style-basic.git) ($rep/style-basic.git) + EOO + } + + : shallow + : + { + +$clone_cfg + + : respected + : + { + $clone_cfg; + $* 2>!; + + $* --shallow "dir:($rep/libbar.git)" 2>>"EOE"; + 3 package\(s\) in 2 repository\(s\) + EOE + + $rep_list >>"EOO" + dir:($rep/libbar.git) ($rep/libbar.git) + prerequisite dir:($rep/style-basic.git) ($rep/style-basic.git) + EOO + } + + : ignored + : + { + $clone_cfg; + + $* --shallow 2>>"EOE"; + fetching dir:($rep/libbar.git) + fetching dir:($rep/style-basic.git) \(prerequisite of dir:($rep/libbar.git)\) + 3 package\(s\) in 2 repository\(s\) + EOE + + $rep_list >>"EOO" + dir:($rep/libbar.git) ($rep/libbar.git) + prerequisite dir:($rep/style-basic.git) ($rep/style-basic.git) + EOO + } + } +} + +: iter +: +{ + rep_add += --type dir + + : multiple-repos + : + { + cp -r $src/libhello-1.0.0 libhello1; + cp -r $src/libhello-1.0.0 libhello2; + + $clone_root_cfg && $rep_add libhello1 libhello2; + + $* 2>>~%EOE% != 0 + %fetching dir:.+libhello1% + %fetching dir:.+libhello2% + error: external package libhello/1.0.0 is available from two repositories + % info: repository .+libhello1% + % info: repository .+libhello2% + EOE + } + + : inc + : + { + : path-changed + : + { + $clone_root_cfg && $rep_add $src/libhello-1.0.0; + + $* 2>!; + $pkg_unpack libhello/1.0.0; + + $rep_remove --all; + + cp -r $src/libhello-1.0.0 libhello; + $rep_add libhello; + + $* 2>!; + + $pkg_status libhello >'libhello unpacked 1.0.0 available 1.0.0#1' + } + + : manifest-changed + : + { + cp -r $src/libhello-1.0.0 libhello; + + $clone_root_cfg && $rep_add libhello; + + $* 2>!; + $pkg_unpack libhello/1.0.0; + + echo "" >+ libhello/manifest; + $* 2>!; + + $pkg_status libhello >'libhello unpacked 1.0.0 available 1.0.0#1' + } + + : pkg-rep + { + +$clone_root_cfg + + +$* --auth all --trust-yes $rep/hello &cfg/.bpkg/certs/** 2>! + +$pkg_fetch libhello/1.0.0 + +$pkg_unpack libhello + + : unchanged-external + : + { + $clone_cfg && $rep_add $src/libhello-1.0.0; + $* 2>!; + + $pkg_status libhello >'libhello unpacked 1.0.0' + } + + : changed-external + : + { + cp -r $src/libhello-1.0.0 libhello; + echo "" >+ libhello/manifest; + + $clone_cfg && $rep_add libhello; + $* 2>!; + + $pkg_status libhello >'libhello unpacked 1.0.0 available 1.0.0#1' + } + + -$pkg_purge libhello 2>'purged libhello/1.0.0' + } + + : git-rep + : + if ($git_supported == true && $remote != true) + { + rep = $canonicalize([dir_path] $out_git/state0); + + $clone_root_cfg; + + $* "$rep/style.git#master" 2>! &cfg/.bpkg/repos/*/***; + + # Convert specific warnings to infos as we expect them to appear. This, + # in particular, prevents bbot workers to set task result status to + # warning. + # + $pkg_checkout "style/1.0.0" 2>&1 | \ + sed -e 's/warning: (fetching (over|whole) .*)/info: \1/' >&2 2>!; + + $rep_add $rep/style.git; + $* 2>!; + + $pkg_status style >"style unpacked 1.0.0"; + + $pkg_purge style 2>"purged style/1.0.0" + } + } + + : no-inc + : + { + $clone_root_cfg; + + $pkg_unpack -e $src/libhello-1.0.0; + + $rep_add $src/libhello-1.0.0; + + $* 2>>~%EOE%; + %fetching dir:.+libhello-1.0.0% + 1 package(s) in 1 repository(s) + EOE + + $pkg_status libhello >'libhello unpacked 1.0.0' + } +} + +: git-rep +: +if ($git_supported != true) +{ + # Skip git repository tests. + # +} +else +{ + : proto + : + if ($remote != true) + { + git_protocol = 'local' + .include rep-fetch-git.testscript + } + else + { + : https-dumb + : + { + git_protocol = 'https-dumb' + .include rep-fetch-git.testscript + } + + : https-smart + : + { + git_protocol = 'https-smart' + .include rep-fetch-git.testscript + } + + : https-smart-unadv + : + { + git_protocol = 'https-smart-unadv' + .include rep-fetch-git.testscript + } + + : git + : + { + git_protocol = 'git' + .include rep-fetch-git.testscript + } + } + + : strip-ext + : + : Test that if the local prerequisite git repository having the .git + : extension does not exist but the one without the extension does, then + : it is picked up by rep-fetch. + : + if ($remote != true) + { + cp -r $out_git/state0/libbar.git libbar.git; + cp -r $out_git/state0/style-basic.git style-basic; + + $clone_root_cfg; + + rep = ($cxx.target.class != 'windows' \ + ? "file:$~" \ + : "file:/$regex.replace($~, '\\', '/')"); + + $* "$rep/libbar.git#master" 2>>~%EOE% &cfg/.bpkg/repos/*/***; + %added git:.+libbar#master% + %querying .+libbar\.git% + %fetching from .+libbar\.git% + %fetching git:.+style-basic#stable \(prerequisite of git:.+libbar#master\)% + %querying .+style-basic% + %fetching from .+style-basic% + 3 package(s) in 2 repository(s) + EOE + + $rep_list >>~%EOO% + %git:.+libbar#master file:.+libbar\.git#master% + % prerequisite git:.+style-basic#stable file:.+style-basic#stable \(heads/master\)% + EOO + } + + : checkout-submodules + : + : Test that if some of the packages are located in the repository + : submodules directory, then rep-fetch checks out submoodules. + : + { + $clone_root_cfg && $rep_add "$rep_git/state0/libfox.git#master"; + + $* 2>>~%EOE% &cfg/.bpkg/repos/*/*** + %fetching git:.+libfox#master% + %querying .+libfox\.git% + %fetching from .+libfox\.git% + %warning: .+%{0,2} + %querying .+libbar\.git%? + %fetching submodule 'libbar' from .+libbar\.git% + %warning: .+%{0,2} + %submodule path 'libbar': checked out '.+'% + 2 package(s) in 1 repository(s) + EOE + } + + : re-fetching + : + : Test that repository is re-fetched on the location change. Here it happens + : due to the scheme change. + : + if ($remote == true) + { + $clone_root_cfg && $rep_add "$rep_git_git/state0/libfoo.git#master"; + $* 2>! &cfg/.bpkg/repos/*/***; + $rep_add "$rep_git_https_smart_unadv/state0/libfoo.git#master"; + + $* 2>>~%EOE% + %fetching git:.+libfoo#master% + %info: location changed for git:.+libfoo#master% + % info: new location https://.+libfoo\.git#master% + % info: old location git://.+libfoo\.git#master% + %querying .+libfoo\.git% + 1 package(s) in 1 repository(s) + EOE + } + + : cleanup-failed + : + : Test that configuration is cleaned up if fetch fails after the repository + : filesystem state is changed. + : + { + $clone_root_cfg && $rep_add "$rep_git/state0/libfoo.git#master"; + + # Extract the repository path from the output line like this: + # + # fetching from in 'cfg/.bpkg/tmp/4bde15f59461'... + # + $* --verbose 2 2>&1 | \ + sed -n -e "s/fetching from .+ in '\(.+\)'/\$1/p" | \ + sed -n -e 's%(.+[\\/])tmp([\\/].+)%$1repos$2%p' | \ + set r; + + # Break the repo (drop the remote repository URL) and try to re-fetch. + # + rm "$r/.git/config"; + + $* 2>>~%EOE% != 0; + %.+ + warning: repository state is now broken and will be cleaned up + info: run 'bpkg rep-fetch' to update + EOE + + $pkg_status libfoo >'libfoo unknown' + } + + : ref-filters + : + { + test.cleanups += &?cfg/.bpkg/repos/*/*** + + : pattern + : + { + : matching + : + { + $clone_root_cfg; + + $* "$rep_git/state0/libfoo.git#v**" 2>>~%EOE% + %added .+libfoo#v\*\*% + %querying .+libfoo\.git% + %fetching from .+libfoo\.git% + %warning: .+%{0,2} + 2 package(s) in 1 repository(s) + EOE + } + + : non-matching + : + { + $clone_root_cfg; + + $* "$rep_git/state0/libfoo.git#tags/mast*" 2>>~%EOE% + %added .+libfoo#tags/mast\*% + %querying .+libfoo\.git% + 0 package(s) in 1 repository(s) + EOE + } + } + + : name + : + { + : non-matching + : + { + $clone_root_cfg; + + $* "$rep_git/state0/libfoo.git#foo" 2>>~%EOE% != 0 + %added .+libfoo#foo% + %querying .+libfoo\.git% + error: reference 'foo' is not found + EOE + } + } + + : commit + : + { + : non-matching-pattern + : + { + $clone_root_cfg; + + $* "$rep_git/state0/libfoo.git#foo*@9ab039761936802d61b8e591d6812a4dd4605029" 2>>~%EOE% != 0 + %added .+libfoo#foo\*@9ab039761936802d61b8e591d6812a4dd4605029% + %querying .+libfoo\.git% + error: no names match pattern 'foo*' + EOE + } + + : unexisting + : + { + $clone_root_cfg; + + $* "$rep_git/state0/libfoo.git#9ab039761936802d61b8e591d6812a4dd4605029" 2>>~%EOE% != 0 + %added .+libfoo#9ab039761936802d61b8e591d6812a4dd4605029% + %querying .+libfoo\.git% + %fetching from .+libfoo\.git% + %warning: .+%{0,2} + error: unable to fetch commit 9ab039761936802d61b8e591d6812a4dd4605029 + EOE + } + } + + : exclusion + : + { + $clone_root_cfg; + + $* "$rep_git/state0/libfoo.git#mast*,-master" 2>>~%EOE% + %added .+libfoo#mast\*,-master% + %querying .+libfoo\.git% + 0 package(s) in 1 repository(s) + EOE + } + + : inclusion + : + { + $clone_root_cfg; + + $* "$rep_git/state0/libfoo.git#tags/mast*,+master" 2>>~%EOE% + %added .+libfoo#tags/mast\*,\+master% + %querying .+libfoo\.git% + %fetching from .+libfoo\.git% + %warning: .+%{0,2} + 1 package(s) in 1 repository(s) + EOE + } + + : default + : + { + : no-fragment + : + { + $clone_root_cfg; + + $* "$rep_git/state0/libfoo.git" 2>>~%EOE% + %added .+libfoo% + %querying .+libfoo\.git% + %fetching from .+libfoo\.git% + %warning: .+%{0,2} + 2 package(s) in 1 repository(s) + EOE + } + + : with-exclusion + : + { + $clone_root_cfg; + + $* "$rep_git/state0/libfoo.git##-/tags/v1*" 2>>~%EOE% + %added .+libfoo##-/tags/v1\*% + %querying .+libfoo\.git% + %fetching from .+libfoo\.git% + %warning: .+%{0,2} + 1 package(s) in 1 repository(s) + EOE + } + } + } +} diff --git a/tests/rep-info.test b/tests/rep-info.test deleted file mode 100644 index d7a80a9..0000000 --- a/tests/rep-info.test +++ /dev/null @@ -1,251 +0,0 @@ -# file : tests/rep-info.test -# copyright : Copyright (c) 2014-2018 Code Synthesis Ltd -# license : MIT; see accompanying LICENSE file - -.include common.test auth.test remote.test remote-git.test - -# Source repository: -# -# rep-info -# |-- testing -> stable (complement), ../foo/testing (prerequisite) -# | |-- foo-1.tar.gz -# | `-- repositories.manifest -# | -# `-- git -# |-- libbar.git -> style-basic.git (prerequisite) -# `-- style-basic.git - -# Prepare repositories used by tests if running in the local mode. -# -+if ($remote != true) - rc = $rep_create 2>! - - # Create the unsigned 'testing' repository. - # - cp -r $src/testing $out/testing - $rc $out/testing &$out/testing/packages.manifest - - # Create the signed 'testing' repository. - # - cp -r $src/testing $out/signed - cat <<<$cert_manifest >+$out/signed/repositories.manifest - - $rc --key $key $out/signed &$out/signed/packages.manifest \ - &$out/signed/signature.manifest - - # Create git repositories. - # - $git_extract $src/git/libbar.tar - $git_extract $src/git/style-basic.tar &$out_git/state0/*** -end - -test.options += --auth all --trust-yes - -: no-location -: -$* 2>>EOE != 0 -error: repository location argument expected - info: run 'bpkg help rep-info' for more information -EOE - -: default -: -{ - : unsigned - : - $* $rep/testing >>"EOO" - pkg:build2.org/rep-info/testing ($rep/testing) - prerequisite pkg:build2.org/foo/testing ($rep_root/foo/testing) - complement pkg:build2.org/rep-info/stable ($rep/stable) - - foo/1 - EOO - - : signed - : - $* $rep/signed >>"EOO" - pkg:build2.org/rep-info/signed ($rep/signed) - CN=build2.org/O=Code Synthesis/info@build2.org - $cert_fp - prerequisite pkg:build2.org/foo/testing ($rep_root/foo/testing) - complement pkg:build2.org/rep-info/stable ($rep/stable) - - foo/1 - EOO -} - -: name -: -$* --name $rep/testing >"pkg:build2.org/rep-info/testing ($rep/testing)" - -: packages -: -{ - test.arguments += --packages # Should go after the rep-info command argument. - - : list - : - $* $rep/testing >>EOO - - foo/1 - EOO - - : manifest - : - $* --manifest $rep/testing >>EOO - : 1 - name: foo - version: 1 - summary: The "Foo" utility - license: MIT - url: http://www.example.org/foo - email: foo-users@example.org - location: foo-1.tar.gz - sha256sum: fee330a362a4f87ff42a954aa305b6446d541b7b60000ebcd2fbf68f2b1ae58e - EOO - - : to-file - : - { - : no-manifest - : - $* --packages-file m $rep/testing 2>>EOE != 0 - error: --packages-file specified without --manifest - info: run 'bpkg help rep-info' for more information - EOE - - : manifest - : - { - $* --manifest --packages-file m $rep/testing &m; - - cat m >>EOO - : 1 - name: foo - version: 1 - summary: The "Foo" utility - license: MIT - url: http://www.example.org/foo - email: foo-users@example.org - location: foo-1.tar.gz - sha256sum: fee330a362a4f87ff42a954aa305b6446d541b7b60000ebcd2fbf68f2b1ae58e - EOO - } - } -} - -: repositories -: -{ - # Should go after the rep-info command argument. - # - test.arguments += --repositories - - : list - : - $* $rep/testing >>"EOO" - prerequisite pkg:build2.org/foo/testing ($rep_root/foo/testing) - complement pkg:build2.org/rep-info/stable ($rep/stable) - EOO - - : manifest - : - $* --manifest $rep/testing >>EOO - : 1 - location: ../../foo/testing - type: pkg - role: prerequisite - : - location: ../stable - type: pkg - role: complement - : - EOO - - : to-file - : - { - : no-manifest - : - $* --repositories-file m $rep/testing 2>>EOE != 0 - error: --repositories-file specified without --manifest - info: run 'bpkg help rep-info' for more information - EOE - - : manifest - : - { - $* --manifest --repositories-file m $rep/testing &m; - - cat m >>EOO - : 1 - location: ../../foo/testing - type: pkg - role: prerequisite - : - location: ../stable - type: pkg - role: complement - : - EOO - } - } -} - -: cert -: -{ - test.arguments += $rep/signed - - $* --cert-fingerprint >"$cert_fp" : fingerprint - $* --cert-name >'name:build2.org' : name - $* --cert-organization >'Code Synthesis' : organization - $* --cert-email >'info@build2.org' : email -} - -: git-rep -: -if ($git_supported != true) -{ - # Skip git repository tests. - # -} -else -{ - rep = "$rep_git/state0" - test.redirects += 2>! - - : version-module - : - : Version module is enabled for the project. - : - $* "$rep/style-basic.git#master" >>~%EOO% - %git:.+style-basic#master .+style-basic.git#master% - - %style-basic/1\.1\.0-a\.0\.\d+\..+% - EOO - - : manifest-lists - : - : The packages.manifest and repositories.manifest files are present in the - : repository root. - : - $* "$rep/libbar.git#master" >>~%EOO% - %git:.+libbar#master .+libbar.git#master% - %prerequisite git:.+style-basic#stable .+style-basic.git#stable% - - libbar/1.0.0 - libmbar/1.0.0 - EOO - - : repository-manifests - : - : Here we test that the base repository manifest that comes from the stable - : branch is printed because the stable head commit is newer that of the - : master branch. - : - $* -r --manifest "$rep/style-basic.git#stable,master" >>~%EOO% - : 1 - email: user@example.com - EOO -} diff --git a/tests/rep-info.testscript b/tests/rep-info.testscript new file mode 100644 index 0000000..3ccbeb6 --- /dev/null +++ b/tests/rep-info.testscript @@ -0,0 +1,254 @@ +# file : tests/rep-info.testscript +# copyright : Copyright (c) 2014-2018 Code Synthesis Ltd +# license : MIT; see accompanying LICENSE file + +.include common.testscript \ + auth.testscript \ + remote.testscript \ + remote-git.testscript + +# Source repository: +# +# rep-info +# |-- testing -> stable (complement), ../foo/testing (prerequisite) +# | |-- foo-1.tar.gz +# | `-- repositories.manifest +# | +# `-- git +# |-- libbar.git -> style-basic.git (prerequisite) +# `-- style-basic.git + +# Prepare repositories used by tests if running in the local mode. +# ++if ($remote != true) + rc = $rep_create 2>! + + # Create the unsigned 'testing' repository. + # + cp -r $src/testing $out/testing + $rc $out/testing &$out/testing/packages.manifest + + # Create the signed 'testing' repository. + # + cp -r $src/testing $out/signed + cat <<<$cert_manifest >+$out/signed/repositories.manifest + + $rc --key $key $out/signed &$out/signed/packages.manifest \ + &$out/signed/signature.manifest + + # Create git repositories. + # + $git_extract $src/git/libbar.tar + $git_extract $src/git/style-basic.tar &$out_git/state0/*** +end + +test.options += --auth all --trust-yes + +: no-location +: +$* 2>>EOE != 0 +error: repository location argument expected + info: run 'bpkg help rep-info' for more information +EOE + +: default +: +{ + : unsigned + : + $* $rep/testing >>"EOO" + pkg:build2.org/rep-info/testing ($rep/testing) + prerequisite pkg:build2.org/foo/testing ($rep_root/foo/testing) + complement pkg:build2.org/rep-info/stable ($rep/stable) + + foo/1 + EOO + + : signed + : + $* $rep/signed >>"EOO" + pkg:build2.org/rep-info/signed ($rep/signed) + CN=build2.org/O=Code Synthesis/info@build2.org + $cert_fp + prerequisite pkg:build2.org/foo/testing ($rep_root/foo/testing) + complement pkg:build2.org/rep-info/stable ($rep/stable) + + foo/1 + EOO +} + +: name +: +$* --name $rep/testing >"pkg:build2.org/rep-info/testing ($rep/testing)" + +: packages +: +{ + test.arguments += --packages # Should go after the rep-info command argument. + + : list + : + $* $rep/testing >>EOO + + foo/1 + EOO + + : manifest + : + $* --manifest $rep/testing >>EOO + : 1 + name: foo + version: 1 + summary: The "Foo" utility + license: MIT + url: http://www.example.org/foo + email: foo-users@example.org + location: foo-1.tar.gz + sha256sum: fee330a362a4f87ff42a954aa305b6446d541b7b60000ebcd2fbf68f2b1ae58e + EOO + + : to-file + : + { + : no-manifest + : + $* --packages-file m $rep/testing 2>>EOE != 0 + error: --packages-file specified without --manifest + info: run 'bpkg help rep-info' for more information + EOE + + : manifest + : + { + $* --manifest --packages-file m $rep/testing &m; + + cat m >>EOO + : 1 + name: foo + version: 1 + summary: The "Foo" utility + license: MIT + url: http://www.example.org/foo + email: foo-users@example.org + location: foo-1.tar.gz + sha256sum: fee330a362a4f87ff42a954aa305b6446d541b7b60000ebcd2fbf68f2b1ae58e + EOO + } + } +} + +: repositories +: +{ + # Should go after the rep-info command argument. + # + test.arguments += --repositories + + : list + : + $* $rep/testing >>"EOO" + prerequisite pkg:build2.org/foo/testing ($rep_root/foo/testing) + complement pkg:build2.org/rep-info/stable ($rep/stable) + EOO + + : manifest + : + $* --manifest $rep/testing >>EOO + : 1 + location: ../../foo/testing + type: pkg + role: prerequisite + : + location: ../stable + type: pkg + role: complement + : + EOO + + : to-file + : + { + : no-manifest + : + $* --repositories-file m $rep/testing 2>>EOE != 0 + error: --repositories-file specified without --manifest + info: run 'bpkg help rep-info' for more information + EOE + + : manifest + : + { + $* --manifest --repositories-file m $rep/testing &m; + + cat m >>EOO + : 1 + location: ../../foo/testing + type: pkg + role: prerequisite + : + location: ../stable + type: pkg + role: complement + : + EOO + } + } +} + +: cert +: +{ + test.arguments += $rep/signed + + $* --cert-fingerprint >"$cert_fp" : fingerprint + $* --cert-name >'name:build2.org' : name + $* --cert-organization >'Code Synthesis' : organization + $* --cert-email >'info@build2.org' : email +} + +: git-rep +: +if ($git_supported != true) +{ + # Skip git repository tests. + # +} +else +{ + rep = "$rep_git/state0" + test.redirects += 2>! + + : version-module + : + : Version module is enabled for the project. + : + $* "$rep/style-basic.git#master" >>~%EOO% + %git:.+style-basic#master .+style-basic.git#master% + + %style-basic/1\.1\.0-a\.0\.\d+\..+% + EOO + + : manifest-lists + : + : The packages.manifest and repositories.manifest files are present in the + : repository root. + : + $* "$rep/libbar.git#master" >>~%EOO% + %git:.+libbar#master .+libbar.git#master% + %prerequisite git:.+style-basic#stable .+style-basic.git#stable% + + libbar/1.0.0 + libmbar/1.0.0 + EOO + + : repository-manifests + : + : Here we test that the base repository manifest that comes from the stable + : branch is printed because the stable head commit is newer that of the + : master branch. + : + $* -r --manifest "$rep/style-basic.git#stable,master" >>~%EOO% + : 1 + email: user@example.com + EOO +} diff --git a/tests/rep-list.test b/tests/rep-list.test deleted file mode 100644 index 63d95ed..0000000 --- a/tests/rep-list.test +++ /dev/null @@ -1,147 +0,0 @@ -# file : tests/rep-list.test -# copyright : Copyright (c) 2014-2018 Code Synthesis Ltd -# license : MIT; see accompanying LICENSE file - -.include common.test config.test remote.test remote-git.test - -# Source repository: -# -# rep-list -# |-- extra -> stable (prerequisite) -# | |-- libbar-1.1.0+1.tar.gz -# | `-- repositories.manifest -# | -# |-- math -> extra (prerequisite) -# | |-- libbar-1.0.0.tar.gz -# | `-- repositories.manifest -# | -# |-- stable -> math (prerequisite) -# | |-- libfoo-1.0.0.tar.gz -# | `-- repositories.manifest -# | -# `-- testing -> stable (complement), extra (prerequisite) -# | |-- libbar-2.0.0.tar.gz -# | `-- repositories.manifest -# | -# `-- git -# |-- libbar.git -> style-basic.git (prerequisite) -# `-- style-basic.git - -# Prepare repositories used by tests if running in the local mode. -# -+if ($remote != true) - cp -r $src/extra $out/extra - cp -r $src/math $out/math - cp -r $src/stable $out/stable - cp -r $src/testing $out/testing - - c = $rep_create 2>! - - $c $out/extra &$out/extra/packages.manifest - $c $out/math &$out/math/packages.manifest - $c $out/stable &$out/stable/packages.manifest - $c $out/testing &$out/testing/packages.manifest - - # Create git repositories. - # - $git_extract $src/git/libbar.tar - $git_extract $src/git/style-basic.tar &$out_git/state0/*** -end - -rep_add += -d cfg 2>! -rep_fetch += -d cfg --auth all --trust-yes 2>! - -: unexpected-arg -: -{ - $clone_cfg; - - $* unexpected 2>>EOE != 0 - error: unexpected argument 'unexpected' - info: run 'bpkg help rep-list' for more information - EOE -} - -: top-level -: -{ - $clone_cfg; - $rep_add $rep/stable && $rep_add $rep/testing && $rep_fetch; - - $* >>"EOO" - pkg:build2.org/rep-list/stable ($rep/stable) - pkg:build2.org/rep-list/testing ($rep/testing) - EOO -} - -: prerequisites -: -: Note that here we also test that the prerequisites cycle is handled properly. -: -{ - $clone_cfg; - $rep_add $rep/stable && $rep_fetch; - - $* --prerequisites >>"EOO" - pkg:build2.org/rep-list/stable ($rep/stable) - prerequisite pkg:build2.org/rep-list/math ($rep/math) - prerequisite pkg:build2.org/rep-list/extra ($rep/extra) - prerequisite pkg:build2.org/rep-list/stable ($rep/stable) - EOO -} - -: complements -: -{ - $clone_cfg; - $rep_add $rep/testing && $rep_fetch; - - $* --complements >>"EOO" - pkg:build2.org/rep-list/testing ($rep/testing) - complement pkg:build2.org/rep-list/stable ($rep/stable) - EOO -} - -: all -: -{ - $clone_cfg; - $rep_add $rep/testing && $rep_fetch; - - $* --prerequisites --complements >>"EOO" - pkg:build2.org/rep-list/testing ($rep/testing) - complement pkg:build2.org/rep-list/stable ($rep/stable) - prerequisite pkg:build2.org/rep-list/math ($rep/math) - prerequisite pkg:build2.org/rep-list/extra ($rep/extra) - prerequisite pkg:build2.org/rep-list/stable ($rep/stable) - prerequisite pkg:build2.org/rep-list/extra ($rep/extra) - prerequisite pkg:build2.org/rep-list/stable ($rep/stable) - prerequisite pkg:build2.org/rep-list/math ($rep/math) - prerequisite pkg:build2.org/rep-list/extra ($rep/extra) - EOO -} - -: git-rep -: -if ($git_supported != true) -{ - # Skip git repository tests. - # -} -else -{ - rep = "$rep_git/state0" - test.cleanups += &cfg/.bpkg/repos/*/*** - - : root-complement - : - : Test that the root repository complement is handled properly. - : - $clone_root_cfg; - $rep_add "$rep/libbar.git#master" && $rep_fetch; - - $* --complements --prerequisites >>~%EOO% - %git:.+libbar#master .+libbar\.git#master% - % prerequisite git:.+style-basic#stable .+style-basic\.git#stable \(heads/master\)% - EOO -} diff --git a/tests/rep-list.testscript b/tests/rep-list.testscript new file mode 100644 index 0000000..978ce73 --- /dev/null +++ b/tests/rep-list.testscript @@ -0,0 +1,150 @@ +# file : tests/rep-list.testscript +# copyright : Copyright (c) 2014-2018 Code Synthesis Ltd +# license : MIT; see accompanying LICENSE file + +.include common.testscript \ + config.testscript \ + remote.testscript \ + remote-git.testscript + +# Source repository: +# +# rep-list +# |-- extra -> stable (prerequisite) +# | |-- libbar-1.1.0+1.tar.gz +# | `-- repositories.manifest +# | +# |-- math -> extra (prerequisite) +# | |-- libbar-1.0.0.tar.gz +# | `-- repositories.manifest +# | +# |-- stable -> math (prerequisite) +# | |-- libfoo-1.0.0.tar.gz +# | `-- repositories.manifest +# | +# `-- testing -> stable (complement), extra (prerequisite) +# | |-- libbar-2.0.0.tar.gz +# | `-- repositories.manifest +# | +# `-- git +# |-- libbar.git -> style-basic.git (prerequisite) +# `-- style-basic.git + +# Prepare repositories used by tests if running in the local mode. +# ++if ($remote != true) + cp -r $src/extra $out/extra + cp -r $src/math $out/math + cp -r $src/stable $out/stable + cp -r $src/testing $out/testing + + c = $rep_create 2>! + + $c $out/extra &$out/extra/packages.manifest + $c $out/math &$out/math/packages.manifest + $c $out/stable &$out/stable/packages.manifest + $c $out/testing &$out/testing/packages.manifest + + # Create git repositories. + # + $git_extract $src/git/libbar.tar + $git_extract $src/git/style-basic.tar &$out_git/state0/*** +end + +rep_add += -d cfg 2>! +rep_fetch += -d cfg --auth all --trust-yes 2>! + +: unexpected-arg +: +{ + $clone_cfg; + + $* unexpected 2>>EOE != 0 + error: unexpected argument 'unexpected' + info: run 'bpkg help rep-list' for more information + EOE +} + +: top-level +: +{ + $clone_cfg; + $rep_add $rep/stable && $rep_add $rep/testing && $rep_fetch; + + $* >>"EOO" + pkg:build2.org/rep-list/stable ($rep/stable) + pkg:build2.org/rep-list/testing ($rep/testing) + EOO +} + +: prerequisites +: +: Note that here we also test that the prerequisites cycle is handled properly. +: +{ + $clone_cfg; + $rep_add $rep/stable && $rep_fetch; + + $* --prerequisites >>"EOO" + pkg:build2.org/rep-list/stable ($rep/stable) + prerequisite pkg:build2.org/rep-list/math ($rep/math) + prerequisite pkg:build2.org/rep-list/extra ($rep/extra) + prerequisite pkg:build2.org/rep-list/stable ($rep/stable) + EOO +} + +: complements +: +{ + $clone_cfg; + $rep_add $rep/testing && $rep_fetch; + + $* --complements >>"EOO" + pkg:build2.org/rep-list/testing ($rep/testing) + complement pkg:build2.org/rep-list/stable ($rep/stable) + EOO +} + +: all +: +{ + $clone_cfg; + $rep_add $rep/testing && $rep_fetch; + + $* --prerequisites --complements >>"EOO" + pkg:build2.org/rep-list/testing ($rep/testing) + complement pkg:build2.org/rep-list/stable ($rep/stable) + prerequisite pkg:build2.org/rep-list/math ($rep/math) + prerequisite pkg:build2.org/rep-list/extra ($rep/extra) + prerequisite pkg:build2.org/rep-list/stable ($rep/stable) + prerequisite pkg:build2.org/rep-list/extra ($rep/extra) + prerequisite pkg:build2.org/rep-list/stable ($rep/stable) + prerequisite pkg:build2.org/rep-list/math ($rep/math) + prerequisite pkg:build2.org/rep-list/extra ($rep/extra) + EOO +} + +: git-rep +: +if ($git_supported != true) +{ + # Skip git repository tests. + # +} +else +{ + rep = "$rep_git/state0" + test.cleanups += &cfg/.bpkg/repos/*/*** + + : root-complement + : + : Test that the root repository complement is handled properly. + : + $clone_root_cfg; + $rep_add "$rep/libbar.git#master" && $rep_fetch; + + $* --complements --prerequisites >>~%EOO% + %git:.+libbar#master .+libbar\.git#master% + % prerequisite git:.+style-basic#stable .+style-basic\.git#stable \(heads/master\)% + EOO +} diff --git a/tests/rep-remove.test b/tests/rep-remove.test deleted file mode 100644 index c49ee3e..0000000 --- a/tests/rep-remove.test +++ /dev/null @@ -1,209 +0,0 @@ -# file : tests/rep-remove.test -# copyright : Copyright (c) 2014-2018 Code Synthesis Ltd -# license : MIT; see accompanying LICENSE file - -.include common.test config.test remote.test remote-git.test - -# Source repository: -# -# rep-remove -# |-- extra -> stable (prerequisite) -# | |-- libbar-1.1.0+1.tar.gz -# | `-- repositories.manifest -# | -# |-- math -> extra (prerequisite) -# | |-- libbar-1.0.0.tar.gz -# | `-- repositories.manifest -# | -# |-- stable -> math (prerequisite) -# | |-- libfoo-1.0.0.tar.gz -# | `-- repositories.manifest -# | -# `-- testing -> stable (complement), extra (prerequisite) -# | |-- libbar-2.0.0.tar.gz -# | `-- repositories.manifest -# | -# `-- alpha -# | |-- libbar-2.0.0.tar.gz -# | `-- repositories.manifest -# | -# `-- git -# `-- style-basic.git - -# Prepare repositories used by tests if running in the local mode. -# -+if ($remote != true) - cp -r $src/extra $out/extra - cp -r $src/math $out/math - cp -r $src/stable $out/stable - cp -r $src/testing $out/testing - cp -r $src/alpha $out/alpha - - c = $rep_create 2>! - - $c $out/extra &$out/extra/packages.manifest - $c $out/math &$out/math/packages.manifest - $c $out/stable &$out/stable/packages.manifest - $c $out/testing &$out/testing/packages.manifest - $c $out/alpha &$out/alpha/packages.manifest - - # Create git repositories. - # - $git_extract $src/git/style-basic.tar &$out_git/state0/*** -end - -rep_add += -d cfg 2>! -rep_fetch += -d cfg --auth all --trust-yes 2>! -rep_list += -d cfg --prerequisites --complements -pkg_status += -d cfg - -: invalid-args -: -{ - : clean-all - : - $* --clean --all 2>>EOE != 0 - error: both --clean and --all|-a specified - info: run 'bpkg help rep-remove' for more information - EOE - - : clean-repos - : - $* --clean $rep/extra 2>>EOE != 0 - error: both --clean and repository argument specified - info: run 'bpkg help rep-remove' for more information - EOE - - : all-repos - : - $* --all $rep/extra 2>>EOE != 0 - error: both --all|-a and repository argument specified - info: run 'bpkg help rep-remove' for more information - EOE - - : none - : - $* 2>>EOE != 0 - error: repository name or location argument expected - info: run 'bpkg help rep-remove' for more information - EOE -} - -: clean -: -{ - $clone_cfg; - $rep_add $rep/extra && $rep_fetch; - - $* --clean 2>>"EOE"; - cleaned pkg:build2.org/rep-remove/extra - EOE - - $rep_list >>"EOE"; - pkg:build2.org/rep-remove/extra ($rep/extra) - EOE - - $pkg_status libbar >'libbar unknown' -} - -: all -: -{ - $clone_cfg; - $rep_add $rep/extra && $rep_fetch; - - $* --all 2>>"EOE"; - removed pkg:build2.org/rep-remove/extra - EOE - - $rep_list >:""; - $pkg_status libbar >'libbar unknown' -} - -: by-name -: -{ - $clone_cfg; - $rep_add $rep/extra && $rep_fetch; - - $* 'pkg:build2.org/rep-remove/extra' 2>>"EOE"; - removed pkg:build2.org/rep-remove/extra - EOE - - $rep_list >:""; - $pkg_status libbar >'libbar unknown' -} - -: prerequisites-cycle -: -{ - $clone_cfg; - $rep_add $rep/testing && $rep_fetch; - - $* $rep/testing 2>>"EOE"; - removed pkg:build2.org/rep-remove/testing - EOE - - $rep_list >:""; - $pkg_status libbar >'libbar unknown'; - $pkg_status libfoo >'libfoo unknown' -} - -: reacheable -: -{ - $clone_cfg; - $rep_add $rep/testing && $rep_add $rep/math && $rep_fetch; - - $* $rep/testing 2>>"EOE"; - removed pkg:build2.org/rep-remove/testing - EOE - - $rep_list >>"EOO"; - pkg:build2.org/rep-remove/math ($rep/math) - prerequisite pkg:build2.org/rep-remove/extra ($rep/extra) - prerequisite pkg:build2.org/rep-remove/stable ($rep/stable) - prerequisite pkg:build2.org/rep-remove/math ($rep/math) - EOO - - $pkg_status libbar >'libbar available [1.1.0+1] 1.0.0'; - $pkg_status libfoo >'libfoo available [1.0.0]' -} - -: package-locations -: -{ - $clone_cfg; - $rep_add $rep/testing && $rep_add $rep/alpha && $rep_fetch; - - $* $rep/testing 2>!; - $pkg_status libbar >'libbar available 2.0.0'; - - $* $rep/alpha 2>!; - $pkg_status libbar >'libbar unknown' -} - -: git-rep -: -if ($git_supported != true) -{ - # Skip git repository tests. - # -} -else -{ - rep = "$rep_git/state0" - - : root-complement - : - : Test that git repository root complement is handled properly. Note that - : we also test that the repository state directory is removed. Otherwise - : the testscript would fail to cleanup the working directory. - : - $clone_root_cfg; - $rep_add "$rep/style-basic.git#master" && $rep_fetch; - - $* "$rep/style-basic.git#master" 2>>~%EOO% - %removed git:.+style-basic#master% - EOO -} diff --git a/tests/rep-remove.testscript b/tests/rep-remove.testscript new file mode 100644 index 0000000..0b7955a --- /dev/null +++ b/tests/rep-remove.testscript @@ -0,0 +1,212 @@ +# file : tests/rep-remove.testscript +# copyright : Copyright (c) 2014-2018 Code Synthesis Ltd +# license : MIT; see accompanying LICENSE file + +.include common.testscript \ + config.testscript \ + remote.testscript \ + remote-git.testscript + +# Source repository: +# +# rep-remove +# |-- extra -> stable (prerequisite) +# | |-- libbar-1.1.0+1.tar.gz +# | `-- repositories.manifest +# | +# |-- math -> extra (prerequisite) +# | |-- libbar-1.0.0.tar.gz +# | `-- repositories.manifest +# | +# |-- stable -> math (prerequisite) +# | |-- libfoo-1.0.0.tar.gz +# | `-- repositories.manifest +# | +# `-- testing -> stable (complement), extra (prerequisite) +# | |-- libbar-2.0.0.tar.gz +# | `-- repositories.manifest +# | +# `-- alpha +# | |-- libbar-2.0.0.tar.gz +# | `-- repositories.manifest +# | +# `-- git +# `-- style-basic.git + +# Prepare repositories used by tests if running in the local mode. +# ++if ($remote != true) + cp -r $src/extra $out/extra + cp -r $src/math $out/math + cp -r $src/stable $out/stable + cp -r $src/testing $out/testing + cp -r $src/alpha $out/alpha + + c = $rep_create 2>! + + $c $out/extra &$out/extra/packages.manifest + $c $out/math &$out/math/packages.manifest + $c $out/stable &$out/stable/packages.manifest + $c $out/testing &$out/testing/packages.manifest + $c $out/alpha &$out/alpha/packages.manifest + + # Create git repositories. + # + $git_extract $src/git/style-basic.tar &$out_git/state0/*** +end + +rep_add += -d cfg 2>! +rep_fetch += -d cfg --auth all --trust-yes 2>! +rep_list += -d cfg --prerequisites --complements +pkg_status += -d cfg + +: invalid-args +: +{ + : clean-all + : + $* --clean --all 2>>EOE != 0 + error: both --clean and --all|-a specified + info: run 'bpkg help rep-remove' for more information + EOE + + : clean-repos + : + $* --clean $rep/extra 2>>EOE != 0 + error: both --clean and repository argument specified + info: run 'bpkg help rep-remove' for more information + EOE + + : all-repos + : + $* --all $rep/extra 2>>EOE != 0 + error: both --all|-a and repository argument specified + info: run 'bpkg help rep-remove' for more information + EOE + + : none + : + $* 2>>EOE != 0 + error: repository name or location argument expected + info: run 'bpkg help rep-remove' for more information + EOE +} + +: clean +: +{ + $clone_cfg; + $rep_add $rep/extra && $rep_fetch; + + $* --clean 2>>"EOE"; + cleaned pkg:build2.org/rep-remove/extra + EOE + + $rep_list >>"EOE"; + pkg:build2.org/rep-remove/extra ($rep/extra) + EOE + + $pkg_status libbar >'libbar unknown' +} + +: all +: +{ + $clone_cfg; + $rep_add $rep/extra && $rep_fetch; + + $* --all 2>>"EOE"; + removed pkg:build2.org/rep-remove/extra + EOE + + $rep_list >:""; + $pkg_status libbar >'libbar unknown' +} + +: by-name +: +{ + $clone_cfg; + $rep_add $rep/extra && $rep_fetch; + + $* 'pkg:build2.org/rep-remove/extra' 2>>"EOE"; + removed pkg:build2.org/rep-remove/extra + EOE + + $rep_list >:""; + $pkg_status libbar >'libbar unknown' +} + +: prerequisites-cycle +: +{ + $clone_cfg; + $rep_add $rep/testing && $rep_fetch; + + $* $rep/testing 2>>"EOE"; + removed pkg:build2.org/rep-remove/testing + EOE + + $rep_list >:""; + $pkg_status libbar >'libbar unknown'; + $pkg_status libfoo >'libfoo unknown' +} + +: reacheable +: +{ + $clone_cfg; + $rep_add $rep/testing && $rep_add $rep/math && $rep_fetch; + + $* $rep/testing 2>>"EOE"; + removed pkg:build2.org/rep-remove/testing + EOE + + $rep_list >>"EOO"; + pkg:build2.org/rep-remove/math ($rep/math) + prerequisite pkg:build2.org/rep-remove/extra ($rep/extra) + prerequisite pkg:build2.org/rep-remove/stable ($rep/stable) + prerequisite pkg:build2.org/rep-remove/math ($rep/math) + EOO + + $pkg_status libbar >'libbar available [1.1.0+1] 1.0.0'; + $pkg_status libfoo >'libfoo available [1.0.0]' +} + +: package-locations +: +{ + $clone_cfg; + $rep_add $rep/testing && $rep_add $rep/alpha && $rep_fetch; + + $* $rep/testing 2>!; + $pkg_status libbar >'libbar available 2.0.0'; + + $* $rep/alpha 2>!; + $pkg_status libbar >'libbar unknown' +} + +: git-rep +: +if ($git_supported != true) +{ + # Skip git repository tests. + # +} +else +{ + rep = "$rep_git/state0" + + : root-complement + : + : Test that git repository root complement is handled properly. Note that + : we also test that the repository state directory is removed. Otherwise + : the testscript would fail to cleanup the working directory. + : + $clone_root_cfg; + $rep_add "$rep/style-basic.git#master" && $rep_fetch; + + $* "$rep/style-basic.git#master" 2>>~%EOO% + %removed git:.+style-basic#master% + EOO +} -- cgit v1.1