void-packages/srcpkgs/rabbitmq-c/patches/test.patch

90 lines
3.5 KiB
Diff

From 26ecf6d3012be81f5dfb8a2d822c722e916a86cb Mon Sep 17 00:00:00 2001
From: Simon Lepasteur <simon.lepasteur@swissdotnet.ch>
Date: Wed, 11 Mar 2020 15:13:29 +0100
Subject: [PATCH] Add option to run system tests (disabled by default).
System tests require a RabbitMQ or other AMQP server to be running on
`localhost` at TCP port number 5672 and therefore fails if no such
server is running on the build machine.
This is surprising for everyone running the standard `make test`
to ensure the library is built correctly.
---
.travis.yml | 2 +-
CMakeLists.txt | 1 +
README.md | 2 ++
appveyor.yml | 2 +-
tests/CMakeLists.txt | 8 +++++---
5 files changed, 10 insertions(+), 5 deletions(-)
diff --git .travis.yml .travis.yml
index 52a66b9c..5f56cb03 100644
--- .travis.yml
+++ .travis.yml
@@ -19,7 +19,7 @@ addons:
name: "alanxz/rabbitmq-c"
description: "C AMQP client for RabbitMQ"
notification_email: alan.antonuk@gmail.com
- build_command_prepend: mkdir build && pushd build && cmake .. && popd
+ build_command_prepend: mkdir build && pushd build && cmake .. -DRUN_SYSTEM_TESTS=ON && popd
build_command: cmake --build ./build
branch_pattern: coverity_scan
diff --git CMakeLists.txt CMakeLists.txt
index f620ddc8..a39645f4 100644
--- CMakeLists.txt
+++ CMakeLists.txt
@@ -266,6 +266,7 @@ option(BUILD_TOOLS "Build Tools (requires POPT Library)" ${POPT_FOUND})
option(BUILD_TOOLS_DOCS "Build man pages for Tools (requires xmlto)" ${DO_DOCS})
option(BUILD_TESTS "Build tests (run tests with make test)" ON)
option(BUILD_API_DOCS "Build Doxygen API docs" ${DOXYGEN_FOUND})
+option(RUN_SYSTEM_TESTS "Run system tests (i.e. tests requiring an accessible RabbitMQ server instance on localhost)" OFF)
if (NOT BUILD_SHARED_LIBS AND NOT BUILD_STATIC_LIBS)
message(FATAL_ERROR "One or both of BUILD_SHARED_LIBS or BUILD_STATIC_LIBS must be set to ON to build")
diff --git README.md README.md
index b7776c65..31347b15 100644
--- README.md
+++ README.md
@@ -84,6 +84,8 @@ Other interesting flags that can be passed to CMake:
default this is ON if the OpenSSL headers and library can be found.
* `BUILD_API_DOCS=ON/OFF` - toggles building the Doxygen API documentation, by
default this is OFF
+* `RUN_SYSTEM_TESTS=ON/OFF` toggles building the system tests (i.e. tests requiring
+ an accessible RabbitMQ server instance on localhost), by default this is OFF
## Running the examples
diff --git appveyor.yml appveyor.yml
index 7e41c099..af315227 100644
--- appveyor.yml
+++ appveyor.yml
@@ -30,7 +30,7 @@ install:
- "Win%BITS%OpenSSL-%OPENSSL_VER%.exe /SP- /SILENT /SUPPRESSMSGBOXES /NORESTART"
before_build:
- - cmake -DBUILD_SHARED_LIBS=ON -DBUILD_STATIC_LIBS=ON -DBUILD_TESTS=ON -DENABLE_SSL_SUPPORT=True -G"%GENERATOR%" .
+ - cmake -DBUILD_SHARED_LIBS=ON -DBUILD_STATIC_LIBS=ON -DBUILD_TESTS=ON -DRUN_SYSTEM_TESTS=ON -DENABLE_SSL_SUPPORT=True -G"%GENERATOR%" .
build:
project: ALL_BUILD.vcxproj
diff --git tests/CMakeLists.txt tests/CMakeLists.txt
index cf042b04..320a73d7 100644
--- tests/CMakeLists.txt
+++ tests/CMakeLists.txt
@@ -33,9 +33,11 @@ add_executable(test_basic
test_basic.c)
target_link_libraries(test_basic rabbitmq-static)
-if (NOT APPLE)
- add_test(basic test_basic)
-endif()
+if (RUN_SYSTEM_TESTS)
+ if (NOT APPLE)
+ add_test(basic test_basic)
+ endif()
+endif(RUN_SYSTEM_TESTS)
add_executable(test_sasl_mechanism test_sasl_mechanism.c)
target_link_libraries(test_sasl_mechanism rabbitmq-static)