PlatformIO Community

Gtest not working on pio 4.1

Hi

I have had a running googletest unit test running on platformio 4.0.3.
After the upgrade to 4.1 it is not working anymore. I get the following message:

pio test -e native -f native_FSMachine --verbose
Verbose mode can be enabled via `-v, --verbose` option
Collected 5 items

Processing native_FSMachine in native environment
--------------------------------------------------------------------------------------------------------------------------------------------------------
Building...

Verbose mode can be enabled via `-v, --verbose` option
PACKAGES: 
LDF: Library Dependency Finder -> http://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 3 compatible libraries
Scanning dependencies...
Dependency Graph
|-- <FSMachine>
|   |-- <Protocol>
|   |   |-- <Packet>
|   |-- <Packet>
|-- <Packet>
Building in release mode
Compiling .pio/build/native/test/native_FSMachine/main.o
test/native_FSMachine/main.cpp:1:10: fatal error: 'gtest/gtest.h' file not found
#include "gtest/gtest.h"
         ^~~~~~~~~~~~~~~
1 error generated.
*** [.pio/build/native/test/native_FSMachine/main.o] Error 1

the platformio.ini has the following settings for this environment:

[env:native]
platform = native
lib_deps =
  googletest@1.8.1
lib_ignore =
  NetworkClient
build_flags =
  -std=c++11
lib_archive = false
test_ignore = embedded*

any idea how to fix?

any help appreciated.
cheers

Could you provide a simple project to reproduce this issue?

Hi

sure:


created with pio 4.1
just run: pio test

Hi

not sure what is the diff in checking for includes and libs between 4.0.3 and 4.1.

thx

did some output using -v.

with 4.0.3 looks like this:

Verbose mode can be enabled via `-v, --verbose` option
Collected 1 items

Processing native in native environment
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Building...
Verbose mode can be enabled via `-v, --verbose` option
PACKAGES:
LDF: Library Dependency Finder -> http://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 1 compatible libraries
Scanning dependencies...
Dependency Graph
|-- <googletest> 1.8.1
Testing...
[==========] Running 0 tests from 0 test suites.
[==========] 0 tests from 0 test suites ran. (0 ms total)
[  PASSED  ] 0 tests.

YOU HAVE 1 DISABLED TEST

======================================================================================================== [PASSED] Took 1.45 seconds ========================================================================================================

Test    Environment    Status    Duration
------  -------------  --------  ------------
native  lolin32        IGNORED
native  native         PASSED    00:00:01.446
======================================================================================================= 1 succeeded in 00:00:01.446 =======================================================================================================

there is a difference when doing the same on 4.1:

Verbose mode can be enabled via `-v, --verbose` option
Collected 1 items

Processing native in native environment
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Building...
Verbose mode can be enabled via `-v, --verbose` option
PACKAGES:
LDF: Library Dependency Finder -> http://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 0 compatible libraries
Scanning dependencies...
No dependencies
Building in release mode
Compiling .pio\build\native\test\native\main.o
Archiving .pio\build\native\libUnityTestLib.a
test\native\main.cpp:1:10: fatal error: gtest/gtest.h: No such file or directory
 #include "gtest/gtest.h"
          ^~~~~~~~~~~~~~~
compilation terminated.
*** [.pio\build\native\test\native\main.o] Error 1
Indexing .pio\build\native\libUnityTestLib.a
======================================================================================================== [FAILED] Took 1.40 seconds ========================================================================================================

Test    Environment    Status    Duration
------  -------------  --------  ------------
native  lolin32        IGNORED
native  native         FAILED    00:00:01.396
================================================================================================== 1 failed, 0 succeeded in 00:00:01.396 ==================================================================================================

using 4.1 it is not finding any lib and therefore the dependency tree is empty.

1 Like

did even some more investigations on 4.1:

added the googletest lib_deps to the board envirnment lolin32.

[env:lolin32]
platform = espressif32
lib_deps =
  googletest
board = lolin32
framework = arduino

I now observe two changes on 4.1 when running it on lolin32 and not the native level (native still failing):

  • google test is included and found as dependency
  • I’m not limited to 1.8.1 anymore, but as well the current version 1.10.0 is working fine (this was another problem not yet brought up)

could it be that the native@1.1.1 has some problems to run with 4.1?

in the meantime native @ 1.1.2 is out, but no change on windows or osx.

Hi @jipp! I’d say that is expected behavior because for some reason only Arduino framework is specified in the library manifest. Try adding lib_compat_mode = off option to your [env:native] and it should work.

1 Like

Hi

you are right with your tip. It works now (tested on windows so far). But I’m not sure how you figured this out. Looking at the history above I see with 4.0.3 it was working with also with lib_compat_mode = soft.
In the manifest I see "frameworks": "arduino".

nevertheless thanks a lot :slight_smile: