platformio / platformio-examples

PlatformIO Project Examples
Apache License 2.0
590 stars 175 forks source link

unity.h libraty for unit testing is not compiling #28

Closed LoisRForgeFlow closed 5 years ago

LoisRForgeFlow commented 5 years ago

Hi, I was trying to add unit test for an arduino project and I found in your documentation that you recommend to use a library called unity.h, which seems quite what was searching for. However, I was giving problems to me in the compilation so I tried the documentation example (blink) which did not work either and then I ended here. Just tested you calculator unit test example and my output was again a compilation error:

platformio ci --lib="." --board=uno ./test/
The next files/directories have been created in /tmp/tmpUPV1Fa
include - Put project header files here
lib - Put here project specific (private) libraries
src - Put project source files here
platformio.ini - Project Configuration File

Project has been successfully initialized! Useful commands:
`pio run` - process/build project from the current directory
`pio run --target upload` or `pio run -t upload` - upload firmware to a target
`pio run --target clean` - clean project (remove compiled files)
`pio run --help` - additional information
Processing uno (platform: atmelavr; board: uno; framework: arduino)
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Verbose mode can be enabled via `-v, --verbose` option
CONFIGURATION: https://docs.platformio.org/page/boards/atmelavr/uno.html
PLATFORM: Atmel AVR > Arduino Uno
HARDWARE: ATMEGA328P 16MHz 2KB RAM (31.50KB Flash)
Library Dependency Finder -> http://bit.ly/configure-pio-ldf
LDF MODES: FINDER(chain) COMPATIBILITY(soft)
Collected 7 compatible libraries
Scanning dependencies...
Dependency Graph
|--  0.0.2
Compiling .pioenvs/uno/src/test_common/test_calculator.cpp.o
Compiling .pioenvs/uno/src/test_desktop/test_calculator.cpp.o
src/test_common/test_calculator.cpp:17:24: fatal error: calculator.h: No such file or directory

********************************************************************
* Looking for calculator.h dependency? Check our library registry!
*
* CLI  > platformio lib search "header:calculator.h"
* Web  > https://platformio.org/lib/search?query=header:calculator.h
*
********************************************************************

#include 
^
compilation terminated.
Compiling .pioenvs/uno/src/test_embedded/test_calculator.cpp.o
src/test_desktop/test_calculator.cpp:17:24: fatal error: calculator.h: No such file or directory

********************************************************************
* Looking for calculator.h dependency? Check our library registry!
*
* CLI  > platformio lib search "header:calculator.h"
* Web  > https://platformio.org/lib/search?query=header:calculator.h
*
********************************************************************

#include 
^
compilation terminated.
Compiling .pioenvs/uno/lib8b3/arduinoUnity_ID1466/unity.c.o
Archiving .pioenvs/uno/libFrameworkArduinoVariant.a
src/test_embedded/test_calculator.cpp:18:24: fatal error: calculator.h: No such file or directory

********************************************************************
* Looking for calculator.h dependency? Check our library registry!
*
* CLI  > platformio lib search "header:calculator.h"
* Web  > https://platformio.org/lib/search?query=header:calculator.h
*
********************************************************************

#include 
^
compilation terminated.
Indexing .pioenvs/uno/libFrameworkArduinoVariant.a
Compiling .pioenvs/uno/FrameworkArduino/CDC.cpp.o
In file included from /home/lois/.platformio/lib/arduinoUnity_ID1466/src/unity.h:16:0,
from /home/lois/.platformio/lib/arduinoUnity_ID1466/src/unity.c:7:
/home/lois/.platformio/lib/arduinoUnity_ID1466/src/unity.c: In function 'UnityConcludeTest':
/home/lois/.platformio/lib/arduinoUnity_ID1466/src/unity_internals.h:255:28: warning: statement with no effect [-Wunused-value]
#define UNITY_OUTPUT_FLUSH export_flush
^
/home/lois/.platformio/lib/arduinoUnity_ID1466/src/unity_internals.h:256:28: note: in expansion of macro 'UNITY_OUTPUT_FLUSH'
#define UNITY_FLUSH_CALL() UNITY_OUTPUT_FLUSH
^
/home/lois/.platformio/lib/arduinoUnity_ID1466/src/unity.c:370:5: note: in expansion of macro 'UNITY_FLUSH_CALL'
UNITY_FLUSH_CALL();
^
/home/lois/.platformio/lib/arduinoUnity_ID1466/src/unity.c: In function 'UnityBegin':
/home/lois/.platformio/lib/arduinoUnity_ID1466/src/unity_internals.h:263:43: warning: large integer implicitly truncated to unsigned type [-Woverflow]
#define UNITY_OUTPUT_START() export_start(115200)
^
/home/lois/.platformio/lib/arduinoUnity_ID1466/src/unity.c:1212:5: note: in expansion of macro 'UNITY_OUTPUT_START'
UNITY_OUTPUT_START();
^
/home/lois/.platformio/lib/arduinoUnity_ID1466/src/unity.c: In function 'UnityEnd':
/home/lois/.platformio/lib/arduinoUnity_ID1466/src/unity_internals.h:255:28: warning: statement with no effect [-Wunused-value]
#define UNITY_OUTPUT_FLUSH export_flush
^
/home/lois/.platformio/lib/arduinoUnity_ID1466/src/unity_internals.h:256:28: note: in expansion of macro 'UNITY_OUTPUT_FLUSH'
#define UNITY_FLUSH_CALL() UNITY_OUTPUT_FLUSH
^
/home/lois/.platformio/lib/arduinoUnity_ID1466/src/unity.c:1240:5: note: in expansion of macro 'UNITY_FLUSH_CALL'
UNITY_FLUSH_CALL();
^
Compiling .pioenvs/uno/FrameworkArduino/HardwareSerial.cpp.o
*** [.pioenvs/uno/src/test_common/test_calculator.cpp.o] Error 1
*** [.pioenvs/uno/src/test_desktop/test_calculator.cpp.o] Error 1
Compiling .pioenvs/uno/FrameworkArduino/HardwareSerial0.cpp.o
*** [.pioenvs/uno/src/test_embedded/test_calculator.cpp.o] Error 1
========================================================================= [ERROR] Took 0.42 seconds ==============================

Is this library still supported/working, I'm missing something?

Thanks!

ivankravets commented 5 years ago

You need to use pio test command. See https://docs.platformio.org/en/latest/userguide/cmd_test.html