commit: f3bd66dffa477b017a66bea1dbb32afc022860f8
Author: Andreas Sturmlechner <asturm <AT> gentoo <DOT> org>
AuthorDate: Mon Aug 14 21:29:30 2017 +0000
Commit: Andreas Sturmlechner <asturm <AT> gentoo <DOT> org>
CommitDate: Mon Aug 14 21:29:30 2017 +0000
URL: https://gitweb.gentoo.org/proj/kde.git/commit/?id=f3bd66df
kde5.eclass: KDE_TEST=forceoptional-recursive reloaded
Searches for test subdirectory pattern in CMakeLists.txt recursively,
enclose it with BUILD_TESTING conditional.
Creates unified diff to easily pick up for cosmetics and submission
upstream.
eclass/kde5.eclass | 26 ++++++++++++++++++++++----
1 file changed, 22 insertions(+), 4 deletions(-)
diff --git a/eclass/kde5.eclass b/eclass/kde5.eclass
index e34dcc7f33..251026233d 100644
--- a/eclass/kde5.eclass
+++ b/eclass/kde5.eclass
@@ -90,6 +90,13 @@ else
: ${KDE_QTHELP:=false}
fi
+# @ECLASS-VARIABLE: KDE_TESTPATTERN
+# @DESCRIPTION:
+# DANGER: Only touch it if you know what you are doing.
+# By default, matches autotest(s), unittest(s) and test(s) pattern inside
+# cmake add_subdirectory calls.
+: ${KDE_TESTPATTERN:="\(auto|unit\)\?tests\?"}
+
# @ECLASS-VARIABLE: KDE_TEST
# @DESCRIPTION:
# If set to "false", do nothing.
@@ -628,13 +635,24 @@ kde5_src_prepare() {
cmake_comment_add_subdirectory autotests test tests
elif [[ ${KDE_TEST} = forceoptional-recursive ]] ; then
punt_bogus_dep Qt5 Test
- local d
- for d in $(find . -type d -name "autotests" -or -name
"tests" -or -name "test" -or -name "unittests"); do
- pushd ${d%/*} > /dev/null || die
+ local f pf="${T}/${P}"-tests-optional.patch
+ touch ${pf} || die "Failed to touch patch file"
+ for f in $(find . -type f -name "CMakeLists.txt" -exec \
+ grep -l
"^\s*add_subdirectory\s*\(\s*.*${KDE_TESTPATTERN}\s*)\s*\)" {} \;); do
+ cp ${f} ${f}.old || die "Failed to prepare
patch origfile"
+ pushd ${f%/*} > /dev/null || die
punt_bogus_dep Qt5 Test
- cmake_comment_add_subdirectory
autotests test tests
+ sed -i CMakeLists.txt -e \
+ "/^#/!
s/add_subdirectory\s*\(\s*.*${KDE_TESTPATTERN}\s*)\s*\)/if(BUILD_TESTING)\n&\nendif()/"
\
+ || die
popd > /dev/null || die
+ diff -Naur ${f}.old ${f} 1>>${pf}
+ rm ${f}.old || die "Failed to clean up"
done
+ einfo "Build system was modified by
KDE_TEST=forceoptional-recursive."
+ einfo "Unified diff file ready for pickup in:"
+ einfo " ${pf}"
+ einfo "Push it upstream to make this message go away."
elif [[ ${CATEGORY} = kde-frameworks || ${CATEGORY} =
kde-plasma || ${CATEGORY} = kde-apps ]] ; then
cmake_comment_add_subdirectory autotests test tests
fi