Compare commits
19 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 0d614c2921 | |||
| 9466b091dd | |||
| 511288bd03 | |||
| 51b144f60c | |||
| 5fd50e1c85 | |||
| 51939a566a | |||
| 26fccda6bf | |||
| 405fb82fca | |||
| 6064d96138 | |||
| 0658540cc2 | |||
| 7bf946dabe | |||
| f52d7bbe53 | |||
| c83ebccb55 | |||
| f17ef8a3a1 | |||
| ddb18abc21 | |||
| 358ade8c98 | |||
| 46bdb44cfb | |||
| 41519c97cb | |||
| b9475c6e9b |
3
.gitignore
vendored
3
.gitignore
vendored
@@ -8,6 +8,8 @@ dist
|
||||
/.vscode
|
||||
.venv/
|
||||
.flatpak-builder/
|
||||
package/flatpak/repo/
|
||||
package/flatpak/*.flatpak
|
||||
crash.tx*
|
||||
report_test.tx*
|
||||
*.autosave
|
||||
@@ -24,6 +26,7 @@ package/appimage/*.AppImage
|
||||
package/appimage/src
|
||||
package/appimage/*.py
|
||||
AppDir
|
||||
*.squashfs
|
||||
doc/manual/doxygen
|
||||
doc/manual/sphinx/build/*
|
||||
doc/manual/sphinx/source/_build/*
|
||||
|
||||
37
CLAUDE.md
37
CLAUDE.md
@@ -183,6 +183,8 @@ Icons are assigned once when the test file is loaded (not updated live on theme
|
||||
|
||||
The sub-test's own pass/fail result is intentionally not propagated.
|
||||
|
||||
The interpreter and entry point used to spawn the sub-instance are picked automatically by `_testium_launch_cmd()` based on how the parent was started (AppImage → `$APPIMAGE`; Flatpak → `flatpak run`; PyInstaller → the frozen binary; source/wheel → `[sys.executable, abspath(sys.argv[0])]`). The user cannot override either via the YAML — selecting a different testium binary or Python from a sub-test was removed because it was either ill-defined (bundle modes have no separable Python) or could mismatch the parent's environment in surprising ways.
|
||||
|
||||
### Report exporters & plugins
|
||||
`src/testium/interpreter/test_report/test_report.py` — `_EXPORTER_REGISTRY` dict maps a format name (cmd key in the YAML `report.export`) to a lazy loader. Built-ins: `text`, `json`, `junit` (needs `junit_xml`), `html` (needs `lxml`). `sqlite` is the storage layer, no-op as an export.
|
||||
|
||||
@@ -201,17 +203,38 @@ A real-world test plugin lives at `test/validation/fake_exporter/` (CSV exporter
|
||||
|
||||
## Packaging
|
||||
|
||||
Three distribution channels coexist, sharing the single `src/testium/` package:
|
||||
Four distribution channels coexist, all sharing the single `src/testium/` package and the single `src/requirements.txt` dependency list:
|
||||
|
||||
| Channel | Where | Notes |
|
||||
|---------|-------|-------|
|
||||
| Wheel (`pip install`) | `src/pyproject.toml` | Vanilla Python package; entry point `testium = "testium:main"` |
|
||||
| PyInstaller binary | `package/pyinstaller/` | Single ~130 MB binary. `py_func`, `runtime`, `lua_func` bundled at `_MEIPASS` root so the **host** Python can find them when launched as `python3 py_func`. `api`/`interpreter` are **not** exposed (subprocess isolation). |
|
||||
| Flatpak | `package/flatpak/` | (Existing recipe, not actively maintained in current refactor wave.) |
|
||||
| Channel | Where | Build | Notes |
|
||||
|---------|-------|-------|-------|
|
||||
| Wheel (`pip install`) | `src/pyproject.toml` | `python -m build` | Vanilla Python package; entry point `testium = "testium:main"`. |
|
||||
| PyInstaller binary | `package/pyinstaller/` | `build.sh` | Single ~130 MB binary. `py_func`, `runtime`, `lua_func` bundled at `_MEIPASS` root so the **host** Python can find them when launched as `python3 py_func`. `api`/`interpreter` are **not** exposed (subprocess isolation). |
|
||||
| Flatpak | `package/flatpak/` | `build.sh` (uses `flatpak-builder`) | KDE 6.10 runtime. The bundled Python runs only the main process; `py_func` / `lua_func` MUST run under the **host** interpreter (no Python/Lua bundled). Produces a distributable `.flatpak` bundle. |
|
||||
| AppImage | `package/appimage/` | `build.sh` (Debian Bookworm container via Podman/Docker) | Bundles Python 3.11 for the main process; `py_func` / `lua_func` MUST run under the **host** interpreter. Build runs in a container so it works on Arch / any non-Debian host. |
|
||||
|
||||
The `.deb` work-in-progress lives in `package/deb/`:
|
||||
- `test_distro.sh debian:bookworm | debian:trixie | ubuntu:24.04` spins up a Docker/Podman container, reports system package availability, falls back to pip for what's missing (`pyside6` on bookworm/ubuntu, `telnetlib3`, `junit_xml`), runs the validation suite. Currently green on the three targets.
|
||||
|
||||
### Host-only py_func / lua_func in sandboxed bundles (Flatpak, AppImage)
|
||||
|
||||
The bundled Python (Flatpak's runtime python, AppImage's `python3.11`) is reserved for the **main process only**. Subprocesses (`py_func`, `lua_func`, `git`) must use the host's interpreters and tools so user-installed modules (pyserial, junit_xml, …) are visible. This is enforced by `interpreter/utils/bins.py`:
|
||||
|
||||
- `_in_flatpak()` (checks `/.flatpak-info`) and `_in_appimage()` (checks `APPIMAGE` env var) detect the sandbox.
|
||||
- `_which(name)` probes only host bin dirs in those modes:
|
||||
- Flatpak: `/run/host/usr/{local/,}bin`, `/run/host/bin` (host mounted via `--filesystem=host-os`).
|
||||
- AppImage: `/usr/local/bin`, `/usr/bin`, `/bin` (we are directly on the host filesystem).
|
||||
- If the host has no python3/lua, `ensure()` raises `ETUMRuntimeError` at test load with the candidate list — no silent fallback to a bundled interpreter.
|
||||
- User overrides (`python_bin`/`lua_bin` in globdict): bare names are resolved through `_which()` (host-only), absolute paths are accepted as-is.
|
||||
- `apply_host_libs(env)` is called by `py_process.py` / `lua_process.py` on the env passed to Popen:
|
||||
- Flatpak: prepends host lib dirs to `LD_LIBRARY_PATH` so the dynamic linker finds host `.so`'s.
|
||||
- AppImage: strips `$APPDIR`-prefixed entries from `LD_LIBRARY_PATH` / `PYTHONPATH` / `PATH` and drops `PYTHONHOME`, so the host Python doesn't try to load the bundled stdlib/site-packages.
|
||||
- `apply_host_lua_paths(env)` (Flatpak only) prepends `/run/host/usr/{lib,share}/lua/X.Y` to `LUA_PATH` / `LUA_CPATH` so `cjson`, `socket`, etc. resolve. Must be called **after** user `lua_env` overrides so host paths win. AppImage relies on host Lua's compiled-in defaults.
|
||||
- `py_process.py` additionally pops `PYTHONUSERBASE` (set to `/var/data/python` by the Flatpak runtime, which would hide `~/.local/lib/...`).
|
||||
|
||||
### Version reporting (`interpreter/utils/version.py`)
|
||||
|
||||
Both Flatpak and AppImage export `TESTIUM_VERSION` from a launcher (Flatpak: launcher script in `org.testium.Testium.yaml`; AppImage: `runtime.env` in `AppImageBuilder.yml`). `get_testium_version()` checks `/.flatpak-info` / `APPIMAGE` and reads `TESTIUM_VERSION` rather than relying on package metadata or repo introspection.
|
||||
|
||||
## Recent fixes / notable changes
|
||||
- Restructure: single `src/testium/` Python package (was 4 sibling top-levels: `testium`, `lib`, `py_func`, `lua_func`). `lib/` → `runtime/`, `libs/` → `api/`. `pip install` now produces a clean `site-packages/testium/` with no top-level pollution; `.lua` files travel via `package_data`.
|
||||
- `bins.py`: centralised resolution + cache of external `python3` / `lua` binaries. Replaces the scattered `tm.gd("python_bin")`/`tm.gd("lua_bin")` dance and the duplicated discovery logic in `py_process.py`/`lua_process.py`. Validates at test load via `TestSet._validate_runtime_deps()` so missing interpreters fail fast.
|
||||
@@ -242,7 +265,7 @@ The `.deb` work-in-progress lives in `package/deb/`:
|
||||
## Validation tests
|
||||
Located in `test/validation/`. Run with `-b` flag:
|
||||
```
|
||||
./run.sh -b -l mon_log.log -- test/validation/main.tum
|
||||
./run.sh -b -- test/validation/main.tum
|
||||
```
|
||||
Parallel item tests: `test/validation/items/parallel/test.tum`
|
||||
|
||||
|
||||
101
CONTRIBUTING.md
101
CONTRIBUTING.md
@@ -45,7 +45,7 @@ For existing files, keep the header that is already there.
|
||||
3. Commit with a clear message (one logical change per commit).
|
||||
4. Make sure the validation suite still passes:
|
||||
```
|
||||
./run.sh -b -l mon_log.log -- test/validation/main.tum
|
||||
./run.sh -b -- test/validation/main.tum
|
||||
```
|
||||
5. Open a pull request against `main`.
|
||||
|
||||
@@ -56,6 +56,105 @@ For existing files, keep the header that is already there.
|
||||
- Add or update tests in `test/validation/` for new test items or behaviours
|
||||
- Update `CLAUDE.md` and the Sphinx manual for user-visible changes
|
||||
|
||||
## Development
|
||||
|
||||
### Debugging in VSCode
|
||||
|
||||
The recommended workflow:
|
||||
|
||||
1. Add a debug configuration to `.vscode/launch.json`:
|
||||
```json
|
||||
{
|
||||
"configurations": [
|
||||
{
|
||||
"name": "Python : testium",
|
||||
"type": "python",
|
||||
"request": "launch",
|
||||
"program": "${workspaceFolder}/src/testium",
|
||||
"console": "integratedTerminal",
|
||||
"args": ["-g"],
|
||||
"justMyCode": true
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
2. Install `debugpy` in the venv: `python -m pip install debugpy`.
|
||||
3. Open the *Run and Debug* tab and press play. testium starts; load and
|
||||
run a `.tum` file. Set breakpoints where you want to investigate.
|
||||
|
||||
### Qt GUI modification
|
||||
|
||||
UI files (`*.ui`) are edited in **Qt Creator**. After editing, regenerate
|
||||
the corresponding Python and resource files:
|
||||
|
||||
```sh
|
||||
scripts/qt_generate.sh
|
||||
```
|
||||
|
||||
Icons come from <https://github.com/free-icons/free-icons>.
|
||||
|
||||
### Sphinx documentation
|
||||
|
||||
```sh
|
||||
pip install sphinx linuxdoc
|
||||
doc/manual/sphinx/build_doc.sh
|
||||
```
|
||||
|
||||
PDF generation requires `texlive`:
|
||||
|
||||
```sh
|
||||
sudo apt install texlive-full
|
||||
```
|
||||
|
||||
### Validation suite
|
||||
|
||||
Batch mode (CI-friendly, headless):
|
||||
|
||||
```sh
|
||||
./run.sh -b -- test/validation/main.tum
|
||||
```
|
||||
|
||||
GUI mode (loads the suite, click *Run* to execute and inspect the tree):
|
||||
|
||||
```sh
|
||||
./run.sh test/validation/main.tum
|
||||
```
|
||||
|
||||
GUI run-and-close (executes the suite, then closes):
|
||||
|
||||
```sh
|
||||
./run.sh -r -- test/validation/main.tum
|
||||
```
|
||||
|
||||
Subset run via the `items` define (works in any mode):
|
||||
|
||||
```sh
|
||||
./run.sh -b -d "items=['parallel','common']" -- test/validation/main.tum
|
||||
```
|
||||
|
||||
### Cross-distribution check
|
||||
|
||||
`package/deb/test_distro.sh` spins up a Docker/Podman container of the
|
||||
target image, installs the expected system Python deps via apt (with
|
||||
pip fallback for what is missing), installs the testium wheel and runs
|
||||
the validation suite end-to-end. Currently green on `debian:bookworm`,
|
||||
`debian:trixie`, `ubuntu:24.04`.
|
||||
|
||||
```sh
|
||||
./package/deb/test_distro.sh debian:trixie
|
||||
```
|
||||
|
||||
## Release procedure
|
||||
|
||||
1. Update `release_note.txt`.
|
||||
2. Bump the version in `src/VERSION`.
|
||||
3. Make sure the documentation is up to date — rebuild with
|
||||
`doc/manual/sphinx/build_doc.sh` if needed.
|
||||
4. Push and tag the commit with the new version.
|
||||
5. Build the binary release: `package/pyinstaller/build.sh`.
|
||||
6. Run the validation suite against each generated binary.
|
||||
7. Confirm all validation results are green before publishing.
|
||||
|
||||
## Reporting security issues
|
||||
|
||||
Please do **not** report security vulnerabilities through public GitHub
|
||||
|
||||
295
README.md
295
README.md
@@ -1,185 +1,122 @@
|
||||
# Documentation
|
||||
# testium
|
||||
|
||||
[See here](doc/manual/testium_manual.pdf).
|
||||
testium is a YAML-driven test sequencer for hardware-in-the-loop and
|
||||
integration testing. A test campaign is described in a `.tum` file as a tree
|
||||
of items (checks, console interactions, Python/Lua functions, parallel blocks,
|
||||
dialogs, …); testium executes the tree, captures results, and produces
|
||||
reports in several formats.
|
||||
|
||||
# License
|
||||
## Documentation
|
||||
|
||||
Copyright (c) 2025-2026 François Dausseur.
|
||||
* [Quick start](doc/quick_start.md) — install and run your first test in
|
||||
five minutes.
|
||||
* [Tutorial](doc/tutorial.md) — guided walk-through of the most common
|
||||
test items with a runnable example.
|
||||
* [User manual (PDF)](doc/manual/testium_manual.pdf) — full reference.
|
||||
* [`doc/examples/`](doc/examples/) — runnable `.tum` snippets.
|
||||
|
||||
## Pre-built releases
|
||||
|
||||
Pre-built artifacts are published at
|
||||
<https://git.beafrancois.fr/v-and-v/testium/releases>:
|
||||
|
||||
* **Python wheel** (`testium-<version>-py3-none-any.whl`) — install with
|
||||
`pip install testium-*.whl`. Lighter than the binary; pulls Python
|
||||
dependencies from PyPI on install.
|
||||
* **Self-contained Linux binary** (`testium`, built with PyInstaller) —
|
||||
runnable directly, no Python installation required on the host. Lua
|
||||
support still needs a system `lua` interpreter and the `lua-socket` /
|
||||
`lua-cjson` modules.
|
||||
* **Flatpak bundle** (`testium.flatpak`) — install with:
|
||||
|
||||
```sh
|
||||
# Add Flathub (once, to fetch the KDE/PySide runtimes)
|
||||
flatpak remote-add --user --if-not-exists flathub https://flathub.org/repo/flathub.flatpakrepo
|
||||
|
||||
# Install the bundle
|
||||
flatpak install --user testium.flatpak
|
||||
```
|
||||
|
||||
After installation testium appears in the desktop application menu and the
|
||||
`testium` command is available in the terminal (requires `~/.local/bin` in
|
||||
`PATH`, which most modern distributions provide by default).
|
||||
|
||||
## Quick start
|
||||
|
||||
From a checkout of the repository:
|
||||
|
||||
| OS | Command |
|
||||
|----|---------|
|
||||
| Linux | `./run.sh` |
|
||||
| Windows (cmd) | `run.bat` |
|
||||
| Windows (PowerShell) | `run.ps1` |
|
||||
|
||||
The wrapper creates a Python virtual environment on first run and starts
|
||||
testium in GUI mode. Add `-b path/to/test.tum` to run a test in batch mode.
|
||||
|
||||
## Manual installation
|
||||
|
||||
If the wrapper script does not fit your environment, set up testium manually:
|
||||
|
||||
```sh
|
||||
python3 -m venv .venv
|
||||
source .venv/bin/activate
|
||||
pip install -r src/requirements.txt
|
||||
```
|
||||
|
||||
Required Python packages (see `src/requirements.txt`):
|
||||
`pyside6`, `pyserial`, `pyyaml`, `pexpect`, `gitpython`, `jinja2`, `colorama`,
|
||||
`matplotlib`, `junit-xml`, `lxml`.
|
||||
|
||||
For tests using `lua_func` items, install Lua (>= 5.1) plus the `socket` and
|
||||
`cjson` modules. On Debian/Ubuntu:
|
||||
|
||||
```sh
|
||||
sudo apt install lua5.4 lua-socket lua-cjson
|
||||
```
|
||||
|
||||
Run testium:
|
||||
|
||||
```sh
|
||||
python3 src/testium # GUI
|
||||
python3 src/testium -b mytest.tum # batch
|
||||
```
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
### `wl_proxy_marshal_flags` symbol error
|
||||
|
||||
```
|
||||
testium: symbol lookup error: ... undefined symbol: wl_proxy_marshal_flags
|
||||
```
|
||||
|
||||
Force the X11 Qt backend:
|
||||
|
||||
```sh
|
||||
export QT_QPA_PLATFORM=xcb
|
||||
testium
|
||||
```
|
||||
|
||||
### `xcb plugin missing`
|
||||
|
||||
```
|
||||
qt.qpa.plugin: Could not load the Qt platform plugin "xcb"
|
||||
```
|
||||
|
||||
Install the missing system libraries:
|
||||
|
||||
```sh
|
||||
sudo apt install libxcb-cursor0 libicu-dev libxcb-cursor-dev
|
||||
```
|
||||
|
||||
## License
|
||||
|
||||
Copyright © 2025-2026 François Dausseur.
|
||||
|
||||
testium is distributed under the **European Union Public Licence v. 1.2
|
||||
(EUPL-1.2)** — see the [LICENSE](LICENSE) file for the full text.
|
||||
(EUPL-1.2)** — see [`LICENSE`](LICENSE) for the full text. SPDX:
|
||||
`EUPL-1.2`.
|
||||
|
||||
SPDX identifier: `EUPL-1.2`
|
||||
|
||||
Contributions are accepted under the same licence (inbound = outbound). See
|
||||
[CONTRIBUTING.md](CONTRIBUTING.md) for details.
|
||||
|
||||
# run testium
|
||||
|
||||
From the root path, on windows `cmd`:
|
||||
|
||||
run.bat
|
||||
|
||||
On windows powershell:
|
||||
|
||||
run.ps1
|
||||
|
||||
On linux:
|
||||
|
||||
./run.sh
|
||||
|
||||
The virtual environment is created if needed and *testium* is started.
|
||||
|
||||
# Manual setup
|
||||
|
||||
A python virtual environment should be created:
|
||||
|
||||
python3 -m venv <testium_venv>
|
||||
|
||||
## Requirements
|
||||
|
||||
In the virtual environment, the following modules must be installed:
|
||||
|
||||
* pyside6
|
||||
* pyserial
|
||||
* pyyaml
|
||||
* pexpect
|
||||
* gitpython
|
||||
* jinja2
|
||||
* colorama
|
||||
* matplotlib
|
||||
* junit-xml
|
||||
* lxml
|
||||
|
||||
A `requirements.txt` file is also available in the git repository in the path `testium/src/`.
|
||||
|
||||
|
||||
## run testium
|
||||
|
||||
from the testium path, execute
|
||||
|
||||
python3 -m src/testium
|
||||
|
||||
# Doc generation
|
||||
|
||||
## Install sphinx
|
||||
|
||||
pip install sphinx linuxdoc
|
||||
|
||||
## Generate the doc
|
||||
|
||||
Execute
|
||||
|
||||
doc/manual/sphinx/./build_doc.sh
|
||||
|
||||
This command works if texlive package has been installed on the system. It can be done by invoking the following command.
|
||||
|
||||
sudo apt install texlive-full
|
||||
|
||||
# QT GUI
|
||||
|
||||
## QT GUI modification
|
||||
|
||||
Open the ".ui" file with `qtcreator` and modify the gui. Then regenerate the python code.
|
||||
|
||||
On linux, a helper script has been created:
|
||||
scripts/./qt_generate.sh
|
||||
|
||||
# Debugging
|
||||
|
||||
In order to debug testium or your python script executed within testium.
|
||||
|
||||
## In VSCODE
|
||||
|
||||
This is the prefered method :
|
||||
|
||||
1. Create a debug configuration like the following:
|
||||
|
||||
```
|
||||
"configurations": [
|
||||
{
|
||||
"name": "Python : testium",
|
||||
"type": "python",
|
||||
"request": "launch",
|
||||
"program": "${workspaceFolder}/src/testium",
|
||||
"console": "integratedTerminal",
|
||||
"args": ["-g"],
|
||||
"justMyCode": true
|
||||
},
|
||||
]
|
||||
```
|
||||
|
||||
2. Install debugpy module in python
|
||||
|
||||
python -m pip install debugpy
|
||||
3. Then get to the "RUN AND DEBUG" tab and press the play button.
|
||||
4. A testium window will pops up ; start execution of your tum.
|
||||
5. Do not forget to put breakpoints where you want to investigate.
|
||||
|
||||
## Icons
|
||||
|
||||
Icons are coming from the following site: https://github.com/free-icons/free-icons.git
|
||||
|
||||
# testium Release
|
||||
|
||||
## Pre-requisite
|
||||
|
||||
A `python` virtual environment must have been set as described above.
|
||||
|
||||
### Install pyinstaller
|
||||
|
||||
Install `pyinstaller` package using pip.
|
||||
|
||||
## Generate the binary package
|
||||
|
||||
The procedure for a binary release is as follows:
|
||||
|
||||
1. update the `release_note.txt` file
|
||||
2. modify the version in `src/VERSION` file
|
||||
3. be sure that the documentation is up to date, and if not execute `doc/manual/sphinx/build_doc.sh` script
|
||||
4. push modifications and create a tag with the new version on the git repository
|
||||
5. generate an executable file by calling `package/pyinstaller/./build.sh`
|
||||
6. run the complete validation test for each generated binary
|
||||
7. check that all the validation results are OK
|
||||
|
||||
# Troubleshooting
|
||||
|
||||
## The testium exe crashes `wl_proxy_marshal_flags`
|
||||
|
||||
### Error message
|
||||
|
||||
/testium: symbol lookup error: /tmp/_MEIOhDCPF/libQt6WaylandClient.so.6: undefined symbol: wl_proxy_marshal_flags
|
||||
|
||||
### Solution
|
||||
|
||||
Set the appropriate environment variable
|
||||
|
||||
export QT_QPA_PLATFORM=xcb
|
||||
testium
|
||||
|
||||
## xcb plugin missing
|
||||
|
||||
### Error message
|
||||
|
||||
qt.qpa.plugin: Could not load the Qt platform plugin "xcb" in "" even though it was found.
|
||||
|
||||
### Solution
|
||||
|
||||
A package is missing
|
||||
|
||||
sudo apt install libxcb-cursor0
|
||||
sudo apt-get install libicu-dev
|
||||
sudo apt-get install libxcb-cursor-dev
|
||||
|
||||
## The testium appimage crashes when opening a file
|
||||
|
||||
This is usually because wayland is defined as the default X server.
|
||||
|
||||
To change it :
|
||||
|
||||
* Disable Wayland by uncommenting WaylandEnable=false in the `/etc/gdm3/daemon.conf`
|
||||
* Add `QT_QPA_PLATFORM=xcb` in `/etc/environment`
|
||||
* After a reboot, check that the environment variable value returns `x11`:
|
||||
|
||||
$ echo $XDG_SESSION_TYPE
|
||||
x11
|
||||
Contributions are accepted under the same licence (inbound = outbound).
|
||||
See [`CONTRIBUTING.md`](CONTRIBUTING.md) for development setup, debugging
|
||||
workflow, and the release procedure.
|
||||
|
||||
85
build_all.sh
Executable file
85
build_all.sh
Executable file
@@ -0,0 +1,85 @@
|
||||
#!/bin/bash
|
||||
# Build every distribution channel of testium, in order:
|
||||
# 1. Wheel -> dist/testium-<v>-py3-none-any.whl (PEP 427 name)
|
||||
# 2. PyInstaller binary -> dist/testium-<v>
|
||||
# 3. Flatpak bundle -> dist/testium-<v>.flatpak
|
||||
# 4. AppImage -> dist/Testium-<v>-x86_64.AppImage (original name)
|
||||
# All artifacts are collected (copied) under <repo>/dist/. Original outputs in
|
||||
# src/dist/, package/*/dist/ are left in place. The wheel and AppImage keep
|
||||
# their original names (which already contain the version); pyinstaller and
|
||||
# flatpak are renamed to a normalized testium-<version>(.suff) form.
|
||||
#
|
||||
# Re-uses scripts/build_env.sh and scripts/set_env.sh — the same pair invoked
|
||||
# by run.sh — so the venv at test/tmp/.venv stays the single source of Python
|
||||
# dependencies. `build` and `pyinstaller` are installed into that venv on
|
||||
# demand if not already there. Flatpak and AppImage build in their own
|
||||
# container/sandbox; their build.sh scripts have their own toolchain checks.
|
||||
|
||||
set -e
|
||||
|
||||
SCRIPT_DIR=$(realpath "$(dirname "$0")")
|
||||
VERSION=$(cat "$SCRIPT_DIR/src/VERSION")
|
||||
DIST_DIR="$SCRIPT_DIR/dist"
|
||||
mkdir -p "$DIST_DIR"
|
||||
|
||||
export PY_VENV_NAME=".venv"
|
||||
export PY_VENV_DIR="$SCRIPT_DIR/test/tmp/$PY_VENV_NAME"
|
||||
export REQ_PATH="$SCRIPT_DIR/src/requirements.txt"
|
||||
|
||||
bash "$SCRIPT_DIR/scripts/build_env.sh"
|
||||
source "$SCRIPT_DIR/scripts/set_env.sh"
|
||||
|
||||
# Ensure wheel/PyInstaller toolchains are present in the venv.
|
||||
python -m pip install --quiet --upgrade build pyinstaller
|
||||
|
||||
step() {
|
||||
echo
|
||||
echo "================================================================"
|
||||
echo " $1"
|
||||
echo "================================================================"
|
||||
}
|
||||
|
||||
# 1. Wheel — PEP 427 name kept (already contains version)
|
||||
step "1/4 Wheel (version $VERSION)"
|
||||
(
|
||||
cd "$SCRIPT_DIR/src"
|
||||
rm -rf dist build *.egg-info
|
||||
python -m build --wheel
|
||||
)
|
||||
WHEEL_SRC=$(ls -1t "$SCRIPT_DIR/src/dist"/*.whl | head -1)
|
||||
WHEEL="$DIST_DIR/$(basename "$WHEEL_SRC")"
|
||||
cp -f "$WHEEL_SRC" "$WHEEL"
|
||||
|
||||
# 2. PyInstaller binary
|
||||
step "2/4 PyInstaller binary (version $VERSION)"
|
||||
bash "$SCRIPT_DIR/package/pyinstaller/build.sh"
|
||||
PYI_SRC="$SCRIPT_DIR/package/pyinstaller/dist/testium"
|
||||
PYI_BIN="$DIST_DIR/testium-${VERSION}"
|
||||
cp -f "$PYI_SRC" "$PYI_BIN"
|
||||
|
||||
# 3. Flatpak bundle
|
||||
step "3/4 Flatpak bundle (version $VERSION)"
|
||||
(
|
||||
cd "$SCRIPT_DIR/package/flatpak"
|
||||
bash build.sh
|
||||
)
|
||||
FLATPAK_SRC="$SCRIPT_DIR/package/flatpak/testium.flatpak"
|
||||
FLATPAK_BUNDLE="$DIST_DIR/testium-${VERSION}.flatpak"
|
||||
cp -f "$FLATPAK_SRC" "$FLATPAK_BUNDLE"
|
||||
|
||||
# 4. AppImage
|
||||
step "4/4 AppImage (version $VERSION)"
|
||||
(
|
||||
cd "$SCRIPT_DIR/package/appimage"
|
||||
bash build.sh
|
||||
)
|
||||
APPIMAGE_SRC=$(ls -1t "$SCRIPT_DIR/package/appimage"/*.AppImage 2>/dev/null | head -1)
|
||||
APPIMAGE="$DIST_DIR/$(basename "$APPIMAGE_SRC")"
|
||||
cp -f "$APPIMAGE_SRC" "$APPIMAGE"
|
||||
chmod +x "$APPIMAGE"
|
||||
|
||||
step "All packages built"
|
||||
printf " wheel : %s\n" "$WHEEL"
|
||||
printf " pyinstaller : %s\n" "$PYI_BIN"
|
||||
printf " flatpak : %s\n" "$FLATPAK_BUNDLE"
|
||||
printf " appimage : %s\n" "$APPIMAGE"
|
||||
Binary file not shown.
66
doc/quick_start.md
Normal file
66
doc/quick_start.md
Normal file
@@ -0,0 +1,66 @@
|
||||
# Quick start
|
||||
|
||||
Five minutes from zero to a passing test.
|
||||
|
||||
## Install
|
||||
|
||||
From a checkout of the repository:
|
||||
|
||||
```sh
|
||||
./run.sh --version # Linux
|
||||
run.bat # Windows cmd
|
||||
```
|
||||
|
||||
The wrapper creates a Python virtual environment on first run and verifies
|
||||
testium starts. If you prefer a manual install, see the README.
|
||||
|
||||
## Your first test
|
||||
|
||||
Create `hello.tum`:
|
||||
|
||||
```yaml
|
||||
main:
|
||||
name: hello world
|
||||
steps:
|
||||
- check:
|
||||
name: 1 + 1 makes 2
|
||||
values:
|
||||
- <| 1 + 1 == 2 |>
|
||||
```
|
||||
|
||||
Run it in batch mode:
|
||||
|
||||
```sh
|
||||
./run.sh -b -- hello.tum
|
||||
```
|
||||
|
||||
You should see something like:
|
||||
|
||||
```
|
||||
-----> step "1 + 1 makes 2" started
|
||||
Check passed
|
||||
<----- step "1 + 1 makes 2" finished: PASS
|
||||
Test run success.
|
||||
```
|
||||
|
||||
Replace `==` with `!=` and re-run — the step now ends with **FAIL** and
|
||||
the process exits with code 1.
|
||||
|
||||
## Open it in the GUI
|
||||
|
||||
```sh
|
||||
./run.sh hello.tum
|
||||
```
|
||||
|
||||
The test tree appears in the left panel; click *Run test* in the toolbar.
|
||||
Each item turns green or red live as it executes. Use `F1` on a selected
|
||||
item to open its detail panel.
|
||||
|
||||
## Where to go next
|
||||
|
||||
* [`doc/tutorial.md`](tutorial.md) — a guided walk-through of the most
|
||||
common test items (`py_func`, `let`, `group`, `condition`, `report`).
|
||||
* [`doc/examples/`](examples/) — runnable `.tum` snippets covering one
|
||||
feature each.
|
||||
* [`doc/manual/testium_manual.pdf`](manual/testium_manual.pdf) —
|
||||
full reference manual.
|
||||
223
doc/tutorial.md
Normal file
223
doc/tutorial.md
Normal file
@@ -0,0 +1,223 @@
|
||||
# Tutorial — testing a small Python utility
|
||||
|
||||
This walk-through builds, step by step, a testium campaign that exercises
|
||||
a small Python module. Each section adds one feature; you can follow
|
||||
along by editing a single `.tum` file and re-running it.
|
||||
|
||||
If you have not yet run testium, start with [`quick_start.md`](quick_start.md).
|
||||
|
||||
## The code under test
|
||||
|
||||
Create `calc.py` next to your `.tum` file:
|
||||
|
||||
```python
|
||||
def add(a, b):
|
||||
return a + b
|
||||
|
||||
def divide(a, b):
|
||||
return a / b
|
||||
```
|
||||
|
||||
## Step 1 — a static check
|
||||
|
||||
The simplest item is `check`: it evaluates an expression and the test
|
||||
passes iff the expression is truthy. Create `tutorial.tum`:
|
||||
|
||||
```yaml
|
||||
main:
|
||||
name: calc.py campaign
|
||||
steps:
|
||||
- check:
|
||||
name: addition is correct
|
||||
values:
|
||||
- <| 2 + 3 == 5 |>
|
||||
```
|
||||
|
||||
The `<| ... |>` markers turn the body into a Python expression evaluated
|
||||
at run time. Run it:
|
||||
|
||||
```sh
|
||||
./run.sh -b -- tutorial.tum
|
||||
```
|
||||
|
||||
## Step 2 — call your code with `py_func`
|
||||
|
||||
`check` only sees Python literals; to exercise `calc.py` we need a
|
||||
`py_func` item. Replace the step:
|
||||
|
||||
```yaml
|
||||
- py_func:
|
||||
name: add 2 and 3
|
||||
file: calc.py
|
||||
func_name: add
|
||||
param: [2, 3]
|
||||
expected_result: 5
|
||||
```
|
||||
|
||||
`expected_result` makes the item PASS only when the function returns
|
||||
exactly that value.
|
||||
|
||||
The result is also stored in the global dict under `pfn_<name>`
|
||||
(here `pfn_add 2 and 3`).
|
||||
|
||||
Anywhere in a `.tum`, `$(key)` is replaced at runtime by the value
|
||||
stored in the global dict under `key`. A subsequent step can read the
|
||||
result back with `$(pfn_<name>)`:
|
||||
|
||||
```yaml
|
||||
- check:
|
||||
name: result was 5
|
||||
values:
|
||||
- <| $(pfn_add 2 and 3) == 5 |>
|
||||
```
|
||||
|
||||
## Step 3 — group several checks
|
||||
|
||||
Wrap the steps in a `group` to keep them visually together and let
|
||||
testium report a per-group status:
|
||||
|
||||
```yaml
|
||||
main:
|
||||
name: calc.py campaign
|
||||
steps:
|
||||
- group:
|
||||
name: add
|
||||
steps:
|
||||
- py_func:
|
||||
name: 2 + 3
|
||||
file: calc.py
|
||||
func_name: add
|
||||
param: [2, 3]
|
||||
expected_result: 5
|
||||
- py_func:
|
||||
name: -1 + 1
|
||||
file: calc.py
|
||||
func_name: add
|
||||
param: [-1, 1]
|
||||
expected_result: 0
|
||||
- group:
|
||||
name: divide
|
||||
steps:
|
||||
- py_func:
|
||||
name: 6 / 2
|
||||
file: calc.py
|
||||
func_name: divide
|
||||
param: [6, 2]
|
||||
expected_result: 3.0
|
||||
```
|
||||
|
||||
A group fails as soon as one of its steps fails (set
|
||||
`stop_on_failure: false` to keep going).
|
||||
|
||||
## Step 4 — define a variable with `let`
|
||||
|
||||
Avoid hard-coding the same number twice with a variable:
|
||||
|
||||
```yaml
|
||||
- let:
|
||||
name: define numerator
|
||||
values:
|
||||
- num: 6
|
||||
- py_func:
|
||||
name: divide num by 2
|
||||
file: calc.py
|
||||
func_name: divide
|
||||
param:
|
||||
- $(num)
|
||||
- 2
|
||||
expected_result: 3.0
|
||||
```
|
||||
|
||||
`$(num)` expands to the global dict entry — when the stored value is a
|
||||
number it is substituted as a number, no need to wrap it in `<| ... |>`.
|
||||
|
||||
## Step 5 — conditional execution
|
||||
|
||||
Skip a step when a condition is false:
|
||||
|
||||
```yaml
|
||||
- py_func:
|
||||
name: divide by zero only on linux
|
||||
condition: <| "$(os)" == "Linux" |>
|
||||
file: calc.py
|
||||
func_name: divide
|
||||
param: [1, 0]
|
||||
```
|
||||
|
||||
Items skipped this way report `SKIP` and do not affect the overall
|
||||
result.
|
||||
|
||||
## Step 6 — generate a report
|
||||
|
||||
Add a `report` block at the root of the file:
|
||||
|
||||
```yaml
|
||||
main:
|
||||
name: calc.py campaign
|
||||
steps:
|
||||
# ... your steps here ...
|
||||
|
||||
report:
|
||||
enabled: true
|
||||
log_stored: true
|
||||
export:
|
||||
- junit:
|
||||
path: ./reports
|
||||
file_name: calc.xml
|
||||
- html:
|
||||
path: ./reports
|
||||
file_name: calc.html
|
||||
```
|
||||
|
||||
The `path` directory must exist before the test runs — testium does not
|
||||
create it. Create it once:
|
||||
|
||||
```sh
|
||||
mkdir -p reports
|
||||
```
|
||||
|
||||
Re-run the test — `./reports/calc.xml` (CI-friendly) and
|
||||
`./reports/calc.html` (human-friendly) are produced. Set
|
||||
`log_stored: true` to include each item's captured stdout.
|
||||
|
||||
## Step 7 — share state between calls
|
||||
|
||||
By default each `py_func` runs in its own short-lived subprocess.
|
||||
To keep state across calls, use `context_id`:
|
||||
|
||||
```yaml
|
||||
- py_func:
|
||||
name: open
|
||||
file: calc.py
|
||||
func_name: open_resource
|
||||
context_id: my_ctx
|
||||
- py_func:
|
||||
name: use
|
||||
file: calc.py
|
||||
func_name: use_resource
|
||||
context_id: my_ctx
|
||||
```
|
||||
|
||||
Both steps share the same persistent Python interpreter, so `calc.py`
|
||||
can store any object in module-level globals or in `tm.setgd()`.
|
||||
|
||||
To share data without `context_id`, write it to the testium global dict
|
||||
via the JSON-RPC bridge:
|
||||
|
||||
```python
|
||||
import py_func.tm as tm
|
||||
|
||||
def producer():
|
||||
tm.setgd("computed", 42)
|
||||
|
||||
def consumer():
|
||||
return tm.gd("computed")
|
||||
```
|
||||
|
||||
## Where to go next
|
||||
|
||||
* [`doc/examples/`](examples/) — one runnable `.tum` per feature
|
||||
(cycles, dialogs, console, plots, parallel, run-of-tum, …).
|
||||
* [`doc/manual/testium_manual.pdf`](manual/testium_manual.pdf) — full
|
||||
reference manual covering every test item, every attribute and the
|
||||
YAML syntax extensions.
|
||||
@@ -24,9 +24,8 @@ AppDir:
|
||||
|
||||
runtime:
|
||||
env:
|
||||
SEQUENCER_REV: '{{APP_VERSION}}'
|
||||
TESTIUM_VERSION: '{{APP_VERSION}}'
|
||||
PYTHONPATH: $APPDIR/usr/lib/python3.11/site-packages:$APPDIR/usr/lib/python3.11
|
||||
QT_QPA_PLATFORM: xcb
|
||||
|
||||
path_mappings:
|
||||
- /usr/share/matplotlib/mpl-data/matplotlibrc:$APPDIR/etc/matplotlibrc
|
||||
@@ -69,12 +68,13 @@ AppDir:
|
||||
|
||||
# Set python 3.11 as default
|
||||
ln -fs python3.11 $TARGET_APPDIR/usr/bin/python3
|
||||
# Install pip
|
||||
if [ ! -f "get-pip.py" ]; then curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py; fi
|
||||
|
||||
# Bootstrap pip into the AppDir Python
|
||||
if [ ! -f "get-pip.py" ]; then curl -sS https://bootstrap.pypa.io/get-pip.py -o get-pip.py; fi
|
||||
python3.11 get-pip.py --break-system-packages
|
||||
|
||||
# Install application dependencies in AppDir
|
||||
python3.11 -m pip install --break-system-packages --upgrade --isolated --no-input --ignore-installed --prefix=$TARGET_APPDIR/usr -r requirements.txt
|
||||
python3.11 -m pip install --break-system-packages --upgrade --isolated --no-input --ignore-installed --prefix=$TARGET_APPDIR/usr -r ../../src/requirements.txt
|
||||
|
||||
export PIP_CONFIG_FILE=$HOME/.pip/pip.conf
|
||||
python3.11 -m pip install --break-system-packages --upgrade --isolated --no-input --ignore-installed --prefix=$TARGET_APPDIR/usr ../../src/dist/testium-{{APP_VERSION}}-py3-none-any.whl
|
||||
|
||||
@@ -1,12 +1,54 @@
|
||||
#!/usr/bin/bash
|
||||
#!/bin/bash
|
||||
# Build the testium AppImage inside a Debian container (Podman or Docker).
|
||||
# The resulting .AppImage file is written to this directory.
|
||||
|
||||
export APP_VERSION=$(<../../src/VERSION)
|
||||
set -e
|
||||
|
||||
appimage-builder --recipe AppImageBuilder.yml
|
||||
REPO_ROOT="$(cd "$(dirname "$0")/../.." && pwd)"
|
||||
APP_VERSION="$(<"$REPO_ROOT/src/VERSION")"
|
||||
|
||||
RESULT=$?
|
||||
if [ -n "$1" ] && [ "$1" = "install" ]; then
|
||||
if [ $RESULT -eq 0 ]; then
|
||||
install -v "testium-${APP_VERSION}-x86_64.AppImage" "${HOME}/.local/bin/testium"
|
||||
fi
|
||||
if command -v podman &>/dev/null; then
|
||||
RUNTIME=podman
|
||||
elif command -v docker &>/dev/null; then
|
||||
RUNTIME=docker
|
||||
else
|
||||
echo "Error: neither podman nor docker found." >&2
|
||||
exit 1
|
||||
fi
|
||||
echo "Using $RUNTIME — building testium $APP_VERSION AppImage..."
|
||||
|
||||
# APPIMAGE_EXTRACT_AND_RUN=1 lets appimagetool run without FUSE in the container.
|
||||
$RUNTIME run --rm \
|
||||
--privileged \
|
||||
-e APPIMAGE_EXTRACT_AND_RUN=1 \
|
||||
-v "$REPO_ROOT:/work" \
|
||||
-w /work/package/appimage \
|
||||
debian:bookworm bash -c "
|
||||
set -e
|
||||
export DEBIAN_FRONTEND=noninteractive
|
||||
|
||||
apt-get update -qq
|
||||
apt-get install -y -qq \
|
||||
python3 python3-pip python3-venv python3-build \
|
||||
dpkg-dev fakeroot squashfs-tools wget curl file binutils \
|
||||
libglib2.0-0 patchelf zsync > /dev/null
|
||||
|
||||
# Build the wheel
|
||||
cd /work/src
|
||||
python3 -m build --wheel --outdir dist/ > /dev/null
|
||||
cd /work/package/appimage
|
||||
|
||||
# Install appimage-builder
|
||||
pip3 install appimage-builder --quiet --break-system-packages
|
||||
|
||||
# Run the build
|
||||
export APP_VERSION=$APP_VERSION
|
||||
appimage-builder --recipe AppImageBuilder.yml --skip-test
|
||||
"
|
||||
|
||||
APPIMAGE_FILE=$(ls -1t Testium-*-x86_64.AppImage 2>/dev/null | head -1)
|
||||
echo "Done: ${APPIMAGE_FILE}"
|
||||
|
||||
if [ "${1}" = "install" ] && [ -n "${APPIMAGE_FILE}" ]; then
|
||||
install -v "${APPIMAGE_FILE}" "${HOME}/.local/bin/testium"
|
||||
fi
|
||||
|
||||
@@ -1,3 +0,0 @@
|
||||
tables
|
||||
pandas
|
||||
scapy
|
||||
@@ -5,4 +5,22 @@
|
||||
# flatpak install flathub org.kde.Sdk//6.10
|
||||
# flatpak install flathub io.qt.PySide.BaseApp//6.10
|
||||
|
||||
flatpak-builder --user --verbose --force-clean --install build org.testium.Testium.yaml
|
||||
set -e
|
||||
|
||||
# Build + install local
|
||||
flatpak-builder --user --verbose --force-clean --install --repo=repo build org.testium.Testium.yaml
|
||||
|
||||
# Génère le bundle distribuable
|
||||
flatpak build-bundle repo testium.flatpak org.testium.Testium
|
||||
echo "Bundle généré : $(pwd)/testium.flatpak"
|
||||
|
||||
# Crée ~/.local/bin/testium pour pouvoir taper "testium" en console
|
||||
WRAPPER="$HOME/.local/bin/testium"
|
||||
mkdir -p "$HOME/.local/bin"
|
||||
cat > "$WRAPPER" <<'EOF'
|
||||
#!/bin/sh
|
||||
exec flatpak run org.testium.Testium "$@"
|
||||
EOF
|
||||
chmod +x "$WRAPPER"
|
||||
echo "Wrapper installé : $WRAPPER"
|
||||
echo "Assurez-vous que ~/.local/bin est dans votre PATH."
|
||||
|
||||
7
package/flatpak/org.testium.Testium-mime.xml
Normal file
7
package/flatpak/org.testium.Testium-mime.xml
Normal file
@@ -0,0 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<mime-info xmlns="http://www.freedesktop.org/standards/shared-mime-info">
|
||||
<mime-type type="application/x-testium">
|
||||
<comment>Testium test script</comment>
|
||||
<glob pattern="*.tum"/>
|
||||
</mime-type>
|
||||
</mime-info>
|
||||
10
package/flatpak/org.testium.Testium.desktop
Normal file
10
package/flatpak/org.testium.Testium.desktop
Normal file
@@ -0,0 +1,10 @@
|
||||
[Desktop Entry]
|
||||
Name=Testium
|
||||
GenericName=Test Sequencer
|
||||
Comment=YAML-based test sequencer and runner
|
||||
Exec=testium %f
|
||||
Icon=org.testium.Testium
|
||||
Type=Application
|
||||
Categories=Development;
|
||||
MimeType=application/x-testium;
|
||||
StartupNotify=true
|
||||
@@ -13,7 +13,9 @@ finish-args:
|
||||
- --socket=wayland
|
||||
- --device=dri
|
||||
- --share=network
|
||||
- --filesystem=home # Optionnel : si votre testium doit lire des fichiers utilisateurs
|
||||
- --filesystem=home
|
||||
- --filesystem=/tmp
|
||||
- --filesystem=host-os
|
||||
|
||||
build-options:
|
||||
build-args:
|
||||
@@ -41,18 +43,41 @@ modules:
|
||||
sources:
|
||||
- type: dir
|
||||
path: ../../src
|
||||
- type: file
|
||||
path: org.testium.Testium.desktop
|
||||
- type: file
|
||||
path: org.testium.Testium-mime.xml
|
||||
- type: file
|
||||
path: ../../package/testium.png
|
||||
build-commands:
|
||||
# On installe le code source dans /app/lib/testium
|
||||
# Code source
|
||||
- mkdir -p /app/lib
|
||||
- cp -r . /app/lib/
|
||||
- cp -r testium /app/lib/
|
||||
- cp VERSION /app/lib/testium/VERSION
|
||||
|
||||
# Création du launcher exécutable
|
||||
# Launcher exécutable
|
||||
- mkdir -p /app/bin
|
||||
- |
|
||||
cat <<EOF > /app/bin/testium
|
||||
#!/bin/sh
|
||||
# On ajoute le code source et l'extension PySide6 au PYTHONPATH
|
||||
export TESTIUM_VERSION="\$(cat /app/lib/testium/VERSION 2>/dev/null || echo unknown)"
|
||||
export PYTHONPATH="/app/lib/testium:/usr/lib/sdk/pyside6/lib/python3.13/site-packages:\$PYTHONPATH"
|
||||
exec python3 /app/lib/testium "\$@"
|
||||
# Expose host binaries (git, python3, lua, …) for subprocess lookups.
|
||||
# PATH is appended (not prepended) so the main process keeps the sandbox python3.
|
||||
export PATH="\$PATH:/run/host/usr/local/bin:/run/host/usr/bin:/run/host/bin"
|
||||
export GIT_PYTHON_GIT_EXECUTABLE="/run/host/usr/bin/git"
|
||||
exec /usr/bin/python3 /app/lib/testium "\$@"
|
||||
EOF
|
||||
- chmod +x /app/bin/testium
|
||||
|
||||
# Icône
|
||||
- mkdir -p /app/share/icons/hicolor/256x256/apps
|
||||
- cp testium.png /app/share/icons/hicolor/256x256/apps/org.testium.Testium.png
|
||||
|
||||
# Entrée menu
|
||||
- mkdir -p /app/share/applications
|
||||
- cp org.testium.Testium.desktop /app/share/applications/
|
||||
|
||||
# Type MIME pour .tum
|
||||
- mkdir -p /app/share/mime/packages
|
||||
- cp org.testium.Testium-mime.xml /app/share/mime/packages/
|
||||
|
||||
@@ -1,3 +1,20 @@
|
||||
version 0.1.2
|
||||
==============
|
||||
- Flatpak: opening a test from the GUI now correctly finds its companion
|
||||
files (param.yaml, .py scripts, ...).
|
||||
|
||||
version 0.1.1
|
||||
==============
|
||||
- New install channels: Flatpak bundle and AppImage. The AppImage runs
|
||||
on any distribution (built inside a Debian container).
|
||||
- About dialog: version is now correct in Flatpak and AppImage builds
|
||||
(used to display "unknown").
|
||||
- GUI dialogs no longer hang on pure-Wayland sessions.
|
||||
- Plot "last values" API: more tolerant timeout on loaded machines.
|
||||
- run item: `testium_path` and `python_bin` parameters removed —
|
||||
sub-instances are launched in the same packaging mode as the parent.
|
||||
- License: EUPL-1.2.
|
||||
|
||||
version 0.1
|
||||
==============
|
||||
- Start of the project
|
||||
|
||||
315
src/LICENSE
Normal file
315
src/LICENSE
Normal file
@@ -0,0 +1,315 @@
|
||||
Copyright (c) 2025-2026 François Dausseur
|
||||
|
||||
Licensed under the EUPL
|
||||
|
||||
|
||||
EUROPEAN UNION PUBLIC LICENCE v. 1.2
|
||||
EUPL © the European Union 2007, 2016
|
||||
|
||||
This European Union Public Licence (the 'EUPL') applies to the Work (as
|
||||
defined below) which is provided under the terms of this Licence. Any use of
|
||||
the Work, other than as authorised under this Licence is prohibited (to the
|
||||
extent such use is covered by a right of the copyright holder of the Work).
|
||||
|
||||
The Work is provided under the terms of this Licence when the Licensor (as
|
||||
defined below) has placed the following notice immediately following the
|
||||
copyright notice for the Work:
|
||||
|
||||
Licensed under the EUPL
|
||||
|
||||
or has expressed by any other means his willingness to license under the EUPL.
|
||||
|
||||
|
||||
1. Definitions
|
||||
|
||||
In this Licence, the following terms have the following meaning:
|
||||
|
||||
- 'The Licence': this Licence.
|
||||
|
||||
- 'The Original Work': the work or software distributed or communicated by the
|
||||
Licensor under this Licence, available as Source Code and also as Executable
|
||||
Code as the case may be.
|
||||
|
||||
- 'Derivative Works': the works or software that could be created by the
|
||||
Licensee, based upon the Original Work or modifications thereof. This Licence
|
||||
does not define the extent of modification or dependence on the Original
|
||||
Work required in order to classify a work as a Derivative Work; this extent
|
||||
is determined by copyright law applicable in the country mentioned in
|
||||
Article 15.
|
||||
|
||||
- 'The Work': the Original Work or its Derivative Works.
|
||||
|
||||
- 'The Source Code': the human-readable form of the Work which is the most
|
||||
convenient for people to study and modify.
|
||||
|
||||
- 'The Executable Code': any code which has generally been compiled and which
|
||||
is meant to be interpreted by a computer as a program.
|
||||
|
||||
- 'The Licensor': the natural or legal person that distributes or communicates
|
||||
the Work under the Licence.
|
||||
|
||||
- 'Contributor(s)': any natural or legal person who modifies the Work under
|
||||
the Licence, or otherwise contributes to the creation of a Derivative Work.
|
||||
|
||||
- 'The Licensee' or 'You': any natural or legal person who makes any usage of
|
||||
the Work under the terms of the Licence.
|
||||
|
||||
- 'Distribution' or 'Communication': any act of selling, giving, lending,
|
||||
renting, distributing, communicating, transmitting, or otherwise making
|
||||
available, online or offline, copies of the Work or providing access to its
|
||||
essential functionalities at the disposal of any other natural or legal
|
||||
person.
|
||||
|
||||
|
||||
2. Scope of the rights granted by the Licence
|
||||
|
||||
The Licensor hereby grants You a worldwide, royalty-free, non-exclusive,
|
||||
sublicensable licence to do the following, for the duration of copyright
|
||||
vested in the Original Work:
|
||||
|
||||
- use the Work in any circumstance and for all usage,
|
||||
- reproduce the Work,
|
||||
- modify the Work, and make Derivative Works based upon the Work,
|
||||
- communicate to the public, including the right to make available or display
|
||||
the Work or copies thereof to the public and perform publicly, as the case
|
||||
may be, the Work,
|
||||
- distribute the Work or copies thereof,
|
||||
- lend and rent the Work or copies thereof,
|
||||
- sublicense rights in the Work or copies thereof.
|
||||
|
||||
Those rights can be exercised on any media, supports and formats, whether now
|
||||
known or later invented, as far as the applicable law permits so.
|
||||
|
||||
In the countries where moral rights apply, the Licensor waives his right to
|
||||
exercise his moral right to the extent allowed by law in order to make
|
||||
effective the licence of the economic rights here above listed.
|
||||
|
||||
The Licensor grants to the Licensee royalty-free, non-exclusive usage rights
|
||||
to any patents held by the Licensor, to the extent necessary to make use of
|
||||
the rights granted on the Work under this Licence.
|
||||
|
||||
|
||||
3. Communication of the Source Code
|
||||
|
||||
The Licensor may provide the Work either in its Source Code form, or as
|
||||
Executable Code. If the Work is provided as Executable Code, the Licensor
|
||||
provides in addition a machine-readable copy of the Source Code of the Work
|
||||
along with each copy of the Work that the Licensor distributes or indicates,
|
||||
in a notice following the copyright notice attached to the Work, a repository
|
||||
where the Source Code is easily and freely accessible for as long as the
|
||||
Licensor continues to distribute or communicate the Work.
|
||||
|
||||
|
||||
4. Limitations on copyright
|
||||
|
||||
Nothing in this Licence is intended to deprive the Licensee of the benefits
|
||||
from any exception or limitation to the exclusive rights of the rights owners
|
||||
in the Work, of the exhaustion of those rights or of other applicable
|
||||
limitations thereto.
|
||||
|
||||
|
||||
5. Obligations of the Licensee
|
||||
|
||||
The grant of the rights mentioned above is subject to some restrictions and
|
||||
obligations imposed on the Licensee. Those obligations are the following:
|
||||
|
||||
Attribution right: The Licensee shall keep intact all copyright, patent or
|
||||
trademarks notices and all notices that refer to the Licence and to the
|
||||
disclaimer of warranties. The Licensee must include a copy of such notices
|
||||
and a copy of the Licence with every copy of the Work he/she distributes or
|
||||
communicates. The Licensee must cause any Derivative Work to carry prominent
|
||||
notices stating that the Work has been modified and the date of modification.
|
||||
|
||||
Copyleft clause: If the Licensee distributes or communicates copies of the
|
||||
Original Works or Derivative Works, this Distribution or Communication will
|
||||
be done under the terms of this Licence or of a later version of this Licence
|
||||
unless the Original Work is expressly distributed only under this version of
|
||||
the Licence — for example by communicating 'EUPL v. 1.2 only'. The Licensee
|
||||
(becoming Licensor) cannot offer or impose any additional terms or conditions
|
||||
on the Work or Derivative Work that alter or restrict the terms of the
|
||||
Licence.
|
||||
|
||||
Compatibility clause: If the Licensee Distributes or Communicates Derivative
|
||||
Works or copies thereof based upon both the Work and another work licensed
|
||||
under a Compatible Licence, this Distribution or Communication can be done
|
||||
under the terms of this Compatible Licence. For the sake of this clause,
|
||||
'Compatible Licence' refers to the licences listed in the appendix attached
|
||||
to this Licence. Should the Licensee's obligations under the Compatible
|
||||
Licence conflict with his/her obligations under this Licence, the obligations
|
||||
of the Compatible Licence shall prevail.
|
||||
|
||||
Provision of Source Code: When distributing or communicating copies of the
|
||||
Work, the Licensee will provide a machine-readable copy of the Source Code or
|
||||
indicate a repository where this Source will be easily and freely available
|
||||
for as long as the Licensee continues to distribute or communicate the Work.
|
||||
|
||||
Legal Protection: This Licence does not grant permission to use the trade
|
||||
names, trademarks, service marks, or names of the Licensor, except as
|
||||
required for reasonable and customary use in describing the origin of the
|
||||
Work and reproducing the content of the copyright notice.
|
||||
|
||||
|
||||
6. Chain of Authorship
|
||||
|
||||
The original Licensor warrants that the copyright in the Original Work
|
||||
granted hereunder is owned by him/her or licensed to him/her and that he/she
|
||||
has the power and authority to grant the Licence.
|
||||
|
||||
Each Contributor warrants that the copyright in the modifications he/she
|
||||
brings to the Work are owned by him/her or licensed to him/her and that
|
||||
he/she has the power and authority to grant the Licence.
|
||||
|
||||
Each time You accept the Licence, the original Licensor and subsequent
|
||||
Contributors grant You a licence to their contributions to the Work, under
|
||||
the terms of this Licence.
|
||||
|
||||
|
||||
7. Disclaimer of Warranty
|
||||
|
||||
The Work is a work in progress, which is continuously improved by numerous
|
||||
Contributors. It is not a finished work and may therefore contain defects or
|
||||
'bugs' inherent to this type of development.
|
||||
|
||||
For the above reason, the Work is provided under the Licence on an 'as is'
|
||||
basis and without warranties of any kind concerning the Work, including
|
||||
without limitation merchantability, fitness for a particular purpose, absence
|
||||
of defects or errors, accuracy, non-infringement of intellectual property
|
||||
rights other than copyright as stated in Article 6 of this Licence.
|
||||
|
||||
This disclaimer of warranty is an essential part of the Licence and a
|
||||
condition for the grant of any rights to the Work.
|
||||
|
||||
|
||||
8. Disclaimer of Liability
|
||||
|
||||
Except in the cases of wilful misconduct or damages directly caused to
|
||||
natural persons, the Licensor will in no event be liable for any direct or
|
||||
indirect, material or moral, damages of any kind, arising out of the Licence
|
||||
or of the use of the Work, including without limitation, damages for loss of
|
||||
goodwill, work stoppage, computer failure or malfunction, loss of data or any
|
||||
commercial damage, even if the Licensor has been advised of the possibility
|
||||
of such damage. However, the Licensor will be liable under statutory product
|
||||
liability laws as far such laws apply to the Work.
|
||||
|
||||
|
||||
9. Additional agreements
|
||||
|
||||
While distributing the Work, You may choose to conclude an additional
|
||||
agreement, defining obligations or services consistent with this Licence.
|
||||
However, if accepting obligations, You may act only on your own behalf and on
|
||||
your sole responsibility, not on behalf of the original Licensor or any other
|
||||
Contributor, and only if You agree to indemnify, defend, and hold each
|
||||
Contributor harmless for any liability incurred by, or claims asserted
|
||||
against such Contributor by the fact You have accepted any warranty or
|
||||
additional liability.
|
||||
|
||||
|
||||
10. Acceptance of the Licence
|
||||
|
||||
The provisions of this Licence can be accepted by clicking on an icon 'I
|
||||
agree' placed under the bottom of a window displaying the text of this
|
||||
Licence or by affirming consent in any other similar way, in accordance with
|
||||
the rules of applicable law. Clicking on that icon indicates your clear and
|
||||
irrevocable acceptance of this Licence and all of its terms and conditions.
|
||||
|
||||
Similarly, you irrevocably accept this Licence and all of its terms and
|
||||
conditions by exercising any rights granted to You by Article 2 of this
|
||||
Licence, such as the use of the Work, the creation by You of a Derivative
|
||||
Work or the Distribution or Communication by You of the Work or copies
|
||||
thereof.
|
||||
|
||||
|
||||
11. Information to the public
|
||||
|
||||
In case of any Distribution or Communication of the Work by means of
|
||||
electronic communication by You (for example, by offering to download the
|
||||
Work from a remote location) the distribution channel or media (for example,
|
||||
a website) must at least provide to the public the information requested by
|
||||
the applicable law regarding the Licensor, the Licence and the way it may be
|
||||
accessible, concluded, stored and reproduced by the Licensee.
|
||||
|
||||
|
||||
12. Termination of the Licence
|
||||
|
||||
The Licence and the rights granted hereunder will terminate automatically
|
||||
upon any breach by the Licensee of the terms of the Licence.
|
||||
|
||||
Such a termination will not terminate the licences of any person who has
|
||||
received the Work from the Licensee under the Licence, provided such persons
|
||||
remain in full compliance with the Licence.
|
||||
|
||||
|
||||
13. Miscellaneous
|
||||
|
||||
Without prejudice of Article 9 above, the Licence represents the complete
|
||||
agreement between the Parties as to the Work.
|
||||
|
||||
If any provision of the Licence is invalid or unenforceable under applicable
|
||||
law, this will not affect the validity or enforceability of the Licence as a
|
||||
whole. Such provision will be construed or reformed so as necessary to make
|
||||
it valid and enforceable.
|
||||
|
||||
The European Commission may publish other linguistic versions or new versions
|
||||
of this Licence or updated versions of the Appendix, so far this is required
|
||||
and reasonable, without reducing the scope of the rights granted by the
|
||||
Licence. New versions of the Licence will be published with a unique version
|
||||
number.
|
||||
|
||||
All linguistic versions of this Licence, approved by the European Commission,
|
||||
have identical value. Parties can take advantage of the linguistic version of
|
||||
their choice.
|
||||
|
||||
|
||||
14. Jurisdiction
|
||||
|
||||
Without prejudice to specific agreement between parties,
|
||||
|
||||
- any litigation resulting from the interpretation of this License, arising
|
||||
between the European Union institutions, bodies, offices or agencies, as a
|
||||
Licensor, and any Licensee, will be subject to the jurisdiction of the
|
||||
Court of Justice of the European Union, as laid down in article 272 of the
|
||||
Treaty on the Functioning of the European Union,
|
||||
|
||||
- any litigation arising between other parties and resulting from the
|
||||
interpretation of this License, will be subject to the exclusive
|
||||
jurisdiction of the competent court where the Licensor resides or conducts
|
||||
its primary business.
|
||||
|
||||
|
||||
15. Applicable Law
|
||||
|
||||
Without prejudice to specific agreement between parties,
|
||||
|
||||
- this Licence shall be governed by the law of the European Union Member
|
||||
State where the Licensor has his seat, resides or has his registered
|
||||
office,
|
||||
|
||||
- this licence shall be governed by Belgian law if the Licensor has no seat,
|
||||
residence or registered office inside a European Union Member State.
|
||||
|
||||
|
||||
Appendix
|
||||
|
||||
|
||||
'Compatible Licences' according to Article 5 EUPL are:
|
||||
|
||||
- GNU General Public License (GPL) v. 2, v. 3
|
||||
- GNU Affero General Public License (AGPL) v. 3
|
||||
- Open Software License (OSL) v. 2.1, v. 3.0
|
||||
- Eclipse Public License (EPL) v. 1.0
|
||||
- CeCILL v. 2.0, v. 2.1
|
||||
- Mozilla Public Licence (MPL) v. 2
|
||||
- GNU Lesser General Public Licence (LGPL) v. 2.1, v. 3
|
||||
- Creative Commons Attribution-ShareAlike v. 3.0 Unported (CC BY-SA 3.0) for
|
||||
works other than software
|
||||
- European Union Public Licence (EUPL) v. 1.1, v. 1.2
|
||||
- Québec Free and Open-Source Licence — Reciprocity (LiLiQ-R) or Strong
|
||||
Reciprocity (LiLiQ-R+).
|
||||
|
||||
The European Commission may update this Appendix to later versions of the
|
||||
above licences without producing a new version of the EUPL, as long as they
|
||||
provide the rights granted in Article 2 of this Licence and protect the
|
||||
covered Source Code from exclusive appropriation.
|
||||
|
||||
All other changes or additions to this Appendix require the production of a
|
||||
new EUPL version.
|
||||
@@ -1 +1 @@
|
||||
0.1
|
||||
0.1.2
|
||||
@@ -1,5 +1,6 @@
|
||||
import sys
|
||||
import os
|
||||
import queue
|
||||
import multiprocessing as mp
|
||||
from threading import Timer
|
||||
from time import sleep, monotonic
|
||||
@@ -367,7 +368,7 @@ class RuntimePlot:
|
||||
self.msg_queue_in.get()
|
||||
self.msg_queue_out.put({"command": "last_values"})
|
||||
try:
|
||||
res = self.msg_queue_in.get(timeout=1)
|
||||
except:
|
||||
res = self.msg_queue_in.get(timeout=5)
|
||||
except queue.Empty:
|
||||
raise ETUMRuntimeError(f"Impossible to retrieve the last values of the \"{self.name}\" plot")
|
||||
return res
|
||||
|
||||
@@ -10,6 +10,8 @@ import os
|
||||
def setup():
|
||||
"""Configure the Qt environment for dialog subprocess usage."""
|
||||
if sys.platform.startswith('linux'):
|
||||
# On Linux/Wayland, force X11 (via XWayland) to avoid crashes
|
||||
# when Qt is initialized inside a multiprocessing subprocess.
|
||||
os.environ['QT_QPA_PLATFORM'] = 'xcb'
|
||||
if os.environ.get('DISPLAY'):
|
||||
# X11 available: force xcb to avoid crashes in multiprocessing subprocesses.
|
||||
os.environ['QT_QPA_PLATFORM'] = 'xcb'
|
||||
elif os.environ.get('WAYLAND_DISPLAY'):
|
||||
os.environ['QT_QPA_PLATFORM'] = 'wayland'
|
||||
|
||||
@@ -13,6 +13,32 @@ from interpreter.utils.constants import TestItemType as cst
|
||||
from runtime.tum_except import ETUMSyntaxError, ETUMRuntimeError, item_load_context
|
||||
|
||||
|
||||
def _testium_launch_cmd():
|
||||
"""Command prefix to launch a fresh testium instance, runtime-aware.
|
||||
|
||||
AppImage / Flatpak / PyInstaller / wheel / source all need a different
|
||||
entry point than just the path to __main__.py (which may be a .py inside
|
||||
a read-only bundle, or unreachable from the sub-instance's cwd).
|
||||
"""
|
||||
# AppImage: the env var holds the path to the .AppImage file itself.
|
||||
appimage = os.environ.get("APPIMAGE")
|
||||
if appimage:
|
||||
return [appimage]
|
||||
# Flatpak: re-launch via the Flatpak app id.
|
||||
if os.path.isfile("/.flatpak-info"):
|
||||
return ["flatpak", "run", "org.testium.Testium"]
|
||||
# PyInstaller frozen exe: sys.executable is the binary itself.
|
||||
if getattr(sys, "frozen", False):
|
||||
return [sys.executable]
|
||||
# Source / wheel: re-use the same Python with the same entry point that
|
||||
# launched this instance, made absolute so cwd changes in the sub-instance
|
||||
# don't break the lookup. argv[0] is either:
|
||||
# - the package directory (source: `python3 src/testium ...`)
|
||||
# - the console_scripts wrapper (wheel: `/usr/bin/testium`)
|
||||
# Both are runnable as `python <argv0>`.
|
||||
return [sys.executable, os.path.abspath(sys.argv[0])]
|
||||
|
||||
|
||||
def nowInBetween(start, end):
|
||||
"""
|
||||
Check wether current time is within boundaries
|
||||
@@ -33,8 +59,6 @@ class TestItemRun(TestItem):
|
||||
with item_load_context(self.cmd(), self.name(), self.seqFilename()):
|
||||
self.tum_file = self._prms.getParam('tum', required=True)
|
||||
self.param_file = self._prms.getParam('param_file', default='')
|
||||
self.python_bin = self._prms.getParam('python_bin', default='')
|
||||
self.testium_path = self._prms.getParam('testium_path', default='')
|
||||
self.log_path = self._prms.getParam('log_file', default='')
|
||||
self.report_path = self._prms.getParam('report_file', default='')
|
||||
self.start_time = self._prms.getParam('start_time')
|
||||
@@ -52,18 +76,9 @@ class TestItemRun(TestItem):
|
||||
'"{}" file could not be found'.format(file_path))
|
||||
self.tum_file = file_path
|
||||
pf = self._prms.expanse(self.param_file)
|
||||
pp = self._prms.expanse(self.python_bin)
|
||||
sp = self._prms.expanse(self.testium_path)
|
||||
lp = self._prms.expanse(self.log_path)
|
||||
rp = self._prms.expanse(self.report_path)
|
||||
cmd = []
|
||||
if sp == '':
|
||||
sp = sys.argv[0]
|
||||
if pp != '':
|
||||
cmd.append(pp)
|
||||
elif not os.path.isfile(sp) or not os.access(sp, os.X_OK):
|
||||
cmd.append(sys.executable)
|
||||
cmd.append(sp)
|
||||
cmd = _testium_launch_cmd()
|
||||
if tm.text_mode():
|
||||
cmd.append("-b")
|
||||
else:
|
||||
|
||||
@@ -17,7 +17,7 @@ Public API
|
||||
``reset()`` : clear the cache (mostly useful for tests)
|
||||
"""
|
||||
|
||||
import shutil
|
||||
import os
|
||||
import subprocess
|
||||
|
||||
import api.testium as tm
|
||||
@@ -30,10 +30,126 @@ from runtime.tum_except import ETUMRuntimeError
|
||||
_PYTHON_CANDIDATES = ["python3", "python"]
|
||||
_LUA_CANDIDATES = ["lua", "lua5.5", "lua5.4", "lua5.3", "lua5.2", "lua5.1"]
|
||||
|
||||
# When running inside a Flatpak, --filesystem=host-os mounts the host at
|
||||
# /run/host (read-only). Binaries and libraries from the host are not on the
|
||||
# sandbox PATH/LD_LIBRARY_PATH, so we probe and inject them explicitly.
|
||||
_FLATPAK_HOST_DIRS = [
|
||||
"/run/host/usr/local/bin",
|
||||
"/run/host/usr/bin",
|
||||
"/run/host/bin",
|
||||
]
|
||||
_FLATPAK_HOST_LIB_DIRS = [
|
||||
"/run/host/usr/lib",
|
||||
"/run/host/usr/lib64",
|
||||
"/run/host/usr/local/lib",
|
||||
]
|
||||
|
||||
# Inside an AppImage, AppRun prepends $APPDIR/usr/bin to PATH and exports a
|
||||
# bundle-local PYTHONHOME / PYTHONPATH / LD_LIBRARY_PATH. We want py_func and
|
||||
# lua_func to run under the *host* interpreter (not the bundled one), so we
|
||||
# probe standard host bin dirs directly and scrub APPDIR-prefixed entries from
|
||||
# the env passed to host subprocesses.
|
||||
_APPIMAGE_HOST_DIRS = [
|
||||
"/usr/local/bin",
|
||||
"/usr/bin",
|
||||
"/bin",
|
||||
]
|
||||
|
||||
|
||||
def _in_flatpak():
|
||||
return os.path.isfile("/.flatpak-info")
|
||||
|
||||
|
||||
def _in_appimage():
|
||||
return "APPIMAGE" in os.environ
|
||||
|
||||
|
||||
def apply_host_lua_paths(env):
|
||||
"""Prepend host Lua module dirs to LUA_PATH / LUA_CPATH (Flatpak only).
|
||||
|
||||
Must be called after user-defined lua_env overrides are applied, so host
|
||||
paths are always first regardless of user config. User-defined paths remain
|
||||
in the variable but after the host ones.
|
||||
"""
|
||||
if not _in_flatpak():
|
||||
return
|
||||
_LUA_VERSIONS = ["5.5", "5.4", "5.3", "5.2", "5.1"]
|
||||
_HOST = "/run/host/usr"
|
||||
cpath_dirs, lpath_dirs = [], []
|
||||
for v in _LUA_VERSIONS:
|
||||
for base in [f"{_HOST}/lib/lua/{v}",
|
||||
f"{_HOST}/lib64/lua/{v}",
|
||||
f"{_HOST}/lib/x86_64-linux-gnu/lua/{v}"]:
|
||||
cpath_dirs.append(f"{base}/?.so")
|
||||
lpath_dirs.append(f"{_HOST}/share/lua/{v}/?.lua")
|
||||
lpath_dirs.append(f"{_HOST}/share/lua/{v}/?/init.lua")
|
||||
sep = ";"
|
||||
host_cpath = sep.join(cpath_dirs)
|
||||
host_lpath = sep.join(lpath_dirs)
|
||||
# ;; keeps Lua's compiled-in defaults at the end as last resort
|
||||
env["LUA_CPATH"] = host_cpath + sep + env.get("LUA_CPATH", ";;")
|
||||
env["LUA_PATH"] = host_lpath + sep + env.get("LUA_PATH", ";;")
|
||||
|
||||
|
||||
def apply_host_libs(env):
|
||||
"""Prepare *env* for launching a host binary from inside our bundle.
|
||||
|
||||
- Flatpak: prepend host library dirs to LD_LIBRARY_PATH so the dynamic
|
||||
linker can find host .so files mounted under /run/host.
|
||||
- AppImage: strip $APPDIR-prefixed entries from LD_LIBRARY_PATH and
|
||||
PYTHONPATH and drop PYTHONHOME, so the host interpreter doesn't try
|
||||
to load the bundled (incompatible) Python lib/site-packages.
|
||||
- Otherwise: no-op.
|
||||
"""
|
||||
if _in_flatpak():
|
||||
dirs = ":".join(d for d in _FLATPAK_HOST_LIB_DIRS if os.path.isdir(d))
|
||||
if dirs:
|
||||
existing = env.get("LD_LIBRARY_PATH", "")
|
||||
env["LD_LIBRARY_PATH"] = dirs + (":" + existing if existing else "")
|
||||
return
|
||||
if _in_appimage():
|
||||
appdir = os.environ.get("APPDIR", "")
|
||||
if appdir:
|
||||
for var, sep in (("LD_LIBRARY_PATH", ":"),
|
||||
("PYTHONPATH", os.pathsep),
|
||||
("PATH", os.pathsep)):
|
||||
cur = env.get(var, "")
|
||||
if not cur:
|
||||
continue
|
||||
cleaned = sep.join(
|
||||
p for p in cur.split(sep)
|
||||
if p and not p.startswith(appdir)
|
||||
)
|
||||
if cleaned:
|
||||
env[var] = cleaned
|
||||
else:
|
||||
env.pop(var, None)
|
||||
env.pop("PYTHONHOME", None)
|
||||
|
||||
|
||||
def _which(name):
|
||||
func = sys_app_path_win if tm.OS() == "Windows" else sys_app_path_lin
|
||||
return func(name)
|
||||
if tm.OS() == "Windows":
|
||||
return sys_app_path_win(name)
|
||||
if _in_flatpak():
|
||||
for d in _FLATPAK_HOST_DIRS:
|
||||
p = os.path.join(d, name)
|
||||
if os.path.isfile(p) and os.access(p, os.X_OK):
|
||||
return p
|
||||
return ""
|
||||
if _in_appimage():
|
||||
for d in _APPIMAGE_HOST_DIRS:
|
||||
p = os.path.join(d, name)
|
||||
if os.path.isfile(p) and os.access(p, os.X_OK):
|
||||
return p
|
||||
return ""
|
||||
return sys_app_path_lin(name)
|
||||
|
||||
|
||||
def _probe_env():
|
||||
"""Subprocess env for probing host binaries (adds host libs in Flatpak)."""
|
||||
env = os.environ.copy()
|
||||
apply_host_libs(env)
|
||||
return env
|
||||
|
||||
|
||||
def _python_version(path):
|
||||
@@ -41,7 +157,7 @@ def _python_version(path):
|
||||
try:
|
||||
r = subprocess.run(
|
||||
cmd, capture_output=True, text=True,
|
||||
encoding=tm.sys_encoding(), timeout=10,
|
||||
encoding=tm.sys_encoding(), timeout=10, env=_probe_env(),
|
||||
)
|
||||
except (FileNotFoundError, PermissionError, subprocess.TimeoutExpired):
|
||||
return None
|
||||
@@ -60,6 +176,7 @@ def _lua_version(path):
|
||||
try:
|
||||
r = subprocess.run(
|
||||
[path, "-v"], capture_output=True, text=True, timeout=10,
|
||||
env=_probe_env(),
|
||||
)
|
||||
except (FileNotFoundError, PermissionError, subprocess.TimeoutExpired):
|
||||
return None
|
||||
@@ -97,8 +214,16 @@ def _resolve(name):
|
||||
|
||||
path = ""
|
||||
if override:
|
||||
if shutil.which(override) and validator(override):
|
||||
path = override
|
||||
# Absolute path: accept as-is (user knows exactly what they want).
|
||||
# Bare name: resolve via _which() so the override stays host-only in
|
||||
# Flatpak/AppImage instead of silently picking the bundled interpreter.
|
||||
if os.path.isabs(override):
|
||||
resolved = override if (os.path.isfile(override)
|
||||
and os.access(override, os.X_OK)) else ""
|
||||
else:
|
||||
resolved = _which(override)
|
||||
if resolved and validator(resolved):
|
||||
path = resolved
|
||||
else:
|
||||
tm.print_warn(
|
||||
f"Configured {display} interpreter '{override}' is not usable; "
|
||||
|
||||
@@ -8,6 +8,7 @@ from runtime.jrpc import JsonRpcClient
|
||||
from interpreter.utils.paths import subproc_path
|
||||
from runtime.tum_except import ETUMRuntimeError
|
||||
from interpreter.utils import bins
|
||||
from interpreter.utils.proc_drain import drain_to_log
|
||||
|
||||
|
||||
class LuaProcessBase:
|
||||
@@ -59,6 +60,7 @@ class LuaProcessBase:
|
||||
|
||||
lua_env = tm.gd("lua_env", {})
|
||||
env = os.environ.copy()
|
||||
bins.apply_host_libs(env)
|
||||
if not isinstance(lua_env, dict):
|
||||
raise ETUMRuntimeError(f"The 'lua_env' global value should be a dictionary. But it is '{lua_env}'.")
|
||||
|
||||
@@ -69,6 +71,7 @@ class LuaProcessBase:
|
||||
env[k] = e
|
||||
else:
|
||||
env[k] = e + ";" + env.get(k, "")
|
||||
bins.apply_host_lua_paths(env)
|
||||
|
||||
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
||||
sock.bind(("localhost", 0))
|
||||
@@ -93,10 +96,14 @@ class LuaProcessBase:
|
||||
self._process = subprocess.Popen(
|
||||
params, env=env, cwd=func_proc_path,
|
||||
stdin=subprocess.DEVNULL,
|
||||
stdout=subprocess.DEVNULL,
|
||||
stderr=subprocess.DEVNULL,
|
||||
stdout=subprocess.PIPE,
|
||||
stderr=subprocess.PIPE,
|
||||
restore_signals=False,
|
||||
)
|
||||
# Route subprocess stdout/stderr (lua require failures, syntax
|
||||
# errors, anything written to fd 1/2 before the in-script
|
||||
# remote_print is set up) into the parent's log.
|
||||
drain_to_log(self._process, prefix="[lua_func] ")
|
||||
|
||||
self._rpc = JsonRpcClient(
|
||||
"localhost", self._port, req_handler=self._req_handler
|
||||
|
||||
48
src/testium/interpreter/utils/proc_drain.py
Normal file
48
src/testium/interpreter/utils/proc_drain.py
Normal file
@@ -0,0 +1,48 @@
|
||||
"""Drain a subprocess stdout/stderr into testium's print pipeline.
|
||||
|
||||
Captured lines go through the parent's stdio_redir, so they reach the
|
||||
test log AND the live output (terminal in batch mode, GUI text panel
|
||||
in -r mode). This is essential for diagnosing early-startup errors
|
||||
of py_func / lua_func subprocesses (missing modules, unhandled
|
||||
exceptions before the in-process redirection kicks in, lua
|
||||
``require`` failures, anything written to fd 1/2 directly).
|
||||
"""
|
||||
import threading
|
||||
|
||||
|
||||
def _drain_pipe(pipe, prefix):
|
||||
try:
|
||||
for raw in iter(pipe.readline, b""):
|
||||
line = raw.decode("utf-8", errors="replace").rstrip("\r\n")
|
||||
if not line:
|
||||
continue
|
||||
if prefix:
|
||||
print(f"{prefix}{line}")
|
||||
else:
|
||||
print(line)
|
||||
finally:
|
||||
try:
|
||||
pipe.close()
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
|
||||
def drain_to_log(process, prefix=""):
|
||||
"""Spawn daemon threads that read ``process.stdout`` and
|
||||
``process.stderr`` line by line and print each line through the
|
||||
parent's stdout (so it reaches the log + live output).
|
||||
|
||||
Each thread exits cleanly when the subprocess closes the
|
||||
corresponding pipe (i.e. when it exits). Daemon flag ensures they
|
||||
do not block testium exit.
|
||||
"""
|
||||
threads = []
|
||||
for pipe in (process.stdout, process.stderr):
|
||||
if pipe is None:
|
||||
continue
|
||||
t = threading.Thread(
|
||||
target=_drain_pipe, args=(pipe, prefix), daemon=True,
|
||||
)
|
||||
t.start()
|
||||
threads.append(t)
|
||||
return threads
|
||||
@@ -7,6 +7,7 @@ import api.testium as tm
|
||||
from runtime.tum_except import ETUMRuntimeError
|
||||
from interpreter.utils.paths import testium_path, subproc_path
|
||||
from interpreter.utils import bins
|
||||
from interpreter.utils.proc_drain import drain_to_log
|
||||
|
||||
|
||||
class PyProcessBase:
|
||||
@@ -41,6 +42,10 @@ class PyProcessBase:
|
||||
raise ETUMRuntimeError(f"The 'py_env' global value should be a dictionary. But it is '{py_env}'.")
|
||||
|
||||
env = os.environ.copy()
|
||||
bins.apply_host_libs(env)
|
||||
# PYTHONUSERBASE is set by the Flatpak runtime to isolate sandbox
|
||||
# user packages; remove it so the host Python finds ~/.local packages.
|
||||
env.pop("PYTHONUSERBASE", None)
|
||||
for k, v in self.CUST_ENV.items():
|
||||
e = py_env.get(k, "")
|
||||
if e != "":
|
||||
@@ -77,10 +82,15 @@ class PyProcessBase:
|
||||
self._process = subprocess.Popen(
|
||||
params, env=env, cwd=func_proc_path,
|
||||
stdin=subprocess.DEVNULL,
|
||||
stdout=subprocess.DEVNULL,
|
||||
stderr=subprocess.DEVNULL,
|
||||
stdout=subprocess.PIPE,
|
||||
stderr=subprocess.PIPE,
|
||||
restore_signals=False,
|
||||
)
|
||||
# Route subprocess stdout/stderr (early-startup errors,
|
||||
# unhandled exceptions, anything written to fd 1/2 before the
|
||||
# in-process JSON-RPC stdio_redir kicks in) into the parent's
|
||||
# log.
|
||||
drain_to_log(self._process, prefix="[py_func] ")
|
||||
|
||||
self._rpc = JsonRpcClient(
|
||||
"localhost", self._port, req_handler=self._req_handler
|
||||
|
||||
@@ -31,39 +31,47 @@ def get_version(path :str)-> str:
|
||||
return "Warning git not supported in your settings, version of {} unknown".format(path)
|
||||
|
||||
def get_testium_version():
|
||||
# case where we're executing from an Appimage
|
||||
if 'APPIMAGE' in os.environ:
|
||||
ver = 'unknown'
|
||||
if 'SEQUENCER_REV' in os.environ:
|
||||
ver = os.getenv('SEQUENCER_REV')
|
||||
return (ver + " (binary release)")
|
||||
# Flatpak bundle
|
||||
if os.path.isfile('/.flatpak-info'):
|
||||
ver = os.environ.get('TESTIUM_VERSION', '').strip()
|
||||
return (ver if ver else 'unknown') + " (flatpak release)"
|
||||
|
||||
# case where we're executing from pyinstaller exe
|
||||
# AppImage
|
||||
if 'APPIMAGE' in os.environ:
|
||||
ver = os.environ.get('TESTIUM_VERSION', '').strip()
|
||||
return (ver if ver else 'unknown') + " (binary release)"
|
||||
|
||||
# PyInstaller frozen exe
|
||||
if getattr(sys, 'frozen', False):
|
||||
file_path = os.path.join(sys._MEIPASS, "VERSION")
|
||||
with open(file_path, 'r') as file:
|
||||
ver = file.read()
|
||||
return (ver + " (binary release)")
|
||||
try:
|
||||
with open(file_path, 'r') as f:
|
||||
ver = f.read().strip()
|
||||
return ver + " (binary release)"
|
||||
except OSError:
|
||||
return "unknown (binary release)"
|
||||
|
||||
# Executed from sources
|
||||
try:
|
||||
if prefs.settings.git_supported:
|
||||
# Source checkout: prefer git revision when available
|
||||
if prefs.settings.git_supported:
|
||||
try:
|
||||
git = import_module("git")
|
||||
path = tm.get_main_dir()
|
||||
try:
|
||||
return repo_rev(path)
|
||||
except git.InvalidGitRepositoryError:
|
||||
pkg_rec = import_module("pkg_resources")
|
||||
try:
|
||||
ret = pkg_rec.get_distribution("testium").version
|
||||
_cached_versions.update({path: ret})
|
||||
return str(ret) + " (wheel release)"
|
||||
except:
|
||||
return "Warning : testium not versioned"
|
||||
else:
|
||||
return "Warning git not supported in your settings, version of testium is unknown."
|
||||
except:
|
||||
return ("Unknown")
|
||||
return repo_rev(tm.get_main_dir())
|
||||
except Exception:
|
||||
# Not a git repo (typical pip install): fall through.
|
||||
pass
|
||||
|
||||
# Pip-installed wheel: use the package metadata baked from VERSION
|
||||
try:
|
||||
from importlib.metadata import version as _pkg_version
|
||||
from importlib.metadata import PackageNotFoundError
|
||||
try:
|
||||
return _pkg_version("testium") + " (wheel release)"
|
||||
except PackageNotFoundError:
|
||||
pass
|
||||
except ImportError:
|
||||
pass
|
||||
|
||||
return "unknown"
|
||||
|
||||
def get_modifications(path : str)-> str:
|
||||
|
||||
|
||||
@@ -212,8 +212,17 @@ class TestFileManager:
|
||||
d = ""
|
||||
if w.testFile is not None:
|
||||
d = os.path.dirname(w.testFile)
|
||||
# In Flatpak the native dialog goes through the XDG document portal,
|
||||
# which returns /run/user/UID/doc/.../test.tum and only exposes the
|
||||
# selected file — sibling files (param.yaml, .py, etc.) are unreachable.
|
||||
# Force Qt's own dialog, which walks the real filesystem mounted via
|
||||
# --filesystem=home and returns a regular path with sibling access.
|
||||
options = QFileDialog.Options()
|
||||
if os.path.isfile("/.flatpak-info"):
|
||||
options |= QFileDialog.Option.DontUseNativeDialog
|
||||
file_name, _ = QFileDialog.getOpenFileName(
|
||||
w, "Open the test file", d, "testium file (*.tum);;All Files (*)"
|
||||
w, "Open the test file", d,
|
||||
"testium file (*.tum);;All Files (*)", options=options
|
||||
)
|
||||
if file_name:
|
||||
self.reload(file_name)
|
||||
|
||||
@@ -8,16 +8,20 @@ def exception_handler(typ_exc, value, trbk):
|
||||
print(f"Critical failure : '{value}'.")
|
||||
tb = traceback.format_exception(typ_exc, value, trbk)
|
||||
print("".join(tb))
|
||||
print(f" python : {sys.executable}")
|
||||
print(f" sys.path : {sys.path}")
|
||||
|
||||
sys.excepthook = exception_handler
|
||||
|
||||
p = Path(__file__)
|
||||
p = p.parent / ".."
|
||||
p = p.resolve()
|
||||
|
||||
sys.path.append(p)
|
||||
# Make the parent directory of py_func/ (= the testium package dir, which also
|
||||
# contains runtime/, lua_func/, …) the first entry on sys.path so `from py_func
|
||||
# import main` and `from runtime…` resolve regardless of cwd or how this script
|
||||
# was invoked. str() because some importers don't play well with PathLike entries.
|
||||
_pkg_parent = str((Path(__file__).resolve().parent / "..").resolve())
|
||||
if _pkg_parent not in sys.path:
|
||||
sys.path.insert(0, _pkg_parent)
|
||||
|
||||
from py_func import main
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
main()
|
||||
|
||||
Reference in New Issue
Block a user