218 lines
7.6 KiB
Diff
218 lines
7.6 KiB
Diff
From 4a282212f73ae2ed225e6906b76b4ecbcfc239ab Mon Sep 17 00:00:00 2001
|
|
From: "Endi S. Dewata" <edewata@redhat.com>
|
|
Date: Wed, 26 May 2021 21:20:25 -0500
|
|
Subject: [PATCH] Fix build.sh --without-test
|
|
|
|
The cmake files have been modified not to build the test
|
|
classes when the --without-test is specified. Also, the
|
|
spec file has been modified not to run the test when the
|
|
option is specified.
|
|
---
|
|
base/server/CMakeLists.txt | 89 +++++++++++++++++++-------------------
|
|
base/util/CMakeLists.txt | 56 ++++++++++++------------
|
|
build.sh | 5 +--
|
|
pki.spec | 2 +-
|
|
4 files changed, 77 insertions(+), 75 deletions(-)
|
|
|
|
diff --git a/base/server/CMakeLists.txt b/base/server/CMakeLists.txt
|
|
index fddb60c4b7..e470b0d487 100644
|
|
--- a/base/server/CMakeLists.txt
|
|
+++ b/base/server/CMakeLists.txt
|
|
@@ -52,51 +52,52 @@ if(WITH_SYSTEMD_NOTIFICATION)
|
|
add_subdirectory(systemd)
|
|
endif(WITH_SYSTEMD_NOTIFICATION)
|
|
|
|
-# build pki-server-test
|
|
-# TODO: build test only when the test is invoked
|
|
-javac(pki-server-test-classes
|
|
- DEPENDS
|
|
- pki-util-test-classes pki-cmsutil-jar pki-certsrv-jar pki-cms-jar pki-cmsbundle-jar
|
|
- SOURCES
|
|
- src/test/java/*.java
|
|
- CLASSPATH
|
|
- ${PKI_CMSUTIL_JAR} ${PKI_CERTSRV_JAR} ${PKI_CMS_JAR} ${PKI_CMSBUNDLE_JAR}
|
|
- ${LDAPJDK_JAR} ${SERVLET_JAR} ${XALAN_JAR} ${XERCES_JAR}
|
|
- ${JSS_JAR} ${COMMONS_CODEC_JAR} ${SYMKEY_JAR}
|
|
- ${HAMCREST_JAR} ${JUNIT_JAR} ${COMMONS_IO_JAR}
|
|
- ${CMAKE_BINARY_DIR}/test/classes
|
|
- OUTPUT_DIR
|
|
- ${CMAKE_BINARY_DIR}/test/classes
|
|
-)
|
|
+if(WITH_TEST)
|
|
+ # build pki-server-test
|
|
+ javac(pki-server-test-classes
|
|
+ DEPENDS
|
|
+ pki-util-test-classes pki-cmsutil-jar pki-certsrv-jar pki-cms-jar pki-cmsbundle-jar
|
|
+ SOURCES
|
|
+ src/test/java/*.java
|
|
+ CLASSPATH
|
|
+ ${PKI_CMSUTIL_JAR} ${PKI_CERTSRV_JAR} ${PKI_CMS_JAR} ${PKI_CMSBUNDLE_JAR}
|
|
+ ${LDAPJDK_JAR} ${SERVLET_JAR} ${XALAN_JAR} ${XERCES_JAR}
|
|
+ ${JSS_JAR} ${COMMONS_CODEC_JAR} ${SYMKEY_JAR}
|
|
+ ${HAMCREST_JAR} ${JUNIT_JAR} ${COMMONS_IO_JAR}
|
|
+ ${CMAKE_BINARY_DIR}/test/classes
|
|
+ OUTPUT_DIR
|
|
+ ${CMAKE_BINARY_DIR}/test/classes
|
|
+ )
|
|
|
|
-# create test target
|
|
-# do not include xalan and xerces in class path
|
|
-# TODO: create CMake function to find all JUnit test classes
|
|
-add_junit_test(test-pki-server
|
|
- DEPENDS
|
|
- pki-server-test-classes
|
|
- CLASSPATH
|
|
- ${SLF4J_API_JAR} ${SLF4J_SIMPLE_JAR}
|
|
- ${PKI_CMSUTIL_JAR} ${PKI_CERTSRV_JAR} ${PKI_CMS_JAR} ${PKI_CMSBUNDLE_JAR}
|
|
- ${LDAPJDK_JAR} ${SERVLET_JAR}
|
|
- ${COMMONS_CODEC_JAR} ${COMMONS_LANG3_JAR}
|
|
- ${JSS_JAR} ${SYMKEY_JAR}
|
|
- ${HAMCREST_JAR} ${JUNIT_JAR} ${COMMONS_IO_JAR}
|
|
- ${CMAKE_BINARY_DIR}/test/classes
|
|
- TESTS
|
|
- com.netscape.cmscore.authentication.AuthTokenTest
|
|
- com.netscape.cmscore.dbs.CertRecordListTest
|
|
- com.netscape.cmscore.dbs.DBRegistryTest
|
|
- com.netscape.cmscore.request.AgentApprovalsTest
|
|
- com.netscape.cmscore.request.ExtAttrDynMapperTest
|
|
- com.netscape.cmscore.request.ExtDataHashtableTest
|
|
- com.netscape.cmscore.request.RequestQueueTest
|
|
- com.netscape.cmscore.request.RequestRecordTest
|
|
- com.netscape.cmscore.request.RequestTest
|
|
- com.netscape.cmscore.password.PlainPasswordFileTest
|
|
- REPORTS_DIR
|
|
- reports
|
|
-)
|
|
+ # create test target
|
|
+ # do not include xalan and xerces in class path
|
|
+ # TODO: create CMake function to find all JUnit test classes
|
|
+ add_junit_test(test-pki-server
|
|
+ DEPENDS
|
|
+ pki-server-test-classes
|
|
+ CLASSPATH
|
|
+ ${SLF4J_API_JAR} ${SLF4J_SIMPLE_JAR}
|
|
+ ${PKI_CMSUTIL_JAR} ${PKI_CERTSRV_JAR} ${PKI_CMS_JAR} ${PKI_CMSBUNDLE_JAR}
|
|
+ ${LDAPJDK_JAR} ${SERVLET_JAR}
|
|
+ ${COMMONS_CODEC_JAR} ${COMMONS_LANG3_JAR}
|
|
+ ${JSS_JAR} ${SYMKEY_JAR}
|
|
+ ${HAMCREST_JAR} ${JUNIT_JAR} ${COMMONS_IO_JAR}
|
|
+ ${CMAKE_BINARY_DIR}/test/classes
|
|
+ TESTS
|
|
+ com.netscape.cmscore.authentication.AuthTokenTest
|
|
+ com.netscape.cmscore.dbs.CertRecordListTest
|
|
+ com.netscape.cmscore.dbs.DBRegistryTest
|
|
+ com.netscape.cmscore.request.AgentApprovalsTest
|
|
+ com.netscape.cmscore.request.ExtAttrDynMapperTest
|
|
+ com.netscape.cmscore.request.ExtDataHashtableTest
|
|
+ com.netscape.cmscore.request.RequestQueueTest
|
|
+ com.netscape.cmscore.request.RequestRecordTest
|
|
+ com.netscape.cmscore.request.RequestTest
|
|
+ com.netscape.cmscore.password.PlainPasswordFileTest
|
|
+ REPORTS_DIR
|
|
+ reports
|
|
+ )
|
|
+endif(WITH_TEST)
|
|
|
|
# Create /usr/share/pki/server/lib. This can be customized for different platforms in RPM spec.
|
|
|
|
diff --git a/base/util/CMakeLists.txt b/base/util/CMakeLists.txt
|
|
index 6664be008b..174d128b43 100644
|
|
--- a/base/util/CMakeLists.txt
|
|
+++ b/base/util/CMakeLists.txt
|
|
@@ -43,34 +43,36 @@ install(
|
|
|
|
set(PKI_CMSUTIL_JAR ${CMAKE_BINARY_DIR}/dist/pki-cmsutil.jar CACHE INTERNAL "pki-cmsutil jar file")
|
|
|
|
-javac(pki-util-test-classes
|
|
- SOURCES
|
|
- src/test/java/*.java
|
|
- CLASSPATH
|
|
- ${PKI_CMSUTIL_JAR}
|
|
- ${JSS_JAR} ${LDAPJDK_JAR} ${COMMONS_CODEC_JAR} ${XALAN_JAR} ${XERCES_JAR}
|
|
- ${HAMCREST_JAR} ${JUNIT_JAR}
|
|
- OUTPUT_DIR
|
|
- ${CMAKE_BINARY_DIR}/test/classes
|
|
- DEPENDS
|
|
- pki-cmsutil-jar
|
|
-)
|
|
+if(WITH_TEST)
|
|
+ javac(pki-util-test-classes
|
|
+ SOURCES
|
|
+ src/test/java/*.java
|
|
+ CLASSPATH
|
|
+ ${PKI_CMSUTIL_JAR}
|
|
+ ${JSS_JAR} ${LDAPJDK_JAR} ${COMMONS_CODEC_JAR} ${XALAN_JAR} ${XERCES_JAR}
|
|
+ ${HAMCREST_JAR} ${JUNIT_JAR}
|
|
+ OUTPUT_DIR
|
|
+ ${CMAKE_BINARY_DIR}/test/classes
|
|
+ DEPENDS
|
|
+ pki-cmsutil-jar
|
|
+ )
|
|
|
|
-# TODO: create CMake function to find all JUnit test classes
|
|
-add_junit_test(test-pki-util
|
|
- CLASSPATH
|
|
- ${SLF4J_API_JAR} ${SLF4J_JDK14_JAR}
|
|
- ${PKI_CMSUTIL_JAR}
|
|
- ${JSS_JAR} ${LDAPJDK_JAR} ${COMMONS_CODEC_JAR}
|
|
- ${HAMCREST_JAR} ${JUNIT_JAR}
|
|
- ${CMAKE_BINARY_DIR}/test/classes
|
|
- TESTS
|
|
- com.netscape.cmsutil.crypto.KeyIDCodecTest
|
|
- REPORTS_DIR
|
|
- reports
|
|
- DEPENDS
|
|
- pki-util-test-classes
|
|
-)
|
|
+ # TODO: create CMake function to find all JUnit test classes
|
|
+ add_junit_test(test-pki-util
|
|
+ CLASSPATH
|
|
+ ${SLF4J_API_JAR} ${SLF4J_JDK14_JAR}
|
|
+ ${PKI_CMSUTIL_JAR}
|
|
+ ${JSS_JAR} ${LDAPJDK_JAR} ${COMMONS_CODEC_JAR}
|
|
+ ${HAMCREST_JAR} ${JUNIT_JAR}
|
|
+ ${CMAKE_BINARY_DIR}/test/classes
|
|
+ TESTS
|
|
+ com.netscape.cmsutil.crypto.KeyIDCodecTest
|
|
+ REPORTS_DIR
|
|
+ reports
|
|
+ DEPENDS
|
|
+ pki-util-test-classes
|
|
+ )
|
|
+endif(WITH_TEST)
|
|
|
|
install(
|
|
FILES
|
|
diff --git a/build.sh b/build.sh
|
|
index 533888ab97..67cf339cab 100755
|
|
--- a/build.sh
|
|
+++ b/build.sh
|
|
@@ -153,9 +153,8 @@ generate_rpm_spec() {
|
|
|
|
# hard-code test option
|
|
if [ "$WITHOUT_TEST" = true ] ; then
|
|
- commands="${commands}; s/%\(bcond_without *test\)\$/# \1\n%global with_test 0/g"
|
|
- else
|
|
- commands="${commands}; s/%\(bcond_without *test\)\$/# \1\n%global with_test 1/g"
|
|
+ # convert bcond_without into bcond_with such that unit tests do not run by default
|
|
+ commands="${commands}; s/%\(bcond_without *test\)\$/# \1\n%bcond_with test/g"
|
|
fi
|
|
|
|
# hard-code packages to build
|
|
diff --git a/pki.spec b/pki.spec
|
|
index 9bfe2d9af1..505e9ce06d 100644
|
|
--- a/pki.spec
|
|
+++ b/pki.spec
|
|
@@ -906,7 +906,7 @@ cd %{_vpath_builddir}
|
|
--no-print-directory \
|
|
install
|
|
|
|
-%if %{with_test}
|
|
+%if %{with test}
|
|
ctest --output-on-failure
|
|
%endif
|
|
|
|
--
|
|
2.31.1
|
|
|