aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/common.test2
-rw-r--r--tests/rep-add.test107
-rw-r--r--tests/rep-list.test142
-rw-r--r--tests/rep-list/extra/libbar-1.1.0+1.tar.gzbin0 -> 243 bytes
-rw-r--r--tests/rep-list/extra/repositories3
l---------tests/rep-list/git/libbar.tar1
l---------tests/rep-list/git/style-basic.tar1
-rw-r--r--tests/rep-list/math/libbar-1.0.0.tar.gzbin0 -> 241 bytes
-rw-r--r--tests/rep-list/math/repositories3
-rw-r--r--tests/rep-list/stable/libfoo-1.0.0.tar.gzbin0 -> 240 bytes
-rw-r--r--tests/rep-list/stable/repositories3
-rw-r--r--tests/rep-list/testing/libbar-2.0.0.tar.gzbin0 -> 245 bytes
-rw-r--r--tests/rep-list/testing/repositories6
-rw-r--r--tests/rep-remove.test139
-rw-r--r--tests/rep-remove/alpha/libbar-2.0.0.tar.gzbin0 -> 245 bytes
-rw-r--r--tests/rep-remove/alpha/repositories1
-rw-r--r--tests/rep-remove/extra/libbar-1.1.0+1.tar.gzbin0 -> 243 bytes
-rw-r--r--tests/rep-remove/extra/repositories3
l---------tests/rep-remove/git/style-basic.tar1
-rw-r--r--tests/rep-remove/math/libbar-1.0.0.tar.gzbin0 -> 241 bytes
-rw-r--r--tests/rep-remove/math/repositories3
-rw-r--r--tests/rep-remove/stable/libfoo-1.0.0.tar.gzbin0 -> 240 bytes
-rw-r--r--tests/rep-remove/stable/repositories3
-rw-r--r--tests/rep-remove/testing/libbar-2.0.0.tar.gzbin0 -> 245 bytes
-rw-r--r--tests/rep-remove/testing/repositories6
25 files changed, 393 insertions, 31 deletions
diff --git a/tests/common.test b/tests/common.test
index b919da4..4002df3 100644
--- a/tests/common.test
+++ b/tests/common.test
@@ -33,6 +33,8 @@ 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.
diff --git a/tests/rep-add.test b/tests/rep-add.test
index be72b51..c96b32b 100644
--- a/tests/rep-add.test
+++ b/tests/rep-add.test
@@ -4,6 +4,8 @@
.include common.test config.test
+rep_list += -d cfg
+
: location
:
{
@@ -18,9 +20,13 @@
: empty
:
- $* '' 2>>EOE != 0
- error: empty repository location
- EOE
+ {
+ $clone_cfg;
+
+ $* '' 2>>EOE != 0
+ error: empty repository location
+ EOE
+ }
: unknown-type
:
@@ -30,28 +36,43 @@
: no-version
:
- $* 'stable' 2>>/~%EOE% != 0
- %error: invalid bpkg repository location '.+/no-version/stable': missing repository version%
- info: consider using --type to specify repository type
- EOE
+ {
+ $clone_cfg;
+
+ $* 'stable' 2>>/~%EOE% != 0
+ %error: invalid bpkg repository location '.+/no-version/stable': missing repository version%
+ info: consider using --type to specify repository type
+ EOE
+ }
: git-no-branch
:
- $* 'git://example.org/repo' 2>>EOE != 0
- error: invalid git repository location 'git://example.org/repo': missing branch/tag or commit id for git repository
- EOE
+ {
+ $clone_cfg;
+
+ $* 'git://example.org/repo' 2>>EOE != 0
+ error: invalid git repository location 'git://example.org/repo': missing branch/tag or commit id for git repository
+ EOE
+ }
: bpkg-git-scheme
:
- $* 'git://example.org/repo' --type bpkg 2>>EOE != 0
- error: invalid bpkg repository location 'git://example.org/repo': unsupported scheme for bpkg repository
- EOE
+ {
+ $clone_cfg;
+
+ $* 'git://example.org/repo' --type bpkg 2>>EOE != 0
+ error: invalid bpkg repository location 'git://example.org/repo': unsupported scheme for bpkg 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
@@ -66,21 +87,21 @@
:
$clone_cfg;
$* 'git://example.org/repo#master' 2>>EOE
- added repository git:example.org/repo#master
+ added git:example.org/repo#master
EOE
: http-git
:
$clone_cfg;
$* 'http://example.org/repo.git#master' 2>>EOE
- added repository git:example.org/repo#master
+ added git:example.org/repo#master
EOE
: http-bpkg
:
$clone_cfg;
$* 'http://example.org/1/repo' 2>>EOE
- added repository bpkg:example.org/repo
+ added bpkg:example.org/repo
EOE
: file-git
@@ -96,7 +117,7 @@
$clone_cfg;
$* '1/repo' 2>>/~%EOE%
- %added repository .+/repo%
+ %added .+/repo%
EOE
}
}
@@ -107,11 +128,11 @@
$clone_cfg;
$* ./1/bar/stable 2>>/~%EOE%;
- %added repository bpkg:.+/relative-path/bar/stable%
+ %added bpkg:.+/relative-path/bar/stable%
EOE
- $* ./1/../1/bar/stable 2>>/~%EOE% != 0
- %error: bpkg:.+/relative-path/bar/stable is already a repository of this configuration%
+ $* ./1/../1/bar/stable 2>>/~%EOE%
+ %unchanged bpkg:.+/relative-path/bar/stable%
EOE
}
@@ -121,11 +142,11 @@
$clone_cfg;
$* $~/1/foo/stable 2>>/~%EOE%;
- %added repository bpkg:.+/absolute-path/foo/stable%
+ %added bpkg:.+/absolute-path/foo/stable%
EOE
- $* $~/1/../1/foo/stable 2>>/~%EOE% != 0
- %error: bpkg:.+/absolute-path/foo/stable is already a repository of this configuration%
+ $* $~/1/../1/foo/stable 2>>/~%EOE%
+ %unchanged bpkg:.+/absolute-path/foo/stable%
EOE
}
@@ -138,23 +159,47 @@
:
$clone_cfg;
- $* 'http://pkg.example.org/1/testing' 2>>~%EOE%;
- %added repository bpkg:example.org/testing%
+ $* 'http://pkg.example.org/1/testing' 2>>EOE;
+ added bpkg:example.org/testing
EOE
- $* 'https://www.example.org/1/testing' 2>>~%EOE% != 0
- %error: bpkg:example.org/testing is already a repository of this configuration%
+ $* 'https://www.example.org/1/testing' 2>>EOE;
+ updated bpkg:example.org/testing
EOE
+ $rep_list >>EOO
+ bpkg:example.org/testing https://www.example.org/1/testing
+ EOO
+
: git
:
$clone_cfg;
- $* 'git://example.org/testing#master' 2>>~%EOE%;
- %added repository git:example.org/testing#master%
+ $* 'git://example.org/testing.git#master' 2>>~%EOE%;
+ %added git:example.org/testing#master%
EOE
- $* 'git://www.example.org/testing#master' 2>>~%EOE% != 0
- %error: git:example.org/testing#master is already a repository of this configuration%
+ $* '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 bpkg:example.org/alpha
+ added bpkg:example.org/beta
+ EOE
+
+ $rep_list >>EOO
+ bpkg:example.org/alpha http://pkg.example.org/1/alpha
+ bpkg:example.org/beta http://pkg.example.org/1/beta
+ EOO
}
diff --git a/tests/rep-list.test b/tests/rep-list.test
new file mode 100644
index 0000000..aea7d84
--- /dev/null
+++ b/tests/rep-list.test
@@ -0,0 +1,142 @@
+# file : tests/rep-list.test
+# copyright : Copyright (c) 2014-2017 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
+# |
+# |-- math -> extra (prerequisite)
+# | |-- libbar-1.0.0.tar.gz
+# | `-- repositories
+# |
+# |-- stable -> math (prerequisite)
+# | |-- libfoo-1.0.0.tar.gz
+# | `-- repositories
+# |
+# `-- testing -> stable (complement), extra (prerequisite)
+# | |-- libbar-2.0.0.tar.gz
+# | `-- repositories
+# |
+# `-- git
+# |-- libbar.git -> style-basic.git (prerequisite)
+# `-- style-basic.git
+
+# Prepare repositories used by tests if running in the local mode.
+#
++if ($remote != true)
+ c = $rep_create 2>!
+
+ cp -r $src/extra $out/extra && $c $out/extra &$out/extra/packages
+ cp -r $src/math $out/math && $c $out/math &$out/math/packages
+ cp -r $src/stable $out/stable && $c $out/stable &$out/stable/packages
+ cp -r $src/testing $out/testing && $c $out/testing &$out/testing/packages
+
+ # 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"
+ bpkg:build2.org/rep-list/stable ($rep/stable)
+ bpkg: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"
+ bpkg:build2.org/rep-list/stable ($rep/stable)
+ prerequisite bpkg:build2.org/rep-list/math ($rep/math)
+ prerequisite bpkg:build2.org/rep-list/extra ($rep/extra)
+ prerequisite bpkg:build2.org/rep-list/stable ($rep/stable)
+ EOO
+}
+
+: complements
+:
+{
+ $clone_cfg;
+ $rep_add $rep/testing && $rep_fetch;
+
+ $* --complements >>"EOO"
+ bpkg:build2.org/rep-list/testing ($rep/testing)
+ complement bpkg:build2.org/rep-list/stable ($rep/stable)
+ EOO
+}
+
+: all
+:
+{
+ $clone_cfg;
+ $rep_add $rep/testing && $rep_fetch;
+
+ $* --prerequisites --complements >>"EOO"
+ bpkg:build2.org/rep-list/testing ($rep/testing)
+ complement bpkg:build2.org/rep-list/stable ($rep/stable)
+ prerequisite bpkg:build2.org/rep-list/math ($rep/math)
+ prerequisite bpkg:build2.org/rep-list/extra ($rep/extra)
+ prerequisite bpkg:build2.org/rep-list/stable ($rep/stable)
+ prerequisite bpkg:build2.org/rep-list/extra ($rep/extra)
+ prerequisite bpkg:build2.org/rep-list/stable ($rep/stable)
+ prerequisite bpkg:build2.org/rep-list/math ($rep/math)
+ prerequisite bpkg:build2.org/rep-list/extra ($rep/extra)
+ EOO
+}
+
+: git-repos
+:
+if ($git_supported != true)
+{
+ # Skip git repository tests.
+ #
+}
+else
+{
+ rep = "$rep_git/state0"
+ test.cleanups += &cfg/.bpkg/repositories/*/***
+
+ : 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%
+ EOO
+}
diff --git a/tests/rep-list/extra/libbar-1.1.0+1.tar.gz b/tests/rep-list/extra/libbar-1.1.0+1.tar.gz
new file mode 100644
index 0000000..890e9e2
--- /dev/null
+++ b/tests/rep-list/extra/libbar-1.1.0+1.tar.gz
Binary files differ
diff --git a/tests/rep-list/extra/repositories b/tests/rep-list/extra/repositories
new file mode 100644
index 0000000..ecaa454
--- /dev/null
+++ b/tests/rep-list/extra/repositories
@@ -0,0 +1,3 @@
+: 1
+location: ../stable
+:
diff --git a/tests/rep-list/git/libbar.tar b/tests/rep-list/git/libbar.tar
new file mode 120000
index 0000000..67ccdb1
--- /dev/null
+++ b/tests/rep-list/git/libbar.tar
@@ -0,0 +1 @@
+../../common/git/state0/libbar.tar \ No newline at end of file
diff --git a/tests/rep-list/git/style-basic.tar b/tests/rep-list/git/style-basic.tar
new file mode 120000
index 0000000..2833f83
--- /dev/null
+++ b/tests/rep-list/git/style-basic.tar
@@ -0,0 +1 @@
+../../common/git/state0/style-basic.tar \ No newline at end of file
diff --git a/tests/rep-list/math/libbar-1.0.0.tar.gz b/tests/rep-list/math/libbar-1.0.0.tar.gz
new file mode 100644
index 0000000..97e6e32
--- /dev/null
+++ b/tests/rep-list/math/libbar-1.0.0.tar.gz
Binary files differ
diff --git a/tests/rep-list/math/repositories b/tests/rep-list/math/repositories
new file mode 100644
index 0000000..14d6ce0
--- /dev/null
+++ b/tests/rep-list/math/repositories
@@ -0,0 +1,3 @@
+: 1
+location: ../extra
+:
diff --git a/tests/rep-list/stable/libfoo-1.0.0.tar.gz b/tests/rep-list/stable/libfoo-1.0.0.tar.gz
new file mode 100644
index 0000000..5e7fa17
--- /dev/null
+++ b/tests/rep-list/stable/libfoo-1.0.0.tar.gz
Binary files differ
diff --git a/tests/rep-list/stable/repositories b/tests/rep-list/stable/repositories
new file mode 100644
index 0000000..b49d922
--- /dev/null
+++ b/tests/rep-list/stable/repositories
@@ -0,0 +1,3 @@
+: 1
+location: ../math
+:
diff --git a/tests/rep-list/testing/libbar-2.0.0.tar.gz b/tests/rep-list/testing/libbar-2.0.0.tar.gz
new file mode 100644
index 0000000..6cc5890
--- /dev/null
+++ b/tests/rep-list/testing/libbar-2.0.0.tar.gz
Binary files differ
diff --git a/tests/rep-list/testing/repositories b/tests/rep-list/testing/repositories
new file mode 100644
index 0000000..7bd7269
--- /dev/null
+++ b/tests/rep-list/testing/repositories
@@ -0,0 +1,6 @@
+: 1
+location: ../stable
+role: complement
+:
+location: ../extra
+:
diff --git a/tests/rep-remove.test b/tests/rep-remove.test
new file mode 100644
index 0000000..0dea240
--- /dev/null
+++ b/tests/rep-remove.test
@@ -0,0 +1,139 @@
+# file : tests/rep-remove.test
+# copyright : Copyright (c) 2014-2017 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
+# |
+# |-- math -> extra (prerequisite)
+# | |-- libbar-1.0.0.tar.gz
+# | `-- repositories
+# |
+# |-- stable -> math (prerequisite)
+# | |-- libfoo-1.0.0.tar.gz
+# | `-- repositories
+# |
+# `-- testing -> stable (complement), extra (prerequisite)
+# | |-- libbar-2.0.0.tar.gz
+# | `-- repositories
+# |
+# `-- alpha
+# | |-- libbar-2.0.0.tar.gz
+# | `-- repositories
+# |
+# `-- git
+# `-- style-basic.git
+
+# Prepare repositories used by tests if running in the local mode.
+#
++if ($remote != true)
+ c = $rep_create 2>!
+
+ cp -r $src/extra $out/extra && $c $out/extra &$out/extra/packages
+ cp -r $src/math $out/math && $c $out/math &$out/math/packages
+ cp -r $src/stable $out/stable && $c $out/stable &$out/stable/packages
+ cp -r $src/testing $out/testing && $c $out/testing &$out/testing/packages
+ cp -r $src/alpha $out/alpha && $c $out/alpha &$out/alpha/packages
+
+ # 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
+pkg_status += -d cfg
+
+: by-name
+:
+{
+ $clone_cfg;
+ $rep_add $rep/extra && $rep_fetch;
+
+ $* 'bpkg:build2.org/rep-remove/extra' 2>>"EOE";
+ removed bpkg:build2.org/rep-remove/extra
+ EOE
+
+ $rep_list >:""
+}
+
+: prerequisites-cycle
+:
+{
+ $clone_cfg;
+ $rep_add $rep/testing && $rep_fetch;
+
+ $* $rep/testing 2>>"EOE";
+ removed bpkg:build2.org/rep-remove/testing
+ EOE
+
+ $rep_list >:"";
+ $pkg_status libbar >'unknown';
+ $pkg_status libfoo >'unknown'
+}
+
+: reacheable
+:
+{
+ $clone_cfg;
+ $rep_add $rep/testing && $rep_add $rep/math && $rep_fetch;
+
+ $* $rep/testing 2>>"EOE";
+ removed bpkg:build2.org/rep-remove/testing
+ EOE
+
+ $rep_list --prerequisites --complements >>"EOO";
+ bpkg:build2.org/rep-remove/math ($rep/math)
+ prerequisite bpkg:build2.org/rep-remove/extra ($rep/extra)
+ prerequisite bpkg:build2.org/rep-remove/stable ($rep/stable)
+ prerequisite bpkg:build2.org/rep-remove/math ($rep/math)
+ EOO
+
+ $pkg_status libbar >'available 1.0.0 sys:?';
+ $pkg_status libfoo >'unknown'
+}
+
+: package-locations
+:
+{
+ $clone_cfg;
+ $rep_add $rep/testing && $rep_add $rep/alpha && $rep_fetch;
+
+ $* $rep/testing 2>!;
+ $pkg_status libbar >'available 2.0.0 sys:?';
+
+ $* $rep/alpha 2>!;
+ $pkg_status libbar >'unknown'
+}
+
+: git-repos
+:
+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/alpha/libbar-2.0.0.tar.gz b/tests/rep-remove/alpha/libbar-2.0.0.tar.gz
new file mode 100644
index 0000000..6cc5890
--- /dev/null
+++ b/tests/rep-remove/alpha/libbar-2.0.0.tar.gz
Binary files differ
diff --git a/tests/rep-remove/alpha/repositories b/tests/rep-remove/alpha/repositories
new file mode 100644
index 0000000..5b70556
--- /dev/null
+++ b/tests/rep-remove/alpha/repositories
@@ -0,0 +1 @@
+: 1
diff --git a/tests/rep-remove/extra/libbar-1.1.0+1.tar.gz b/tests/rep-remove/extra/libbar-1.1.0+1.tar.gz
new file mode 100644
index 0000000..890e9e2
--- /dev/null
+++ b/tests/rep-remove/extra/libbar-1.1.0+1.tar.gz
Binary files differ
diff --git a/tests/rep-remove/extra/repositories b/tests/rep-remove/extra/repositories
new file mode 100644
index 0000000..ecaa454
--- /dev/null
+++ b/tests/rep-remove/extra/repositories
@@ -0,0 +1,3 @@
+: 1
+location: ../stable
+:
diff --git a/tests/rep-remove/git/style-basic.tar b/tests/rep-remove/git/style-basic.tar
new file mode 120000
index 0000000..2833f83
--- /dev/null
+++ b/tests/rep-remove/git/style-basic.tar
@@ -0,0 +1 @@
+../../common/git/state0/style-basic.tar \ No newline at end of file
diff --git a/tests/rep-remove/math/libbar-1.0.0.tar.gz b/tests/rep-remove/math/libbar-1.0.0.tar.gz
new file mode 100644
index 0000000..97e6e32
--- /dev/null
+++ b/tests/rep-remove/math/libbar-1.0.0.tar.gz
Binary files differ
diff --git a/tests/rep-remove/math/repositories b/tests/rep-remove/math/repositories
new file mode 100644
index 0000000..14d6ce0
--- /dev/null
+++ b/tests/rep-remove/math/repositories
@@ -0,0 +1,3 @@
+: 1
+location: ../extra
+:
diff --git a/tests/rep-remove/stable/libfoo-1.0.0.tar.gz b/tests/rep-remove/stable/libfoo-1.0.0.tar.gz
new file mode 100644
index 0000000..5e7fa17
--- /dev/null
+++ b/tests/rep-remove/stable/libfoo-1.0.0.tar.gz
Binary files differ
diff --git a/tests/rep-remove/stable/repositories b/tests/rep-remove/stable/repositories
new file mode 100644
index 0000000..b49d922
--- /dev/null
+++ b/tests/rep-remove/stable/repositories
@@ -0,0 +1,3 @@
+: 1
+location: ../math
+:
diff --git a/tests/rep-remove/testing/libbar-2.0.0.tar.gz b/tests/rep-remove/testing/libbar-2.0.0.tar.gz
new file mode 100644
index 0000000..6cc5890
--- /dev/null
+++ b/tests/rep-remove/testing/libbar-2.0.0.tar.gz
Binary files differ
diff --git a/tests/rep-remove/testing/repositories b/tests/rep-remove/testing/repositories
new file mode 100644
index 0000000..7bd7269
--- /dev/null
+++ b/tests/rep-remove/testing/repositories
@@ -0,0 +1,6 @@
+: 1
+location: ../stable
+role: complement
+:
+location: ../extra
+: