Skip to content

pio test compiles with and without UNIT_TEST defined #5509

Description

@Shoxx98

I am having an issue where I build a file in a test environment and am testing for the presence of the macro UNIT_TEST in a library and have a different size of global variables depending on if the macro is defined or not.
If I check for the define using a codesnippet like this, I get both manually-placed warnings during compilation using pio test, ARENA_SIZE is 200 in the end and the linker tells me that SRAM overflows because of it:

#ifdef UNIT_TEST
#warning "unit test active"
#define ARENA_SIZE 100
#else
#warning "unit test not active"
#define ARENA_SIZE 200
#endif /* ifdef UNIT_TEST */
uint8_t arena[ARENA_SIZE];

I am using a fork of platformio-core that has an additional target __test to generate a compiledb for the test-dir (#5480). I don't know whether this is an issue of platformio-core as-is, or if it is an issue with the branch, so I am creating the issue here and am mentioning the PR.

I expect the ARENA_SIZE to be 100 while compiling and linking.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions