platformio / platformio-core

Your Gateway to Embedded Software Development Excellence :alien:
https://platformio.org
Apache License 2.0
7.87k stars 791 forks source link

Add UNITY_INCLUDE_CONFIG_H and path to it in c_cpp_properties.json #4710

Open dzid26 opened 1 year ago

dzid26 commented 1 year ago

What kind of issue is this?

PlatformIO Version (platformio --version): PlatformIO Core, version 6.1.9

Description of the problem

c_cpp_properties.json already has test related Unity path .pio/libdeps/Release/Unity/src",. I think it should also have the UNITY_INCLUDE_CONFIG_H and the include path definition.

I use unity_config.h to define some common top-level features:

#define UNITY_INCLUDE_PRINT_FORMATTED
#include "stm32f10x.h"
#endif

Because this is not linked by IntelliSense some functions in unit test are not resolved:

image

Or.

image

Of course, I can include everything in each test, but unity_config.h seems like a better central place.

dzid26 commented 1 year ago

Hmm, I noticed UNITY_INCLUDE_CONFIG_H appears in c_cpp_properties.json when unit testing env is selected. I guess I would prefer for it to be added if a single test is detected in the workspace.

Conversely .pio/libdeps/XXX_env/Unity/src" is added to c_cpp_properties.json for any env, as long as that directory was created and matches env name.
So this include may be defined or not, depending on whether the testing was done for a given env in the past.

For me my default env is a release one and it ignores all the tests. Without a path definition to unity.h, no function gets resolved by Intelisense in unit tests.

I don't know, but to me, it would be better if was coming from .platformio\packages\tool-unity and the unit testing definition could be added to c_cpp_properties.json if there is at least one test detected.

ivankravets commented 1 year ago

Have you tried to test a project? It will pull all dependencies. Restart VSCode.

dzid26 commented 1 year ago

Yes, I go through all my envs using VScode sidebar unittester. It pulls unity sources into here:

image

That's works, although, for the release env I have test_ignore = *, so I need to temporarily fake that I am doing the test in order to pull Unity and for the path to libdeps/xxx_release/Unity/src to appear in c_cpp_properties.json to appear.

But that's only this one path define. Others, i.e. UNITY_INCLUDE_CONFIG_H and path to unity_config.h don't appear automatically for the release. I don't like to switch away from the release though, because then Upload button becomes useless.

I can't get UNITY_INCLUDE_CONFIG_H to appear c_cpp_properties.json anymore even by switching env to unit test one. Maybe it was never there.

ivankravets commented 8 months ago

Could you provide a simple project (as a ZIP archive attached to this issue) to reproduce this issue?