-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add cpputest/4.0 #4366
Merged
conan-center-bot
merged 51 commits into
conan-io:master
from
claremacrae:cpputest-support
Feb 8, 2021
Merged
Add cpputest/4.0 #4366
Changes from all commits
Commits
Show all changes
51 commits
Select commit
Hold shift + click to select a range
9fcbbe0
Copy in files from szip as a starting point
claremacrae 084c76d
Update versions for cpputest
claremacrae a77a96a
Copy in values for CppUTest
claremacrae ce4a8c8
Fix error:
claremacrae 64bc267
Remove references to patches
claremacrae ebb7a0b
Remove reference to CMAKE_POSITION_INDEPENDENT_CODE
claremacrae c59cec4
Copy in test code from https://github.com/cpputest/conan-cpputest/blo…
claremacrae 43bb36e
Fix building of cpputest test package
claremacrae 5669bba
Remove remnant references to szip
claremacrae cddb69e
Fix inconsistent quoting of version numbers
claremacrae d98daa6
Second attempt at fixing quoting of version numbers
claremacrae 657c9be
Fix PC-FILES (KB-H020) by deleting lib/pkgconfig directory
claremacrae 86907bb
Fix CMAKE-MODULES-CONFIG-FILES (KB-H016) by deleting lib/CppUTest/cmake
claremacrae 9558c6d
Add options
claremacrae 1af011c
Turn tests off, by default
claremacrae f4327a5
Update recipes/cpputest/all/conanfile.py
claremacrae a43fa98
Remove coverage and tests options - and force them to always be off.
claremacrae e8ee75a
Code review feedback: Fix use of find_package()
claremacrae 8f855a6
Correct homepage URL to use https
claremacrae 380caae
Remove unnecessary quotes in add_subdirectory() call
claremacrae 3750ed8
Whitespace change: Fix inconsistent indentation
claremacrae d47ab82
Make default fPIC value consistent with majority of other recipes
claremacrae 1f56212
Code review feedback: Set pkg_config name
claremacrae 505c09b
Code review feedback: Remove unnecessary setting of self.cpp_info.fil…
claremacrae b8899f8
Attempt to fix Windows linker errors
claremacrae b83b8da
Further attempt to fix Windows linker errors
claremacrae 767a0f5
Code review feedback: conditionally remove C++ settings
claremacrae 33fd6c9
Further attempt to fix Windows linker errors
claremacrae 73ad770
Fix typo in configure()
claremacrae 5a3afcc
Remove ".lib" from library names, in further attempt to fix
claremacrae 669e1e0
Remove verbose option - it doesn't affect the output library
claremacrae b4e90e8
Make tests pass if extensions are disabled
claremacrae 11b570c
Invert if condition, to reduce nesting of code
claremacrae e65a2ef
Further attempt at fixing missing symbols on Windows
claremacrae 5369177
Another attempt at fixing missing symbols on Windows
claremacrae 6b43b85
Revert back to the way of specifying winmm in b83b8da0f8daed0f898b6d4…
claremacrae 3a0a038
Fix windows linker errors
claremacrae 3750335
Delete fPIC option if shared
claremacrae 4c8c23e
Shared libraries are not supported, so remove that option
claremacrae e1de550
Completely remove shared option, as shared builds not supported
claremacrae 7966248
Code-review feedback: Remove commented-out lines
claremacrae 33014fd
Code-review feedback: Add pthread dependency on some platforms
claremacrae 98104da
Add target CppUTest::CppUTestExt
claremacrae 6a90c31
Make CppUTest::CppUTestExt depend on CppUTest::CppUTest
claremacrae 5b91652
Port remaining package_info() code to components
claremacrae 67cbd74
Rename option extensions to with_extensions
claremacrae 95d10ac
Rename option longlong to with_longlong
claremacrae a53aff0
Rename option detect_mem_leaks to detect_memory_leaks
claremacrae ba70c31
Remove all options except fPIC and with_extensions
claremacrae a20a050
Remove empty method configure()
claremacrae 9108346
Code review suggestion: "with_extensions" now uses [True, False]
claremacrae File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
cmake_minimum_required(VERSION 2.8.11) | ||
project(cmake_wrapper) | ||
|
||
include(conanbuildinfo.cmake) | ||
conan_basic_setup() | ||
|
||
add_subdirectory(source_subfolder) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
sources: | ||
"4.0": | ||
url: "https://github.com/cpputest/cpputest/releases/download/v4.0/cpputest-4.0.tar.gz" | ||
sha256: 21c692105db15299b5529af81a11a7ad80397f92c122bd7bf1e4a4b0e85654f7 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
import os | ||
|
||
from conans import ConanFile, CMake, tools | ||
|
||
class CppUTestConan(ConanFile): | ||
name = "cpputest" | ||
description = \ | ||
"CppUTest is a C /C++ based unit xUnit test framework for unit testing and for test-driving your code." \ | ||
"It is written in C++ but is used in C and C++ projects and frequently" \ | ||
"used in embedded systems but it works for any C/C++ project." | ||
license = "BSD-3-Clause" | ||
topics = ("conan", "testing", "unit-testing") | ||
homepage = "https://cpputest.github.io" | ||
url = "https://github.com/conan-io/conan-center-index" | ||
exports_sources = ["CMakeLists.txt"] | ||
generators = "cmake" | ||
settings = "os", "arch", "compiler", "build_type" | ||
options = { | ||
"fPIC": [True, False], | ||
"with_extensions": [True, False], | ||
} | ||
default_options = { | ||
"fPIC": True, | ||
"with_extensions": True, | ||
} | ||
|
||
_cmake = None | ||
|
||
@property | ||
def _source_subfolder(self): | ||
return "source_subfolder" | ||
|
||
@property | ||
def _build_subfolder(self): | ||
return "build_subfolder" | ||
|
||
def config_options(self): | ||
if self.settings.os == "Windows": | ||
del self.options.fPIC | ||
|
||
def source(self): | ||
tools.get(**self.conan_data["sources"][self.version]) | ||
os.rename(self.name + "-" + self.version, self._source_subfolder) | ||
|
||
def build(self): | ||
cmake = self._configure_cmake() | ||
cmake.build() | ||
|
||
def _configure_cmake(self): | ||
if self._cmake: | ||
return self._cmake | ||
self._cmake = CMake(self) | ||
self._cmake.definitions["STD_C"] = "ON" | ||
self._cmake.definitions["STD_CPP"] = "ON" | ||
self._cmake.definitions["C++11"] = "ON" | ||
self._cmake.definitions["MEMORY_LEAK_DETECTION"] = "ON" | ||
self._cmake.definitions["EXTENSIONS"] = self.options.with_extensions | ||
self._cmake.definitions["LONGLONG"] = "ON" | ||
self._cmake.definitions["COVERAGE"] = "OFF" | ||
self._cmake.definitions["TESTS"] = "OFF" | ||
self._cmake.configure(build_folder=self._build_subfolder) | ||
return self._cmake | ||
|
||
def package(self): | ||
self.copy("COPYING", dst="licenses", src=self._source_subfolder) | ||
cmake = self._configure_cmake() | ||
cmake.install() | ||
tools.rmdir(os.path.join(self.package_folder, "lib", "pkgconfig")) | ||
tools.rmdir(os.path.join(self.package_folder, "lib", "CppUTest", "cmake")) | ||
|
||
def package_info(self): | ||
self.cpp_info.names["cmake_find_package"] = "CppUTest" | ||
self.cpp_info.names["cmake_find_package_multi"] = "CppUTest" | ||
self.cpp_info.names["pkg_config"] = "cpputest" | ||
|
||
self.cpp_info.components["CppUTest"].names["cmake_find_package"] = "CppUTest" | ||
self.cpp_info.components["CppUTest"].names["cmake_find_package_multi"] = "CppUTest" | ||
self.cpp_info.components["CppUTest"].libs = ["CppUTest"] | ||
|
||
if self.options.with_extensions: | ||
self.cpp_info.components["CppUTestExt"].names["cmake_find_package"] = "CppUTestExt" | ||
self.cpp_info.components["CppUTestExt"].names["cmake_find_package_multi"] = "CppUTestExt" | ||
self.cpp_info.components["CppUTestExt"].libs = ["CppUTestExt"] | ||
self.cpp_info.components["CppUTestExt"].requires = ["CppUTest"] | ||
|
||
if self.settings.os == "Windows": | ||
self.cpp_info.components["CppUTest"].system_libs.extend(["winmm"]) | ||
elif self.settings.os in ("Linux", "FreeBSD"): | ||
self.cpp_info.components["CppUTest"].system_libs = ["pthread"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
cmake_minimum_required(VERSION 3.1) | ||
project(test_package CXX) | ||
|
||
include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) | ||
conan_basic_setup() | ||
|
||
find_package(CppUTest REQUIRED CONFIG) | ||
|
||
add_executable(test_package test_package.cpp) | ||
target_link_libraries(test_package CppUTest::CppUTest) | ||
|
||
if(WITH_EXTENSIONS) | ||
add_executable(test_package_with_extensions test_package_with_extensions.cpp) | ||
# Note: CppUTest::CppUTestExt adds dependency on CppUTest::CppUTest | ||
target_link_libraries(test_package_with_extensions CppUTest::CppUTestExt) | ||
endif() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import os | ||
|
||
from conans import ConanFile, CMake, tools | ||
|
||
class TestPackageConan(ConanFile): | ||
settings = "os", "compiler", "build_type", "arch" | ||
generators = "cmake", "cmake_find_package_multi" | ||
|
||
def build(self): | ||
cmake = CMake(self) | ||
cmake.definitions["WITH_EXTENSIONS"] = self.options["cpputest"].with_extensions | ||
cmake.configure() | ||
cmake.build() | ||
|
||
def test(self): | ||
if tools.cross_building(self.settings): | ||
return | ||
|
||
self.run(os.path.join("bin", "test_package"), run_environment=True) | ||
|
||
if self.options["cpputest"].with_extensions: | ||
self.run(os.path.join("bin", "test_package_with_extensions"), run_environment=True) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#include <CppUTest/TestHarness.h> | ||
#include <CppUTest/TestRegistry.h> | ||
#include <CppUTest/CommandLineTestRunner.h> | ||
|
||
TEST_GROUP(FirstTestGroup) | ||
{ | ||
}; | ||
|
||
TEST(FirstTestGroup, FirstTest) | ||
{ | ||
CHECK_TRUE(true); | ||
} | ||
|
||
int main(int argc, const char** argv) | ||
{ | ||
CommandLineTestRunner runner(argc, argv, TestRegistry::getCurrentRegistry()); | ||
return runner.runAllTestsMain(); | ||
} |
19 changes: 19 additions & 0 deletions
19
recipes/cpputest/all/test_package/test_package_with_extensions.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
#include <CppUTest/TestHarness.h> | ||
#include <CppUTest/TestRegistry.h> | ||
#include <CppUTest/CommandLineTestRunner.h> | ||
#include <CppUTestExt/GTestSupport.h> // Only found if extensions enabled | ||
|
||
TEST_GROUP(FirstTestGroup) | ||
{ | ||
}; | ||
|
||
TEST(FirstTestGroup, FirstTest) | ||
{ | ||
CHECK_TRUE(true); | ||
} | ||
|
||
int main(int argc, const char** argv) | ||
{ | ||
CommandLineTestRunner runner(argc, argv, TestRegistry::getCurrentRegistry()); | ||
return runner.runAllTestsMain(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
versions: | ||
"4.0": | ||
folder: all |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You need to explicitly set the pkg_config names
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not exactly sure that I understand that, but I have improved code in this area in e8ee75a.
If that's not what you mean, please can I have a bit more info?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You do not need file name ... the default is names
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Via mobile⚠️