Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to override managed component with mock (IDFGH-9210) #10599

Closed
3 tasks done
ljden opened this issue Jan 22, 2023 · 4 comments
Closed
3 tasks done

Unable to override managed component with mock (IDFGH-9210) #10599

ljden opened this issue Jan 22, 2023 · 4 comments
Assignees
Labels
Awaiting Response awaiting a response from the author Resolution: Done Issue is done internally Status: Done Issue is done internally Type: Bug bugs in IDF

Comments

@ljden
Copy link
Contributor

ljden commented Jan 22, 2023

Answers checklist.

  • I have read the documentation ESP-IDF Programming Guide and the issue is not addressed there.
  • I have updated my IDF branch (master or release) to the latest version and checked that the issue is present there.
  • I have searched the issue tracker for a similar issue and not found a similar issue.

IDF version.

v5.0

Operating System used.

Linux

How did you build your project?

Command line with idf.py

If you are using Windows, please specify command line type.

None

What is the expected behavior?

I am trying to build a linux based host_test project to unit test a component. This component has a dependency on espressif/esp-idf-cxx. I am unable to override the dependency so that the build uses the mock. I'm not sure if I have implemented it correctly, the documentation for host testing, mocking and component manager are a bit lacking.

What is the actual behavior?

It errors when adding the mock via any one of component manager, extra components dir, components dir.

-- building ESP EVENT MOCKS
-- building FREERTOS MOCKS (only task, event-groups and queue)
-- building esp-idf-cxx MOCKS (I2C only)
CMake Error at /home/vbox/esp/esp-idf/tools/cmake/component.cmake:249 (message):
  ERROR: Cannot process component requirements.  Multiple candidates to
  satisfy project requirements:

    requirement: "esp-idf-cxx" candidates: "esp-idf-cxx, espressif__esp-idf-cxx"

Call Stack (most recent call first):
  /home/vbox/esp/esp-idf/tools/cmake/build.cmake:553 (__component_get_requirements)
  /home/vbox/esp/esp-idf/tools/cmake/project.cmake:440 (idf_build_process)
  CMakeLists.txt:15 (project)

Steps to reproduce.

vbox@vbox:~/comp/host_test$ cat comp/host_test/CMakeLists.txt
cmake_minimum_required(VERSION 3.16)
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

include($ENV{IDF_PATH}/tools/cmake/project.cmake)
set(COMPONENTS main)

idf_build_set_property(COMPILE_DEFINITIONS "-DconfigTICK_RATE_HZ=1000" APPEND)

list(APPEND EXTRA_COMPONENT_DIRS "$ENV{IDF_PATH}/tools/mocks/freertos/")
list(APPEND EXTRA_COMPONENT_DIRS "$ENV{IDF_PATH}/tools/mocks/esp_event/")
...
list(APPEND EXTRA_COMPONENT_DIRS "./mock_comps/mocks/esp-idf-cxx")

project(sensor_manager_host_test)
vbox@vbox:~/comp/host_test$ cat main/CMakeLists.txt
idf_component_register(SRCS "test_comp.cpp"
    WHOLE_ARCHIVE
    PRIV_REQUIRES comp cmock
    )

find_package(Catch2 3 REQUIRED)
find_package(trompeloeil REQUIRED)

target_link_libraries(${COMPONENT_LIB}
  PRIVATE
  Catch2::Catch2WithMain
  trompeloeil::trompeloeil
  )
vbox@vbox:~/comp/host_test$ cat main/idf_component.yml
dependencies:
  idf: "5.0.*"
  comp:
    path: "../../"
vbox@vbox:~/comp/host_test$ cat ../idf_component.yml
version: "0.0.1"
description: component
dependencies:
  idf: "5.0.*"
  espressif/esp-idf-cxx: "~1.0.0-beta"
...
vbox@vbox:~/sensor_manager/host_test$ tree mock_comps/
mock_comps/
└── mocks
    ├── esp-idf-cxx
    │   ├── CMakeLists.txt
    │   └── include
    │       └── i2c_cxx.hpp
    └── README.md
vbox@vbox:~/comp/host_test$ rm -rf dependencies.lock managed_components/ sdkconfig build/ && idf.py build
...
-- building ESP EVENT MOCKS
-- building FREERTOS MOCKS (only task, event-groups and queue)
-- building esp-idf-cxx MOCKS (I2C only)
CMake Error at /home/vbox/esp/esp-idf/tools/cmake/component.cmake:249 (message):
  ERROR: Cannot process component requirements.  Multiple candidates to
  satisfy project requirements:

    requirement: "esp-idf-cxx" candidates: "espressif__esp-idf-cxx, esp-idf-cxx"

Call Stack (most recent call first):
  /home/vbox/esp/esp-idf/tools/cmake/build.cmake:553 (__component_get_requirements)
  /home/vbox/esp/esp-idf/tools/cmake/project.cmake:440 (idf_build_process)
  CMakeLists.txt:15 (project)

Build or installation Logs.

No response

More Information.

This may have something to do with the espressif version being namespaced? If that's the case, is there a workaround?
According to the docs, I would have expected to be able to override https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-guides/build-system.html#multiple-components-with-the-same-name

@ljden ljden added the Type: Bug bugs in IDF label Jan 22, 2023
@espressif-bot espressif-bot added the Status: Opened Issue is new label Jan 22, 2023
@github-actions github-actions bot changed the title Unable to override managed component with mock Unable to override managed component with mock (IDFGH-9210) Jan 22, 2023
@0xjakob
Copy link
Contributor

0xjakob commented Feb 14, 2023

@ljden Sorry for the long waiting time! Thanks for taking action and posting this issue at idf-component-manager. Let's wait what the developers there will say.

@espressif-bot espressif-bot added the Awaiting Response awaiting a response from the author label Mar 13, 2023
@0xjakob
Copy link
Contributor

0xjakob commented Apr 11, 2023

@ljden BTW, if you are trying to mock ESP-IDF-CXX, it might not work as easily as mocking C-APIs since CMock cannot easily mock C++ classes.

@ljden
Copy link
Contributor Author

ljden commented Apr 11, 2023

Yeah, we've been using trompeloeil for mocking c++ apis

@Alvin1Zhang
Copy link
Collaborator

Thanks for reporting, let us track in the component manager issue tracker, espressif/idf-component-manager#23, thanks.

@espressif-bot espressif-bot added Status: Done Issue is done internally Resolution: Done Issue is done internally and removed Status: Opened Issue is new labels Jun 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Awaiting Response awaiting a response from the author Resolution: Done Issue is done internally Status: Done Issue is done internally Type: Bug bugs in IDF
Projects
None yet
Development

No branches or pull requests

4 participants