use uv to run test, more fixes
This commit is contained in:
@@ -1,31 +1,15 @@
|
||||
# Test Suite
|
||||
|
||||
Integration tests for the gammaray-mcp bridge, written in Python using `pytest`. Tests communicate with the bridge over stdio JSON-RPC (the same protocol MCP clients use), exercising every tool end-to-end against a real GammaRay probe.
|
||||
Integration tests for the gammaray-mcp bridge, written in Python using `pytest`.
|
||||
Tests communicate with the bridge over stdio JSON-RPC, exercising every MCP tool
|
||||
end-to-end against a real GammaRay probe.
|
||||
|
||||
## Prerequisites
|
||||
|
||||
- The bridge must be built: `cmake --build bridge/build`
|
||||
- `pytest` (install via `pip3 install pytest` or `pip install pytest` in a venv)
|
||||
- For probe-dependent tests: a QML test app at `~/Sources/testqml/relayout.qml` (configurable via `TEST_QML` env)
|
||||
|
||||
## Running
|
||||
## Quick start
|
||||
|
||||
```bash
|
||||
# From the project root:
|
||||
./tests/run_tests.sh --no-probe # unit tests only (no probe needed)
|
||||
./tests/run_tests.sh -v # full suite, verbose
|
||||
./tests/run_tests.sh -k "item" # run only item-related tests
|
||||
./tests/run_tests.sh --no-probe -x # stop on first failure, no probe
|
||||
```
|
||||
|
||||
Or directly with pytest:
|
||||
|
||||
```bash
|
||||
cd tests
|
||||
LD_LIBRARY_PATH=../install-prefix/lib \
|
||||
QT_QPA_PLATFORM=offscreen \
|
||||
QT_PLUGIN_PATH=../bridge/build/lib/x86_64-linux-gnu/qt6/plugins \
|
||||
pytest -v
|
||||
./run_tests.sh --no-probe # unit tests only (no probe needed)
|
||||
./run_tests.sh -v # full suite, verbose
|
||||
./run_tests.sh -k "item" # item-related tests only
|
||||
```
|
||||
|
||||
## Test files
|
||||
@@ -37,19 +21,51 @@ pytest -v
|
||||
| `test_items.py` | `selectQuickItem`, `getItemProperties`, position, visual properties, groups | Yes |
|
||||
| `test_scenegraph.py` | `selectScenegraphNode`, `getNodeVertices`, `getNodeAdjacency`, `getMaterialShaders`, `getMaterialProperties`, `setRenderMode`, `setSlowMode` | Yes |
|
||||
|
||||
## Test QML application
|
||||
|
||||
`testapp/main.qml` is a simple Qt Quick Controls application that exercises all
|
||||
the tools: buttons, switches, sliders, a list view with delegate items, and
|
||||
visibility/opacity controls.
|
||||
|
||||
## Configuration
|
||||
|
||||
**`run_tests.sh` is the single configuration point.** All paths default to
|
||||
project-local locations. When GammaRay is installed elsewhere (e.g. from a
|
||||
system package), override these by editing the variables at the top of
|
||||
`run_tests.sh`:
|
||||
|
||||
| Variable | Default | Description |
|
||||
|---|---|---|
|
||||
| `GAMMARAY_BIN` | `install-prefix/bin/gammaray` | Path to the probe binary |
|
||||
| `GAMMARAY_LIB_DIR` | `install-prefix/lib` | Runtime library directory for GammaRay |
|
||||
| `QML_RUNNER` | `/usr/lib/qt6/bin/qml` | QML runtime executable |
|
||||
| `TEST_QML` | `testapp/main.qml` | Test QML application |
|
||||
| `BRIDGE_EXE` | `bridge/build/qml-sg-mcp-bridge` | Bridge executable |
|
||||
| `BRIDGE_RUN_SCRIPT` | `bridge/run.sh` | Bridge wrapper script |
|
||||
|
||||
You can also override any of these via environment variables when calling
|
||||
`run_tests.sh` or `pytest` directly:
|
||||
|
||||
```bash
|
||||
GAMMARAY_BIN=/usr/bin/gammaray GAMMARAY_LIB_DIR=/usr/lib/x86_64-linux-gnu \
|
||||
./run_tests.sh --no-probe
|
||||
```
|
||||
|
||||
## pytest options
|
||||
|
||||
| Flag | Default | Description |
|
||||
|---|---|---|
|
||||
| `--no-probe` | `false` | Skip all probe-dependent tests |
|
||||
| `--probe-timeout` | 15s | Seconds to wait for probe to become ready |
|
||||
|
||||
## Markers
|
||||
|
||||
- `@pytest.mark.probe` — test requires a running GammaRay probe. Automatically skipped with `--no-probe`.
|
||||
- `@pytest.mark.probe` — test requires a running GammaRay probe.
|
||||
Automatically skipped with `--no-probe`.
|
||||
|
||||
## Fixtures
|
||||
|
||||
- `bridge` — fresh `McpClient` instance per test (initialized, not connected)
|
||||
- `connected_bridge` — bridge connected to a probe (via `connectProbeDefault`)
|
||||
- `probe_process` — session-scoped, starts a probe via `systemd-run` (fallback: direct spawn) and waits for `ready()`
|
||||
|
||||
## Options
|
||||
|
||||
| Flag | Default | Description |
|
||||
|---|---|---|
|
||||
| `--no-probe` | `false` | Skip all probe-dependent tests |
|
||||
| `--probe-timeout` | 15s | Seconds to wait for probe to become ready |
|
||||
- `probe_process` — session-scoped, starts a probe via `systemd-run` (fallback:
|
||||
direct spawn) and waits for `ready()`
|
||||
Reference in New Issue
Block a user