aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorKaren Arutyunov <karen@codesynthesis.com>2018-08-25 20:42:44 +0300
committerKaren Arutyunov <karen@codesynthesis.com>2018-08-28 23:30:37 +0300
commit2abd895682ec8707f30fc6babbf3787e00a8c280 (patch)
treef214eddd5150da7e92097118d6d63278fed98575 /tests
parentfe6aa3aa87bdff77ca667e012a9d1cc34f1fb8ea (diff)
Implement CI request submission
Diffstat (limited to 'tests')
-rw-r--r--tests/ci.test198
-rw-r--r--tests/publish.test26
2 files changed, 213 insertions, 11 deletions
diff --git a/tests/ci.test b/tests/ci.test
new file mode 100644
index 0000000..85155de
--- /dev/null
+++ b/tests/ci.test
@@ -0,0 +1,198 @@
+# file : tests/ci.test
+# copyright : Copyright (c) 2014-2018 Code Synthesis Ltd
+# license : MIT; see accompanying LICENSE file
+
+.include common.test project.test
+
+# bdep-ci requirements for the minimum supported git version are higher then
+# the default 2.1.0 (see bdep/ci.cxx for details).
+#
++if! ($git_version_major > 2 || \
+ $git_version_major == 2 && $git_version_minor >= 11)
+ exit
+end
+
+# Server to use for the CI request submissions simulation.
+#
+# Note that the empty config.bdep.test.repository value is used to suppress
+# these tests (which require network access).
+#
+server = ($config.bdep.test.repository == [null] \
+ ? ($build.version.stage \
+ ? 'https://stage.build2.org' \
+ : 'https://ci.cppget.org') \
+ : "$config.bdep.test.repository")
+
++if ("$server" == '')
+ exit
+end
+
+# Create the remote repository.
+#
++mkdir --no-cleanup prj.git
++git -C prj.git init --bare 2>! >&2 &prj.git/***
+
+# Adjust the local repository and push it to the remote one.
+#
++sed -i -e 's/^(version:) .*$/\1 1.0.1/' prj/manifest
+
+g = git -C prj 2>! >&2
+
++$g remote add origin $~/prj.git
++$g add '*'
++$g commit -m 'Create'
++$g push --set-upstream origin master
+
+# Repository the CI-ed packages come from.
+#
+repository='http://example.com/prj.git'
+
+test.arguments += --yes --repository "$repository" --server "$server" \
+--simulate 'success'
+
+cxx = cc "config.cxx=$config.cxx"
+
+new += 2>!
+init += $cxx -d prj 2>! &prj/**/bootstrap/***
+
+windows = ($cxx.target.class == 'windows')
+
+: single-pkg
+:
+{
+ : single-cfg
+ :
+ {
+ $clone_root_prj;
+ $init -C @cfg &prj-cfg/***;
+
+ $* 2>>~"%EOE%"
+ submitting to $server
+ %.*
+ %CI request is queued \(.+\)%
+ EOE
+ }
+
+ : no-cfg
+ :
+ {
+ $new prj &prj/***;
+
+ $* 2>>~%EOE% != 0
+ %error: no default configuration in project .+%
+ % info: use .+%
+ EOE
+ }
+
+ : multi-cfg
+ :
+ {
+ $clone_root_prj;
+ $init -C @cfg1 &prj-cfg1/***;
+ $init -C @cfg2 &prj-cfg2/***;
+
+ $* --all 2>'error: multiple configurations specified for ci' != 0
+ }
+
+ : no-commits
+ :
+ {
+ $new prj &prj/***;
+ $init -C @cfg &prj-cfg/***;
+
+ $* 2>>~%EOE% != 0
+ error: no commits in project repository
+ % info: run .+%
+ EOE
+ }
+
+ : invalid-repo
+ :
+ {
+ test.arguments += --repository "$repository#frag"
+
+ $clone_root_prj;
+ $init -C @cfg &prj-cfg/***;
+
+ $* 2>>"EOE" != 0
+ error: remote git repository URL '$repository#frag' already has fragment
+ EOE
+ }
+}
+
+: multi-pkg
+:
+{
+ # Create the remote repository.
+ #
+ +mkdir --no-cleanup prj.git
+ +git -C prj.git init --bare 2>! >&2 &prj.git/***
+
+ # Create the local repository and push it to the remote one.
+ #
+ +$new -t empty prj &prj/***
+ +$new --package -t lib libprj -d prj
+ +$new --package -t exe prj -d prj
+ +sed -i -e 's/^(version:) .*$/\1 1.0.1/' prj/libprj/manifest
+ +sed -i -e 's/^(version:) .*$/\1 1.0.1/' prj/prj/manifest
+
+ +$g remote add origin $~/prj.git
+ +$g add '*'
+ +$g commit -m 'Create'
+ +$g push --set-upstream origin master
+
+ : both
+ :
+ {
+ $clone_prj;
+ $init -C @cfg &prj-cfg/***;
+
+ $* 2>>~"%EOE%"
+ submitting to $server
+ %.*
+ %CI request is queued \(.+\)%
+ EOE
+ }
+
+ : single
+ :
+ {
+ $clone_prj;
+ $init -C @cfg &prj-cfg/***;
+
+ # CI the single libprj package rather than the whole prj project.
+ #
+ test.arguments = $regex.apply($test.arguments, '^(prj)$', '\1/libprj');
+
+ $* 2>>~"%EOE%"
+ submitting to $server
+ %.*
+ %CI request is queued \(.+\)%
+ EOE
+ }
+
+ : prompt
+ :
+ {
+ $clone_prj;
+ $init -C @cfg &prj-cfg/***;
+
+ # Suppress the --yes option.
+ #
+ test.arguments = $regex.apply($test.arguments, '^(--yes)$', '');
+
+ $* <'y' 2>>~"%EOE%"
+ submitting:
+ to: $server
+ % in: $repository#master@.{40}%
+
+ package: libprj
+ version: 1.0.1
+
+ package: prj
+ version: 1.0.1
+ %.*
+ %CI request is queued \(.+\)%
+ EOE
+ }
+}
diff --git a/tests/publish.test b/tests/publish.test
index 4756abc..ba88e9a 100644
--- a/tests/publish.test
+++ b/tests/publish.test
@@ -14,8 +14,8 @@ end
# Repository to use for the package submissions simulation.
#
-# Note: could use empty config.bdep.test.repository value to suppress
-# these test (which require network access).
+# Note that the empty config.bdep.test.repository value is used to suppress
+# these tests (which require network access).
#
repository = ($config.bdep.test.repository == [null] \
? ($build.version.stage \
@@ -23,6 +23,10 @@ repository = ($config.bdep.test.repository == [null] \
: 'https://cppget.org') \
: "$config.bdep.test.repository")
++if ("$repository" == '')
+ exit
+end
+
test.arguments += --repository "$repository" --yes \
--author-name user --author-email user@example.com
@@ -49,7 +53,7 @@ windows = ($cxx.target.class == 'windows')
{
test.arguments += --simulate 'success'
- : basic
+ : single-cfg
:
{
$clone_root_prj;
@@ -205,7 +209,7 @@ windows = ($cxx.target.class == 'windows')
submitting prj-1.0.6.tar.gz
%.*
error: submission handling failed
- % info: consider reporting this to .+ repository maintainers%
+ % info: consider reporting this to .+ maintainers%
EOE
}
@@ -224,7 +228,7 @@ windows = ($cxx.target.class == 'windows')
submitting prj-1.0.7.tar.gz
%.*
error: HTTP status code 500 (internal server error)
- % info: consider reporting this to .+ repository maintainers%
+ % info: consider reporting this to .+ maintainers%
EOE
}
}
@@ -237,19 +241,19 @@ windows = ($cxx.target.class == 'windows')
# simulation. We specify it to enable the control branch-related
# functionality.
#
- test.arguments += --simulate 'success' --control "http://example.com/rep.git"
+ test.arguments += --simulate 'success' --control 'http://example.com/rep.git'
# Create the remote repository.
#
+mkdir --no-cleanup prj.git
- +git -C prj.git init --bar >! &prj.git/***
+ +git -C prj.git init --bare >! &prj.git/***
+$clone_prj
g = git -C prj >! 2>!
- +$g config user.name "Test Script"
- +$g config user.email "testscript@example.com"
+ +$g config user.name 'Test Script'
+ +$g config user.email 'testscript@example.com'
clone_rep = cp --no-cleanup -r ../prj.git ./ &prj.git/***
clone_prj = cp --no-cleanup -r ../prj ./ &prj/***
@@ -365,8 +369,8 @@ windows = ($cxx.target.class == 'windows')
git clone "$rep" prj2 &prj2/*** 2>&1 | \
sed -e 's/warning: (remote HEAD refers to nonexistent .*)/info: \1/' >&2 2>!;
- $g2 config user.name "Test Script";
- $g2 config user.email "testscript@example.com";
+ $g2 config user.name 'Test Script';
+ $g2 config user.email 'testscript@example.com';
$g2 checkout -b build2-control --track origin/build2-control;
$g2 commit --allow-empty -m 'Dummy1';
$g2 push;