aboutsummaryrefslogtreecommitdiff
path: root/tests/submit
diff options
context:
space:
mode:
Diffstat (limited to 'tests/submit')
-rw-r--r--tests/submit/data.testscript21
-rw-r--r--tests/submit/submit-dir.testscript11
-rw-r--r--tests/submit/submit-git.testscript67
-rw-r--r--tests/submit/submit-pub.testscript52
4 files changed, 112 insertions, 39 deletions
diff --git a/tests/submit/data.testscript b/tests/submit/data.testscript
index 875b4eb..b0fe8f0 100644
--- a/tests/submit/data.testscript
+++ b/tests/submit/data.testscript
@@ -3,12 +3,13 @@
# Pre-created submission data directory that will be copied by subsequent
# tests and scope setup commands. The common approach will be that group
-# scopes copy and modify the parent scope submission directory as required by
-# the nested tests and scopes. Tests will also clone the parent scope
-# submission data directory to optionally modify it, use and cleanup at the
-# end. Note that configuration can not be shared between multiple submission
-# handler processes. Also we need to make sure that submission data
-# directories are not cloned while being used by submission handler scripts.
+# scopes copy and modify the parent scope submission data directory as
+# required by the nested tests and scopes. Tests will also clone the parent
+# scope submission data directory to optionally modify it, use and cleanup at
+# the end. Note that submission data directory can not be shared between
+# multiple submission handler processes. Also we need to make sure that
+# submission data directories are not cloned while being used by submission
+# handler scripts.
#
data_dir = $regex.replace($path_search('*/request.manifest', $src_base), \
'(.*)/.*', \
@@ -25,10 +26,10 @@ root_data_dir = $~/$data_dir
# The most commonly used submission data directory cloning command that copies
# it from the parent scope working directory.
#
-clone_data = cp --no-cleanup -r ../$data_dir ./
-clone_data_clean = cp --no-cleanup -r ../$data_dir ./ &$data_dir/***
+clone_data = [cmdline] cp --no-cleanup -r ../$data_dir ./
+clone_data_clean = [cmdline] cp --no-cleanup -r ../$data_dir ./ &$data_dir/***
# Clones the original submission data directory.
#
-clone_root_data = cp --no-cleanup -r $root_data_dir ./
-clone_root_data_clean = cp --no-cleanup -r $root_data_dir ./ &$data_dir/***
+clone_root_data = [cmdline] cp --no-cleanup -r $root_data_dir ./
+clone_root_data_clean = [cmdline] cp --no-cleanup -r $root_data_dir ./ &$data_dir/***
diff --git a/tests/submit/submit-dir.testscript b/tests/submit/submit-dir.testscript
index 81dc494..285710f 100644
--- a/tests/submit/submit-dir.testscript
+++ b/tests/submit/submit-dir.testscript
@@ -77,7 +77,16 @@
$* >>"EOO"
: 1
status: 400
- message: archive is not a valid package \(run bpkg pkg-verify for details\)
+ message:\\
+ package archive is not valid
+
+ gzip: libhello-0.1.0.tar.gz: not in gzip format
+ tar: This does not look like a tar archive
+ tar: libhello-0.1.0/manifest: Not found in archive
+ tar: Exiting with failure status due to previous errors
+ info: libhello-0.1.0.tar.gz does not appear to be a bpkg package
+ info: run bpkg pkg-verify for details
+ \\
reference: $checksum
EOO
}
diff --git a/tests/submit/submit-git.testscript b/tests/submit/submit-git.testscript
index 8cdb29a..5197afc 100644
--- a/tests/submit/submit-git.testscript
+++ b/tests/submit/submit-git.testscript
@@ -9,19 +9,23 @@
#
# test.redirects += 2>!
-g = git 2>! >&2
+g = [cmdline] git 2>! >&2
# Create and clone the reference repository.
#
root_ref = $~/ref.git
root_ref_dir = $~/ref
-clone_root_ref = cp --no-cleanup -r $root_ref ./ &ref.git/***
+clone_root_ref = [cmdline] cp --no-cleanup -r $root_ref ./ &ref.git/***
+mkdir --no-cleanup $root_ref
+$g -C $root_ref init --bare &ref.git/***
-+$g clone $root_ref $root_ref_dir &ref/***
+# Convert specific warnings to infos as we expect them to appear. This, in
+# particular, prevents bbot workers to set task result status to warning.
+#
++git clone $root_ref $root_ref_dir &ref/*** 2>&1 | \
+ sed -e 's/warning: (.*cloned an empty repository.*)/info: \1/' >&2 2>!
+cat <<EOI >=$root_ref_dir/submit.config.bash
sections[alpha]=1/alpha
@@ -44,7 +48,7 @@ root_tgt_url = "file:///$~/tgt.git"
+cp -r $root_ref $root_tgt
-clone_root_tgt = cp --no-cleanup -r $root_tgt ./ &tgt.git/***
+clone_root_tgt = [cmdline] cp --no-cleanup -r $root_tgt ./ &tgt.git/***
# Extract the package repository.
#
@@ -466,21 +470,14 @@ pkg_ctl="$prj_ctl/hello.git"
sections['*']=1/alpha
EOI
- # Add the libhello/0.1.0+1 package revision to the target repository.
- #
- tar -xf $data_dir/libhello-0.1.0.tar.gz &libhello-0.1.0/***;
- sed -i -e 's/(version: 0.1.0)/\1+1/' libhello-0.1.0/manifest;
- mv libhello-0.1.0 libhello-0.1.0+1;
- mkdir -p tgt/1/alpha/hello/;
- tar cfz tgt/1/alpha/hello/libhello-0.1.0+1.tar.gz libhello-0.1.0+1;
- $g -C tgt add 1/;
-
$g -C tgt config user.name 'Test Script';
$g -C tgt config user.email 'testscript@example.com';
$g -C tgt commit -am 'Add config and archive';
$g -C tgt push;
- $* "file:///$~/tgt.git" $data_dir >>"EOO" &tgt/1/alpha/hello/libhello-0.1.0.tar.gz;
+ # Initial submission.
+ #
+ $* "file:///$~/tgt.git" $data_dir >>"EOO";
: 1
status: 200
message: package submission is queued: libhello/0.1.0
@@ -489,8 +486,46 @@ pkg_ctl="$prj_ctl/hello.git"
$g -C tgt pull;
- test -f tgt/1/alpha/hello/libhello-0.1.0+1.tar.gz == 1;
- test -f tgt/1/alpha/hello/libhello-0.1.0.tar.gz
+ test -f tgt/1/alpha/hello/libhello-0.1.0.tar.gz;
+
+ # Revision submission.
+ #
+ # Here we test that the handler removes the previous revision.
+ #
+ $clone_root_data_clean;
+
+ tar -xf $~/$data_dir/libhello-0.1.0.tar.gz;
+ sed -i -e 's/(version: 0.1.0)/\1+1/' libhello-0.1.0/manifest;
+ mv libhello-0.1.0 libhello-0.1.0+1;
+ tar cfz $~/$data_dir/libhello-0.1.0+1.tar.gz libhello-0.1.0+1;
+ rm -r libhello-0.1.0+1;
+ rm $~/$data_dir/libhello-0.1.0.tar.gz;
+ sed -i -e 's/(archive: libhello-0.1.0)(.tar.gz)/\1+1\2/' $data_dir/request.manifest;
+
+ $* "file:///$~/tgt.git" $data_dir >>"EOO" &tgt/1/alpha/hello/libhello-0.1.0+1.tar.gz;
+ : 1
+ status: 200
+ message: package submission is queued: libhello/0.1.0+1
+ reference: $checksum
+ EOO
+
+ $g -C tgt pull;
+
+ test -f tgt/1/alpha/hello/libhello-0.1.0.tar.gz == 1;
+ test -f tgt/1/alpha/hello/libhello-0.1.0+1.tar.gz;
+
+ # While at it, test the older revision submission.
+ #
+ $clone_root_data_clean;
+
+ $* "file:///$~/tgt.git" $data_dir >>"EOO";
+ : 1
+ status: 422
+ message: newer revision libhello/0.1.0+1 is present
+ reference: $checksum
+ EOO
+
+ test -f tgt/1/alpha/hello/libhello-0.1.0+1.tar.gz
}
: section-fallback
diff --git a/tests/submit/submit-pub.testscript b/tests/submit/submit-pub.testscript
index 78c42b6..8c042a7 100644
--- a/tests/submit/submit-pub.testscript
+++ b/tests/submit/submit-pub.testscript
@@ -17,7 +17,7 @@ root_rep=$~/pkg-1
+echo ": 1" >=$root_rep/1/repositories.manifest
+bpkg rep-create $root_rep/1 2>! &$root_rep/1/packages.manifest
-clone_root_rep = cp --no-cleanup -r $root_rep ./ &pkg-1/*** &?pkg.lock
+clone_root_rep = [cmdline] cp --no-cleanup -r $root_rep ./ &pkg-1/*** &?pkg.lock
: args
{
@@ -84,14 +84,8 @@ clone_root_rep = cp --no-cleanup -r $root_rep ./ &pkg-1/*** &?pkg.lock
$clone_root_rep;
ln -s pkg-1 pkg;
- # Add the libhello/0.1.0+1 package revision to the repository.
+ # Initial submission.
#
- mkdir --no-cleanup pkg-1/1/hello;
- tar -xf $~/$data_dir/libhello-0.1.0.tar.gz &libhello-0.1.0/***;
- sed -i -e 's/(version: 0.1.0)/\1+1/' libhello-0.1.0/manifest;
- mv libhello-0.1.0 libhello-0.1.0+1;
- tar cfz pkg-1/1/hello/libhello-0.1.0+1.tar.gz libhello-0.1.0+1;
-
$* $~/pkg $~/$data_dir &!pkg-1/*** &pkg-*/*** >>"EOO";
: 1
status: 200
@@ -99,7 +93,6 @@ clone_root_rep = cp --no-cleanup -r $root_rep ./ &pkg-1/*** &?pkg.lock
reference: $checksum
EOO
- test -f pkg/1/hello/libhello-0.1.0+1.tar.gz == 1;
test -f pkg/1/hello/libhello-0.1.0.tar.gz;
# While at it, test the duplicate submission.
@@ -113,7 +106,42 @@ clone_root_rep = cp --no-cleanup -r $root_rep ./ &pkg-1/*** &?pkg.lock
reference: $checksum
EOO
- test -f pkg/1/hello/libhello-0.1.0.tar.gz
+ test -f pkg/1/hello/libhello-0.1.0.tar.gz;
+
+ # Revision submission.
+ #
+ # Here we test that the handler removes the previous revision.
+ #
+ tar -xf $~/$data_dir/libhello-0.1.0.tar.gz;
+ sed -i -e 's/(version: 0.1.0)/\1+1/' libhello-0.1.0/manifest;
+ mv libhello-0.1.0 libhello-0.1.0+1;
+ tar cfz $~/$data_dir/libhello-0.1.0+1.tar.gz libhello-0.1.0+1;
+ rm -r libhello-0.1.0+1;
+ rm $~/$data_dir/libhello-0.1.0.tar.gz;
+ sed -i -e 's/(archive: libhello-0.1.0)(.tar.gz)/\1+1\2/' $data_dir/request.manifest;
+
+ $* $~/pkg $~/$data_dir >>"EOO";
+ : 1
+ status: 200
+ message: package is published: libhello/0.1.0+1
+ reference: $checksum
+ EOO
+
+ test -f pkg/1/hello/libhello-0.1.0.tar.gz == 1;
+ test -f pkg/1/hello/libhello-0.1.0+1.tar.gz;
+
+ # While at it, test the older revision submission.
+ #
+ $clone_root_data_clean;
+
+ $* $~/pkg $~/$data_dir >>"EOO";
+ : 1
+ status: 422
+ message: newer revision libhello/0.1.0+1 is present
+ reference: $checksum
+ EOO
+
+ test -f pkg/1/hello/libhello-0.1.0+1.tar.gz
}
: result-url
@@ -154,7 +182,7 @@ clone_root_rep = cp --no-cleanup -r $root_rep ./ &pkg-1/*** &?pkg.lock
$* $~/brep-loader $~/pkg $~/$data_dir >>~"%EOO%"
: 1
status: 400
- message: \\
+ message:\\
submitted archive is not a valid package
%.+
\\
@@ -175,7 +203,7 @@ clone_root_rep = cp --no-cleanup -r $root_rep ./ &pkg-1/*** &?pkg.lock
$* $~/brep-loader $~/pkg $~/$data_dir >>~"%EOO%"
: 1
status: 400
- message: \\
+ message:\\
unable to add package to repository
%.+
\\