Compare commits
6 Commits
feature/ls
...
v0.2
| Author | SHA1 | Date | |
|---|---|---|---|
| e989d131ad | |||
| cc561e961a | |||
| 87066fabd6 | |||
| bd1cd03334 | |||
| 63467c17c3 | |||
| 7b569df202 |
32
README.md
32
README.md
@@ -27,6 +27,27 @@ Pre-built artifacts are published at
|
||||
runnable directly, no Python installation required on the host. Lua
|
||||
support still needs a system `lua` interpreter and the `lua-socket` /
|
||||
`lua-cjson` modules.
|
||||
* **AppImage** (`Testium-<version>-x86_64.AppImage`) — single-file
|
||||
Linux binary, runnable directly:
|
||||
|
||||
```sh
|
||||
chmod +x Testium-*-x86_64.AppImage
|
||||
./Testium-*-x86_64.AppImage
|
||||
```
|
||||
|
||||
Requires `libfuse2` on the host (FUSE 2 — distinct from `fuse3`, which
|
||||
most distros now ship by default):
|
||||
|
||||
| Distro | Package |
|
||||
|--------|---------|
|
||||
| Arch / CachyOS / Manjaro | `fuse2` |
|
||||
| Debian trixie / Ubuntu 24.04+ | `libfuse2t64` |
|
||||
| Debian bookworm / Ubuntu 22.04 | `libfuse2` |
|
||||
| Fedora | `fuse-libs` |
|
||||
|
||||
If you can't install libfuse2 (e.g. minimal container), prefix the
|
||||
invocation with `APPIMAGE_EXTRACT_AND_RUN=1` — the AppImage will
|
||||
self-extract to `/tmp` on each run instead of FUSE-mounting.
|
||||
* **Flatpak bundle** (`testium.flatpak`) — install with:
|
||||
|
||||
```sh
|
||||
@@ -41,17 +62,6 @@ Pre-built artifacts are published at
|
||||
`testium` command is available in the terminal (requires `~/.local/bin` in
|
||||
`PATH`, which most modern distributions provide by default).
|
||||
|
||||
* **AppImage** (`Testium-<version>-x86_64.AppImage`) — a single self-contained
|
||||
executable bundling its own Python. Make it executable and run it:
|
||||
|
||||
```sh
|
||||
chmod +x Testium-*-x86_64.AppImage
|
||||
./Testium-*-x86_64.AppImage -b mytest.tum
|
||||
```
|
||||
|
||||
As with the binary and Flatpak, `py_func` / `lua_func` items run under the
|
||||
*host* Python / Lua so your own modules stay visible.
|
||||
|
||||
Every channel ships the language server, so `testium lsp` (see
|
||||
[Editor support](#editor-support)) works out of the box from any of them.
|
||||
|
||||
|
||||
@@ -23,3 +23,47 @@ graphical interface.
|
||||
:caption: call a test in batch mode
|
||||
|
||||
testium -b test/my_test/main.tum
|
||||
|
||||
.. _sec_language_server:
|
||||
|
||||
Language server (editor support)
|
||||
--------------------------------
|
||||
|
||||
*testium* ships a `Language Server Protocol
|
||||
<https://microsoft.github.io/language-server-protocol/>`_ server so that
|
||||
``.tum`` files get editor assistance — completion of test item types, hover
|
||||
documentation of their parameters, and an outline view — in any LSP-capable
|
||||
editor.
|
||||
|
||||
The server speaks LSP over standard input/output and is started with:
|
||||
|
||||
.. code-block:: text
|
||||
:caption: start the language server
|
||||
|
||||
testium lsp
|
||||
|
||||
It is not meant to be launched directly by the user: an editor's LSP client
|
||||
spawns it and drives the exchange. A VSCode / VSCodium client extension,
|
||||
*testium_assist*, is provided for that purpose; any other LSP client (Neovim,
|
||||
Emacs ``lsp-mode``, …) can be pointed at ``testium lsp`` as well.
|
||||
|
||||
The information the server exposes is the test item schema, which can also be
|
||||
dumped as JSON for inspection or tooling:
|
||||
|
||||
.. code-block:: text
|
||||
:caption: dump the item / parameter schema
|
||||
|
||||
testium schema
|
||||
|
||||
Because the schema is built from *testium* itself, every new item type or
|
||||
parameter becomes available in the editor on the next *testium* upgrade, with
|
||||
no change to the client.
|
||||
|
||||
The language server is included in the pre-built binary, Flatpak and AppImage
|
||||
releases. For a source or wheel installation, pull the optional ``lsp``
|
||||
dependencies:
|
||||
|
||||
.. code-block:: text
|
||||
:caption: enable the language server for a wheel / source install
|
||||
|
||||
pip install 'testium[lsp]'
|
||||
|
||||
@@ -232,6 +232,15 @@ list of the main test item (and eventually of the loop test item).
|
||||
TUM file ``main`` item is itself a variant of test items with a name and an
|
||||
step list attributes.
|
||||
|
||||
.. note::
|
||||
|
||||
Each test item declares the parameters it accepts. When a ``.tum`` file
|
||||
uses a key the item does not know, *testium* emits a warning listing the
|
||||
accepted parameter names (catching typos such as ``param_filee`` for
|
||||
``param_file``); a missing **required** parameter aborts loading with an
|
||||
error pointing at the source ``.tum`` file. Valid existing tests are
|
||||
unaffected.
|
||||
|
||||
|
||||
|
||||
.. toctree::
|
||||
|
||||
@@ -1,10 +1,54 @@
|
||||
import atexit
|
||||
import os
|
||||
import stat
|
||||
import sys
|
||||
import tempfile
|
||||
from importlib import import_module
|
||||
|
||||
import interpreter.utils.settings as prefs
|
||||
import api.testium as tm
|
||||
|
||||
|
||||
# When running inside a Flatpak, the host /usr/bin/git is reachable at
|
||||
# /run/host/usr/bin/git but linked against host glibc/zlib, which the
|
||||
# sandbox can't load (``libz-ng.so.2`` not found). gitpython resolves git
|
||||
# eagerly on import and would crash the whole test run. We install a
|
||||
# tiny shell wrapper under /tmp that forwards to ``flatpak-spawn --host
|
||||
# git``, and point gitpython at it via ``GIT_PYTHON_GIT_EXECUTABLE``.
|
||||
_HOST_GIT_WRAPPER = None
|
||||
|
||||
|
||||
def _setup_flatpak_git():
|
||||
global _HOST_GIT_WRAPPER
|
||||
if not os.path.isfile("/.flatpak-info"):
|
||||
return
|
||||
if _HOST_GIT_WRAPPER is not None:
|
||||
return
|
||||
fd, path = tempfile.mkstemp(prefix="testium-git-host-", suffix=".sh", dir="/tmp")
|
||||
with os.fdopen(fd, "w") as f:
|
||||
f.write('#!/bin/sh\nexec flatpak-spawn --host git "$@"\n')
|
||||
os.chmod(path, stat.S_IRWXU)
|
||||
_HOST_GIT_WRAPPER = path
|
||||
atexit.register(_cleanup_flatpak_git)
|
||||
os.environ["GIT_PYTHON_GIT_EXECUTABLE"] = path
|
||||
# Silence gitpython's warning if its refresh probe ever still fails;
|
||||
# the wrapper itself should make the probe succeed.
|
||||
os.environ.setdefault("GIT_PYTHON_REFRESH", "quiet")
|
||||
|
||||
|
||||
def _cleanup_flatpak_git():
|
||||
global _HOST_GIT_WRAPPER
|
||||
if _HOST_GIT_WRAPPER and os.path.isfile(_HOST_GIT_WRAPPER):
|
||||
try:
|
||||
os.unlink(_HOST_GIT_WRAPPER)
|
||||
except OSError:
|
||||
pass
|
||||
_HOST_GIT_WRAPPER = None
|
||||
|
||||
|
||||
_setup_flatpak_git()
|
||||
|
||||
|
||||
_cached_versions = {}
|
||||
|
||||
def repo_rev(path):
|
||||
|
||||
@@ -97,7 +97,10 @@ case "$MODE" in
|
||||
echo "Creating wheel venv at $WHEEL_VENV"
|
||||
python3 -m venv --system-site-packages "$WHEEL_VENV"
|
||||
"$WHEEL_VENV/bin/pip" install --quiet --upgrade pip
|
||||
"$WHEEL_VENV/bin/pip" install --quiet "$WHEEL"
|
||||
# Install with the [lsp] extra so the wheel channel is validated in
|
||||
# its language-server-capable form (pulls pygls), matching how a
|
||||
# user enables `testium lsp` from a wheel: pip install testium[lsp].
|
||||
"$WHEEL_VENV/bin/pip" install --quiet "${WHEEL}[lsp]"
|
||||
fi
|
||||
CMD=("$WHEEL_VENV/bin/python" -m testium)
|
||||
;;
|
||||
|
||||
Reference in New Issue
Block a user