ThrowTheSwitch / Ceedling

Ruby-based unit testing and build system for C projects
http://throwtheswitch.org
Other
587 stars 247 forks source link

Same header file name, need to mock both file, how to? #227

Open biboc opened 6 years ago

biboc commented 6 years ago

Here is the my tree view:

/src/A/fileA.h
/src/fileA.h 
/src/fileB.c
/src/fileB.h  
/test/test_fileB.c

In fileB.c, I have:

#include "A/fileA.h"
#include "fileA.h"

I want to mock both fileA.h How can I do that with ceedling?

Ceddling allows me to add

#include "mock_fileA.h" 

So it chooses ONLY the first fileA in the :source: path

fetiu commented 4 years ago

I'm also interested in this issue. if the file name is not unique, CMock just generates the first one found in the path.

So I think there should be a feature that designates subdirectories for the mocks.

@mvandervoord Has there been any more discussion about this? Is there some workaround I'm missing?

biboc commented 4 years ago

@mvandervoord worked on it on last release but failed to add the feature due to too many under-the-hood changes and a solution that can break retro-compatibility. I hope they'll find a solution soon

ycyang1229 commented 3 years ago

I am also interested in this feature. Any progress? thanks.

davewhitters commented 2 years ago

This would be very helpful

biboc commented 10 months ago

@mvandervoord any update on this?

parmi93 commented 8 months ago

any update on this?

mvandervoord commented 8 months ago

The soon-to-be-released Ceedling has a lot of internal changes that are working towards fixing problems like these. It solves part of the problem, in that it will match the best header file for a given situation now, but we still aren't to a point where we support matching multiple headers of the same name within the same test. That still IS on our goal list, but requires a few more changes.

The upside is the redesigned internals should be much more flexible for all sorts of "fun" situations like these when it's finished.