aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorKaren Arutyunov <karen@codesynthesis.com>2018-02-19 14:26:02 +0300
committerKaren Arutyunov <karen@codesynthesis.com>2018-02-19 14:27:24 +0300
commit3d4838d3706de2ba0045dc9f99a3dc96398def64 (patch)
treeece29423c4ece1139169a8b952914471593fe577 /tests
parentd3ef22615ba7d37be18c31b2fdd1bdb6be164939 (diff)
Parse repositories and packages files for git repositories
Diffstat (limited to 'tests')
-rw-r--r--tests/common/git/state0/libbar.tarbin61440 -> 71680 bytes
-rw-r--r--tests/common/git/state0/libfoo.tarbin256000 -> 296960 bytes
-rw-r--r--tests/common/git/state0/style-basic.tarbin61440 -> 71680 bytes
-rw-r--r--tests/common/git/state0/style.tarbin112640 -> 133120 bytes
-rw-r--r--tests/common/git/state1/libbaz.tarbin61440 -> 61440 bytes
-rw-r--r--tests/common/git/state1/libfoo.tarbin337920 -> 378880 bytes
-rw-r--r--tests/common/git/state1/style-basic.tarbin61440 -> 71680 bytes
-rw-r--r--tests/common/git/state1/style.tarbin112640 -> 133120 bytes
-rwxr-xr-xtests/publish30
-rw-r--r--tests/remote-git.test20
-rw-r--r--tests/remote.test2
-rw-r--r--tests/rep-fetch-git-branch.test8
-rw-r--r--tests/rep-fetch-git-commit.test14
-rw-r--r--tests/rep-fetch-git.test2
-rw-r--r--tests/rep-fetch.test28
-rw-r--r--tests/rep-info.test52
l---------tests/rep-info/git/libbar.tar1
l---------tests/rep-info/git/style-basic.tar1
18 files changed, 110 insertions, 48 deletions
diff --git a/tests/common/git/state0/libbar.tar b/tests/common/git/state0/libbar.tar
index 879f042..e78ae06e 100644
--- a/tests/common/git/state0/libbar.tar
+++ b/tests/common/git/state0/libbar.tar
Binary files differ
diff --git a/tests/common/git/state0/libfoo.tar b/tests/common/git/state0/libfoo.tar
index 0533b6d..141a341 100644
--- a/tests/common/git/state0/libfoo.tar
+++ b/tests/common/git/state0/libfoo.tar
Binary files differ
diff --git a/tests/common/git/state0/style-basic.tar b/tests/common/git/state0/style-basic.tar
index 9d0ff47..217ee7c 100644
--- a/tests/common/git/state0/style-basic.tar
+++ b/tests/common/git/state0/style-basic.tar
Binary files differ
diff --git a/tests/common/git/state0/style.tar b/tests/common/git/state0/style.tar
index d83c39f..fc3faa0 100644
--- a/tests/common/git/state0/style.tar
+++ b/tests/common/git/state0/style.tar
Binary files differ
diff --git a/tests/common/git/state1/libbaz.tar b/tests/common/git/state1/libbaz.tar
index c0cdb40..373863e 100644
--- a/tests/common/git/state1/libbaz.tar
+++ b/tests/common/git/state1/libbaz.tar
Binary files differ
diff --git a/tests/common/git/state1/libfoo.tar b/tests/common/git/state1/libfoo.tar
index 5708d07..23275c8 100644
--- a/tests/common/git/state1/libfoo.tar
+++ b/tests/common/git/state1/libfoo.tar
Binary files differ
diff --git a/tests/common/git/state1/style-basic.tar b/tests/common/git/state1/style-basic.tar
index 71b5985..e4e14e9 100644
--- a/tests/common/git/state1/style-basic.tar
+++ b/tests/common/git/state1/style-basic.tar
Binary files differ
diff --git a/tests/common/git/state1/style.tar b/tests/common/git/state1/style.tar
index c939a87..52389c3 100644
--- a/tests/common/git/state1/style.tar
+++ b/tests/common/git/state1/style.tar
Binary files differ
diff --git a/tests/publish b/tests/publish
index 253c703..5d1e928 100755
--- a/tests/publish
+++ b/tests/publish
@@ -56,22 +56,28 @@ for r in $(find test -type d -regex '.*/git/.*/[^/]+\.git'); do
d=$(echo $br | sed -n -e 's%.*/git-bare/\(.*\)%\1%p')
for u in "${urls[@]}"; do
+ url="$u/$d"
- # Point the bare repository origin to the remote repository.
+ # Push local branches and tags to the remote repository, if it exists.
#
- git -C $br config remote.origin.url "$u/$d"
+ if git ls-remote "$url" 2>/dev/null >&2; then
+ # Point the bare repository origin to the remote repository.
+ #
+ git -C $br config remote.origin.url "$url"
- # Delete all remote branches and tags.
- #
- while read commit ref; do
- $echo_git git -C $br push origin ":$ref"
- done < <(git -C $br ls-remote --refs origin)
+ # Delete all remote branches and tags.
+ #
+ while read commit ref; do
+ $echo_git git -C $br push origin ":$ref"
+ done < <(git -C $br ls-remote --refs origin)
- # Push local branches.
- #
- while read branch; do
- $echo_git git -C $br push --tags origin "$branch:$branch"
- done < <(git -C $br for-each-ref --format='%(refname:short)' 'refs/heads/')
+ # Push local branches.
+ #
+ while read branch; do
+ $echo_git git -C $br push --tags origin "$branch:$branch"
+ done < <(git -C $br for-each-ref --format='%(refname:short)' \
+ 'refs/heads/')
+ fi
done
# Prepare the bare repository for serving via the HTTPS dumb protocol.
diff --git a/tests/remote-git.test b/tests/remote-git.test
index 5283b91..466acb9 100644
--- a/tests/remote-git.test
+++ b/tests/remote-git.test
@@ -25,11 +25,14 @@ 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 contains.
+# required by tests they contain.
#
out_git = $canonicalize([dir_path] $~/git/$cmd)
@@ -42,10 +45,25 @@ remote = $config.bpkg.test.remote
? "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 bpkg packages (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
index 581d8be..af0c6f6 100644
--- a/tests/remote.test
+++ b/tests/remote.test
@@ -12,7 +12,7 @@
#
# Output directory path that testscripts must use to prepare repositories
-# required by tests they contains.
+# 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
diff --git a/tests/rep-fetch-git-branch.test b/tests/rep-fetch-git-branch.test
index ea78986..86f5cb1 100644
--- a/tests/rep-fetch-git-branch.test
+++ b/tests/rep-fetch-git-branch.test
@@ -55,7 +55,7 @@ warning: fetching over dumb HTTP, no progress will be shown'
$warn4
%Cloning into '.+libbar'.+%
%Submodule path 'libbar': checked out .+%
- 0 package\(s\) in 1 repository\(s\)
+ 1 package\(s\) in 1 repository\(s\)
EOE
}
@@ -82,7 +82,7 @@ warning: fetching over dumb HTTP, no progress will be shown'
%fetching git:.+libfoo%
$warn
%Fetching in '.+$branch'.+%
- 0 package\(s\) in 1 repository\(s\)
+ 1 package\(s\) in 1 repository\(s\)
EOE
}
@@ -117,7 +117,7 @@ warning: fetching over dumb HTTP, no progress will be shown'
# Preconditions.
#
test -f $r/tests/TODO;
- test -f $r/libbar/manifest;
+ test -f $r/libbar/libbar/manifest;
test -f $r/doc/style/README != 0;
test -d $r/libbaz != 0;
@@ -143,7 +143,7 @@ warning: fetching over dumb HTTP, no progress will be shown'
$warn3
%Cloning into '.+libbaz'.+%
%Submodule path 'libbaz': checked out .+%
- 0 package\(s\) in 1 repository\(s\)
+ 1 package\(s\) in 1 repository\(s\)
EOE
# Postconditions.
diff --git a/tests/rep-fetch-git-commit.test b/tests/rep-fetch-git-commit.test
index e2752b6..3547010 100644
--- a/tests/rep-fetch-git-commit.test
+++ b/tests/rep-fetch-git-commit.test
@@ -45,7 +45,7 @@ warning: fetching over dumb HTTP, no progress will be shown'
$warn
%Cloning into '.+$abbr_commit'.+%
$fetch
- 0 package\(s\) in 1 repository\(s\)
+ 1 package\(s\) in 1 repository\(s\)
EOE
}
@@ -56,7 +56,7 @@ warning: fetching over dumb HTTP, no progress will be shown'
if ($git_protocol == 'https-smart-unadv')
warn = '%.{0}'
- fetch = "%Fetching in '.+stable'.+%"
+ fetch = "%Fetching in '.+$abbr_commit'.+%"
else
warn = "warning: fetching whole branch history"
@@ -72,9 +72,9 @@ warning: fetching over dumb HTTP, no progress will be shown'
$* 2>>~"%EOE%"
%fetching git:.+style-basic%
$warn
- %Cloning into '.+stable'.+%
+ %Cloning into '.+$abbr_commit'.+%
$fetch
- 0 package\(s\) in 1 repository\(s\)
+ 1 package\(s\) in 1 repository\(s\)
EOE
}
}
@@ -103,7 +103,7 @@ warning: fetching over dumb HTTP, no progress will be shown'
$warn
%Cloning into '.+$abbr_commit'.+%
$fetch
- 0 package\(s\) in 1 repository\(s\)
+ 1 package\(s\) in 1 repository\(s\)
EOE
}
@@ -121,8 +121,8 @@ warning: fetching over dumb HTTP, no progress will be shown'
$* 2>>~"%EOE%"
%fetching git:.+style-basic%
$warn
- %Cloning into '.+stable'.+%
- 0 package\(s\) in 1 repository\(s\)
+ %Cloning into '.+$abbr_commit'.+%
+ 1 package\(s\) in 1 repository\(s\)
EOE
}
}
diff --git a/tests/rep-fetch-git.test b/tests/rep-fetch-git.test
index b3bf875..45badc3 100644
--- a/tests/rep-fetch-git.test
+++ b/tests/rep-fetch-git.test
@@ -6,7 +6,7 @@
# the final states. See tests/common/git/init script for more details.
#
-rep_add += --type git -d cfg 2>!
+rep_add += -d cfg 2>!
test.cleanups += &cfg/.bpkg/repositories/*/***
+if ($git_protocol == 'local')
diff --git a/tests/rep-fetch.test b/tests/rep-fetch.test
index 3630709..499541f 100644
--- a/tests/rep-fetch.test
+++ b/tests/rep-fetch.test
@@ -60,23 +60,15 @@
# Create git repositories.
#
- # 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 bpkg packages (see
- # pkg-unpack.cxx).
- #
- x = ($cxx.target.class != 'windows' \
- ? tar -C $out_git -xf \
- : tar -C $regex.replace($out_git, '\\', '/') --force-local -xf)
-
- $x $src/git/state0/libfoo.tar
- $x $src/git/state0/libbar.tar
- $x $src/git/state0/style.tar
- $x $src/git/state0/style-basic.tar &$out_git/state0/***
-
- $x $src/git/state1/libfoo.tar
- $x $src/git/state1/libbaz.tar
- $x $src/git/state1/style.tar
- $x $src/git/state1/style-basic.tar &$out_git/state1/***
+ $git_extract $src/git/state0/libfoo.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
: no-repos
@@ -165,7 +157,7 @@ $* 2>>/EOE != 0
:
if ($git_supported != true)
{
- # Skip git repository fetch tests.
+ # Skip git repository tests.
#
}
elif ($remote != true)
diff --git a/tests/rep-info.test b/tests/rep-info.test
index 4c90ab6..32b77fb 100644
--- a/tests/rep-info.test
+++ b/tests/rep-info.test
@@ -2,14 +2,18 @@
# copyright : Copyright (c) 2014-2017 Code Synthesis Ltd
# license : MIT; see accompanying LICENSE file
-.include common.test auth.test remote.test
+.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
+# |-- testing -> stable (complement), ../foo/testing (prerequisite)
+# | |-- foo-1.tar.gz
+# | `-- repositories
+# |
+# `-- git
+# |-- libbar.git -> style-basic.git (prerequisite)
+# `-- style-basic.git
# Prepare repositories used by tests if running in the local mode.
#
@@ -26,6 +30,11 @@
cp -r $src/testing $out/signed
cat <<<$cert_manifest >+$out/signed/repositories
$rc --key $key $out/signed &$out/signed/packages &$out/signed/signature
+
+ # 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
@@ -126,3 +135,38 @@ $* --name $rep/testing >"bpkg:build2.org/rep-info/testing ($rep/testing)"
$* --cert-organization >'Code Synthesis' : organization
$* --cert-email >'info@build2.org' : email
}
+
+: git-repos
+:
+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 .+style-basic.git#master%
+
+ %style-basic/1\.1\.0-a\.0\..+%
+ EOO
+
+ : manifest-lists
+ :
+ : The packages and repositories files are present in the repository root.
+ :
+ $* "$rep/libbar.git#master" >>~%EOO%
+ %git:.+libbar .+libbar.git#master%
+ %prerequisite git:.+style-basic .+style-basic.git#stable%
+
+ libbar/1.0.0
+ libmbar/1.0.0
+ EOO
+}
diff --git a/tests/rep-info/git/libbar.tar b/tests/rep-info/git/libbar.tar
new file mode 120000
index 0000000..67ccdb1
--- /dev/null
+++ b/tests/rep-info/git/libbar.tar
@@ -0,0 +1 @@
+../../common/git/state0/libbar.tar \ No newline at end of file
diff --git a/tests/rep-info/git/style-basic.tar b/tests/rep-info/git/style-basic.tar
new file mode 120000
index 0000000..2833f83
--- /dev/null
+++ b/tests/rep-info/git/style-basic.tar
@@ -0,0 +1 @@
+../../common/git/state0/style-basic.tar \ No newline at end of file