-
Notifications
You must be signed in to change notification settings - Fork 28
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
Allow mocking a function that isn't linked into the exe #11
Comments
Sorry for late reply. I would opt for alternative approach. A lazy loading of a real function. As long as a given function is not mocked no error will be thrown even if it's not available. |
This is actually what we do in my company. |
A situation in which you call a function which you neither linked with or mocked I see as a bug. I would make a lazy loading the default behaviour. |
Thanks. I'll prepare the code and submit a pull request.
…On Mon, May 7, 2018, 2:33 PM Hubert Jagodziński ***@***.***> wrote:
A situation in which you call a function which you neither linked with or
mocked I see as a bug. I would make a lazy loading the default behaviour.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#11 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AQ8EVh18S7twlA9iOhS1_wph7_YZVO_Jks5twDD-gaJpZM4TX74->
.
|
👍 |
Submitted pull request. CI passed.
BTW, C-Mock now fails to compile with latest Google Mock.
The problem is with the old macros, which rely more heavily on Google Mock
internals than the old ones.
…On Mon, May 7, 2018 at 2:52 PM, Hubert Jagodziński ***@***.*** > wrote:
👍
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#11 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AQ8EViwFAQahJumerDgQKpBOG1Yj3SHyks5twDVngaJpZM4TX74->
.
|
Can you create an issue on that so we can address it as a distinct problem? |
I'm not sure what you see as a distinct problem.
…On Mon, May 14, 2018, 11:38 AM Hubert Jagodziński ***@***.***> wrote:
Can you create an issue on that so we can address it as a distinct problem?
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#11 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AQ8EVh_8YNyWgAR1hUojit_clLTKPlqYks5tyUKQgaJpZM4TX74->
.
|
I have in mind C-Mock now fails to compile with latest Google Mock. |
Ah, sure
…On Mon, May 14, 2018, 12:09 PM Hubert Jagodziński ***@***.***> wrote:
I have in mind *C-Mock now fails to compile with latest Google Mock.*
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#11 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AQ8EVn1Magr6j3fTC2A4rIYDVGbBOlfXks5tyUnkgaJpZM4TX74->
.
|
When linking a test executable, we sometimes don't want to link it with all the libraries that are used in production. Mocking is very useful for this - if you mock all functions in a library, you don't need to link with the library itself. But C-mock searches for the real function with
dlsym
, and fails if it doesn't exist. So you have to link with it.In my company linkage is a mess, so we have a local change that checks if the function exists only if we actually try to call it. This is very useful for us.
You can see the code in a branch in my clone.
But this changes behavior unconditionally, so I don't think it's appropriate for merge.
The only difficulty is how can we make it conditional. There are may alternatives, such as:
make ALLOW_MISSING=1
).CMOCK_MOCK_FUNCTIONn_ALLOW_MISSING
).CMockMocker
(e.g.CMockMockerAllowMissing
).#define CMOCK_ALLOW_MISSING 1
).Can we add this functionality?
Thanks.
The text was updated successfully, but these errors were encountered: