Okay so you just want to unit-test test in the native environment but not build the src/ directory for it, right?
I’d say you can stick a default_envs directive at the top so that the build for native doesn’t get triggered when you do a normal build.
[platformio]
default_envs = nodemcuv2
But with that it will also only use “Test” on the NodeMCUv2 environment.
Or, stick a semantically empty file in src/ that is only used for the native environment and ignored by all other environments using the src_filter. E.g.,
empty_native.c:
int main() { return 0; }
And then src_filter = +<*> -<empty_native.c> in all environments but the native ones.
Fun fact, if you just pio run / Build the example Unit testing project, the calculator, it also fails to build ofc.
#include <Arduino.h>
^~~~~~~~~~~
compilation terminated.
*** [.pio\build\native\src\main.o] Error 1
============================================== [FAILED] Took 4.59 seconds ==============================================
Environment Status Duration
------------- -------- ------------
uno SUCCESS 00:00:07.975
nodemcu SUCCESS 00:00:08.330
native FAILED 00:00:04.590
======================================== 1 failed, 2 succeeded in 00:00:20.895 ========================================
The idea here is that just pio test is invoked to test in ann environments and Build/Upload only on the respective environment(s), with either the VSCode → Project tasks selection by environment or pio run -e env1,env2.