Skip to content

Conversation

@brianignacio5
Copy link
Collaborator

@brianignacio5 brianignacio5 commented Jun 20, 2025

Description

Add idf.pyTestEmbeddedServices and idf.unitTestFilePattern to allow customize the pytest embedded services and the unit test file GLOB pattern to find test files.

Add Unit Test: Build Unit Test App and Unit Test: Flash Unit Test App to just build or just flash the unity-app.

This should allow cpp unit testing according to our user @fenderle. Please take a look.

This PR also fix these issue with current Run test implementation.

Check that the ${workspaceFolder}/unity-app exists on Testing tab -> Run test to avoid copy the unity-app again if exists.

Allow the user to have workspaceFolder defined tests. This means the unity-app will exists in the current workspace folder and tests found are only within the currently selected workspace folder (with ESP-IDF: Pick a Workspace Folder Command) until refresh.

Fixes #1248

Fixes #1536

Type of change

  • New feature (non-breaking change which adds functionality)

Steps to test this pull request

Set idf.unitTestFilePattern to "/test/test_*.cpp to find cpp files instead. Set idf.pyTestEmbeddedServices to ["idf", "qemu"] to use idf and QEMU for testing. Use an ESP-IDF project with unit test according to documentation.

  1. Click on menu View -> Testing. You should be able to see the tests that match pattern in idf.unitTestFilePattern
  2. From the list of tests of each file, press the play button (Run Test).
  3. Observe results. The test should be run according to idf.pyTestEmbeddedServices defined services.
  4. Use Unit Test: Build Unit Test App and Unit Test: Flash Unit Test App commands. You should build or flash only output.
  5. Check that when pressing the Run test (play button) on the Testing tab doesn't override the unity-app if it already exists.
  6. Check that tests found only for the currently selected workspace folder. ESP-IDF: Pick a Workspace Folder Command
  • Expected behaviour:

  • Expected output:

How has this been tested?

Manual testing as described above.

Test Configuration:

  • ESP-IDF Version: 5.4.1
  • OS (Windows,Linux and macOS): macOS

Checklist

  • PR Self Reviewed
  • Applied Code formatting
  • Added Documentation
  • Added Unit Test
  • Verified on all platforms - Windows,Linux and macOS

@brianignacio5 brianignacio5 requested a review from radurentea June 20, 2025 10:49
@brianignacio5 brianignacio5 self-assigned this Jun 20, 2025
@brianignacio5 brianignacio5 added the enhancement New feature or request label Jun 20, 2025
@github-actions
Copy link

github-actions bot commented Jun 20, 2025

Download the artifacts for this pull request:
You can test these changes by installing this VSIX by click menu View -> Command Palette..., type Install from VSIX and then select downloaded esp-idf-extension.vsix file to install the extension.

@fenderle
Copy link

This works as expected. Thank you.

Copy link
Collaborator

@radurentea radurentea left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, nice work!

@brianignacio5 brianignacio5 force-pushed the enhance/cpp-unittest-support branch from a7ea9ce to 1923244 Compare July 11, 2025 08:06
const filePattern =
readParameter("idf.unitTestFilePattern", workspaceFolderUri) ||
"**/test/test_*.c";
const relativePattern = new RelativePattern(workspaceFolderUri, filePattern);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

RelativePattern() constructor will throw an exception with 'Illegal argument: base' when used with my configuration. Using the workspacefolder (with something like workspace.workspaceFolders?.[0]) instead of uri seems to work somehow.

Doctor command for my System (WSL)
report.txt

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've update the PR to use workspace Folder instead of Uri. Please take a look at the latest vsix installer https://nightly.link/espressif/vscode-esp-idf-extension/actions/artifacts/3553155120.zip

@brianignacio5 brianignacio5 force-pushed the enhance/cpp-unittest-support branch from 571a802 to 15680b9 Compare July 17, 2025 09:36
@Fabricio-ESP Fabricio-ESP changed the title Pytest unit test customize services and glob pattern [VSC-1670] Pytest unit test customize services and glob pattern Jul 22, 2025
Copy link
Collaborator

@Fabricio-ESP Fabricio-ESP left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Confirmed working.

@brianignacio5 brianignacio5 merged commit be400d3 into master Jul 29, 2025
7 of 8 checks passed
@brianignacio5 brianignacio5 deleted the enhance/cpp-unittest-support branch July 29, 2025 03:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bugfix Fixing some issue and bug in this PR enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Test Runner will overwrite unity-app when "Run Test" is clicked (VSC-1670) [Feature Request]: Support testing of C++ files (VSC-1428)

6 participants