6.1 KiB
6.1 KiB
Copilot / AI agent instructions for GrifoAutomaticTestEnv
Purpose: concise, actionable guidance for AI coding agents working in this repository.
- Big picture
- Python-based automated test harness for GRIFO radar. Core responsibilities:
- 1553 bus access via SWIG bindings in
PlatformSimulator/bin(interpreter/_interpreter.pyd). - Test framework and helpers under
TestEnvironment/env(leo_grifo_* modules). - Test scripts under
TestEnvironment/scripts(e.g.GRIFO_M_PBIT.py). - Simulation mode implemented in
GRIFO_M_PBIT_mock.py(opt-in via--simulate).
- 1553 bus access via SWIG bindings in
- Primary integration & boundaries
- Native 1553 hardware is wrapped by SWIG:
PlatformSimulator/bin/interpreter.py-> used byleo_grifo_1553.py. - Serial and power control are separate modules:
leo_grifo_terminal.pyandleo_grifo_io_box.py. - Test scripts call the common API in
TestEnvironment/env(singletons such astheGrifo1553,theBrainBox,theRecorder).
- Key coding patterns to preserve
- Singletons: code expects global singletons (e.g.
theGrifo1553 = GrifoInstrumentInterface(...)). Do not replace with factories unless you update all call sites. - TestCommonInterface: modules implement
check(),get(),set()and are consumed via helpers intest_common_function.py(usecheck()/getValue()/setValue()patterns). - Recorder pattern: use
theRecorderto record test steps (add_step,close_session) rather than ad-hoc prints. - Path-bootstrap:
TestEnvironment/scripts/__init__.pyappends../envandenv/site-packagestosys.path; maintain that import behavior for scripts and wrappers. - Simulation approach:
GRIFO_M_PBIT.pydetects--simulateand monkey-patches the global singletons with mock objects fromGRIFO_M_PBIT_mock.py. Respect the same API surface when changing mocks.
- Developer workflows / commands (documented and reproducible)
- Quick simulate (recommended):
- Run
run_simulate_simple.batfrom repo root (uses system Python). - Or:
python TestEnvironment/scripts/GRIFO_M_PBIT.py --simulate.
- Run
- Production-like simulate (embedded):
- Run
run_simulate.batto use embeddedPlatformSimulator/binPython/uPlatSim.
- Run
- Manual wrapper for CI / debug:
python python_simulate_wrapper.py(ensuresenv/site-packagesprecedence).
- Important files to inspect for changes
TestEnvironment/env/leo_grifo_1553.py— 1553 wrapper; showscheck/get/setsemantics andtheGrifo1553singleton.TestEnvironment/env/leo_grifo_terminal.py— serial parsing rules (%%E,%%F,RECYCLE) and statistics keys.TestEnvironment/env/leo_grifo_io_box.py—theBrainBoxandpower_grifo_on/offhelpers.TestEnvironment/env/leo_grifo_core.py&test_common_function.py— recorder and common helper functions used by scripts and reports.TestEnvironment/scripts/GRIFO_M_PBIT.py— main test flow, known-failures list and CSV/PDF export logic.TestEnvironment/scripts/GRIFO_M_PBIT_mock.py— reference mock implementation and configuration options.
- Testing, CI and safety notes for agents
- Prefer non-invasive edits: simulation mode exists to run and validate logic without hardware — use
--simulatein CI. - Do not change singleton names or function signatures (
check,get,set,enable_notification) without sweeping updates acrossTestEnvironment/scripts. - When changing report generation, update
leo_grifo_test_report.pyand ensuregenerate_pdf_report()callers still pass expected JSON templates fromTestEnvironment/json.
- Suggested quick tasks for agents
- Small bugfix: preserve existing
theGrifo1553usage; add defensiveNonechecks when calling native interface methods. - Add small unit-style smoke script that runs
GRIFO_M_PBIT.py --simulateand asserts exit code0and that a PDF appears underTestEnvironment/pdf_reports.
- Where to find more documentation
- Read
GRIFO_Test_Environment_Analysis.md,IMPLEMENTATION_SUMMARY.md, andLAUNCHER_GUIDE.mdat repo root for architecture and run details.
If anything here is unclear or you'd like more examples (e.g. common refactors that are safe), tell me which area to expand. If anything here is unclear or you'd like more examples (e.g. common refactors that are safe), tell me which area to expand.
- System / Interaction rules (from repository owner)
- Language: Communicate with maintainers in Italian for chat, reasoning, and explanations. Keep all code, function names, variables, comments and docstrings in English.
- Coding standards: Follow PEP8 for Python, use type hints for functions and complex variables, and prefer clear, small functions. Avoid one-letter variable names.
- Comments: Keep comments essential and concise; do not include historical or debugging notes in committed code.
- Critical thinking: Evaluate proposals and suggest better alternatives when appropriate (performance, security, maintainability). Explain "how" and "why" before providing code.
- Update protocol (strict - follow these when editing repo files)
- Small changes (<5 lines): show exactly which lines change and the new lines.
- Function-level changes (>5 lines in a few functions): provide full contents of each modified function.
- Module-level changes (majority of a file): provide the full module code.
- Sequential delivery: modify one module at a time and wait for confirmation before the next.
- Provide a brief comparison: what changed and why.
- Agent notes / safe defaults
- When editing tests or reports, prefer using simulation mode (
--simulate) to validate logic without hardware. - Preserve global singleton names (
theGrifo1553,theBrainBox,theRecorder) unless performing a repo-wide refactor. - Prefer non-invasive fixes that add defensive checks (e.g.,
if obj is None:) around native calls tointerpreterobjects.
- Where to put these instructions
- This file (
.github/copilot-instructions.md) is the canonical location; keep it concise and up-to-date.
If you want, I can now: (A) add a short smoke-test script under TestEnvironment/scripts that runs GRIFO_M_PBIT.py --simulate and verifies PDF output, or (B) reformat the file to include inline examples for the update protocol. Which do you prefer?