From 0fb8758d42047c9de9fef2bd34852e80d3ac9a99 Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Sat, 4 Apr 2020 15:55:59 +0300 Subject: Make use of project configuration variables for tests --- tests/build/root.build | 16 ++++++++++++++++ tests/pkg-build.testscript | 8 ++++---- tests/pkg-checkout.testscript | 6 +++--- tests/pkg-clean.testscript | 2 +- tests/pkg-configure.testscript | 2 +- tests/pkg-drop.testscript | 2 +- tests/pkg-fetch.testscript | 2 +- tests/pkg-status.testscript | 4 ++-- tests/pkg-system.testscript | 2 +- tests/pkg-test.testscript | 2 +- tests/pkg-unpack.testscript | 4 ++-- tests/pkg-update.testscript | 2 +- tests/remote-git.testscript | 12 +----------- tests/remote.testscript | 16 +++++++--------- tests/rep-auth.testscript | 8 ++++---- tests/rep-fetch.testscript | 18 +++++++++--------- tests/rep-info.testscript | 4 ++-- tests/rep-list.testscript | 4 ++-- tests/rep-remove.testscript | 4 ++-- 19 files changed, 61 insertions(+), 57 deletions(-) diff --git a/tests/build/root.build b/tests/build/root.build index 2a0666b..55297f8 100644 --- a/tests/build/root.build +++ b/tests/build/root.build @@ -1,6 +1,22 @@ # file : tests/build/root.build # license : MIT; see accompanying LICENSE file +# Use remote repository locations for tests. +# +config [bool] config.bpkg.tests.remote ?= false + +# Enable tests which use ssh protocol for remote git repositories. If true, it +# is assumed that the password-less ssh authentication is arranged for +# git.build2.org. +# +config [bool] config.bpkg.tests.git.ssh ?= false + +# Using the project configuration variables all over the testscripts makes +# them look hairy. Thus, let's provide short aliases for these variables. +# +remote = $config.bpkg.tests.remote +git_ssh = $config.bpkg.tests.git.ssh + # We need to configure C++ module to pass the compiler path to some of bpkg # test commands. # diff --git a/tests/pkg-build.testscript b/tests/pkg-build.testscript index c0bac41..d1cfb91 100644 --- a/tests/pkg-build.testscript +++ b/tests/pkg-build.testscript @@ -120,7 +120,7 @@ # Prepare repositories used by tests if running in the local mode. # -+if ($remote != true) ++if! $remote rep_create += 2>! cp -r $src/t0a $out/t0a && $rep_create $out/t0a &$out/t0a/packages.manifest @@ -3320,7 +3320,7 @@ test.options += --no-progress { $clone_root_cfg; - if ($remote != true) + if! $remote rep = ($cxx.target.class != 'windows' \ ? "file:$rep" \ : "file:/$regex.replace($rep, '\\', '/')") @@ -3782,7 +3782,7 @@ test.options += --no-progress : git-rep : -if ($git_supported != true) +if! $git_supported { # Skip git repository tests. # @@ -3857,7 +3857,7 @@ else : Test that the unpacked external package is properly built for the first : time and is not rebuilt afterwards via the directory argument. : - if ($remote != true) + if! $remote { $clone_root_cfg; diff --git a/tests/pkg-checkout.testscript b/tests/pkg-checkout.testscript index c4f3f28..398080e 100644 --- a/tests/pkg-checkout.testscript +++ b/tests/pkg-checkout.testscript @@ -14,7 +14,7 @@ posix = ($cxx.target.class != 'windows') # Prepare repositories used by tests if running in the local mode. # -+if ($remote != true) ++if! $remote # Create git repositories. # $git_extract $src/git/libbar.tar @@ -29,7 +29,7 @@ end : git-rep : -if ($git_supported != true) +if! $git_supported { # Skip git repository tests. # @@ -122,7 +122,7 @@ else : links : - if ($remote == true || $posix) + if ($remote || $posix) { $clone_root_cfg; diff --git a/tests/pkg-clean.testscript b/tests/pkg-clean.testscript index a4a2d2b..c75055c 100644 --- a/tests/pkg-clean.testscript +++ b/tests/pkg-clean.testscript @@ -35,7 +35,7 @@ # Prepare repositories used by tests if running in the local mode. # -+if ($remote != true) ++if! $remote rep_create += 2>! # Create the signed 'hello' repository. diff --git a/tests/pkg-configure.testscript b/tests/pkg-configure.testscript index 3717f0c..e4cc768 100644 --- a/tests/pkg-configure.testscript +++ b/tests/pkg-configure.testscript @@ -48,7 +48,7 @@ # Prepare repositories used by tests if running in the local mode. # -+if ($remote != true) ++if! $remote rep_create += 2>! # Create the signed 'hello' repository. diff --git a/tests/pkg-drop.testscript b/tests/pkg-drop.testscript index 3e1287c..db9cf7c 100644 --- a/tests/pkg-drop.testscript +++ b/tests/pkg-drop.testscript @@ -23,7 +23,7 @@ # Prepare repositories used by tests if running in the local mode. # -+if ($remote != true) ++if! $remote rep_create += 2>! cp -r $src/t4a $out/t4a && $rep_create $out/t4a &$out/t4a/packages.manifest diff --git a/tests/pkg-fetch.testscript b/tests/pkg-fetch.testscript index afa7d3a..7d32523 100644 --- a/tests/pkg-fetch.testscript +++ b/tests/pkg-fetch.testscript @@ -16,7 +16,7 @@ # Prepare repositories used by tests if running in the local mode. # -+if ($remote != true) ++if! $remote rep_create += 2>! # Create the signed 'hello' repository. diff --git a/tests/pkg-status.testscript b/tests/pkg-status.testscript index 6e69dac..86a85d4 100644 --- a/tests/pkg-status.testscript +++ b/tests/pkg-status.testscript @@ -34,7 +34,7 @@ # Prepare repositories used by tests if running in the local mode. # -+if ($remote != true) ++if! $remote cp -r $src/extra $out/extra cp -r $src/stable $out/stable cp -r $src/testing $out/testing @@ -208,7 +208,7 @@ rep_fetch += -d cfg --auth all --trust-yes 2>! : git-rep : -if ($git_supported != true) +if! $git_supported { # Skip git repository tests. # diff --git a/tests/pkg-system.testscript b/tests/pkg-system.testscript index 8b7472b..cef23d5 100644 --- a/tests/pkg-system.testscript +++ b/tests/pkg-system.testscript @@ -32,7 +32,7 @@ # Prepare repositories used by tests if running in the local mode. # -+if ($remote != true) ++if! $remote rep_create += 2>! cp -r $src/t1 $out/t1 && $rep_create $out/t1 &$out/t1/packages.manifest diff --git a/tests/pkg-test.testscript b/tests/pkg-test.testscript index 1bc9c34..5e212f4 100644 --- a/tests/pkg-test.testscript +++ b/tests/pkg-test.testscript @@ -19,7 +19,7 @@ # Prepare repositories used by tests if running in the local mode. # -+if ($remote != true) ++if! $remote rep_create += 2>! cp -r $src/t0a $out/t0a && $rep_create $out/t0a &$out/t0a/packages.manifest diff --git a/tests/pkg-unpack.testscript b/tests/pkg-unpack.testscript index 8df3499..6190552 100644 --- a/tests/pkg-unpack.testscript +++ b/tests/pkg-unpack.testscript @@ -28,7 +28,7 @@ # Prepare repositories used by tests if running in the local mode. # -+if ($remote != true) ++if! $remote rep_create += 2>! # Create the signed 'hello' repository. @@ -275,7 +275,7 @@ $* 2>>EOE != 0 : Test that the version is populated with the snapshot information for the : package directory that is under the version control. : - if ($remote != true) + if! $remote { $clone_root_cfg; diff --git a/tests/pkg-update.testscript b/tests/pkg-update.testscript index 880f390..6d3e11f 100644 --- a/tests/pkg-update.testscript +++ b/tests/pkg-update.testscript @@ -35,7 +35,7 @@ # Prepare repositories used by tests if running in the local mode. # -+if ($remote != true) ++if! $remote rep_create += 2>! # Create the signed 'hello' repository. diff --git a/tests/remote-git.testscript b/tests/remote-git.testscript index 34c0643..308c067 100644 --- a/tests/remote-git.testscript +++ b/tests/remote-git.testscript @@ -36,11 +36,7 @@ git_supported = ($git_version_major > 2 || \ # out_git = $canonicalize([dir_path] $~/git/$cmd) -# If $remote is true then remote repository locations must be used for tests. -# -remote = $config.bpkg.test.remote - -+if ($remote != true) ++if! $remote rep_git_local = ($cxx.target.class != 'windows' \ ? "file://$out_git" \ : "file:/$regex.replace($out_git, '\\', '/')") @@ -51,12 +47,6 @@ remote = $config.bpkg.test.remote mkdir -p $out_git else - # If $git_ssh is not true then testscripts must skip tests that use the ssh - # protocol. Otherwise, it is assumed that the password-less ssh - # authentication is arranged for git.build2.org. - # - git_ssh = $config.bpkg.test.git.ssh - rep_git_https_dumb = "https://build2.org/bpkg/git/$cmd" rep_git_https_smart = "https://git.build2.org/testing/bpkg/advonly/$cmd" rep_git_https_smart_unadv = "https://git.build2.org/testing/bpkg/unadv/$cmd" diff --git a/tests/remote.testscript b/tests/remote.testscript index 1bf229d..f774a41 100644 --- a/tests/remote.testscript +++ b/tests/remote.testscript @@ -19,18 +19,16 @@ # out = $canonicalize([dir_path] $~/pkg/1/build2.org/) -# If $remote is true then remote repositories locations must be used for -# tests. Variables rep_root and rep refer to the root and the command- -# specific repositories respectively. Note that the variables type is dir_path -# for local repositories (rather than string for the remote ones), that allows -# to portably obtain sub-repositories locations representations. +# Variables rep_root and rep refer to the root and the command-specific +# repositories respectively. Note that the variables type is dir_path for +# local repositories (rather than string for the remote ones), that allows to +# portably obtain sub-repositories locations representations. # -remote = $config.bpkg.test.remote -rep_root = ($remote == true ? [string] "https://build2.org/bpkg/1" : $out) +rep_root = ($remote ? [string] "https://build2.org/bpkg/1" : $out) out += [dir_path] $cmd -rep = ($remote == true ? [string] "$rep_root/$cmd" : $out) +rep = ($remote ? [string] "$rep_root/$cmd" : $out) -+if ($remote != true) ++if! $remote mkdir -p $out end diff --git a/tests/rep-auth.testscript b/tests/rep-auth.testscript index 0d95887..0ba46fa 100644 --- a/tests/rep-auth.testscript +++ b/tests/rep-auth.testscript @@ -23,7 +23,7 @@ # Prepare repositories used by tests if running in the local mode. # -+if ($remote != true) ++if! $remote rc = $rep_create 2>! # Create the 'unsigned1' repository. @@ -337,7 +337,7 @@ sc = " " # Space character to append to here-document line when required. : subdomain : - if ($remote != true) + if! $remote { : first-level : @@ -373,7 +373,7 @@ sc = " " # Space character to append to here-document line when required. : subdomain : - if ($remote != true) + if! $remote { : first-level : @@ -409,7 +409,7 @@ sc = " " # Space character to append to here-document line when required. : subdomain : - if ($remote != true) + if! $remote { : first-level : diff --git a/tests/rep-fetch.testscript b/tests/rep-fetch.testscript index 9d7716f..fdb14f9 100644 --- a/tests/rep-fetch.testscript +++ b/tests/rep-fetch.testscript @@ -68,7 +68,7 @@ # Prepare repositories used by tests if running in the local mode. # -+if ($remote != true) ++if! $remote rep_create += 2>! # Create the signed 'hello' repository. @@ -457,7 +457,7 @@ y' : For dir repository tests we will reuse local git repositories, that have the : same repository structure. : -if ($remote != true) +if! $remote { rep_add += --type dir @@ -644,7 +644,7 @@ if ($remote != true) : git-rep : - if ($git_supported == true && $remote != true) + if ($git_supported && !$remote) { rep = $canonicalize([dir_path] $out_git/state0); @@ -683,7 +683,7 @@ if ($remote != true) : git-rep : -if ($git_supported != true) +if! $git_supported { # Skip git repository tests. # @@ -692,7 +692,7 @@ else { : proto : - if ($remote != true) + if! $remote { git_protocol = 'local' .include rep-fetch-git.testscript @@ -736,7 +736,7 @@ else : ssh : - if ($git_ssh == true) + if $git_ssh { git_protocol = 'ssh' .include rep-fetch-git.testscript @@ -744,7 +744,7 @@ else : ssh-unadv : - if ($git_ssh == true) + if $git_ssh { git_protocol = 'ssh-unadv' .include rep-fetch-git.testscript @@ -757,7 +757,7 @@ else : extension does not exist but the one without the extension does, then : it is picked up by rep-fetch. : - if ($remote != true) + if! $remote { cp -r $out_git/state0/libbar.git libbar.git; cp -r $out_git/state0/style-basic.git style-basic; @@ -816,7 +816,7 @@ else : Test that repository is re-fetched on the location change. Here it happens : due to the scheme change. : - if ($remote == true) + if $remote { $clone_root_cfg && $rep_add "$rep_git_git/state0/libfoo.git#master"; $* 2>! &cfg/.bpkg/repos/*/***; diff --git a/tests/rep-info.testscript b/tests/rep-info.testscript index aa7a860..8ea0e5b 100644 --- a/tests/rep-info.testscript +++ b/tests/rep-info.testscript @@ -19,7 +19,7 @@ # Prepare repositories used by tests if running in the local mode. # -+if ($remote != true) ++if! $remote rc = $rep_create 2>! # Create the unsigned 'testing' repository. @@ -281,7 +281,7 @@ $* --name $rep/testing >"pkg:build2.org/rep-info/testing ($rep/testing)" : git-rep : -if ($git_supported != true) +if! $git_supported { # Skip git repository tests. # diff --git a/tests/rep-list.testscript b/tests/rep-list.testscript index 92a3b90..3e9cfb7 100644 --- a/tests/rep-list.testscript +++ b/tests/rep-list.testscript @@ -31,7 +31,7 @@ # Prepare repositories used by tests if running in the local mode. # -+if ($remote != true) ++if! $remote cp -r $src/extra $out/extra cp -r $src/math $out/math cp -r $src/stable $out/stable @@ -125,7 +125,7 @@ rep_fetch += -d cfg --auth all --trust-yes 2>! : git-rep : -if ($git_supported != true) +if! $git_supported { # Skip git repository tests. # diff --git a/tests/rep-remove.testscript b/tests/rep-remove.testscript index 00e9be1..e6f3d91 100644 --- a/tests/rep-remove.testscript +++ b/tests/rep-remove.testscript @@ -34,7 +34,7 @@ # Prepare repositories used by tests if running in the local mode. # -+if ($remote != true) ++if! $remote cp -r $src/extra $out/extra cp -r $src/math $out/math cp -r $src/stable $out/stable @@ -187,7 +187,7 @@ pkg_status += -d cfg : git-rep : -if ($git_supported != true) +if! $git_supported { # Skip git repository tests. # -- cgit v1.1