Bug #85743 Add support for running unittests from spec files
Submitted: 31 Mar 2017 14:39 Modified: 9 Jun 2017 16:10
Reporter: Daniel Horecki Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Compiling Severity:S4 (Feature request)
Version: OS:Any
Assigned to: CPU Architecture:Any

[31 Mar 2017 14:39] Daniel Horecki
Description:
This patch adds support for running unittests when building MySQL  Server from spec files. 
This allow us to run unittests during builds in PB2, to be in sync with other platform.

How to repeat:
Run rpmbuild  -ba mysql.spec. Notice it doesn't run unittests.

To run unittests with patch, run rpmbuild  '--define=with_unittests 1' -ba mysql.spec.

Suggested fix:
Patch is for 5.7, should apply without problem for trunk.

diff --git a/packaging/rpm-docker/mysql.spec.in b/packaging/rpm-docker/mysql.spec.in
index 70e38cfa50a..dda877be2d7 100644
--- a/packaging/rpm-docker/mysql.spec.in
+++ b/packaging/rpm-docker/mysql.spec.in
@@ -155,6 +155,9 @@ mkdir release
            -DMYSQL_SERVER_SUFFIX="%{?server_suffix}"
   echo BEGIN_NORMAL_CONFIG ; egrep '^#define' include/config.h ; echo END_NORMAL_CONFIG
   make %{?_smp_mflags} VERBOSE=1
+%if 0%{?with_unittests}
+  ctest -VV --output-on-failure
+%endif
 )
 
 %install
diff --git a/packaging/rpm-fedora/mysql.spec.in b/packaging/rpm-fedora/mysql.spec.in
index 5a6ca825e49..7b12b393464 100644
--- a/packaging/rpm-fedora/mysql.spec.in
+++ b/packaging/rpm-fedora/mysql.spec.in
@@ -411,6 +411,9 @@ mkdir debug
            -DMYSQL_SERVER_SUFFIX="%{?server_suffix}"
   echo BEGIN_DEBUG_CONFIG ; egrep '^#define' include/config.h ; echo END_DEBUG_CONFIG
   make %{?_smp_mflags} VERBOSE=1
+%if 0%{?with_unittests}
+  ctest -VV --output-on-failure
+%endif
 )
 
 # Build full release
@@ -441,6 +444,9 @@ mkdir release
            -DMYSQL_SERVER_SUFFIX="%{?server_suffix}"
   echo BEGIN_NORMAL_CONFIG ; egrep '^#define' include/config.h ; echo END_NORMAL_CONFIG
   make %{?_smp_mflags} VERBOSE=1
+%if 0%{?with_unittests}
+  ctest -VV --output-on-failure
+%endif
 )
 
 %install
diff --git a/packaging/rpm-oel/mysql.spec.in b/packaging/rpm-oel/mysql.spec.in
index f9ec67d0259..cab144c4f24 100644
--- a/packaging/rpm-oel/mysql.spec.in
+++ b/packaging/rpm-oel/mysql.spec.in
@@ -707,6 +707,9 @@ mkdir debug
            -DMYSQL_SERVER_SUFFIX="%{?server_suffix}"
   echo BEGIN_DEBUG_CONFIG ; egrep '^#define' include/config.h ; echo END_DEBUG_CONFIG
   make %{?_smp_mflags} VERBOSE=1
+%if 0%{?with_unittests}
+  ctest -VV --output-on-failure
+%endif
 )
 
 # Build full release
@@ -740,6 +743,9 @@ mkdir release
            -DMYSQL_SERVER_SUFFIX="%{?server_suffix}"
   echo BEGIN_NORMAL_CONFIG ; egrep '^#define' include/config.h ; echo END_NORMAL_CONFIG
   make %{?_smp_mflags} VERBOSE=1
+%if 0%{?with_unittests}
+  ctest -VV --output-on-failure
+%endif
 )
 
 %install
diff --git a/packaging/rpm-sles/mysql.spec.in b/packaging/rpm-sles/mysql.spec.in
index 65c86f5aa38..71b39fead68 100644
--- a/packaging/rpm-sles/mysql.spec.in
+++ b/packaging/rpm-sles/mysql.spec.in
@@ -531,6 +531,9 @@ mkdir debug
            -DMYSQL_SERVER_SUFFIX="%{?server_suffix}"
   echo BEGIN_DEBUG_CONFIG ; egrep '^#define' include/config.h ; echo END_DEBUG_CONFIG
   make %{?_smp_mflags} VERBOSE=1
+%if 0%{?with_unittests}
+  ctest -VV --output-on-failure
+%endif
 )
 
 # Build full release
@@ -566,6 +569,9 @@ mkdir release
            -DMYSQL_SERVER_SUFFIX="%{?server_suffix}"
   echo BEGIN_NORMAL_CONFIG ; egrep '^#define' include/config.h ; echo END_NORMAL_CONFIG
   make %{?_smp_mflags} VERBOSE=1
+%if 0%{?with_unittests}
+  ctest -VV --output-on-failure
+%endif
 )
 
 %install
[9 Jun 2017 16:10] Paul DuBois
Posted by developer:
 
Fixed in 5.7.19, 8.0.2.

RPM .spec files now include support for running unit tests.