Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
maltekliemann committed May 15, 2020
2 parents 609c2fe + 6d56c7a commit 900e642
Show file tree
Hide file tree
Showing 87 changed files with 1,362 additions and 554 deletions.
82 changes: 82 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
<!--
Copyright 2020 Ole Kliemann, Malte Kliemann
This file is part of DrMock.
DrMock is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
DrMock is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with DrMock. If not, see <https://www.gnu.org/licenses/>.
-->

# DrMock 0.2.0

Released 2020/05/15

### Added/Changed:

* Autodetect number of threads for compiling in Makefile

* Add convenience Makefile for building all sample projects

* Add tutorial for manually building **DrMock**

* Add pkg-config file

* Add DRMOCK, DRMOCK_DUMMY macros

- Change order of includes in mock objects
(so that `DRMOCK` is defined when including the interface header in
mock object header)

* Allow applying `DRTEST_VERIFY_MOCK` to mock object (not just method objects)

- Add `makeFormattedErrorString` virtual method to `IMethod` interface

- Add `makeFormattedErrorString` method to `MethodCollection`
(concatenates formatted error strings of collected method objects)

- Add `makeFormattedErrorString` method to mock objects (returns
formatted error string of method collection)

* Use `RESOURCES` parameter in `DrMockTest` to add resource files to
test executables

* Add remark about QII pattern to docs

### Removed

* Disable verbose print from DrMockGenerator

### Fixed

* Add missing remark that `DRMOCK_QT_PATH` must be set when using
`DrMockModule` with Qt5 modules to documentation.

* Apply do-while-false pattern to `DRTEST_VERIFY_MOCK`

* Fix formatting errors and typos in source/docs

* Fix transition table in rocket example

* Replace `python3.7` and `pip3.7` with `python` and `pip` and shifting
the responsibility of managing the python versions to the user.

* Replace odd error message thrown when using `DrMockModule` with
`QTMODULE` parameter but unset `DRMOCK_QT_PATH` environment variable.

* Throw error message if `DrMockTest` can't find files specified in `TESTS`.

# DrMock 0.1.0

Released 2020/01/10

Official open-source release
66 changes: 38 additions & 28 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ cmake_minimum_required (VERSION 3.13)

project(
DrMock
VERSION 0.1.0
VERSION 0.2.0
DESCRIPTION "C++17 testing and mocking framework"
LANGUAGES CXX
)
Expand All @@ -38,7 +38,7 @@ find_library(
LIBCLANG_PATH
NAMES clang clang-6.0 clang-7.0 clang-8.0
PATH_SUFFIXES lib
HINTS
HINTS
/Library/Developer/CommandLineTools/usr
/usr/lib/llvm-7/lib
)
Expand All @@ -48,24 +48,24 @@ endif()

# Write the libclang path to the mocker.cfg.
configure_file(
${CMAKE_SOURCE_DIR}/python/mocker/mocker.cfg.in
${CMAKE_SOURCE_DIR}/python/mocker/mocker.cfg.in
${CMAKE_SOURCE_DIR}/python/mocker/mocker.cfg
)

