# This file is used compile and run tests located in the `unit` directory.
# For more info, see:
# https://docs.platformio.org/en/latest/plus/unit-testing.html
# https://github.com/ThrowTheSwitch/Unity
# https://github.com/ThrowTheSwitch/Unity/blob/master/docs/UnityAssertionsReference.md

[platformio]
test_dir = unit
src_dir = ../espurna

# TODO: add `-t coverage` via python scripting?
# TODO: do we need `-O0`?

# To prepare coverage data for lcov, add ${coverage.build_flags} to env:test build flags
# To actually generate coverage report:
# $ `pio test` / run the test `program` manually
# $ lcov --include (readlink -f ../espurna)'/*' --capture --directory .pio/build/test/ --output-file test.info
# $ genhtml --ignore-errors source test.info --output-directory out

[coverage]
build_flags = -lgcov -fprofile-arcs -ftest-coverage

[env:test]
platform = native
lib_compat_mode = off
test_build_project_src = true
src_filter =
    +<../espurna/terminal_commands.cpp>
    +<../espurna/terminal_parsing.cpp>
lib_deps =
    StreamString
    https://github.com/bxparks/UnixHostDuino#d740398e
build_flags =
    -DMANUFACTURER="PLATFORMIO"
    -DDEVICE="TEST"
    -std=gnu++11
    -g
    -Os
    -include lib/test_arduino_compat.h
    -I../espurna/
