Skip to content

Commit

Permalink
Add BARRIER_BUILD_TESTS CMake option to make tests optional
Browse files Browse the repository at this point in the history
  • Loading branch information
chewi committed Aug 21, 2020
1 parent d186548 commit 4a031b8
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 2 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ project (barrier C CXX)

option (BARRIER_BUILD_GUI "Build the GUI" ON)
option (BARRIER_BUILD_INSTALLER "Build the installer" ON)
option (BARRIER_BUILD_TESTS "Build the tests" ON)

set (CMAKE_EXPORT_COMPILE_COMMANDS ON)
set (CMAKE_CXX_STANDARD 14)
Expand Down Expand Up @@ -49,7 +50,6 @@ else()
endif()

set (libs)
include_directories (BEFORE SYSTEM ./ext/gtest/include)

if (UNIX)
if (NOT APPLE)
Expand Down
5 changes: 4 additions & 1 deletion src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,10 @@ include_directories (${CMAKE_CURRENT_BINARY_DIR}/lib)

add_subdirectory(lib)
add_subdirectory(cmd)
add_subdirectory(test)

if (BARRIER_BUILD_TESTS)
add_subdirectory(test)
endif()

if (BARRIER_BUILD_GUI)
add_subdirectory(gui)
Expand Down
4 changes: 4 additions & 0 deletions src/lib/barrier/KeyMap.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@
#include "common/stdset.h"
#include "common/stdvector.h"

#ifdef TEST_ENV
#include <gtest/gtest_prod.h>
#endif

namespace barrier {

Expand Down Expand Up @@ -327,6 +329,7 @@ class KeyMap {
//@}

private:
#ifdef TEST_ENV
FRIEND_TEST(KeyMapTests,
findBestKey_requiredDown_matchExactFirstItem);
FRIEND_TEST(KeyMapTests,
Expand All @@ -340,6 +343,7 @@ class KeyMap {
FRIEND_TEST(KeyMapTests,
findBestKey_onlyOneRequiredDown_matchTwoRequiredChangesItem);
FRIEND_TEST(KeyMapTests, findBestKey_noRequiredDown_cannotMatch);
#endif

private:
//! Ways to synthesize a key
Expand Down
2 changes: 2 additions & 0 deletions src/test/unittests/barrier/KeyMapTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

#define TEST_ENV

#include "barrier/KeyMap.h"

#include "test/global/gtest.h"
Expand Down

0 comments on commit 4a031b8

Please sign in to comment.