# If enabled, find Qt.
if (DEFINED ENV{DRMOCK_QT_PATH})
find_package(
Qt5
COMPONENTS
Core
Qt5
COMPONENTS
Core
)
if (${Qt5_FOUND})
# Set CMP0071 to NEW so that generated files are automoc'ed.
cmake_policy(SET CMP0071 NEW)
set(CMAKE_AUTOMOC ON)
else()
message(
FATAL_ERROR
FATAL_ERROR
"DRMOCK_QT_PATH environment variable is set, but Qt5 was not found."
)
endif()
Expand All @@ -90,8 +90,8 @@ set(DrMockMacros
foreach (pathToFile ${${PROJECT_NAME}Macros})
get_filename_component(name ${pathToFile} NAME)
configure_file(
${pathToFile}
${CMAKE_CURRENT_BINARY_DIR}/${name}
${pathToFile}
${CMAKE_CURRENT_BINARY_DIR}/${name}
COPYONLY
)
endforeach()
Expand All @@ -100,11 +100,6 @@ endforeach()
# Configure install.
#######################################

# If install directory is default, install to `prefix` instead.
if (CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
set(CMAKE_INSTALL_PREFIX ${CMAKE_SOURCE_DIR}/prefix CACHE PATH "..." FORCE)
endif()

set(CMAKE_INSTALL_INCLUDEDIR "include/${PROJECT_NAME}")
set(CMAKE_INSTALL_LIBDIR "lib")
set(INSTALL_CONFIGDIR ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME})
Expand All @@ -119,24 +114,39 @@ install(
# Uncomment to alias the libraries on export.
set_target_properties(${PROJECT_NAME} PROPERTIES EXPORT_NAME Core)

install(
DIRECTORY pkgconfig/
DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig
FILES_MATCHING
PATTERN "*.pc"
)
install(
DIRECTORY include/
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
)
install(
DIRECTORY src/
DIRECTORY src/
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
FILES_MATCHING
PATTERN "*.h"
FILES_MATCHING
PATTERN "*.h"
PATTERN "*.tpp"
)

#######################################
# pkgconfig
#######################################

configure_file(
${CMAKE_SOURCE_DIR}/pkgconfig/DrMock.pc.in
${CMAKE_SOURCE_DIR}/pkgconfig/DrMock.pc
)

#######################################
# Configure export.
#######################################

install(
EXPORT
EXPORT
${PROJECT_NAME}Targets
FILE
${PROJECT_NAME}Targets.cmake
Expand All @@ -150,16 +160,16 @@ include(CMakePackageConfigHelpers)

write_basic_package_version_file(
${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake
VERSION
VERSION
${PROJECT_VERSION}
COMPATIBILITY
COMPATIBILITY
SameMajorVersion
)

configure_package_config_file(
${CMAKE_CURRENT_LIST_DIR}/cmake/${PROJECT_NAME}Config.cmake.in
${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Config.cmake
INSTALL_DESTINATION
INSTALL_DESTINATION
${INSTALL_CONFIGDIR}
)

Expand All @@ -168,7 +178,7 @@ install(
FILES
${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Config.cmake
${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake
DESTINATION
DESTINATION
${INSTALL_CONFIGDIR}
)

Expand All @@ -178,17 +188,17 @@ foreach (pathToFile ${${PROJECT_NAME}Macros})
install(
FILES
${CMAKE_CURRENT_BINARY_DIR}/${name}
DESTINATION
DESTINATION
${INSTALL_CONFIGDIR}
)
endforeach()

export(
EXPORT
${PROJECT_NAME}Targets
FILE
${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Targets.cmake
NAMESPACE
EXPORT
${PROJECT_NAME}Targets
FILE
${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Targets.cmake
NAMESPACE
${PROJECT_NAME}::
)

Expand Down
19 changes: 16 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,10 +1,23 @@
# Discover operating system.
uname := $(shell uname -s)

# Get number of threads
ifeq ($(uname), Darwin)
num_threads := $(shell sysctl -n hw.activecpu)
else # Assuming Linux.
num_threads := $(shell nproc)
endif

.PHONY: default
default:
mkdir -p build && cd build && cmake .. -DCMAKE_PREFIX_PATH=${DRMOCK_QT_PATH}
cd python && make && python3.7 setup.py bdist_wheel && cd ..
mkdir -p build && cd build && make -j10 && ctest --output-on-failure
mkdir -p build && cd build && cmake -DCMAKE_INSTALL_PREFIX="../prefix" .. -DCMAKE_PREFIX_PATH=${DRMOCK_QT_PATH}
cd python && make && cd ..
cd build && make -j$(num_threads) && ctest --output-on-failure

.PHONY: clean
clean:
rm -fr build && rm -fr prefix

.PHONY: install
install:
cd build && make install && cd ..
Loading

0 comments on commit 900e642

Please sign in to comment.