ci: introduce helper to preserve select env variables under sudo
Change-Id: I317a3c03d7188501f819b79ddfa6f0a2946a9866
Refs: #4610
diff --git a/.jenkins.d/01-ndn-cxx.sh b/.jenkins.d/01-ndn-cxx.sh
index c9e2a63..29a41ea 100755
--- a/.jenkins.d/01-ndn-cxx.sh
+++ b/.jenkins.d/01-ndn-cxx.sh
@@ -44,7 +44,7 @@
./waf configure --color=yes --enable-shared --disable-static --without-osx-keychain
./waf build --color=yes -j${WAF_JOBS:-1}
-sudo env "PATH=$PATH" ./waf install --color=yes
+sudo_preserve_env PATH -- ./waf install --color=yes
popd >/dev/null
popd >/dev/null
diff --git a/.jenkins.d/10-build.sh b/.jenkins.d/10-build.sh
index 83f7d37..0c952ec 100755
--- a/.jenkins.d/10-build.sh
+++ b/.jenkins.d/10-build.sh
@@ -13,7 +13,7 @@
fi
# Cleanup
-sudo env "PATH=$PATH" ./waf --color=yes distclean
+sudo_preserve_env PATH -- ./waf --color=yes distclean
if [[ $JOB_NAME != *"code-coverage" && $JOB_NAME != *"limited-build" ]]; then
# Configure/build in optimized mode with tests
@@ -21,14 +21,14 @@
./waf --color=yes build -j${WAF_JOBS:-1}
# Cleanup
- sudo env "PATH=$PATH" ./waf --color=yes distclean
+ sudo_preserve_env PATH -- ./waf --color=yes distclean
# Configure/build in optimized mode without tests
./waf --color=yes configure
./waf --color=yes build -j${WAF_JOBS:-1}
# Cleanup
- sudo env "PATH=$PATH" ./waf --color=yes distclean
+ sudo_preserve_env PATH -- ./waf --color=yes distclean
fi
# Configure/build in debug mode with tests
@@ -38,4 +38,4 @@
# (tests will be run against debug version)
# Install
-sudo env "PATH=$PATH" ./waf --color=yes install
+sudo_preserve_env PATH -- ./waf --color=yes install
diff --git a/.jenkins.d/20-tests.sh b/.jenkins.d/20-tests.sh
index fe7981d..b4d8ec9 100755
--- a/.jenkins.d/20-tests.sh
+++ b/.jenkins.d/20-tests.sh
@@ -35,5 +35,8 @@
ASAN_OPTIONS+=":strip_path_prefix=${PWD}/"
export ASAN_OPTIONS
+export BOOST_TEST_BUILD_INFO=1
+export BOOST_TEST_COLOR_OUTPUT=1
+
# Run unit tests
./build/unit-tests $(ut_log_args)
diff --git a/.jenkins.d/util.sh b/.jenkins.d/util.sh
index a89bc27..8ddc4ba 100644
--- a/.jenkins.d/util.sh
+++ b/.jenkins.d/util.sh
@@ -16,3 +16,22 @@
set ${saved_xtrace}
return ${ret}
}
+
+sudo_preserve_env() {
+ local saved_xtrace
+ [[ $- == *x* ]] && saved_xtrace=-x || saved_xtrace=+x
+ set +x
+
+ local vars=()
+ while [[ $# -gt 0 ]]; do
+ local arg=$1
+ shift
+ case ${arg} in
+ --) break ;;
+ *) vars+=("${arg}=${!arg}") ;;
+ esac
+ done
+
+ set ${saved_xtrace}
+ sudo env "${vars[@]}" "$@"
+}