I read the docs in Unit Testing — PlatformIO latest documentation
Here is my platformio.ini
[env:rpipico2]
platform = https://github.com/maxgerhardt/platform-raspberrypi.git
framework = arduino
board_build.core = earlephilhower
board_build.mcu = rp2350
board = rpipico2
lib_archive = no
build_flags = -DUSE_TINYUSB
build_src_filter =
+<*>
-<main_native.cpp>
lib_deps =
adafruit/Adafruit TinyUSB Library@^3.4.3
fortyseveneffects/MIDI Library@^5.0.2
https://github.com/Makuna/NeoPixelBus.git
olikraus/U8g2@^2.36.5
stechio/Analog-Digital Multiplexers@3.0.0
test_filter =
; For running tests on native host machine
[env:desktop]
platform = native
build_src_filter =
+<main_native.cpp>
build_type = debug
test_filter =
native/**
And here is my project tree
> tree lib src test
lib
├── EndlessPotentiometer
│ ├── EndlessPotentiometer.cpp
│ └── EndlessPotentiometer.h
├── mavg
│ ├── mavg.cpp
│ └── mavg.h
└── README
src
├── debug.cpp
├── debug.h
├── knobs.cpp
├── knobs.h
├── main.cpp
├── main_native.cpp
├── midi_io.cpp
├── midi_io.h
├── ui.cpp
└── ui.h
test
├── native
│ └── EndlessPotentiometer
│ └── main.cpp
└── README
WIth the ugly hack of adding main_native.cpp
I could get the build to work, but I am still struggling to exclude the rpipico2
from testing - pio test -e desktop
works. But I just want to click the test button in platform io and don’t have to select the env. Selecting the env won’t scale as ideally one I’ll have tests for the pico 2 as well.
For now I added test_ignore = native/**
to the [env:rpipico2]
, but that is also not pretty (list things multiple times).
I see a lot of similar questions, where people recommend to configure e.g.
[platformio]
default_envs = d1_mini
but I don’t see how that solves anything. The question is not how to configure a default env in general, but how to tell the command (build, test, check) what to do for each env (and if a particular env shoudl be skipped).