Skip to content

Distinguish between unit test compilation and "normal" compilation #159

Closed
@ianfixes

Description

@ianfixes

Feature Request

via https://github.com/ianfixes/arduino_ci/issues/150#issuecomment-689887131

I find that I'd like a way to distinguish between when code is compiled from the Arduino IDE and when code is compiled from arduino_ci. Ideal would be something like #define ARDUINO_CI but the closest I've come is MOCK_PINS_COUNT

Initial thoughts

There is some ability to do this already, as a per-project workaround, by copying platform definitions from default.yml and adding to the defines section of a platform:

# copied from default.yml in september 2020
platforms:
  uno:
    board: arduino:avr:uno
    package: arduino:avr
    gcc:
      features:
      defines:
        - __AVR_ATmega328P__

        # This is the workaround described above
        - ARDUINO_CI
      warnings:
      flags:

Since the platform definitions' gcc section applies only to unit testing (i.e. it's not AVR compilation), this is safe. But possibly not ideal.

Discussion points

What are best practices for injecting "evidence" of test platforms into compilation? For example, should we copy the pattern used by the ARDUINO constant, and if so, what would the numbers represent?

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requesthelp wantedExtra attention is neededquestionFurther information is requestedunittest libsThe assert / assure / unittest reporting apparatus is affected

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions