From d1d9fbc899be37bba7b05f31ac5c7a4d15d64811 Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Tue, 4 Sep 2018 14:32:11 +0300 Subject: Rename .test/test{} to .testscript/testscript{} --- tests/build/root.build | 2 +- tests/buildfile | 4 +- tests/ci.test | 206 -------------------- tests/ci.testscript | 206 ++++++++++++++++++++ tests/common.test | 61 ------ tests/common.testscript | 61 ++++++ tests/config.test | 320 ------------------------------ tests/config.testscript | 320 ++++++++++++++++++++++++++++++ tests/fetch.test | 54 ------ tests/fetch.testscript | 54 ++++++ tests/init.test | 201 ------------------- tests/init.testscript | 201 +++++++++++++++++++ tests/new.test | 217 --------------------- tests/new.testscript | 217 +++++++++++++++++++++ tests/project.test | 26 --- tests/project.testscript | 26 +++ tests/publish.test | 494 ----------------------------------------------- tests/publish.testscript | 494 +++++++++++++++++++++++++++++++++++++++++++++++ tests/status.test | 105 ---------- tests/status.testscript | 105 ++++++++++ tests/sync.test | 204 ------------------- tests/sync.testscript | 204 +++++++++++++++++++ tests/test.test | 106 ---------- tests/test.testscript | 106 ++++++++++ tests/update.test | 91 --------- tests/update.testscript | 91 +++++++++ 26 files changed, 2088 insertions(+), 2088 deletions(-) delete mode 100644 tests/ci.test create mode 100644 tests/ci.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/fetch.test create mode 100644 tests/fetch.testscript delete mode 100644 tests/init.test create mode 100644 tests/init.testscript delete mode 100644 tests/new.test create mode 100644 tests/new.testscript delete mode 100644 tests/project.test create mode 100644 tests/project.testscript delete mode 100644 tests/publish.test create mode 100644 tests/publish.testscript delete mode 100644 tests/status.test create mode 100644 tests/status.testscript delete mode 100644 tests/sync.test create mode 100644 tests/sync.testscript delete mode 100644 tests/test.test create mode 100644 tests/test.testscript delete mode 100644 tests/update.test create mode 100644 tests/update.testscript (limited to 'tests') diff --git a/tests/build/root.build b/tests/build/root.build index 9013029..8176e9e 100644 --- a/tests/build/root.build +++ b/tests/build/root.build @@ -10,7 +10,7 @@ using cxx # Setup the bdep that we are testing. # import bdep = bdep%exe{bdep} -test{*}: test = $bdep +testscript{*}: test = $bdep # Specify the test target for cross-testing. # diff --git a/tests/buildfile b/tests/buildfile index 6ab9123..0640b2f 100644 --- a/tests/buildfile +++ b/tests/buildfile @@ -3,8 +3,8 @@ # license : MIT; see accompanying LICENSE file define common: file -common{*}: extension = test +common{*}: extension = testscript commons = common project -./: test{* -{$commons}} common{$commons} $bdep +./: testscript{* -{$commons}} common{$commons} $bdep diff --git a/tests/ci.test b/tests/ci.test deleted file mode 100644 index f398c5e..0000000 --- a/tests/ci.test +++ /dev/null @@ -1,206 +0,0 @@ -# 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 config user.name 'Test Script' -+$g config user.email 'testscript@example.com' -+$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="$recall($cxx.path)" - -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.*% - %reference: .+% - 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 config user.name 'Test Script' - +$g config user.email 'testscript@example.com' - +$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.*% - %reference: .+% - 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.*% - %reference: .+% - 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.*% - %reference: .+% - EOE - } -} diff --git a/tests/ci.testscript b/tests/ci.testscript new file mode 100644 index 0000000..07d1923 --- /dev/null +++ b/tests/ci.testscript @@ -0,0 +1,206 @@ +# file : tests/ci.testscript +# copyright : Copyright (c) 2014-2018 Code Synthesis Ltd +# license : MIT; see accompanying LICENSE file + +.include common.testscript project.testscript + +# 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 config user.name 'Test Script' ++$g config user.email 'testscript@example.com' ++$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="$recall($cxx.path)" + +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.*% + %reference: .+% + 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 config user.name 'Test Script' + +$g config user.email 'testscript@example.com' + +$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.*% + %reference: .+% + 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.*% + %reference: .+% + 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.*% + %reference: .+% + EOE + } +} diff --git a/tests/common.test b/tests/common.test deleted file mode 100644 index 46c4de9..0000000 --- a/tests/common.test +++ /dev/null @@ -1,61 +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). Note that this implies that -# we don't support cross-testing. -# -# A common approach will be to run build2 as a sanity check in a directory -# produced or updated by a command being tested. -# -build = $recall($build.path) -test.options += --build $build - -# Check that git version is the minimum supported one or above. The lowest -# common denominator for bdep commands is 2.1.0. -# -+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 - -+if! ($git_version_major > 2 || \ - $git_version_major == 2 && $git_version_minor >= 1) - exit "minimum supported git version is 2.1.0" -end - -# 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). -# -clean = $* clean -deinit = $* deinit -init = $* init -fetch = $* fetch -new = $* new --no-checks -status = $* status -sync = $* sync -update = $* update -config = $* config -publish = $* publish - -# All testscripts are named after bdep commands, for example sync.test. So the -# testscript scope id is a name of the command being tested. -# -cmd = [string] $@ -test.arguments = $cmd diff --git a/tests/common.testscript b/tests/common.testscript new file mode 100644 index 0000000..400ae48 --- /dev/null +++ b/tests/common.testscript @@ -0,0 +1,61 @@ +# 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). Note that this implies that +# we don't support cross-testing. +# +# A common approach will be to run build2 as a sanity check in a directory +# produced or updated by a command being tested. +# +build = $recall($build.path) +test.options += --build $build + +# Check that git version is the minimum supported one or above. The lowest +# common denominator for bdep commands is 2.1.0. +# ++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 + ++if! ($git_version_major > 2 || \ + $git_version_major == 2 && $git_version_minor >= 1) + exit "minimum supported git version is 2.1.0" +end + +# 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). +# +clean = $* clean +deinit = $* deinit +init = $* init +fetch = $* fetch +new = $* new --no-checks +status = $* status +sync = $* sync +update = $* update +config = $* config +publish = $* publish + +# All testscripts are named after bdep commands, for example sync.testscript. +# So the testscript scope id is a name of the command being tested. +# +cmd = [string] $@ +test.arguments = $cmd diff --git a/tests/config.test b/tests/config.test deleted file mode 100644 index 0500686..0000000 --- a/tests/config.test +++ /dev/null @@ -1,320 +0,0 @@ -# file : tests/config.test -# copyright : Copyright (c) 2014-2018 Code Synthesis Ltd -# license : MIT; see accompanying LICENSE file - -# Note that we test the list sub-command while testing other sub-commands. -# - -.include common.test project.test - -cxx = cc config.cxx="$recall($cxx.path)" - -status += -d prj -init += -d prj -update += -d prj -deinit += -d prj - -: create -: -{ - : name-dir - : - { - $clone_root_prj; - - $* create @cfg cfg-dir $cxx 2>>/"EOE" &cfg-dir/***; - created configuration @cfg $~/cfg-dir/ 1 default,forwarded,auto-synchronized - EOE - - $status 2>'error: package prj is not initialized in configuration @cfg' != 0; - - $init @cfg 2>>/~"%EOE%"; - initializing in project $~/prj/ - synchronizing: - % new prj.+19700101000000% - EOE - - $status >'prj configured 0.1.0-a.0.19700101000000'; - - $* list @cfg >>/"EOO"; - @cfg $~/cfg-dir/ 1 default,forwarded,auto-synchronized - EOO - - $update @cfg 2>>~%EOE%; - %(mkdir|c\+\+|ld) .+%{3} - EOE - - $deinit @cfg 2>>/"EOE" - deinitializing in project $~/prj/ - synchronizing: - drop prj - EOE - } - - : name - : - { - $clone_root_prj; - - $* create -- @cfg $cxx 2>>/"EOE" &prj-cfg/***; - created configuration @cfg $~/prj-cfg/ 1 default,forwarded,auto-synchronized - EOE - - $init @cfg 2>>/~"%EOE%"; - initializing in project $~/prj/ - synchronizing: - % new prj.+19700101000000% - EOE - - $status >'prj configured 0.1.0-a.0.19700101000000'; - - $* list >>/"EOO"; - @cfg $~/prj-cfg/ 1 default,forwarded,auto-synchronized - EOO - - $update @cfg 2>>~%EOE%; - %(mkdir|c\+\+|ld) .+%{3} - EOE - - $deinit @cfg 2>>/"EOE" - deinitializing in project $~/prj/ - synchronizing: - drop prj - EOE - } - - : dir - : - { - $clone_root_prj; - - $* create cfg $cxx 2>>/"EOE" &cfg/***; - created configuration $~/cfg/ 1 default,forwarded,auto-synchronized - EOE - - $init -c cfg 2>>/~"%EOE%"; - initializing in project $~/prj/ - synchronizing: - % new prj.+19700101000000% - EOE - - $status >'prj configured 0.1.0-a.0.19700101000000'; - - $* list >>/"EOO"; - $~/cfg/ 1 default,forwarded,auto-synchronized - EOO - - $update -c cfg 2>>~%EOE%; - %(mkdir|c\+\+|ld) .+%{3} - EOE - - $deinit -c cfg 2>>/"EOE" - deinitializing in project $~/prj/ - synchronizing: - drop prj - EOE - } - - : wipe - : - { - $clone_root_prj; - - mkdir --no-cleanup cfg; - touch --no-cleanup cfg/a; - - $* create cfg $cxx 2>>/"EOE" != 0; - error: directory $~/cfg/ is not empty - info: use --wipe to clean it up but be careful - EOE - - $* create --wipe cfg $cxx 2>>/"EOE" &cfg/*** - created configuration $~/cfg/ 1 default,forwarded,auto-synchronized - EOE - } -} - -: add -: -{ - $clone_root_prj; - - # Pre-create configurations. - # - $new -C prj-cfg1 tmp1 $cxx 2>! &prj-cfg1/*** &tmp1/***; - $new -C prj-cfg2 tmp2 $cxx 2>! &prj-cfg2/*** &tmp2/***; - - $* add @cfg1 prj-cfg1 2>>/"EOE"; - added configuration @cfg1 $~/prj-cfg1/ 1 default,forwarded,auto-synchronized - EOE - - $* add @cfg2 prj-cfg2 2>>/"EOE"; - added configuration @cfg2 $~/prj-cfg2/ 2 auto-synchronized - EOE - - $init --all 2>>/~"%EOE%"; - initializing in project $~/prj/ - in configuration @cfg1: - synchronizing: - % new prj.+19700101000000% - - in configuration @cfg2: - synchronizing: - % new prj.+19700101000000% - EOE - - $status --all >>EOO; - in configuration @cfg1: - prj configured 0.1.0-a.0.19700101000000 - - in configuration @cfg2: - prj configured 0.1.0-a.0.19700101000000 - EOO - - $* list >>/"EOO"; - @cfg1 $~/prj-cfg1/ 1 default,forwarded,auto-synchronized - @cfg2 $~/prj-cfg2/ 2 auto-synchronized - EOO - - $update --all 2>>~%EOE%; - in configuration @cfg1: - %(mkdir|c\+\+|ld) .+%{3} - - in configuration @cfg2: - %(mkdir|c\+\+|ld) .+%{3} - EOE - - $deinit --all 2>>/"EOE" - deinitializing in project $~/prj/ - in configuration @cfg1: - synchronizing: - drop prj - - in configuration @cfg2: - synchronizing: - drop prj - EOE -} - -: move -: -{ - $clone_root_prj; - - $* create -- @cfg $cxx &prj-cfg/*** 2>>/"EOE"; - created configuration @cfg $~/prj-cfg/ 1 default,forwarded,auto-synchronized - EOE - - $init @cfg 2>>/~"%EOE%"; - initializing in project $~/prj/ - synchronizing: - % new prj.+19700101000000% - EOE - - mv prj-cfg prj-cfg2; - - $* move @cfg prj-cfg2 2>>/"EOE"; - moved configuration @cfg $~/prj-cfg/ 1 to $~/prj-cfg2/ - EOE - - $update --all 2>>~%EOE%; - %(mkdir|c\+\+|ld) .+%{3} - EOE - - $deinit 2>>/"EOE" - deinitializing in project $~/prj/ - synchronizing: - drop prj - EOE -} - -: rename -: -{ - $clone_root_prj; - - $* create -- @cfg $cxx 2>>/"EOE" &prj-cfg/***; - created configuration @cfg $~/prj-cfg/ 1 default,forwarded,auto-synchronized - EOE - - $init @cfg 2>>/~"%EOE%"; - initializing in project $~/prj/ - synchronizing: - % new prj.+19700101000000% - EOE - - $* rename @cfg cfg2 2>>/"EOE"; - renamed configuration @cfg $~/prj-cfg/ 1 to @cfg2 - EOE - - $update @cfg2 2>>~%EOE%; - %(mkdir|c\+\+|ld) .+%{3} - EOE - - $deinit 2>>/"EOE" - deinitializing in project $~/prj/ - synchronizing: - drop prj - EOE -} - -: remove -: -: Here we also test the set sub-command. -: -{ - $clone_root_prj; - - $* create -- @cfg1 $cxx 2>! &prj-cfg1/***; - $* create -- @cfg2 $cxx 2>! &prj-cfg2/***; - - $init --all 2>!; - - $* remove @cfg1 2>>EOE != 0; - error: configuration @cfg1 contains initialized packages - info: use deinit command to deinitialize packages - info: use status command to list initialized packages - EOE - - $deinit @cfg1 2>>/"EOE"; - deinitializing in project $~/prj/ - synchronizing: - drop prj - EOE - - $* remove @cfg1 2>>/"EOE"; - removed configuration @cfg1 $~/prj-cfg1/ 1 - EOE - - $status --all >>EOO; - prj configured 0.1.0-a.0.19700101000000 - EOO - - $* list >>/"EOO"; - @cfg2 $~/prj-cfg2/ 2 auto-synchronized - EOO - - $update 2>>/"EOE" != 0; - error: no default configuration in project $~/prj/ - info: use \(@ | --config|-c | --all|-a\) to specify configuration explicitly - EOE - - $* set @cfg2 --default --forward --no-auto-sync 2>>/"EOE"; - updated configuration @cfg2 $~/prj-cfg2/ 2 default,forwarded - info: explicit bdep-sync is required for changes to take effect - EOE - - $* list >>/"EOO"; - @cfg2 $~/prj-cfg2/ 2 default,forwarded - EOO - - $update 2>>~%EOE%; - %(mkdir|c\+\+|ld) .+%{3} - EOE - - $deinit --all 2>>/"EOE" - deinitializing in project $~/prj/ - synchronizing: - drop prj - EOE -} diff --git a/tests/config.testscript b/tests/config.testscript new file mode 100644 index 0000000..68e504c --- /dev/null +++ b/tests/config.testscript @@ -0,0 +1,320 @@ +# file : tests/config.testscript +# copyright : Copyright (c) 2014-2018 Code Synthesis Ltd +# license : MIT; see accompanying LICENSE file + +# Note that we test the list sub-command while testing other sub-commands. +# + +.include common.testscript project.testscript + +cxx = cc config.cxx="$recall($cxx.path)" + +status += -d prj +init += -d prj +update += -d prj +deinit += -d prj + +: create +: +{ + : name-dir + : + { + $clone_root_prj; + + $* create @cfg cfg-dir $cxx 2>>/"EOE" &cfg-dir/***; + created configuration @cfg $~/cfg-dir/ 1 default,forwarded,auto-synchronized + EOE + + $status 2>'error: package prj is not initialized in configuration @cfg' != 0; + + $init @cfg 2>>/~"%EOE%"; + initializing in project $~/prj/ + synchronizing: + % new prj.+19700101000000% + EOE + + $status >'prj configured 0.1.0-a.0.19700101000000'; + + $* list @cfg >>/"EOO"; + @cfg $~/cfg-dir/ 1 default,forwarded,auto-synchronized + EOO + + $update @cfg 2>>~%EOE%; + %(mkdir|c\+\+|ld) .+%{3} + EOE + + $deinit @cfg 2>>/"EOE" + deinitializing in project $~/prj/ + synchronizing: + drop prj + EOE + } + + : name + : + { + $clone_root_prj; + + $* create -- @cfg $cxx 2>>/"EOE" &prj-cfg/***; + created configuration @cfg $~/prj-cfg/ 1 default,forwarded,auto-synchronized + EOE + + $init @cfg 2>>/~"%EOE%"; + initializing in project $~/prj/ + synchronizing: + % new prj.+19700101000000% + EOE + + $status >'prj configured 0.1.0-a.0.19700101000000'; + + $* list >>/"EOO"; + @cfg $~/prj-cfg/ 1 default,forwarded,auto-synchronized + EOO + + $update @cfg 2>>~%EOE%; + %(mkdir|c\+\+|ld) .+%{3} + EOE + + $deinit @cfg 2>>/"EOE" + deinitializing in project $~/prj/ + synchronizing: + drop prj + EOE + } + + : dir + : + { + $clone_root_prj; + + $* create cfg $cxx 2>>/"EOE" &cfg/***; + created configuration $~/cfg/ 1 default,forwarded,auto-synchronized + EOE + + $init -c cfg 2>>/~"%EOE%"; + initializing in project $~/prj/ + synchronizing: + % new prj.+19700101000000% + EOE + + $status >'prj configured 0.1.0-a.0.19700101000000'; + + $* list >>/"EOO"; + $~/cfg/ 1 default,forwarded,auto-synchronized + EOO + + $update -c cfg 2>>~%EOE%; + %(mkdir|c\+\+|ld) .+%{3} + EOE + + $deinit -c cfg 2>>/"EOE" + deinitializing in project $~/prj/ + synchronizing: + drop prj + EOE + } + + : wipe + : + { + $clone_root_prj; + + mkdir --no-cleanup cfg; + touch --no-cleanup cfg/a; + + $* create cfg $cxx 2>>/"EOE" != 0; + error: directory $~/cfg/ is not empty + info: use --wipe to clean it up but be careful + EOE + + $* create --wipe cfg $cxx 2>>/"EOE" &cfg/*** + created configuration $~/cfg/ 1 default,forwarded,auto-synchronized + EOE + } +} + +: add +: +{ + $clone_root_prj; + + # Pre-create configurations. + # + $new -C prj-cfg1 tmp1 $cxx 2>! &prj-cfg1/*** &tmp1/***; + $new -C prj-cfg2 tmp2 $cxx 2>! &prj-cfg2/*** &tmp2/***; + + $* add @cfg1 prj-cfg1 2>>/"EOE"; + added configuration @cfg1 $~/prj-cfg1/ 1 default,forwarded,auto-synchronized + EOE + + $* add @cfg2 prj-cfg2 2>>/"EOE"; + added configuration @cfg2 $~/prj-cfg2/ 2 auto-synchronized + EOE + + $init --all 2>>/~"%EOE%"; + initializing in project $~/prj/ + in configuration @cfg1: + synchronizing: + % new prj.+19700101000000% + + in configuration @cfg2: + synchronizing: + % new prj.+19700101000000% + EOE + + $status --all >>EOO; + in configuration @cfg1: + prj configured 0.1.0-a.0.19700101000000 + + in configuration @cfg2: + prj configured 0.1.0-a.0.19700101000000 + EOO + + $* list >>/"EOO"; + @cfg1 $~/prj-cfg1/ 1 default,forwarded,auto-synchronized + @cfg2 $~/prj-cfg2/ 2 auto-synchronized + EOO + + $update --all 2>>~%EOE%; + in configuration @cfg1: + %(mkdir|c\+\+|ld) .+%{3} + + in configuration @cfg2: + %(mkdir|c\+\+|ld) .+%{3} + EOE + + $deinit --all 2>>/"EOE" + deinitializing in project $~/prj/ + in configuration @cfg1: + synchronizing: + drop prj + + in configuration @cfg2: + synchronizing: + drop prj + EOE +} + +: move +: +{ + $clone_root_prj; + + $* create -- @cfg $cxx &prj-cfg/*** 2>>/"EOE"; + created configuration @cfg $~/prj-cfg/ 1 default,forwarded,auto-synchronized + EOE + + $init @cfg 2>>/~"%EOE%"; + initializing in project $~/prj/ + synchronizing: + % new prj.+19700101000000% + EOE + + mv prj-cfg prj-cfg2; + + $* move @cfg prj-cfg2 2>>/"EOE"; + moved configuration @cfg $~/prj-cfg/ 1 to $~/prj-cfg2/ + EOE + + $update --all 2>>~%EOE%; + %(mkdir|c\+\+|ld) .+%{3} + EOE + + $deinit 2>>/"EOE" + deinitializing in project $~/prj/ + synchronizing: + drop prj + EOE +} + +: rename +: +{ + $clone_root_prj; + + $* create -- @cfg $cxx 2>>/"EOE" &prj-cfg/***; + created configuration @cfg $~/prj-cfg/ 1 default,forwarded,auto-synchronized + EOE + + $init @cfg 2>>/~"%EOE%"; + initializing in project $~/prj/ + synchronizing: + % new prj.+19700101000000% + EOE + + $* rename @cfg cfg2 2>>/"EOE"; + renamed configuration @cfg $~/prj-cfg/ 1 to @cfg2 + EOE + + $update @cfg2 2>>~%EOE%; + %(mkdir|c\+\+|ld) .+%{3} + EOE + + $deinit 2>>/"EOE" + deinitializing in project $~/prj/ + synchronizing: + drop prj + EOE +} + +: remove +: +: Here we also test the set sub-command. +: +{ + $clone_root_prj; + + $* create -- @cfg1 $cxx 2>! &prj-cfg1/***; + $* create -- @cfg2 $cxx 2>! &prj-cfg2/***; + + $init --all 2>!; + + $* remove @cfg1 2>>EOE != 0; + error: configuration @cfg1 contains initialized packages + info: use deinit command to deinitialize packages + info: use status command to list initialized packages + EOE + + $deinit @cfg1 2>>/"EOE"; + deinitializing in project $~/prj/ + synchronizing: + drop prj + EOE + + $* remove @cfg1 2>>/"EOE"; + removed configuration @cfg1 $~/prj-cfg1/ 1 + EOE + + $status --all >>EOO; + prj configured 0.1.0-a.0.19700101000000 + EOO + + $* list >>/"EOO"; + @cfg2 $~/prj-cfg2/ 2 auto-synchronized + EOO + + $update 2>>/"EOE" != 0; + error: no default configuration in project $~/prj/ + info: use \(@ | --config|-c | --all|-a\) to specify configuration explicitly + EOE + + $* set @cfg2 --default --forward --no-auto-sync 2>>/"EOE"; + updated configuration @cfg2 $~/prj-cfg2/ 2 default,forwarded + info: explicit bdep-sync is required for changes to take effect + EOE + + $* list >>/"EOO"; + @cfg2 $~/prj-cfg2/ 2 default,forwarded + EOO + + $update 2>>~%EOE%; + %(mkdir|c\+\+|ld) .+%{3} + EOE + + $deinit --all 2>>/"EOE" + deinitializing in project $~/prj/ + synchronizing: + drop prj + EOE +} diff --git a/tests/fetch.test b/tests/fetch.test deleted file mode 100644 index d97bf63..0000000 --- a/tests/fetch.test +++ /dev/null @@ -1,54 +0,0 @@ -# file : tests/fetch.test -# copyright : Copyright (c) 2014-2018 Code Synthesis Ltd -# license : MIT; see accompanying LICENSE file - -.include common.test project.test - -cxx = cc config.cxx="$recall($cxx.path)" - -new += 2>! -init += $cxx -d prj 2>! -status += --all -d prj -deinit += -d prj - -: dependency -: -{ - $clone_prj; - $init -C @cfg &prj-cfg/***; - - $new -t lib libbar &libbar/*** 2>!; - $new -t lib libfoo &libfoo/*** 2>!; - - cat <+prj/repositories.manifest; - : - role: prerequisite - location: ../libfoo - type: dir - : - role: complement - location: ../libbar - type: dir - EOI - - cat <+prj/manifest; - depends: libfoo - depends: libbar - EOI - - $* 2>>/"EOE"; - fetching dir:$~/libbar \(complements dir:$~/prj\) - fetching dir:$~/libfoo \(prerequisite of dir:$~/prj\) - EOE - - $status libfoo libbar >>~%EOO%; - %libfoo available \[.+\]% - %libbar available .+% - EOO - - $deinit 2>>/"EOE" - deinitializing in project $~/prj/ - synchronizing: - drop prj - EOE -} diff --git a/tests/fetch.testscript b/tests/fetch.testscript new file mode 100644 index 0000000..2564470 --- /dev/null +++ b/tests/fetch.testscript @@ -0,0 +1,54 @@ +# file : tests/fetch.testscript +# copyright : Copyright (c) 2014-2018 Code Synthesis Ltd +# license : MIT; see accompanying LICENSE file + +.include common.testscript project.testscript + +cxx = cc config.cxx="$recall($cxx.path)" + +new += 2>! +init += $cxx -d prj 2>! +status += --all -d prj +deinit += -d prj + +: dependency +: +{ + $clone_prj; + $init -C @cfg &prj-cfg/***; + + $new -t lib libbar &libbar/*** 2>!; + $new -t lib libfoo &libfoo/*** 2>!; + + cat <+prj/repositories.manifest; + : + role: prerequisite + location: ../libfoo + type: dir + : + role: complement + location: ../libbar + type: dir + EOI + + cat <+prj/manifest; + depends: libfoo + depends: libbar + EOI + + $* 2>>/"EOE"; + fetching dir:$~/libbar \(complements dir:$~/prj\) + fetching dir:$~/libfoo \(prerequisite of dir:$~/prj\) + EOE + + $status libfoo libbar >>~%EOO%; + %libfoo available \[.+\]% + %libbar available .+% + EOO + + $deinit 2>>/"EOE" + deinitializing in project $~/prj/ + synchronizing: + drop prj + EOE +} diff --git a/tests/init.test b/tests/init.test deleted file mode 100644 index 6214985..0000000 --- a/tests/init.test +++ /dev/null @@ -1,201 +0,0 @@ -# file : tests/init.test -# copyright : Copyright (c) 2014-2018 Code Synthesis Ltd -# license : MIT; see accompanying LICENSE file - -# Here we test both init and deinit commands. -# - -.include common.test project.test - -cxx = cc config.cxx="$recall($cxx.path)" - -status += -d prj -deinit += -d prj - -: create-cfg -: -: Here we also test that the configuration variable is properly persisted and -: the project is properly built in the source tree. -: -{ - $clone_prj; - - $* -C @cfg $cxx 'config.cc.poptions=-DTEST' 2>>/~"%EOE%" &prj-cfg/***; - initializing in project $~/prj/ - created configuration @cfg $~/prj-cfg/ 1 default,forwarded,auto-synchronized - synchronizing: - % new prj.+19700101000000% - EOE - - sed -n -e 's/^config.cc.poptions = (.+)$/\1/p' prj-cfg/build/config.build \ - >'-DTEST'; - - $status >'prj configured 0.1.0-a.0.19700101000000'; - - $build prj/ 2>>~%EOE%; - %(mkdir|c\+\+|ld|ln) .+%{4} - EOE - - prj/prj/prj 'testscript' >'Hello, testscript!'; # Make sure is forwarded. - - $build prj-cfg/prj/ 2>>/EOE; - info: prj-cfg/dir{prj/} is up to date - EOE - - $build 'clean:' prj/ 2>>~%EOE%; - %rm .+%{3} - EOE - - $deinit 2>>/"EOE" - deinitializing in project $~/prj/ - synchronizing: - drop prj - EOE -} - -: add-cfg -: -{ - $clone_prj; - - # Pre-create configurations. - # - $new -C prj-cfg1 tmp $cxx 2>! &prj-cfg1/*** &tmp/***; - $init -C prj-cfg2 -d tmp $cxx 2>! &prj-cfg2/***; - - $* -A @cfg1 2>>/~"%EOE%"; - initializing in project $~/prj/ - added configuration @cfg1 $~/prj-cfg1/ 1 default,forwarded,auto-synchronized - synchronizing: - % new prj.+19700101000000% - EOE - - $* -A prj-cfg2 @cfg2 2>>/~"%EOE%"; - initializing in project $~/prj/ - added configuration @cfg2 $~/prj-cfg2/ 2 auto-synchronized - synchronizing: - % new prj.+19700101000000% - EOE - - $status --all >>EOO; - in configuration @cfg1: - prj configured 0.1.0-a.0.19700101000000 - - in configuration @cfg2: - prj configured 0.1.0-a.0.19700101000000 - EOO - - $build prj-cfg1/ 2>>~%EOE%; - %(mkdir|c\+\+|ld) .+%{6} - EOE - - $build prj-cfg2/ 2>>~%EOE%; - %(mkdir|c\+\+|ld) .+%{6} - EOE - - $build prj/ 2>>~%EOE%; - %(ln|info:) .+%{2} - EOE - - $build 'clean:' prj/ 2>>~%EOE%; - %rm .+%{3} - EOE - - $deinit 2>>/"EOE" - deinitializing in project $~/prj/ - synchronizing: - drop prj - EOE -} - -: pkg -: -: Test initializing a package while creating it inside an already existing -: project. -: -{ - # Create (and build) the executable single-package project. - # - cp --no-cleanup -p -r ../prj ./ &prj/***; - - $* -C @cfg $cxx 2>>/~"%EOE%" &prj-cfg/***; - initializing in project $~/prj/ - created configuration @cfg $~/prj-cfg/ 1 default,forwarded,auto-synchronized - synchronizing: - % new prj.+19700101000000% - EOE - - $status >'prj configured 0.1.0-a.0.19700101000000'; - - $build prj/ 2>>~%EOE%; - %(mkdir|c\+\+|ld|ln) .+%{4} - EOE - - # Move the executable package into a separate directory. - # - mkdir --no-cleanup prj/prj.pkg; - - mv prj/prj prj/build prj/buildfile prj/manifest prj/.gitignore prj/prj.pkg/; - mv prj/prj.pkg prj/prj; - - cat <=prj/packages.manifest; - : 1 - location: prj/ - EOI - - # Add the library package. - # - $new --package -t lib libprj -d prj 2>>/"EOE"; - created new library package libprj in $~/prj/libprj/ - EOE - - $init --all -d prj/libprj 2>>/~"%EOE%"; - initializing in project $~/prj/ - synchronizing: - % upgrade prj.+19700101000000#1% - % new libprj.+19700101000000% - EOE - - # Factor out some of the executable package functionality into the library. - # - cat <+prj/prj/manifest; - depends: libprj - EOI - - sed -i -e 's/^(#import .+)$/import libs += libprj%lib{prj}/' \ - prj/prj/prj/buildfile; - - cat <=prj/prj/prj/prj.cxx; - #include - - #include - - using namespace std; - - int main (int argc, char* argv[]) - { - if (argc < 2) - { - cerr << "error: missing name" << endl; - return 1; - } - - prj::say_hello (cout, argv[1]); - } - EOI - - $build prj-cfg/prj/ 2>>/~"%EOE%"; - synchronizing $~/prj-cfg/: - % upgrade prj.+19700101000000#2% - %\(mkdir|version\\.in|c\\+\\+|ld) .+%{7} - EOE - - $deinit 2>>/"EOE" - deinitializing in project $~/prj/ - deinitializing package prj - deinitializing package libprj - synchronizing: - drop prj - drop libprj - EOE -} diff --git a/tests/init.testscript b/tests/init.testscript new file mode 100644 index 0000000..17af7e2 --- /dev/null +++ b/tests/init.testscript @@ -0,0 +1,201 @@ +# file : tests/init.testscript +# copyright : Copyright (c) 2014-2018 Code Synthesis Ltd +# license : MIT; see accompanying LICENSE file + +# Here we test both init and deinit commands. +# + +.include common.testscript project.testscript + +cxx = cc config.cxx="$recall($cxx.path)" + +status += -d prj +deinit += -d prj + +: create-cfg +: +: Here we also test that the configuration variable is properly persisted and +: the project is properly built in the source tree. +: +{ + $clone_prj; + + $* -C @cfg $cxx 'config.cc.poptions=-DTEST' 2>>/~"%EOE%" &prj-cfg/***; + initializing in project $~/prj/ + created configuration @cfg $~/prj-cfg/ 1 default,forwarded,auto-synchronized + synchronizing: + % new prj.+19700101000000% + EOE + + sed -n -e 's/^config.cc.poptions = (.+)$/\1/p' prj-cfg/build/config.build \ + >'-DTEST'; + + $status >'prj configured 0.1.0-a.0.19700101000000'; + + $build prj/ 2>>~%EOE%; + %(mkdir|c\+\+|ld|ln) .+%{4} + EOE + + prj/prj/prj 'testscript' >'Hello, testscript!'; # Make sure is forwarded. + + $build prj-cfg/prj/ 2>>/EOE; + info: prj-cfg/dir{prj/} is up to date + EOE + + $build 'clean:' prj/ 2>>~%EOE%; + %rm .+%{3} + EOE + + $deinit 2>>/"EOE" + deinitializing in project $~/prj/ + synchronizing: + drop prj + EOE +} + +: add-cfg +: +{ + $clone_prj; + + # Pre-create configurations. + # + $new -C prj-cfg1 tmp $cxx 2>! &prj-cfg1/*** &tmp/***; + $init -C prj-cfg2 -d tmp $cxx 2>! &prj-cfg2/***; + + $* -A @cfg1 2>>/~"%EOE%"; + initializing in project $~/prj/ + added configuration @cfg1 $~/prj-cfg1/ 1 default,forwarded,auto-synchronized + synchronizing: + % new prj.+19700101000000% + EOE + + $* -A prj-cfg2 @cfg2 2>>/~"%EOE%"; + initializing in project $~/prj/ + added configuration @cfg2 $~/prj-cfg2/ 2 auto-synchronized + synchronizing: + % new prj.+19700101000000% + EOE + + $status --all >>EOO; + in configuration @cfg1: + prj configured 0.1.0-a.0.19700101000000 + + in configuration @cfg2: + prj configured 0.1.0-a.0.19700101000000 + EOO + + $build prj-cfg1/ 2>>~%EOE%; + %(mkdir|c\+\+|ld) .+%{6} + EOE + + $build prj-cfg2/ 2>>~%EOE%; + %(mkdir|c\+\+|ld) .+%{6} + EOE + + $build prj/ 2>>~%EOE%; + %(ln|info:) .+%{2} + EOE + + $build 'clean:' prj/ 2>>~%EOE%; + %rm .+%{3} + EOE + + $deinit 2>>/"EOE" + deinitializing in project $~/prj/ + synchronizing: + drop prj + EOE +} + +: pkg +: +: Test initializing a package while creating it inside an already existing +: project. +: +{ + # Create (and build) the executable single-package project. + # + cp --no-cleanup -p -r ../prj ./ &prj/***; + + $* -C @cfg $cxx 2>>/~"%EOE%" &prj-cfg/***; + initializing in project $~/prj/ + created configuration @cfg $~/prj-cfg/ 1 default,forwarded,auto-synchronized + synchronizing: + % new prj.+19700101000000% + EOE + + $status >'prj configured 0.1.0-a.0.19700101000000'; + + $build prj/ 2>>~%EOE%; + %(mkdir|c\+\+|ld|ln) .+%{4} + EOE + + # Move the executable package into a separate directory. + # + mkdir --no-cleanup prj/prj.pkg; + + mv prj/prj prj/build prj/buildfile prj/manifest prj/.gitignore prj/prj.pkg/; + mv prj/prj.pkg prj/prj; + + cat <=prj/packages.manifest; + : 1 + location: prj/ + EOI + + # Add the library package. + # + $new --package -t lib libprj -d prj 2>>/"EOE"; + created new library package libprj in $~/prj/libprj/ + EOE + + $init --all -d prj/libprj 2>>/~"%EOE%"; + initializing in project $~/prj/ + synchronizing: + % upgrade prj.+19700101000000#1% + % new libprj.+19700101000000% + EOE + + # Factor out some of the executable package functionality into the library. + # + cat <+prj/prj/manifest; + depends: libprj + EOI + + sed -i -e 's/^(#import .+)$/import libs += libprj%lib{prj}/' \ + prj/prj/prj/buildfile; + + cat <=prj/prj/prj/prj.cxx; + #include + + #include + + using namespace std; + + int main (int argc, char* argv[]) + { + if (argc < 2) + { + cerr << "error: missing name" << endl; + return 1; + } + + prj::say_hello (cout, argv[1]); + } + EOI + + $build prj-cfg/prj/ 2>>/~"%EOE%"; + synchronizing $~/prj-cfg/: + % upgrade prj.+19700101000000#2% + %\(mkdir|version\\.in|c\\+\\+|ld) .+%{7} + EOE + + $deinit 2>>/"EOE" + deinitializing in project $~/prj/ + deinitializing package prj + deinitializing package libprj + synchronizing: + drop prj + drop libprj + EOE +} diff --git a/tests/new.test b/tests/new.test deleted file mode 100644 index ec45788..0000000 --- a/tests/new.test +++ /dev/null @@ -1,217 +0,0 @@ -# file : tests/new.test -# copyright : Copyright (c) 2014-2018 Code Synthesis Ltd -# license : MIT; see accompanying LICENSE file - -.include common.test - -# Disable nesting checks in the created projects. -# -test.arguments += --no-checks - -c = config.c="$recall($c.path)" -cxx = config.cxx="$recall($cxx.path)" - -status += -d prj - -: no-cfg -: -{ - # Disable amalgamation support in the created projects. - # - test.arguments += --no-amalgamation - - : exe - : - { - $* -t exe -l c++ prj-foo 2>>/"EOE" &prj-foo/***; - created new executable project prj-foo in $~/prj-foo/ - EOE - - $build prj-foo/ $cxx 2>>~%EOE% - %(c\+\+|ld) .+%{2} - EOE - } - - : lib - : - { - $* -t lib -l c++ libprj-foo 2>>/"EOE" &libprj-foo/***; - created new library project libprj-foo in $~/libprj-foo/ - EOE - - $build libprj-foo/ $cxx 2>>~%EOE% - %(version\.in|c\+\+|ar|ld) .+%{7} - EOE - } - - : exe-unit-tests - : - { - $* -t exe,unit-tests -l c++ foo 2>>/"EOE" &foo/***; - created new executable project foo in $~/foo/ - EOE - - $build foo/ $cxx 2>>~%EOE% - %(c\+\+|ld|ar) .+%{5} - EOE - } - - : lib-unit-tests - : - { - $* -t lib,unit-tests -l c++ libfoo 2>>/"EOE" &libfoo/***; - created new library project libfoo in $~/libfoo/ - EOE - - $build libfoo/ $cxx 2>>~%EOE% - %(version\.in|c\+\+|ar|ld) .+%{11} - EOE - } - - # C versions of the above. - # - : exe-c - : - { - $* -t exe -l c prj-foo 2>>/"EOE" &prj-foo/***; - created new executable project prj-foo in $~/prj-foo/ - EOE - - $build prj-foo/ $c 2>>~%EOE% - %(c|ld) .+%{2} - EOE - } - - : exe-c-unit-tests - : - { - $* -t exe,unit-tests -l c foo 2>>/"EOE" &foo/***; - created new executable project foo in $~/foo/ - EOE - - $build foo/ $c 2>>~%EOE% - %(c|ld|ar) .+%{5} - EOE - } - - # Our C tests use fmemopen() which is not always available. - # - - : lib-c - : - if ($c.target.class != 'windows' && $c.target.class != 'macos') - { - $* -t lib -l c libprj-foo 2>>/"EOE" &libprj-foo/***; - created new library project libprj-foo in $~/libprj-foo/ - EOE - - $build libprj-foo/ $c 2>>~%EOE% - %(version\.in|c|ar|ld) .+%{7} - EOE - } - - : lib-c-unit-tests - : - if ($c.target.class != 'windows' && $c.target.class != 'macos') - { - $* -t lib,unit-tests -l c libfoo 2>>/"EOE" &libfoo/***; - created new library project libfoo in $~/libfoo/ - EOE - - $build libfoo/ $c 2>>~%EOE% - %(version\.in|c|ar|ld) .+%{11} - EOE - } - - : pkg - : - { - : add - : - : Test creating a library as a separate package in the project. - : - { - $* -t empty prj 2>>/"EOE" &prj/***; - created new empty project prj in $~/prj/ - EOE - - $* --package -t lib libprj -d prj 2>>/"EOE"; - created new library package libprj in $~/prj/libprj/ - EOE - - $build prj/libprj/ $cxx 2>>~%EOE% - %(version\.in|c\+\+|ar|ld) .+%{7} - EOE - } - - : name - : - : Test that the package/project name is validated. - : - { - : package - : - $* x 2>'error: invalid package name: length is less than two characters' != 0 - - : project - : - : Here we also test that the project name is also validated as a package. - : - $* -t empty x 2>'error: invalid project name: length is less than two characters' != 0 - - : project-derived - : - $* -t empty xx &xx/*** 2>>/"EOE"; - created new empty project xx in $~/xx/ - EOE - mv xx x; - $* --package pkg -d x 2>>/"EOE" - warning: project name 'x' is invalid: length is less than two characters - info: leaving the 'project' manifest value empty - created new executable package pkg in $~/x/pkg/ - EOE - } - } -} - -: cfg -{ - : dir-and-name - : - { - $* -C prj-config @cfg prj cc $cxx 2>>/~"%EOE%" &prj/*** &prj-config/***; - created new executable project prj in $~/prj/ - created configuration @cfg $~/prj-config/ 1 default,forwarded,auto-synchronized - synchronizing: - % new prj.+19700101000000% - EOE - - $status >'prj configured 0.1.0-a.0.19700101000000'; - - $build prj/ 2>>~%EOE% - %(mkdir|c\+\+|ld|ln) .+%{4} - EOE - } - - : name - : - : Test deducing the configuration directory path from the project source - : directory path and the configuration name. Here we also use the - : dash-prefixed name (as in Windows PowerShell where the leading '@' - : character is special). - : - { - $* -C -@cfg prj cc $cxx 2>>/~"%EOE%" &prj/*** &prj-cfg/***; - created new executable project prj in $~/prj/ - created configuration @cfg $~/prj-cfg/ 1 default,forwarded,auto-synchronized - synchronizing: - % new prj.+19700101000000% - EOE - - $status >'prj configured 0.1.0-a.0.19700101000000'; - - $build prj/ 2>>~%EOE% - %(mkdir|c\+\+|ld|ln) .+%{4} - EOE - } -} diff --git a/tests/new.testscript b/tests/new.testscript new file mode 100644 index 0000000..abda94b --- /dev/null +++ b/tests/new.testscript @@ -0,0 +1,217 @@ +# file : tests/new.testscript +# copyright : Copyright (c) 2014-2018 Code Synthesis Ltd +# license : MIT; see accompanying LICENSE file + +.include common.testscript + +# Disable nesting checks in the created projects. +# +test.arguments += --no-checks + +c = config.c="$recall($c.path)" +cxx = config.cxx="$recall($cxx.path)" + +status += -d prj + +: no-cfg +: +{ + # Disable amalgamation support in the created projects. + # + test.arguments += --no-amalgamation + + : exe + : + { + $* -t exe -l c++ prj-foo 2>>/"EOE" &prj-foo/***; + created new executable project prj-foo in $~/prj-foo/ + EOE + + $build prj-foo/ $cxx 2>>~%EOE% + %(c\+\+|ld) .+%{2} + EOE + } + + : lib + : + { + $* -t lib -l c++ libprj-foo 2>>/"EOE" &libprj-foo/***; + created new library project libprj-foo in $~/libprj-foo/ + EOE + + $build libprj-foo/ $cxx 2>>~%EOE% + %(version\.in|c\+\+|ar|ld) .+%{7} + EOE + } + + : exe-unit-tests + : + { + $* -t exe,unit-tests -l c++ foo 2>>/"EOE" &foo/***; + created new executable project foo in $~/foo/ + EOE + + $build foo/ $cxx 2>>~%EOE% + %(c\+\+|ld|ar) .+%{5} + EOE + } + + : lib-unit-tests + : + { + $* -t lib,unit-tests -l c++ libfoo 2>>/"EOE" &libfoo/***; + created new library project libfoo in $~/libfoo/ + EOE + + $build libfoo/ $cxx 2>>~%EOE% + %(version\.in|c\+\+|ar|ld) .+%{11} + EOE + } + + # C versions of the above. + # + : exe-c + : + { + $* -t exe -l c prj-foo 2>>/"EOE" &prj-foo/***; + created new executable project prj-foo in $~/prj-foo/ + EOE + + $build prj-foo/ $c 2>>~%EOE% + %(c|ld) .+%{2} + EOE + } + + : exe-c-unit-tests + : + { + $* -t exe,unit-tests -l c foo 2>>/"EOE" &foo/***; + created new executable project foo in $~/foo/ + EOE + + $build foo/ $c 2>>~%EOE% + %(c|ld|ar) .+%{5} + EOE + } + + # Our C tests use fmemopen() which is not always available. + # + + : lib-c + : + if ($c.target.class != 'windows' && $c.target.class != 'macos') + { + $* -t lib -l c libprj-foo 2>>/"EOE" &libprj-foo/***; + created new library project libprj-foo in $~/libprj-foo/ + EOE + + $build libprj-foo/ $c 2>>~%EOE% + %(version\.in|c|ar|ld) .+%{7} + EOE + } + + : lib-c-unit-tests + : + if ($c.target.class != 'windows' && $c.target.class != 'macos') + { + $* -t lib,unit-tests -l c libfoo 2>>/"EOE" &libfoo/***; + created new library project libfoo in $~/libfoo/ + EOE + + $build libfoo/ $c 2>>~%EOE% + %(version\.in|c|ar|ld) .+%{11} + EOE + } + + : pkg + : + { + : add + : + : Test creating a library as a separate package in the project. + : + { + $* -t empty prj 2>>/"EOE" &prj/***; + created new empty project prj in $~/prj/ + EOE + + $* --package -t lib libprj -d prj 2>>/"EOE"; + created new library package libprj in $~/prj/libprj/ + EOE + + $build prj/libprj/ $cxx 2>>~%EOE% + %(version\.in|c\+\+|ar|ld) .+%{7} + EOE + } + + : name + : + : Test that the package/project name is validated. + : + { + : package + : + $* x 2>'error: invalid package name: length is less than two characters' != 0 + + : project + : + : Here we also test that the project name is also validated as a package. + : + $* -t empty x 2>'error: invalid project name: length is less than two characters' != 0 + + : project-derived + : + $* -t empty xx &xx/*** 2>>/"EOE"; + created new empty project xx in $~/xx/ + EOE + mv xx x; + $* --package pkg -d x 2>>/"EOE" + warning: project name 'x' is invalid: length is less than two characters + info: leaving the 'project' manifest value empty + created new executable package pkg in $~/x/pkg/ + EOE + } + } +} + +: cfg +{ + : dir-and-name + : + { + $* -C prj-config @cfg prj cc $cxx 2>>/~"%EOE%" &prj/*** &prj-config/***; + created new executable project prj in $~/prj/ + created configuration @cfg $~/prj-config/ 1 default,forwarded,auto-synchronized + synchronizing: + % new prj.+19700101000000% + EOE + + $status >'prj configured 0.1.0-a.0.19700101000000'; + + $build prj/ 2>>~%EOE% + %(mkdir|c\+\+|ld|ln) .+%{4} + EOE + } + + : name + : + : Test deducing the configuration directory path from the project source + : directory path and the configuration name. Here we also use the + : dash-prefixed name (as in Windows PowerShell where the leading '@' + : character is special). + : + { + $* -C -@cfg prj cc $cxx 2>>/~"%EOE%" &prj/*** &prj-cfg/***; + created new executable project prj in $~/prj/ + created configuration @cfg $~/prj-cfg/ 1 default,forwarded,auto-synchronized + synchronizing: + % new prj.+19700101000000% + EOE + + $status >'prj configured 0.1.0-a.0.19700101000000'; + + $build prj/ 2>>~%EOE% + %(mkdir|c\+\+|ld|ln) .+%{4} + EOE + } +} diff --git a/tests/project.test b/tests/project.test deleted file mode 100644 index 6ab2b4b..0000000 --- a/tests/project.test +++ /dev/null @@ -1,26 +0,0 @@ -# file : tests/project.test -# copyright : Copyright (c) 2014-2018 Code Synthesis Ltd -# license : MIT; see accompanying LICENSE file - -# Create and initialize a sample build2 C++ executable project 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 project as -# required by the nested tests and scopes. Tests will also clone the parent -# scope project to optionally modify it, use and cleanup at the end. Note that -# project can not be shared between multiple bdep processes. Also we need to -# make sure that projects are not cloned while being used by bdep. -# -+$new prj 2>- &prj/*** # By default: -t exe -l c++. - -# The most commonly used project cloning command that copies it from the -# parent scope working directory. -# -clone_prj = cp -p -r ../prj ./ - -# Clones the original project from the root scope working directory. -# -clone_root_prj = cp -p -r $~/prj ./ - -# Setup a test command to use a cloned project directory by default. -# -test.arguments += -d prj diff --git a/tests/project.testscript b/tests/project.testscript new file mode 100644 index 0000000..69288aa --- /dev/null +++ b/tests/project.testscript @@ -0,0 +1,26 @@ +# file : tests/project.testscript +# copyright : Copyright (c) 2014-2018 Code Synthesis Ltd +# license : MIT; see accompanying LICENSE file + +# Create and initialize a sample build2 C++ executable project 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 project as +# required by the nested tests and scopes. Tests will also clone the parent +# scope project to optionally modify it, use and cleanup at the end. Note that +# project can not be shared between multiple bdep processes. Also we need to +# make sure that projects are not cloned while being used by bdep. +# ++$new prj 2>- &prj/*** # By default: -t exe -l c++. + +# The most commonly used project cloning command that copies it from the +# parent scope working directory. +# +clone_prj = cp -p -r ../prj ./ + +# Clones the original project from the root scope working directory. +# +clone_root_prj = cp -p -r $~/prj ./ + +# Setup a test command to use a cloned project directory by default. +# +test.arguments += -d prj diff --git a/tests/publish.test b/tests/publish.test deleted file mode 100644 index 880c538..0000000 --- a/tests/publish.test +++ /dev/null @@ -1,494 +0,0 @@ -# file : tests/publish.test -# copyright : Copyright (c) 2014-2018 Code Synthesis Ltd -# license : MIT; see accompanying LICENSE file - -.include common.test project.test - -# bdep-publish requirements for the minimum supported git version are higher -# then the default 2.1.0 (see bdep/publish.cxx for details). -# -+if! ($git_version_major > 2 || \ - $git_version_major == 2 && $git_version_minor >= 11) - exit -end - -# Repository to use for the package submissions simulation. -# -# 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 \ - ? 'https://stage.build2.org' \ - : 'https://cppget.org') \ - : "$config.bdep.test.repository") - -+if ("$repository" == '') - exit -end - -test.arguments += --repository "$repository" --yes \ - --author-name user --author-email user@example.com - -cxx = cc config.cxx="$recall($cxx.path)" - -new += 2>! -init += $cxx -d prj 2>! &prj/**/bootstrap/*** - -windows = ($cxx.target.class == 'windows') - -# Note that using the same package name and version for tests may result in -# duplicate submissions. We will use unique version for each test, -# incrementing the patch version for 1.0.X. -# -# Next version to use: 1.0.15 -# -: submit -: -{ - test.arguments += --control 'none' - - : single-pkg - : - { - test.arguments += --simulate 'success' - - : single-cfg - : - { - $clone_root_prj; - $init -C @cfg &prj-cfg/***; - sed -i -e 's/^(version:) .*$/\1 1.0.1/' prj/manifest; - - $* 2>>~%EOE% - synchronizing: - upgrade prj/1.0.1 - submitting prj-1.0.1.tar.gz - %.* - %(prj/1\.0\.1 )?submission is queued% - %reference: .{12}% - EOE - } - - : no-cfg - : - { - $clone_root_prj; - - $* 2>>~%EOE% != 0 - %error: no default configuration in project .+% - info: use (@ | --config|-c | --all|-a) to specify configuration explicitly - EOE - } - - : multi-cfg - : - { - $clone_root_prj; - $init -C @cfg1 &prj-cfg1/***; - $init -C @cfg2 &prj-cfg2/***; - - $* --all 2>'error: multiple configurations specified for publish' != 0 - } - } - - : multi-pkg - : - { - test.arguments += --simulate 'success' - - +$new -t empty prj &prj/*** - +$new --package -t lib libprj -d prj - +$new --package -t exe prj -d prj - - : both - : - { - $clone_prj; - sed -i -e 's/^(version:) .*$/\1 1.0.2/' prj/libprj/manifest; - sed -i -e 's/^(version:) .*$/\1 1.0.2/' prj/prj/manifest; - $init -C @cfg &prj-cfg/***; - - $* 2>>~%EOE% - submitting libprj-1.0.2.tar.gz - %.* - %(libprj/1\.0\.2 )?submission is queued% - %reference: .{12}% - submitting prj-1.0.2.tar.gz - %.* - %(prj/1\.0\.2 )?submission is queued% - %reference: .{12}% - EOE - } - - : single - : - { - $clone_prj; - sed -i -e 's/^(version:) .*$/\1 1.0.3/' prj/libprj/manifest; - $init -C @cfg &prj-cfg/***; - - # Publish the single libprj package rather than the whole prj project. - # - test.arguments = $regex.apply($test.arguments, '^(prj)$', '\1/libprj'); - - $* 2>>~%EOE% - submitting libprj-1.0.3.tar.gz - %.* - %(libprj/1\.0\.3 )?submission is queued% - %reference: .{12}% - EOE - } - - : prompt - : - { - $clone_prj; - sed -i -e 's/^(version:) .*$/\1 1.0.4/' prj/libprj/manifest; - sed -i -e 's/^(version:) .*$/\1 1.0.4/' prj/prj/manifest; - $init -C @cfg &prj-cfg/***; - - # Suppress the --yes option. - # - test.arguments = $regex.apply($test.arguments, '^(--yes)$', ''); - - $* <'y' 2>>~"%EOE%" - publishing: - to: $repository - % as: .+@.+% - - package: libprj - version: 1.0.4 - project: prj - section: stable - - package: prj - version: 1.0.4 - project: prj - section: stable - continue? [y/n] submitting libprj-1.0.4.tar.gz - %.* - %\(libprj/1\\.0\\.4 \)?submission is queued% - %reference: .{12}% - submitting prj-1.0.4.tar.gz - %.* - %\(prj/1\\.0\\.4 \)?submission is queued% - %reference: .{12}% - EOE - } - } - - : failure - : - { - : duplicate-archive - : - { - test.arguments += --simulate 'duplicate-archive' - - $clone_root_prj; - $init -C @cfg &prj-cfg/***; - sed -i -e 's/^(version:) .*$/\1 1.0.5/' prj/manifest; - - $* 2>>~%EOE% != 0 - synchronizing: - upgrade prj/1.0.5 - submitting prj-1.0.5.tar.gz - %.* - error: duplicate submission - % info: reference: .{12}%? - EOE - } - - : internal-error-text - : - { - test.arguments += --simulate 'internal-error-text' - - $clone_root_prj; - $init -C @cfg &prj-cfg/***; - sed -i -e 's/^(version:) .*$/\1 1.0.6/' prj/manifest; - - $* 2>>~%EOE% != 0 - synchronizing: - upgrade prj/1.0.6 - submitting prj-1.0.6.tar.gz - %.* - error: submission handling failed - % info: consider reporting this to .+ maintainers% - EOE - } - - : internal-error-html - : - { - test.arguments += --simulate 'internal-error-html' - - $clone_root_prj; - $init -C @cfg &prj-cfg/***; - sed -i -e 's/^(version:) .*$/\1 1.0.7/' prj/manifest; - - $* 2>>~%EOE% != 0 - synchronizing: - upgrade prj/1.0.7 - submitting prj-1.0.7.tar.gz - %.* - error: HTTP status code 500 (internal server error) - % info: consider reporting this to .+ maintainers% - EOE - } - } -} - -: control -: -{ - # The control repository URL doesn't really matter for the submission - # simulation. We specify it to enable the control branch-related - # functionality. - # - test.arguments += --simulate 'success' --control 'http://example.com/rep.git' - - # Create the remote repository. - # - +mkdir --no-cleanup 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' - - clone_rep = cp --no-cleanup -r ../prj.git ./ &prj.git/*** - clone_prj = cp --no-cleanup -r ../prj ./ &prj/*** - - : success - : - { - # Setup the remote repository. - # - rep = "file://($windows ? "$regex.replace($~, '\\', '/')" : "$~")/prj.git" - $clone_rep; - - # Setup the local repository/project. - # - $clone_prj; - $init -C @cfg &prj-cfg/***; - $g remote add origin "$rep"; - - # Publish when neither local nor remote-tracking build2-control branches - # are present. - # - sed -i -e 's/^(version:) .*$/\1 1.0.8/' prj/manifest; - - $* >&2 2>>~%EOE%; - synchronizing: - upgrade prj/1.0.8 - pushing build2-control - %.* - submitting prj-1.0.8.tar.gz - %.* - %(prj/1\.0\.8 )?submission is queued% - %reference: .{12}% - EOE - - # Publish when both local and remote-tracking build2-control branches are - # present. - # - sed -i -e 's/^(version:) .*$/\1 1.0.9/' prj/manifest; - - $* 2>>~%EOE%; - synchronizing: - upgrade prj/1.0.9 - pushing build2-control - %.* - submitting prj-1.0.9.tar.gz - %.* - %(prj/1\.0\.9 )?submission is queued% - %reference: .{12}% - EOE - - # Publish when the local build2-control branch is not present while the - # remote-tracking branch is. - # - sed -i -e 's/^(version:) .*$/\1 1.0.10/' prj/manifest; - - $g branch -D build2-control; - - $* 2>>~%EOE%; - synchronizing: - upgrade prj/1.0.10 - pushing build2-control - %.* - submitting prj-1.0.10.tar.gz - %.* - %(prj/1\.0\.10 )?submission is queued% - %reference: .{12}% - EOE - - # Check for the build2-control branch commits presence and the files they - # add. - # - $g checkout build2-control; - $g log --name-only --pretty='format:%s' >>:~%EOO% - Add prj/1.0.10 publish authorization - %submit/.{16}% - - Add prj/1.0.9 publish authorization - %submit/.{16}% - - Add prj/1.0.8 publish authorization - %submit/.{16}% - - Start - EOO - } - - : failure - : - { - g2 = git -C prj2 >! 2>! - - # Setup the remote repository. - # - rep = "file://($windows ? "$regex.replace($~, '\\', '/')" : "$~")/prj.git" - $clone_rep; - - # Setup the local repository/project. - # - $clone_prj; - $init -C @cfg &prj-cfg/***; - $g remote add origin "$rep"; - - # Publish successfully. - # - sed -i -e 's/^(version:) .*$/\1 1.0.11/' prj/manifest; - - $* >! 2>!; - - # Push into the build2-control branch from another local repository, - # making the subsequent publish of prj package impossible until the next - # fetch. - # - # 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 "$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 checkout -b build2-control --track origin/build2-control; - $g2 commit --allow-empty -m 'Dummy1'; - $g2 push; - - sed -i -e 's/^(version:) .*$/\1 1.0.12/' prj/manifest; - - # Fail to publish (see above for details). - # - $* 2>>~%EOE% != 0; - synchronizing: - upgrade prj/1.0.12 - pushing build2-control - %.* - error: unable to push build2-control branch - info: run 'git fetch' and try again - EOE - - # Publish successfully after the fetch. - # - $g fetch; - - $* 2>>~%EOE%; - pushing build2-control - %.* - submitting prj-1.0.12.tar.gz - %.* - %(prj/1\.0\.12 )?submission is queued% - %reference: .{12}% - EOE - - sed -i -e 's/^(version:) .*$/\1 1.0.13/' prj/manifest; - - # Reproduce the situation when the local build2-control branch exists but - # the remote-tracking one doesn't (see brep/publish.cxx for details). - # - $g branch -D -r origin/build2-control; - - $* >&2 2>>~%EOE%; - synchronizing: - upgrade prj/1.0.13 - pushing build2-control - %.* - submitting prj-1.0.13.tar.gz - %.* - %(prj/1\.0\.13 )?submission is queued% - %reference: .{12}% - EOE - - # Test publishing after implicit fetches. - # - # Push again into the build2-control branch from another local repository - # (see above for details). - # - $g2 pull; - $g2 commit --allow-empty -m 'Dummy2'; - $g2 push; - - sed -i -e 's/^(version:) .*$/\1 1.0.14/' prj/manifest; - - # Note that the prj repository master branch push doesn't implicitly fetch - # the build2-control branch, so the subsequent publishing fails. - # - $g add '*'; - $g commit -m 'Create'; - $g push --set-upstream origin master; - - $* 2>>~%EOE% != 0; - synchronizing: - upgrade prj/1.0.14 - pushing build2-control - %.* - error: unable to push build2-control branch - info: run 'git fetch' and try again - EOE - - # Note that the prj repository master branch pull fetches the - # build2-control branch implicitly, so the subsequent publishing succeeds. - # - $g pull; - - $* 2>>~%EOE%; - pushing build2-control - %.* - submitting prj-1.0.14.tar.gz - %.* - %(prj/1\.0\.14 )?submission is queued% - %reference: .{12}% - EOE - - # Check the build2-control branch commits presence and the files they add. - # - $g checkout build2-control; - $g log --name-only --pretty='format:%s' >>:~%EOO% - %.* - Add prj/1.0.14 publish authorization - %submit/.{16}% - - Dummy2 - Add prj/1.0.13 publish authorization - %submit/.{16}% - - Add prj/1.0.12 publish authorization - %submit/.{16}% - - Dummy1 - Add prj/1.0.11 publish authorization - %submit/.{16}% - - Start - EOO - } -} diff --git a/tests/publish.testscript b/tests/publish.testscript new file mode 100644 index 0000000..500d20e --- /dev/null +++ b/tests/publish.testscript @@ -0,0 +1,494 @@ +# file : tests/publish.testscript +# copyright : Copyright (c) 2014-2018 Code Synthesis Ltd +# license : MIT; see accompanying LICENSE file + +.include common.testscript project.testscript + +# bdep-publish requirements for the minimum supported git version are higher +# then the default 2.1.0 (see bdep/publish.cxx for details). +# ++if! ($git_version_major > 2 || \ + $git_version_major == 2 && $git_version_minor >= 11) + exit +end + +# Repository to use for the package submissions simulation. +# +# 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 \ + ? 'https://stage.build2.org' \ + : 'https://cppget.org') \ + : "$config.bdep.test.repository") + ++if ("$repository" == '') + exit +end + +test.arguments += --repository "$repository" --yes \ + --author-name user --author-email user@example.com + +cxx = cc config.cxx="$recall($cxx.path)" + +new += 2>! +init += $cxx -d prj 2>! &prj/**/bootstrap/*** + +windows = ($cxx.target.class == 'windows') + +# Note that using the same package name and version for tests may result in +# duplicate submissions. We will use unique version for each test, +# incrementing the patch version for 1.0.X. +# +# Next version to use: 1.0.15 +# +: submit +: +{ + test.arguments += --control 'none' + + : single-pkg + : + { + test.arguments += --simulate 'success' + + : single-cfg + : + { + $clone_root_prj; + $init -C @cfg &prj-cfg/***; + sed -i -e 's/^(version:) .*$/\1 1.0.1/' prj/manifest; + + $* 2>>~%EOE% + synchronizing: + upgrade prj/1.0.1 + submitting prj-1.0.1.tar.gz + %.* + %(prj/1\.0\.1 )?submission is queued% + %reference: .{12}% + EOE + } + + : no-cfg + : + { + $clone_root_prj; + + $* 2>>~%EOE% != 0 + %error: no default configuration in project .+% + info: use (@ | --config|-c | --all|-a) to specify configuration explicitly + EOE + } + + : multi-cfg + : + { + $clone_root_prj; + $init -C @cfg1 &prj-cfg1/***; + $init -C @cfg2 &prj-cfg2/***; + + $* --all 2>'error: multiple configurations specified for publish' != 0 + } + } + + : multi-pkg + : + { + test.arguments += --simulate 'success' + + +$new -t empty prj &prj/*** + +$new --package -t lib libprj -d prj + +$new --package -t exe prj -d prj + + : both + : + { + $clone_prj; + sed -i -e 's/^(version:) .*$/\1 1.0.2/' prj/libprj/manifest; + sed -i -e 's/^(version:) .*$/\1 1.0.2/' prj/prj/manifest; + $init -C @cfg &prj-cfg/***; + + $* 2>>~%EOE% + submitting libprj-1.0.2.tar.gz + %.* + %(libprj/1\.0\.2 )?submission is queued% + %reference: .{12}% + submitting prj-1.0.2.tar.gz + %.* + %(prj/1\.0\.2 )?submission is queued% + %reference: .{12}% + EOE + } + + : single + : + { + $clone_prj; + sed -i -e 's/^(version:) .*$/\1 1.0.3/' prj/libprj/manifest; + $init -C @cfg &prj-cfg/***; + + # Publish the single libprj package rather than the whole prj project. + # + test.arguments = $regex.apply($test.arguments, '^(prj)$', '\1/libprj'); + + $* 2>>~%EOE% + submitting libprj-1.0.3.tar.gz + %.* + %(libprj/1\.0\.3 )?submission is queued% + %reference: .{12}% + EOE + } + + : prompt + : + { + $clone_prj; + sed -i -e 's/^(version:) .*$/\1 1.0.4/' prj/libprj/manifest; + sed -i -e 's/^(version:) .*$/\1 1.0.4/' prj/prj/manifest; + $init -C @cfg &prj-cfg/***; + + # Suppress the --yes option. + # + test.arguments = $regex.apply($test.arguments, '^(--yes)$', ''); + + $* <'y' 2>>~"%EOE%" + publishing: + to: $repository + % as: .+@.+% + + package: libprj + version: 1.0.4 + project: prj + section: stable + + package: prj + version: 1.0.4 + project: prj + section: stable + continue? [y/n] submitting libprj-1.0.4.tar.gz + %.* + %\(libprj/1\\.0\\.4 \)?submission is queued% + %reference: .{12}% + submitting prj-1.0.4.tar.gz + %.* + %\(prj/1\\.0\\.4 \)?submission is queued% + %reference: .{12}% + EOE + } + } + + : failure + : + { + : duplicate-archive + : + { + test.arguments += --simulate 'duplicate-archive' + + $clone_root_prj; + $init -C @cfg &prj-cfg/***; + sed -i -e 's/^(version:) .*$/\1 1.0.5/' prj/manifest; + + $* 2>>~%EOE% != 0 + synchronizing: + upgrade prj/1.0.5 + submitting prj-1.0.5.tar.gz + %.* + error: duplicate submission + % info: reference: .{12}%? + EOE + } + + : internal-error-text + : + { + test.arguments += --simulate 'internal-error-text' + + $clone_root_prj; + $init -C @cfg &prj-cfg/***; + sed -i -e 's/^(version:) .*$/\1 1.0.6/' prj/manifest; + + $* 2>>~%EOE% != 0 + synchronizing: + upgrade prj/1.0.6 + submitting prj-1.0.6.tar.gz + %.* + error: submission handling failed + % info: consider reporting this to .+ maintainers% + EOE + } + + : internal-error-html + : + { + test.arguments += --simulate 'internal-error-html' + + $clone_root_prj; + $init -C @cfg &prj-cfg/***; + sed -i -e 's/^(version:) .*$/\1 1.0.7/' prj/manifest; + + $* 2>>~%EOE% != 0 + synchronizing: + upgrade prj/1.0.7 + submitting prj-1.0.7.tar.gz + %.* + error: HTTP status code 500 (internal server error) + % info: consider reporting this to .+ maintainers% + EOE + } + } +} + +: control +: +{ + # The control repository URL doesn't really matter for the submission + # simulation. We specify it to enable the control branch-related + # functionality. + # + test.arguments += --simulate 'success' --control 'http://example.com/rep.git' + + # Create the remote repository. + # + +mkdir --no-cleanup 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' + + clone_rep = cp --no-cleanup -r ../prj.git ./ &prj.git/*** + clone_prj = cp --no-cleanup -r ../prj ./ &prj/*** + + : success + : + { + # Setup the remote repository. + # + rep = "file://($windows ? "$regex.replace($~, '\\', '/')" : "$~")/prj.git" + $clone_rep; + + # Setup the local repository/project. + # + $clone_prj; + $init -C @cfg &prj-cfg/***; + $g remote add origin "$rep"; + + # Publish when neither local nor remote-tracking build2-control branches + # are present. + # + sed -i -e 's/^(version:) .*$/\1 1.0.8/' prj/manifest; + + $* >&2 2>>~%EOE%; + synchronizing: + upgrade prj/1.0.8 + pushing build2-control + %.* + submitting prj-1.0.8.tar.gz + %.* + %(prj/1\.0\.8 )?submission is queued% + %reference: .{12}% + EOE + + # Publish when both local and remote-tracking build2-control branches are + # present. + # + sed -i -e 's/^(version:) .*$/\1 1.0.9/' prj/manifest; + + $* 2>>~%EOE%; + synchronizing: + upgrade prj/1.0.9 + pushing build2-control + %.* + submitting prj-1.0.9.tar.gz + %.* + %(prj/1\.0\.9 )?submission is queued% + %reference: .{12}% + EOE + + # Publish when the local build2-control branch is not present while the + # remote-tracking branch is. + # + sed -i -e 's/^(version:) .*$/\1 1.0.10/' prj/manifest; + + $g branch -D build2-control; + + $* 2>>~%EOE%; + synchronizing: + upgrade prj/1.0.10 + pushing build2-control + %.* + submitting prj-1.0.10.tar.gz + %.* + %(prj/1\.0\.10 )?submission is queued% + %reference: .{12}% + EOE + + # Check for the build2-control branch commits presence and the files they + # add. + # + $g checkout build2-control; + $g log --name-only --pretty='format:%s' >>:~%EOO% + Add prj/1.0.10 publish authorization + %submit/.{16}% + + Add prj/1.0.9 publish authorization + %submit/.{16}% + + Add prj/1.0.8 publish authorization + %submit/.{16}% + + Start + EOO + } + + : failure + : + { + g2 = git -C prj2 >! 2>! + + # Setup the remote repository. + # + rep = "file://($windows ? "$regex.replace($~, '\\', '/')" : "$~")/prj.git" + $clone_rep; + + # Setup the local repository/project. + # + $clone_prj; + $init -C @cfg &prj-cfg/***; + $g remote add origin "$rep"; + + # Publish successfully. + # + sed -i -e 's/^(version:) .*$/\1 1.0.11/' prj/manifest; + + $* >! 2>!; + + # Push into the build2-control branch from another local repository, + # making the subsequent publish of prj package impossible until the next + # fetch. + # + # 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 "$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 checkout -b build2-control --track origin/build2-control; + $g2 commit --allow-empty -m 'Dummy1'; + $g2 push; + + sed -i -e 's/^(version:) .*$/\1 1.0.12/' prj/manifest; + + # Fail to publish (see above for details). + # + $* 2>>~%EOE% != 0; + synchronizing: + upgrade prj/1.0.12 + pushing build2-control + %.* + error: unable to push build2-control branch + info: run 'git fetch' and try again + EOE + + # Publish successfully after the fetch. + # + $g fetch; + + $* 2>>~%EOE%; + pushing build2-control + %.* + submitting prj-1.0.12.tar.gz + %.* + %(prj/1\.0\.12 )?submission is queued% + %reference: .{12}% + EOE + + sed -i -e 's/^(version:) .*$/\1 1.0.13/' prj/manifest; + + # Reproduce the situation when the local build2-control branch exists but + # the remote-tracking one doesn't (see brep/publish.cxx for details). + # + $g branch -D -r origin/build2-control; + + $* >&2 2>>~%EOE%; + synchronizing: + upgrade prj/1.0.13 + pushing build2-control + %.* + submitting prj-1.0.13.tar.gz + %.* + %(prj/1\.0\.13 )?submission is queued% + %reference: .{12}% + EOE + + # Test publishing after implicit fetches. + # + # Push again into the build2-control branch from another local repository + # (see above for details). + # + $g2 pull; + $g2 commit --allow-empty -m 'Dummy2'; + $g2 push; + + sed -i -e 's/^(version:) .*$/\1 1.0.14/' prj/manifest; + + # Note that the prj repository master branch push doesn't implicitly fetch + # the build2-control branch, so the subsequent publishing fails. + # + $g add '*'; + $g commit -m 'Create'; + $g push --set-upstream origin master; + + $* 2>>~%EOE% != 0; + synchronizing: + upgrade prj/1.0.14 + pushing build2-control + %.* + error: unable to push build2-control branch + info: run 'git fetch' and try again + EOE + + # Note that the prj repository master branch pull fetches the + # build2-control branch implicitly, so the subsequent publishing succeeds. + # + $g pull; + + $* 2>>~%EOE%; + pushing build2-control + %.* + submitting prj-1.0.14.tar.gz + %.* + %(prj/1\.0\.14 )?submission is queued% + %reference: .{12}% + EOE + + # Check the build2-control branch commits presence and the files they add. + # + $g checkout build2-control; + $g log --name-only --pretty='format:%s' >>:~%EOO% + %.* + Add prj/1.0.14 publish authorization + %submit/.{16}% + + Dummy2 + Add prj/1.0.13 publish authorization + %submit/.{16}% + + Add prj/1.0.12 publish authorization + %submit/.{16}% + + Dummy1 + Add prj/1.0.11 publish authorization + %submit/.{16}% + + Start + EOO + } +} diff --git a/tests/status.test b/tests/status.test deleted file mode 100644 index 2d60af5..0000000 --- a/tests/status.test +++ /dev/null @@ -1,105 +0,0 @@ -# file : tests/status.test -# copyright : Copyright (c) 2014-2018 Code Synthesis Ltd -# license : MIT; see accompanying LICENSE file - -.include common.test project.test - -cxx = cc config.cxx="$recall($cxx.path)" - -new += 2>! -init += $cxx -d prj 2>! -sync += -d prj 2>! -deinit += -d prj - -: no-cfg -: -{ - $clone_prj; - - $* 2>>/"EOE" != 0 - error: no default configuration in project $~/prj/ - info: use \(@ | --config|-c | --all|-a\) to specify configuration explicitly - EOE -} - -: single-cfg -: -{ - $clone_prj; - - $init -C @cfg &prj-cfg/***; - - $* >'prj configured 0.1.0-a.0.19700101000000'; - - $deinit 2>>/"EOE" - deinitializing in project $~/prj/ - synchronizing: - drop prj - EOE -} - -: multi-cfg -: -{ - $clone_prj; - - $init -C @cfg1 &prj-cfg1/***; - $init -C @cfg2 &prj-cfg2/***; - - $* @cfg2 >'prj configured 0.1.0-a.0.19700101000000'; - - $* --all >>EOO; - in configuration @cfg1: - prj configured 0.1.0-a.0.19700101000000 - - in configuration @cfg2: - prj configured 0.1.0-a.0.19700101000000 - EOO - - $deinit 2>>/"EOE" - deinitializing in project $~/prj/ - synchronizing: - drop prj - EOE -} - -: dependency -: -{ - $clone_prj; - - $init -C @cfg &prj-cfg/***; - - $new -t lib libprj &libprj/***; - - cat <+prj/repositories.manifest; - : - role: prerequisite - location: ../libprj - type: dir - EOI - - cat <+prj/manifest; - depends: libprj - EOI - - $* --recursive >>EOO 2>>/"EOE"; # Note: implicitly fetches in cfg. - prj configured 0.1.0-a.0.19700101000000 available 0.1.0-a.0.19700101000000#1 - EOO - fetching dir:$~/libprj \(prerequisite of dir:$~/prj\) - EOE - - $sync; - - $* --recursive >>~%EOO%; - prj configured 0.1.0-a.0.19700101000000#1 - % libprj configured 0.+% - EOO - - $deinit 2>>/"EOE" - deinitializing in project $~/prj/ - synchronizing: - drop prj - drop libprj - EOE -} diff --git a/tests/status.testscript b/tests/status.testscript new file mode 100644 index 0000000..905281e --- /dev/null +++ b/tests/status.testscript @@ -0,0 +1,105 @@ +# file : tests/status.testscript +# copyright : Copyright (c) 2014-2018 Code Synthesis Ltd +# license : MIT; see accompanying LICENSE file + +.include common.testscript project.testscript + +cxx = cc config.cxx="$recall($cxx.path)" + +new += 2>! +init += $cxx -d prj 2>! +sync += -d prj 2>! +deinit += -d prj + +: no-cfg +: +{ + $clone_prj; + + $* 2>>/"EOE" != 0 + error: no default configuration in project $~/prj/ + info: use \(@ | --config|-c | --all|-a\) to specify configuration explicitly + EOE +} + +: single-cfg +: +{ + $clone_prj; + + $init -C @cfg &prj-cfg/***; + + $* >'prj configured 0.1.0-a.0.19700101000000'; + + $deinit 2>>/"EOE" + deinitializing in project $~/prj/ + synchronizing: + drop prj + EOE +} + +: multi-cfg +: +{ + $clone_prj; + + $init -C @cfg1 &prj-cfg1/***; + $init -C @cfg2 &prj-cfg2/***; + + $* @cfg2 >'prj configured 0.1.0-a.0.19700101000000'; + + $* --all >>EOO; + in configuration @cfg1: + prj configured 0.1.0-a.0.19700101000000 + + in configuration @cfg2: + prj configured 0.1.0-a.0.19700101000000 + EOO + + $deinit 2>>/"EOE" + deinitializing in project $~/prj/ + synchronizing: + drop prj + EOE +} + +: dependency +: +{ + $clone_prj; + + $init -C @cfg &prj-cfg/***; + + $new -t lib libprj &libprj/***; + + cat <+prj/repositories.manifest; + : + role: prerequisite + location: ../libprj + type: dir + EOI + + cat <+prj/manifest; + depends: libprj + EOI + + $* --recursive >>EOO 2>>/"EOE"; # Note: implicitly fetches in cfg. + prj configured 0.1.0-a.0.19700101000000 available 0.1.0-a.0.19700101000000#1 + EOO + fetching dir:$~/libprj \(prerequisite of dir:$~/prj\) + EOE + + $sync; + + $* --recursive >>~%EOO%; + prj configured 0.1.0-a.0.19700101000000#1 + % libprj configured 0.+% + EOO + + $deinit 2>>/"EOE" + deinitializing in project $~/prj/ + synchronizing: + drop prj + drop libprj + EOE +} diff --git a/tests/sync.test b/tests/sync.test deleted file mode 100644 index 4872f11..0000000 --- a/tests/sync.test +++ /dev/null @@ -1,204 +0,0 @@ -# file : tests/sync.test -# copyright : Copyright (c) 2014-2018 Code Synthesis Ltd -# license : MIT; see accompanying LICENSE file - -.include common.test - -cxx = cc config.cxx="$recall($cxx.path)" - -new += 2>! -init += $cxx -d prj 2>! -status += --all --recursive -d prj -deinit += -d prj - -: single-pkg-cfg -: -{ - $new -C @cfg prj $cxx &prj/*** &prj-cfg/***; - - $new -t lib libprj &libprj/***; - - cat <+prj/repositories.manifest; - : - role: prerequisite - location: ../libprj - type: dir - EOI - - cat <+prj/manifest; - depends: libprj - EOI - - sed -i -e 's/^(#import .+)$/import libs += libprj%lib{prj}/' \ - prj/prj/buildfile; - - cat <=prj/prj/prj.cxx; - #include - - #include - - using namespace std; - - int main (int argc, char* argv[]) - { - if (argc < 2) - { - cerr << "error: missing name" << endl; - return 1; - } - - prj::say_hello (cout, argv[1]); - } - EOI - - $* -d prj 2>>/~"%EOE%"; - fetching dir:$~/libprj \(prerequisite of dir:$~/prj\) - synchronizing: - % new libprj.+ \\\(required by prj\\\)% - % upgrade prj.+19700101000000#1% - EOE - - $status >>~%EOO%; - prj configured 0.1.0-a.0.19700101000000#1 - % libprj configured 0.+% - EOO - - $build prj/ 2>>~%EOE%; - %(mkdir|version\.in|c\+\+|ld|ln) .+%{8} - EOE - - $build 'clean:' prj/ 2>>~%EOE%; - %rm .+%{3} - EOE - - $deinit 2>>/"EOE" - deinitializing in project $~/prj/ - synchronizing: - drop prj - drop libprj - EOE -} - -: multi-pkg-cfg -: -{ - $new -t empty prj &prj/***; - - $new --package pkg1 -d prj; - $new --package pkg2 -d prj; - - $init -C @cfg1 &prj-cfg1/***; - $init -C @cfg2 &prj-cfg2/***; - - $new -t lib libprj &libprj/***; - - cat <+prj/repositories.manifest; - : - role: prerequisite - location: ../libprj - type: dir - EOI - - cat <+prj/pkg1/manifest; - depends: libprj - EOI - - sed -i -e 's/^(#import .+)$/import libs += libprj%lib{prj}/' \ - prj/pkg1/pkg1/buildfile; - - cat <=prj/pkg1/pkg1/pkg1.cxx; - #include - - #include - - using namespace std; - - int main (int argc, char* argv[]) - { - if (argc < 2) - { - cerr << "error: missing name" << endl; - return 1; - } - - prj::say_hello (cout, argv[1]); - } - EOI - - cat <+prj/pkg2/manifest; - tags: c++ - EOI - - # Sync the default (cfg1) configuration (via the package directory). - # - $* -d prj/pkg2 2>>/~"%EOE%"; - fetching dir:$~/libprj \(prerequisite of dir:$~/prj\) - synchronizing: - % new libprj.+ \\\(required by pkg1\\\)% - % upgrade pkg1.+19700101000000#1% - % upgrade pkg2.+19700101000000#1% - EOE - - $status >>~%EOO% 2>>/~"%EOE%"; # Note: implicitly fetches into cfg2. - in configuration @cfg1: - pkg1 configured 0.1.0-a.0.19700101000000#1 - % libprj configured 0.+% - pkg2 configured 0.1.0-a.0.19700101000000#1 - - in configuration @cfg2: - pkg1 configured 0.1.0-a.0.19700101000000 available 0.1.0-a.0.19700101000000#1 - pkg2 configured 0.1.0-a.0.19700101000000 available 0.1.0-a.0.19700101000000#1 - EOO - fetching dir:$~/libprj \(prerequisite of dir:$~/prj\) - EOE - - # Sync all configurations (via the project directory). - # - $* --all -d prj 2>>~%EOE%; - in configuration @cfg1: - - in configuration @cfg2: - synchronizing: - % new libprj.+ \(required by pkg1\)% - upgrade pkg1/0.1.0-a.0.19700101000000#1 - upgrade pkg2/0.1.0-a.0.19700101000000#1 - EOE - - $status >>~%EOE%; - in configuration @cfg1: - pkg1 configured 0.1.0-a.0.19700101000000#1 - % libprj configured 0.+% - pkg2 configured 0.1.0-a.0.19700101000000#1 - - in configuration @cfg2: - pkg1 configured 0.1.0-a.0.19700101000000#1 - % libprj configured 0.+% - pkg2 configured 0.1.0-a.0.19700101000000#1 - EOE - - $build prj/pkg1/ 2>>~%EOE%; - %(mkdir|version\.in|c\+\+|ld|ln) .+%{8} - EOE - - $build prj/pkg2/ 2>>~%EOE%; - %(mkdir|c\+\+|ld|ln) .+%{4} - EOE - - $build 'clean:' prj/pkg1/ 2>>~%EOE%; - %rm .+%{3} - EOE - - $build 'clean:' prj/pkg2/ 2>>~%EOE%; - %rm .+%{3} - EOE - - $deinit 2>>/"EOE" - deinitializing in project $~/prj/ - deinitializing package pkg1 - deinitializing package pkg2 - synchronizing: - drop pkg1 - drop libprj - drop pkg2 - EOE -} diff --git a/tests/sync.testscript b/tests/sync.testscript new file mode 100644 index 0000000..d01550b --- /dev/null +++ b/tests/sync.testscript @@ -0,0 +1,204 @@ +# file : tests/sync.testscript +# copyright : Copyright (c) 2014-2018 Code Synthesis Ltd +# license : MIT; see accompanying LICENSE file + +.include common.testscript + +cxx = cc config.cxx="$recall($cxx.path)" + +new += 2>! +init += $cxx -d prj 2>! +status += --all --recursive -d prj +deinit += -d prj + +: single-pkg-cfg +: +{ + $new -C @cfg prj $cxx &prj/*** &prj-cfg/***; + + $new -t lib libprj &libprj/***; + + cat <+prj/repositories.manifest; + : + role: prerequisite + location: ../libprj + type: dir + EOI + + cat <+prj/manifest; + depends: libprj + EOI + + sed -i -e 's/^(#import .+)$/import libs += libprj%lib{prj}/' \ + prj/prj/buildfile; + + cat <=prj/prj/prj.cxx; + #include + + #include + + using namespace std; + + int main (int argc, char* argv[]) + { + if (argc < 2) + { + cerr << "error: missing name" << endl; + return 1; + } + + prj::say_hello (cout, argv[1]); + } + EOI + + $* -d prj 2>>/~"%EOE%"; + fetching dir:$~/libprj \(prerequisite of dir:$~/prj\) + synchronizing: + % new libprj.+ \\\(required by prj\\\)% + % upgrade prj.+19700101000000#1% + EOE + + $status >>~%EOO%; + prj configured 0.1.0-a.0.19700101000000#1 + % libprj configured 0.+% + EOO + + $build prj/ 2>>~%EOE%; + %(mkdir|version\.in|c\+\+|ld|ln) .+%{8} + EOE + + $build 'clean:' prj/ 2>>~%EOE%; + %rm .+%{3} + EOE + + $deinit 2>>/"EOE" + deinitializing in project $~/prj/ + synchronizing: + drop prj + drop libprj + EOE +} + +: multi-pkg-cfg +: +{ + $new -t empty prj &prj/***; + + $new --package pkg1 -d prj; + $new --package pkg2 -d prj; + + $init -C @cfg1 &prj-cfg1/***; + $init -C @cfg2 &prj-cfg2/***; + + $new -t lib libprj &libprj/***; + + cat <+prj/repositories.manifest; + : + role: prerequisite + location: ../libprj + type: dir + EOI + + cat <+prj/pkg1/manifest; + depends: libprj + EOI + + sed -i -e 's/^(#import .+)$/import libs += libprj%lib{prj}/' \ + prj/pkg1/pkg1/buildfile; + + cat <=prj/pkg1/pkg1/pkg1.cxx; + #include + + #include + + using namespace std; + + int main (int argc, char* argv[]) + { + if (argc < 2) + { + cerr << "error: missing name" << endl; + return 1; + } + + prj::say_hello (cout, argv[1]); + } + EOI + + cat <+prj/pkg2/manifest; + tags: c++ + EOI + + # Sync the default (cfg1) configuration (via the package directory). + # + $* -d prj/pkg2 2>>/~"%EOE%"; + fetching dir:$~/libprj \(prerequisite of dir:$~/prj\) + synchronizing: + % new libprj.+ \\\(required by pkg1\\\)% + % upgrade pkg1.+19700101000000#1% + % upgrade pkg2.+19700101000000#1% + EOE + + $status >>~%EOO% 2>>/~"%EOE%"; # Note: implicitly fetches into cfg2. + in configuration @cfg1: + pkg1 configured 0.1.0-a.0.19700101000000#1 + % libprj configured 0.+% + pkg2 configured 0.1.0-a.0.19700101000000#1 + + in configuration @cfg2: + pkg1 configured 0.1.0-a.0.19700101000000 available 0.1.0-a.0.19700101000000#1 + pkg2 configured 0.1.0-a.0.19700101000000 available 0.1.0-a.0.19700101000000#1 + EOO + fetching dir:$~/libprj \(prerequisite of dir:$~/prj\) + EOE + + # Sync all configurations (via the project directory). + # + $* --all -d prj 2>>~%EOE%; + in configuration @cfg1: + + in configuration @cfg2: + synchronizing: + % new libprj.+ \(required by pkg1\)% + upgrade pkg1/0.1.0-a.0.19700101000000#1 + upgrade pkg2/0.1.0-a.0.19700101000000#1 + EOE + + $status >>~%EOE%; + in configuration @cfg1: + pkg1 configured 0.1.0-a.0.19700101000000#1 + % libprj configured 0.+% + pkg2 configured 0.1.0-a.0.19700101000000#1 + + in configuration @cfg2: + pkg1 configured 0.1.0-a.0.19700101000000#1 + % libprj configured 0.+% + pkg2 configured 0.1.0-a.0.19700101000000#1 + EOE + + $build prj/pkg1/ 2>>~%EOE%; + %(mkdir|version\.in|c\+\+|ld|ln) .+%{8} + EOE + + $build prj/pkg2/ 2>>~%EOE%; + %(mkdir|c\+\+|ld|ln) .+%{4} + EOE + + $build 'clean:' prj/pkg1/ 2>>~%EOE%; + %rm .+%{3} + EOE + + $build 'clean:' prj/pkg2/ 2>>~%EOE%; + %rm .+%{3} + EOE + + $deinit 2>>/"EOE" + deinitializing in project $~/prj/ + deinitializing package pkg1 + deinitializing package pkg2 + synchronizing: + drop pkg1 + drop libprj + drop pkg2 + EOE +} diff --git a/tests/test.test b/tests/test.test deleted file mode 100644 index 667ee7a..0000000 --- a/tests/test.test +++ /dev/null @@ -1,106 +0,0 @@ -# file : tests/test.test -# copyright : Copyright (c) 2014-2018 Code Synthesis Ltd -# license : MIT; see accompanying LICENSE file - -.include common.test - -cxx = cc config.cxx="$recall($cxx.path)" - -new += 2>! -init += cc "config.cxx=$config.cxx" -d prj 2>! -deinit += -d prj - -: single-pkg-cfg -: -{ - $new -C @cfg prj $cxx &prj/*** &prj-cfg/***; - - $* -d prj 2>>~%EOE%; - %(mkdir|c\+\+|ld|test) .+%{4} - EOE - - $deinit 2>>/"EOE" - deinitializing in project $~/prj/ - synchronizing: - drop prj - EOE -} - -: multi-pkg-cfg -: -: Here we will also test recursively. -: -{ - $new -t empty prj &prj/***; - - $new --package pkg1 -d prj; - $new --package pkg2 -d prj; - - $init -C @cfg1 &prj-cfg1/***; - $init -C @cfg2 &prj-cfg2/***; - - $new -t lib libprj &libprj/***; - - cat <+prj/repositories.manifest; - : - role: prerequisite - location: ../libprj - type: dir - EOI - - cat <+prj/pkg1/manifest; - depends: libprj - EOI - - sed -i -e 's/^(#import .+)$/import libs += libprj%lib{prj}/' \ - prj/pkg1/pkg1/buildfile; - - cat <=prj/pkg1/pkg1/pkg1.cxx; - #include - - #include - - using namespace std; - - int main (int argc, char* argv[]) - { - if (argc < 2) - { - cerr << "error: missing name" << endl; - return 1; - } - - prj::say_hello (cout, argv[1]); - } - EOI - - cat <+prj/pkg2/manifest; - tags: c++ - EOI - - $* -d prj/pkg2 2>>/~"%EOE%"; # Default (cfg1). - fetching dir:$~/libprj \(prerequisite of dir:$~/prj\) - synchronizing: - % new libprj.+ \\\(required by pkg1\\\)% - % upgrade pkg1.+19700101000000#1% - % upgrade pkg2.+19700101000000#1% - %\(mkdir|c\\+\\+|ld|test\) .+%{4} - EOE - - $* @cfg2 -d prj/pkg2 2>>/~"%EOE%"; # By name (cfg2). - fetching dir:$~/libprj \(prerequisite of dir:$~/prj\) - synchronizing: - % new libprj.+ \\\(required by pkg1\\\)% - % upgrade pkg1.+19700101000000#1% - % upgrade pkg2.+19700101000000#1% - %\(mkdir|c\\+\\+|ld|test\) .+%{4} - EOE - - $* -a --recursive -d prj/pkg1 2>>~%EOE% # All configs recursive. - in configuration @cfg1: - %(mkdir|version\.in|c\+\+|ld|test) .+%{12} - - in configuration @cfg2: - %(mkdir|version\.in|c\+\+|ld|test) .+%{12} - EOE -} diff --git a/tests/test.testscript b/tests/test.testscript new file mode 100644 index 0000000..dec9177 --- /dev/null +++ b/tests/test.testscript @@ -0,0 +1,106 @@ +# file : tests/test.testscript +# copyright : Copyright (c) 2014-2018 Code Synthesis Ltd +# license : MIT; see accompanying LICENSE file + +.include common.testscript + +cxx = cc config.cxx="$recall($cxx.path)" + +new += 2>! +init += cc "config.cxx=$config.cxx" -d prj 2>! +deinit += -d prj + +: single-pkg-cfg +: +{ + $new -C @cfg prj $cxx &prj/*** &prj-cfg/***; + + $* -d prj 2>>~%EOE%; + %(mkdir|c\+\+|ld|test) .+%{4} + EOE + + $deinit 2>>/"EOE" + deinitializing in project $~/prj/ + synchronizing: + drop prj + EOE +} + +: multi-pkg-cfg +: +: Here we will also test recursively. +: +{ + $new -t empty prj &prj/***; + + $new --package pkg1 -d prj; + $new --package pkg2 -d prj; + + $init -C @cfg1 &prj-cfg1/***; + $init -C @cfg2 &prj-cfg2/***; + + $new -t lib libprj &libprj/***; + + cat <+prj/repositories.manifest; + : + role: prerequisite + location: ../libprj + type: dir + EOI + + cat <+prj/pkg1/manifest; + depends: libprj + EOI + + sed -i -e 's/^(#import .+)$/import libs += libprj%lib{prj}/' \ + prj/pkg1/pkg1/buildfile; + + cat <=prj/pkg1/pkg1/pkg1.cxx; + #include + + #include + + using namespace std; + + int main (int argc, char* argv[]) + { + if (argc < 2) + { + cerr << "error: missing name" << endl; + return 1; + } + + prj::say_hello (cout, argv[1]); + } + EOI + + cat <+prj/pkg2/manifest; + tags: c++ + EOI + + $* -d prj/pkg2 2>>/~"%EOE%"; # Default (cfg1). + fetching dir:$~/libprj \(prerequisite of dir:$~/prj\) + synchronizing: + % new libprj.+ \\\(required by pkg1\\\)% + % upgrade pkg1.+19700101000000#1% + % upgrade pkg2.+19700101000000#1% + %\(mkdir|c\\+\\+|ld|test\) .+%{4} + EOE + + $* @cfg2 -d prj/pkg2 2>>/~"%EOE%"; # By name (cfg2). + fetching dir:$~/libprj \(prerequisite of dir:$~/prj\) + synchronizing: + % new libprj.+ \\\(required by pkg1\\\)% + % upgrade pkg1.+19700101000000#1% + % upgrade pkg2.+19700101000000#1% + %\(mkdir|c\\+\\+|ld|test\) .+%{4} + EOE + + $* -a --recursive -d prj/pkg1 2>>~%EOE% # All configs recursive. + in configuration @cfg1: + %(mkdir|version\.in|c\+\+|ld|test) .+%{12} + + in configuration @cfg2: + %(mkdir|version\.in|c\+\+|ld|test) .+%{12} + EOE +} diff --git a/tests/update.test b/tests/update.test deleted file mode 100644 index 12be96e..0000000 --- a/tests/update.test +++ /dev/null @@ -1,91 +0,0 @@ -# file : tests/update.test -# copyright : Copyright (c) 2014-2018 Code Synthesis Ltd -# license : MIT; see accompanying LICENSE file - -# Here we test both update and clean commands. -# - -.include common.test - -cxx = cc config.cxx="$recall($cxx.path)" - -new += 2>! -init += $cxx -d prj 2>! -deinit += -d prj - -: single-pkg-cfg -: -{ - $new -C @cfg prj $cxx &prj/*** &prj-cfg/***; - - $* -d prj 2>>~%EOE%; - %(mkdir|c\+\+|ld) .+%{3} - EOE - - $clean -d prj 2>>~%EOE%; - %rm .+%{3} - EOE - - $deinit 2>>/"EOE" - deinitializing in project $~/prj/ - synchronizing: - drop prj - EOE -} - -: multi-pkg-cfg -: -{ - $new -t empty prj &prj/***; - - $new --package pkg1 -d prj; - $new --package pkg2 -d prj; - - $init -C @cfg1 &prj-cfg1/***; - $init -C @cfg2 &prj-cfg2/***; - - # Update. - # - $* -d prj/pkg1 2>>~%EOE%; # Default (cfg1). - %(mkdir|c\+\+|ld) .+%{3} - EOE - - $* @cfg2 -d prj/pkg1 2>>~%EOE%; # By name (cfg2). - %(mkdir|c\+\+|ld) .+%{3} - EOE - - $* --all -d prj 2>>~%EOE%; # All configs (and packages). - in configuration @cfg1: - %(mkdir|c\+\+|ld|info:) .+%{4} - - in configuration @cfg2: - %(mkdir|c\+\+|ld|info:) .+%{4} - EOE - - # Clean. - # - $clean -d prj/pkg1 2>>~%EOE%; # Default (cfg1). - %rm .+%{3} - EOE - - $clean @cfg2 -d prj/pkg1 2>>~%EOE%; # By name (cfg2). - %rm .+%{3} - EOE - - $clean --all -d prj 2>>~%EOE%; # All configs (and packages). - in configuration @cfg1: - %(rm|info:) .+%{4} - - in configuration @cfg2: - %(rm|info:) .+%{4} - EOE - - $deinit 2>>/"EOE" - deinitializing in project $~/prj/ - deinitializing package pkg1 - deinitializing package pkg2 - synchronizing: - drop pkg1 - drop pkg2 - EOE -} diff --git a/tests/update.testscript b/tests/update.testscript new file mode 100644 index 0000000..947abab --- /dev/null +++ b/tests/update.testscript @@ -0,0 +1,91 @@ +# file : tests/update.testscript +# copyright : Copyright (c) 2014-2018 Code Synthesis Ltd +# license : MIT; see accompanying LICENSE file + +# Here we test both update and clean commands. +# + +.include common.testscript + +cxx = cc config.cxx="$recall($cxx.path)" + +new += 2>! +init += $cxx -d prj 2>! +deinit += -d prj + +: single-pkg-cfg +: +{ + $new -C @cfg prj $cxx &prj/*** &prj-cfg/***; + + $* -d prj 2>>~%EOE%; + %(mkdir|c\+\+|ld) .+%{3} + EOE + + $clean -d prj 2>>~%EOE%; + %rm .+%{3} + EOE + + $deinit 2>>/"EOE" + deinitializing in project $~/prj/ + synchronizing: + drop prj + EOE +} + +: multi-pkg-cfg +: +{ + $new -t empty prj &prj/***; + + $new --package pkg1 -d prj; + $new --package pkg2 -d prj; + + $init -C @cfg1 &prj-cfg1/***; + $init -C @cfg2 &prj-cfg2/***; + + # Update. + # + $* -d prj/pkg1 2>>~%EOE%; # Default (cfg1). + %(mkdir|c\+\+|ld) .+%{3} + EOE + + $* @cfg2 -d prj/pkg1 2>>~%EOE%; # By name (cfg2). + %(mkdir|c\+\+|ld) .+%{3} + EOE + + $* --all -d prj 2>>~%EOE%; # All configs (and packages). + in configuration @cfg1: + %(mkdir|c\+\+|ld|info:) .+%{4} + + in configuration @cfg2: + %(mkdir|c\+\+|ld|info:) .+%{4} + EOE + + # Clean. + # + $clean -d prj/pkg1 2>>~%EOE%; # Default (cfg1). + %rm .+%{3} + EOE + + $clean @cfg2 -d prj/pkg1 2>>~%EOE%; # By name (cfg2). + %rm .+%{3} + EOE + + $clean --all -d prj 2>>~%EOE%; # All configs (and packages). + in configuration @cfg1: + %(rm|info:) .+%{4} + + in configuration @cfg2: + %(rm|info:) .+%{4} + EOE + + $deinit 2>>/"EOE" + deinitializing in project $~/prj/ + deinitializing package pkg1 + deinitializing package pkg2 + synchronizing: + drop pkg1 + drop pkg2 + EOE +} -- cgit v1.1