Skip to content

Commit

Permalink
(conan-io#5114) Add fake function framework (fff)
Browse files Browse the repository at this point in the history
  • Loading branch information
kebadopp authored and AlvaroFS committed May 7, 2021
1 parent 51749ab commit 7d60b04
Show file tree
Hide file tree
Showing 6 changed files with 74 additions and 0 deletions.
4 changes: 4 additions & 0 deletions recipes/fff/all/conandata.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
sources:
"1.1":
url: https://github.com/meekrosoft/fff/archive/refs/tags/v1.1.zip
sha256: 5a8329878f59bd1ea19b734573d63c228f742384b8c78d00e4d005909b90ee83
26 changes: 26 additions & 0 deletions recipes/fff/all/conanfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
from conans import ConanFile, tools
import os

class TypeSafe(ConanFile):
name = 'fff'
description = 'A testing micro framework for creating function test doubles'
url = 'https://github.com/conan-io/conan-center-index'
homepage = 'https://github.com/meekrosoft/fff'
license = 'MIT'
topics = 'conan', 'c', 'c++', 'embedded', 'tdd', 'micro-framework', 'fake-functions'

no_copy_source = True

@property
def _source_subfolder(self):
return "source_subfolder"

def source(self):
tools.get(**self.conan_data["sources"][self.version], strip_root=True, destination=self._source_subfolder)

def package(self):
self.copy("LICENSE*", dst="licenses", src=self._source_subfolder)
self.copy("fff.h", dst="include", src=self._source_subfolder)

def package_id(self):
self.info.header_only()
8 changes: 8 additions & 0 deletions recipes/fff/all/test_package/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
cmake_minimum_required(VERSION 3.1)
project(test_package)

include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
conan_basic_setup()

add_executable(${PROJECT_NAME} test_package.cpp)
target_link_libraries(${PROJECT_NAME} ${CONAN_LIBS})
17 changes: 17 additions & 0 deletions recipes/fff/all/test_package/conanfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
from conans import ConanFile, CMake, tools
import os


class TestPackageConan(ConanFile):
settings = "os", "compiler", "build_type", "arch"
generators = "cmake"

def build(self):
cmake = CMake(self)
cmake.configure()
cmake.build()

def test(self):
if not tools.cross_building(self.settings):
bin_path = os.path.join("bin", "test_package")
self.run(bin_path, run_environment=True)
16 changes: 16 additions & 0 deletions recipes/fff/all/test_package/test_package.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#include <stdint.h>
#include "fff.h"

DEFINE_FFF_GLOBALS;

FAKE_VOID_FUNC(TestFunction, uint32_t, uint8_t);

int main()
{
RESET_FAKE(TestFunction);
FFF_RESET_HISTORY();

TestFunction(8, 16);

return 0;
}
3 changes: 3 additions & 0 deletions recipes/fff/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
versions:
'1.1':
folder: all

0 comments on commit 7d60b04

Please sign in to comment.