Option "includes_h_pre_orig_header" for CMock doesn't work
Hello! Here is what I have.
Test file (Test_DevicesTask_create.c):
#include <FreeRTOS.h>
#include "Mock_queue.h"
#include <unity.h>
void setUp(void)
{
;
}
void tearDown(void)
{
;
}
/**
* Prepare:
* Do:
* Expect:
*/
void test_create_failed(void)
{
TEST_PASS();
}
After running "ceedling test:all" I have the following message:
E:\Projects\Test\Kelly\kellyccfirmware>ceedling test:all
Test 'Test_DevicesTask_create.c'
--------------------------------
Generating runner for Test_DevicesTask_create.c...
Compiling Test_DevicesTask_create_runner.c...
In file included from build/test/mocks/Mock_queue.h:6,
from build/test/runners/Test_DevicesTask_create_runner.c:6:
HalParts/FreeRTos/include/queue.h:32:6: error: #error "include FreeRTOS.h" must appear in source files before "include queue.h"
32 | #error "include FreeRTOS.h" must appear in source files before "include queue.h"
If we peek "Test_DevicesTask_create_runner.c" we see the following:
/* AUTOGENERATED FILE. DO NOT EDIT. */
/*=======Automagically Detected Files To Include=====*/
#include "unity.h"
#include "cmock.h"
#include "Mock_queue.h"
Next, let's take a look into the "Mock_queue.h":
/* AUTOGENERATED FILE. DO NOT EDIT. */
#ifndef _MOCK_QUEUE_H
#define _MOCK_QUEUE_H
#include "unity.h"
#include "queue.h"
There is really no required "FreeRTOS.h" header before the "queue.h". It seems obvious to use the "includes_h_pre_orig_header" option to guarantee it always comes before the queue header:
:cmock:
:includes_h_pre_orig_header:
- FreeRTOS.h
But in fact it does nothing. Other three "precise" options ("includes_h_post_orig_header", "includes_c_pre_header" and "includes_c_post_header") are perfectly fine and add "#include "FreeRTOS.h"" to the expected position.
Nevertheless, it's possible to use the plain "includes" to overcome this issue:
:cmock:
:includes:
- FreeRTOS.h
The aforementioned "Mock_queue.h" file's content in this case is:
/* AUTOGENERATED FILE. DO NOT EDIT. */
#ifndef _MOCK_QUEUE_H
#define _MOCK_QUEUE_H
#include "unity.h"
#include "FreeRTOS.h"
#include "queue.h"
That is exactly what is expected.
So "includes_h_pre_orig_header" gets somehow ignored. Quite strange. Of course, I've checked how this option behaves when CMock is used as a standalone tool, and it worked as expected.
Hope that will be fixed or explained one day. Thanks for your time!
Thanks for the detailed investigation! This should definitely help me to hunt down the issue!
Hey guys! Did anyone resolved the problem?