FabioBatSilva / ArduinoFake

Arduino mocking made easy
https://platformio.org/lib/show/1689/ArduinoFake
MIT License
102 stars 47 forks source link

Use of FakeIt as a dependency with supporting fixes #45

Closed RobertByrnes closed 1 year ago

RobertByrnes commented 1 year ago

@FabioBatSilva ok here goes again. This PR has edited the CMakeList.txt files to pull in FakeIt as a dependency - using latest currently 4.2.0.

In addition to this there are three supporting fixes:

A change from map to unordered_map in ArduinoFake which achieves the same result and avoids an ambiguous reference conflicting with the Arduino map function.

A change to the method setup and verification to use const char instead of const char[]. This matches the actual method signature in the Arduino Print library for printing C-style strings (which are essentially const char). Print class.

Use of a single pointer in test setup and assertions in the client class.

This would close #44

nerdyscout commented 1 year ago

I am currently trying to include this into some project but it fails. Seems like /ArduinoFake/src/ArduinoFake.h includes fakeit.hpp but this is actually deleted by the PR. dont know yet what I do wrong, havn't figured out how the dependency should be pulled.

this is what I am working on https://github.com/nerdyscout/Arduino_MCP3x6x_Library/tree/fakeit

did you verify the platformio build path as well or just cmake? I am using platformio where is no

download_repo(
    URL "https://github.com/eranpeer/FakeIt.git"
    TAG ${PROJECT_VERSION}
    CLONE_DIR ${REPO_DIR}
)
RobertByrnes commented 1 year ago

Arh I missed that! Make brings it in for building with 'make' and running the tests with 'make test'.

I hadn't added the fake it repo to the platformio.ini!

I will be able to look at that tomorrow in the meantime maybe try it ... lib_deps=https://github .... fakeit url ...

nerdyscout commented 1 year ago

thank you for the quick reply. yes it solved the dependencies, but (atleast my) built system is still not able to find the fakeit.hpp. will check out some when later.

RobertByrnes commented 1 year ago

No worries. I'll take another look tomorrow. I am curious to see what happens when the workflow runs now....

RobertByrnes commented 1 year ago

@nerdyscout Have another go at this - the trick here was that FakeIt produces several fakeit.hpp files in subdirectories so dependency resolution was doomed. That is now sorted.

@FabioBatSilva this should now be there - as in, FakeIt being pulled in as a dependency handled within the make pipeline. This is currently set to 4.2.0 in the external/fakeit/CMakeLists.txt file and can be edited from there. There were 3 fixes for change to ArduinoFake to make it work but none of them are/were breaking

RobertByrnes commented 1 year ago

I don't feel it's complete until the FakeiIt version is no longer hard baked into the make file but this is a step 😀