test: add comprehensive C# and Python unit tests for the PyMCU SDK#4
Merged
Merged
Conversation
Agent-Logs-Url: https://github.com/PyMCU/pymcu-sdk/sessions/1eb50c7b-0c67-4b08-83f1-63aac2c394ff Co-authored-by: begeistert <36460223+begeistert@users.noreply.github.com>
Copilot created this pull request from a session on behalf of
begeistert
April 23, 2026 06:26
View session
begeistert
approved these changes
Apr 23, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The SDK had no tests of its own despite containing non-trivial logic across the IR layer, backend analysis passes, serialization, license validation, and Python plugin abstractions. This brings a self-contained test suite ported and adapted from the upstream PyMCU monorepo, extended with edge-case coverage specific to this package.
C# —
tests/csharp/(138 xUnit tests)IR/DataTypeTests.cs—SizeOf,IsSigned,StringToDataType(all type strings includingconst[T],ptr[T], PIORegister, null/unknown),GetPromotedType(same type, larger wins, mixed-signedness promotion at all widths)IR/TackyTests.cs— Record equality/defaults for everyValandInstructionsubtype;ProgramIR/Functiondefaults and mutationBackend/Analysis/StackAllocatorTests.cs— Global allocation, local frame sequencing, param registration via call graph entry points, globals not re-allocated as locals, ISR function allocation,VariableSizesfor all data widths, bit instructions,ArrayLoad/ArrayStorebyte sizingBackend/Analysis/DynamicStackAllocatorTests.cs— Downward-growing offsets, params-before-body-locals ordering, 16-byte alignment invariant, unique offsets, temporaries, custom word sizesBackend/Serialization/IrSerializerTests.cs— Full JSON round-trip for every instruction and value type, includingFlashData,MemoryAddress,FloatConstant,InlineAsmwith operandsBackend/License/LicenseResultTests.cs— All factory methods (Free,Ok,NotFound,Expired,WrongFamily)Backend/License/LicenseValidatorTests.cs—ResolveKeyresolution order (explicit > env > whitespace), JWT parsing for valid/expired/wrong-family/all-families tokens, case-insensitive family matchingPython —
tests/python/(56 pytest tests)test_base_tool.py—_default_platform_keyarch normalisation (amd64→x86_64, aarch64→arm64),_is_non_interactive(CI env, PYMCU_NO_INTERACTIVE, tty),verify_sha256,_extract_archivefor tar.gz/bz2/zip including zip-slip path traversal protection for both tar and zip formats, base dir env override, version cache helperstest_backend_plugin.py—resolve_license_keyfull priority chain,BackendPlugin.supports(exact, prefix, case-insensitive, false-positive guard),validate_licensedefault/override,LicenseStatusenum completenesstest_toolchain_plugin.py—ToolchainPlugin.get_instanceusesdefault_chip,get_ffi_toolchaindefault returnsNone,ExternalToolchainchip storage andassemblecontractInfrastructure
tests/csharp/PyMCU.Backend.SDK.Tests.csproj— references the SDK project; pulls xUnit 2.7 + FluentAssertions 6.12PyMCU.SDK.slnx— test project added to the solutionpyproject.toml—[tool.pytest.ini_options]block pointing attests/python/