Skip to content

added unittest for strip pName/vendor and minor changes#236

Closed
bgn42 wants to merge 10 commits intomainfrom
Unittest-stripPname
Closed

added unittest for strip pName/vendor and minor changes#236
bgn42 wants to merge 10 commits intomainfrom
Unittest-stripPname

Conversation

@bgn42
Copy link
Collaborator

@bgn42 bgn42 commented Oct 16, 2025

Fixes

#226

Changes

  • added unit tests for all combinations od vendor::project::pName

Checklist

  • 🤖 This change is covered by unit tests (if applicable).
  • 🤹 Manual testing has been performed (if necessary).
  • 🛡️ Security impacts have been considered (if relevant).
  • 📖 Documentation updates are complete (if required).
  • 🧠 Third-party dependencies and TPIP updated (if required).

@bgn42 bgn42 requested a review from Copilot October 16, 2025 23:24
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR adds comprehensive unit tests for STM32CubeMX generator functionality, specifically testing the parsing and handling of vendor::project::pName combinations in device specifications. The tests validate the device name extraction logic that strips vendor prefixes and handles various device naming patterns.

  • Added extensive unit test coverage for WriteProjectFile function
  • Updated test data files with generated STM32F2 project configurations
  • Minor code improvements including error handling and comment clarifications

Reviewed Changes

Copilot reviewed 13 out of 15 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
internal/stm32CubeMX/stm32CubeMX_test.go Added comprehensive unit tests for WriteProjectFile function with multiple device naming scenarios
testdata/testExamples/STM32F2/* Added complete STM32F2 test project files including CBUILD configurations and device definitions
testdata/stm32cubemx/cfg/MX_Device.h Added MX_Device.h template file for test data
internal/common/common.go Added missing error return in ReadYml function
internal/readFile/readFile.go Added clarifying comments for file type detection
vcpkg-configuration.json Added vcpkg configuration for ARM toolchain dependencies
testdata/testExamples/STM32H7_SC/STM32CubeMX/device/MX_Device/MX_Device.h Updated timestamp in generated file header

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@bgn42 bgn42 requested a review from jkrech October 16, 2025 23:25
@qltysh
Copy link

qltysh bot commented Oct 16, 2025

Diff Coverage: The code coverage on the diff in this pull request is 0.0%.

Total Coverage: This PR will increase coverage by 1.68%.

File Coverage Changes
Path File Coverage Δ Indirect
internal/common/common.go -1.1
internal/stm32CubeMX/mxDevice.go -0.3
internal/stm32CubeMX/stm32CubeMX.go 5.3
🛟 Help
  • Diff Coverage: Coverage for added or modified lines of code (excludes deleted files). Learn more.

  • Total Coverage: Coverage for the whole repository, calculated as the sum of all File Coverage. Learn more.

  • File Coverage: Covered Lines divided by Covered Lines plus Missed Lines. (Excludes non-executable lines including blank lines and comments.)

    • Indirect Changes: Changes to File Coverage for files that were not modified in this PR. Learn more.

@github-actions
Copy link

github-actions bot commented Oct 16, 2025

Test Results

    6 files  ± 0     54 suites  ±0   13s ⏱️ ±0s
  186 tests + 6    186 ✅ + 6  0 💤 ±0  0 ❌ ±0 
1 116 runs  +36  1 116 ✅ +36  0 💤 ±0  0 ❌ ±0 

Results for commit 2a7e7c2. ± Comparison against base commit e088bed.

♻️ This comment has been updated with latest results.

Copy link
Member

@jkrech jkrech left a comment

Choose a reason for hiding this comment

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

I do not understand what the new files are required for, except vcpkg-configuration.json as they are all generated when calling cbuild setup. Afterwards the launch of the generator will generate the *.cbuild-gen-idx.yml and *.cbuild-gen.yml files which contain the information to be used by cbridge.

@bgn42
Copy link
Collaborator Author

bgn42 commented Oct 17, 2025

I also do not know why all these testdata/.../tmp directories and files exist in github. But they are in since long time and I didn't dare to remove them. Maybe @DavidLesnjak knows more about them.

@bgn42 bgn42 requested a review from DavidLesnjak October 17, 2025 11:21
@DavidLesnjak
Copy link
Collaborator

The reason the testdata/testExamples directories and files are present is that the test suite is using a real STM32CubeMX project as input for the generator, to ensure that we catch corner-cases across different STM32 device families when generating the MX_Device.h.

In other words: rather than synthetic minimal inputs, we purposely used actual CubeMX project exports so the test environment more closely mimics what users will see in practice.

I fully agree that the testExample could likely be cleaned up: we should keep only the necessary files (i.e., the minimal files needed by the generator to parse and generate the output), rather than the full example tree.

@bgn42 bgn42 requested a review from jkrech October 22, 2025 13:42
jkrech
jkrech previously approved these changes Oct 24, 2025
Copy link
Member

@jkrech jkrech left a comment

Choose a reason for hiding this comment

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

LGTM

@jkrech jkrech closed this Oct 24, 2025
@jkrech jkrech deleted the Unittest-stripPname branch October 24, 2025 11:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants