-
Notifications
You must be signed in to change notification settings - Fork 34
Distinguish between unit test compilation and "normal" compilation #159
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
Comments
My main concern is how likely it might be that someone else has defined |
Follow the same precedent Arduino uses by prefixing global macro names with the organization name. This creates a "namespace" of sorts for your macros to avoid collisions: |
I guess that keeps me safe if the project gets forked or adopted elsewhere 😅 Is using my github name appropriate enough for an Arduino project? I feel like it would be a bad mnemonic to have the constant be "the author's github name, underscore arduino, underscore CI". I'm wondering if I should be exploring names more indicative of the idea that "this is not real hardware, this is a unit test". |
That also sounds like a good idea to me, though it would (maybe) not allow code to distinguish whether they're running under arduino_ci, or maybe some alternative non-hardware Arduino core that uses the same non-hardware define. Also, I've been thinking about this same thing for a while (partially for such a define, and partially for finding a name for such a virtual arduino core), and I'm not sure what terminology would be appropriate here. Things I considered are "Running on host" (but that's vague), "Running on x86" (but it might also be amd64 or arm/rpi), "Running on PC" (but how about Macs?). Writing this, maybe "Virtual" is a useful concept here, since all of these are somewhat emulating a virtual Arduino (in the sense that e.g. |
My best idea so far is |
Mocks supplied in arduinomock.cpp are available if ARDUINO_CI is defined (only when running arduino_ci) ARDUINO_CI defined in lib/.arduino-ci.yaml as explained at Arduino-CI/arduino_ci#159 Using this approach until there is a final solution.
I'm still using
Can we just go with our organization name, |
This issue is old enough that it predates the move from my After re-reading this thread, I think I see what was bothering me about this earlier: So, in order of preference, here's how I'd like to name the constant such that it signals to the environment that (1) the "Arduino CI" system is running things, and (2) compilation mocks are in effect. In order of preference:
Any objections to these, and/or is there a better way to convey "Arduino" + "Arduino-CI" + "stuff is mocked" + "this is only for unit test compilation" to the user? |
For me, |
locally added |
Feature Request
via https://github.com/ianfixes/arduino_ci/issues/150#issuecomment-689887131
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 thedefines
section of a platform: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?The text was updated successfully, but these errors were encountered: