Bug: calling set_pou_code with implementationCode only (declarationCode
omitted) would wipe the POU's PROGRAM/VAR...END_VAR block in the binary.
After such a call mirror_export classified the POU as 'UNKNOWN' (no
PROGRAM/FUNCTION_BLOCK keyword in the empty declaration), and the var
block disappeared from the .st mirror file.
Root cause: the TS wrapper substituted '' (empty string) into the Python
template when declarationCode was undefined, giving DECLARATION_CONTENT
= "". The Python script then took the truthy-ish branch (empty string
is not None) and called decl_obj.replace('') -- wiping textual_decl.
Fix: pass explicit SET_DECLARATION / SET_IMPLEMENTATION boolean flags
from the TS wrapper, gate the replace() calls on those flags. Empty
string remains a valid intentional value (caller wants to wipe).
- Reproduced on MCPTest2: PLC_PRG declaration block was wiped between
v1.3.0.0 and v1.3.1.0 by exactly this code path.
- Regression test added in tests/integration/e2e.test.ts covering the
omitted-declarationCode path.
- Existing set_pou_code test extended to assert SET_DECLARATION /
SET_IMPLEMENTATION are emitted in the rendered script.
|
||
|---|---|---|
| .. | ||
| e2e.test.ts | ||
| README.md | ||
Manual CODESYS Integration Tests
These tests require a real CODESYS installation and cannot run in CI.
Prerequisites
- CODESYS 3.5 SP19 or SP21 installed
- No other CODESYS instances running
- Node.js 18+
Steps
1. Build the package
npm run build
2. Test persistent mode
node dist/bin.js \
--codesys-path "C:\path\to\CODESYS.exe" \
--codesys-profile "CODESYS V3.5 SP21 Patch 3" \
--mode persistent \
--verbose
Verify:
- CODESYS UI opens
- Console shows "CODESYS watcher is ready"
- The MCP server accepts connections
3. Test headless fallback
node dist/bin.js \
--codesys-path "C:\path\to\CODESYS.exe" \
--codesys-profile "CODESYS V3.5 SP21 Patch 3" \
--mode headless
4. Test --detect flag
node dist/bin.js --detect
Verify: Lists installed CODESYS versions.
5. Ctrl+C shutdown
- Press Ctrl+C during persistent mode
- Verify CODESYS shuts down cleanly