|
Portals0.7.0 · dev (544a5c68c72e · 2026-11-28 UTC)
|
PORTALS_RELEASE_START_TEST_TIMEOUT controls the offline release-start suite's overall CTest budget: 600 seconds by default, a positive integer up to 86400. The suite creates disposable local Git repositories and checks available PowerShell implementations; it does not publish a release. Slow disks and process startup can dominate this test. Override the budget explicitly at configure time, for example -DPORTALS_RELEASE_START_TEST_TIMEOUT=900. This budget does not change the assertions or the timeout of other tests.
The relocated installed-package check compiles all consumer targets from fresh sources, then runs their tests. CTest separates these into portals.package-install-prepare and portals.package-install, connected by a fixture. Selecting only portals.package-install automatically includes preparation; failed preparation prevents runtime verification against an older build.
PORTALS_PACKAGE_TEST_TIMEOUT controls each phase's limit in seconds per configuration (default 600, positive integer up to 86400). The multi-configuration check gets twice that budget for each phase. The overall pipeline can therefore run longer than one phase's limit; splitting phases does not make compilation faster. Individual consumer runtime tests retain their shorter deadlines. Package commands report start/end timestamps and elapsed time. For example, configure with -DPORTALS_PACKAGE_TEST_TIMEOUT=900 on a slower development disk. A timeout remains a failed check; changing a budget requires a complete successful run.
When set to a nonempty value, CMAKE_LINK_DEPENDS_USE_LINKER is forwarded to the installed consumer build. For linker-generated dependency path issues, configure with -DCMAKE_LINK_DEPENDS_USE_LINKER=OFF as a workaround; this does not skip assertions or change the exported SDK setting.
PORTALS_BUNDLE_SCRIPT_TEST_TIMEOUT controls the bundle script test's CTest limit in seconds (default 30, positive integer up to 86400). Override it at configure time on a slower filesystem, for example with -DPORTALS_BUNDLE_SCRIPT_TEST_TIMEOUT=60. A timeout is a failed check; a complete successful run remains required.
tests/support/test_terminal.hpp is private test support, not an installed Portals API. TestTerminal implements FrameOutput, owns an independent VT oracle and input decoder, and borrows a FakeClock. One executor owns all calls. The clock must outlive the terminal. There are no callbacks, background workers, implicit flushes, real terminal handles or wall-clock sleeps. Input events and snapshots own their data and remain valid after subsequent calls or terminal destruction. Invalid test operations throw std::runtime_error; allocation errors propagate. Discard the terminal/writer pair after an injected output failure or oracle error.
FakeClock::advanceTo() changes monotonic milliseconds without dispatching anything. Call TestTerminal::tick() to deliver input timeouts explicitly, or input() to deliver bytes at the current time. The next scheduler can reuse this clock without acquiring a scheduler from this helper. finish() explicitly ends input; ending a trace does not silently manufacture EOF. The clock rejects backward time and values that cannot be represented by TerminalDeadline.
submit() takes ownership without changing the screen. flush() honors a pre-requested stop or expired fake deadline without consuming output. An injected failAfter(n) accepts at most n pending bytes and then reports an error, even when that prefix ends inside CSI or UTF-8. This models a failed transport, not a safe retry. The remaining suffix is retained and further output is rejected. FrameWriter tests verify that this failure poisons the writer and invalidates its committed frame. Successful flush means accepted bytes, not a hardware guarantee.
A trace is ASCII text with the exact header PORTALS-TRACE 1. Each following nonempty line has an absolute unsigned millisecond timestamp and one operation:
| Record | Payload and meaning |
|---|---|
| time INPUT hex | Input byte fragment at this time; lowercase hex, - for empty. |
| time RESIZE width height | Resize the independent viewport and deliver a resize event. |
| time OUTPUT hex | Submit and flush one owning output transaction. |
| time FAIL_AFTER count | Inject failure into the next flush after this accepted prefix. |
| time TICK | Explicitly drain input timers at this fake time. |
| time FINISH | Explicit input EOF. |
| time SNAPSHOT | Capture the complete current output state. |
Equal timestamps preserve record order. LF and CRLF input are accepted; recording emits LF. Blank records, unknown operations, extra fields, malformed hex, numeric overflow and unsupported/missing versions are errors. Parse diagnostics identify the offending line; aggregate resource failures identify the limit. parseTrace() owns the decoded records; recordTrace() creates canonical text. The caller owns file I/O and must bound reads before passing a string to the parser (the fixture reader demonstrates this). This is a local testing format, not a network protocol or a general serializer.
replay(trace, input_chunk, output_chunk) splits input and interpreter feeds at positive byte sizes while preserving timestamps and transaction boundaries. It returns owning input/resize events with delivery times, explicit snapshots plus one final snapshot, and output results. An output failure is an observable result; submitting further output to that failed transport is a test error. An empty INPUT drains input just like TICK. Resize may occur between input fragments without discarding the decoder's partial sequence.
The oracle does not call the diff encoder, full renderer, grapheme decoder or Unicode width helpers. Its deliberately small alphabet covers printable ASCII, combining acute U+0301, CJK U+4E00–U+9FFF and fixture emoji U+1F300–U+1FAFF. The CJK/emoji ranges have fixed width two; other scalars are rejected. This does not model general Unicode grapheme composition, ZWJ, variation selectors or a complete terminal. The supported CSI subset is cursor positioning, erase-display, encoder SGR (default, bold, italic, underline and RGB), autowrap and the encoder's fixed origin/insert/margin baseline. CAN cancels partial CSI/UTF-8.
Snapshots retain viewport size, every cell's glyph/style/width/continuation role, half-open spans for each lead, cursor coordinates, current style, autowrap and pending wrap. They are semantic screen checkpoints, not parser save states: partial CSI/UTF-8 cannot be restored from them. Resize preserves the intersection, clears a wide glyph cut by the new right edge and homes the cursor. Native emulator resize policies remain separate platform tests.
The private format has named fixed bounds in TraceLimits and VtOracle:
The reusable oracle permits up to 16,384 cells for existing native writer fixtures; TestTerminal and trace validation apply the tighter replay bound.
These caps bound retained snapshot glyph data to 64 MiB plus cell/span metadata, input events and trace storage. Input pulls also have a progress budget; each fragment performs at most twice its byte count plus four pulls. Oracle work is linear in fed bytes plus bounded screen operations; each checkpoint copies at most the bounded viewport. The input decoder's own sequence/paste limits still apply. This is intentionally a bounded fixture harness, not an unbounded session recorder. Changing these format/resource guarantees requires updating the tests and this document.
tests/replay.cpp runs resize-input.trace, wide-edge.trace and writer-failure.trace, checks hand-authored semantic expectations, and compares 512 input/output chunk combinations per fixture. Recording roundtrips preserve the operations and replay evidence. Additional checks cover fake ESC deadlines, stop/deadline output retention, snapshot ownership, real FrameWriter poisoning, malformed records, unsupported versions and resource/arithmetic boundaries. Existing input/diff/writer tests remain separate characterization coverage.
Use the corresponding Linux preset on Linux. Windows test targets include tests/support/no_dialogs.cpp; configure and rebuild before running changed test binaries. Tests terminate themselves without terminal windows or dialog dismissal. Doxygen includes this page when PORTALS_BUILD_DOCS=ON.
Project functions and methods use lowCamelCase; enumerators and named constexpr, class, global and static constants use BIG_SNAKE_CASE. Ordinary local const values and parameters retain their existing variable style. Standard-library operations, external overrides and externally required linker entry points retain their contract names. Any necessary declaration suppression must explain that contract locally.
The repository .clang-tidy checks these rules. Configure a compilation database with tests, tools and examples enabled, then run the Python 3.9+ checker:
On Linux, use linux-gcc-debug and build/linux-gcc-debug. Use a clang-tidy version that can parse the selected C++23 standard library; Clang 20 is checked with the Linux configuration. Run each platform's database to cover conditional native code. The script checks project translation units and their project headers, excludes vendored sources, returns a nonzero status on errors, and never applies fixes. It can also check a separately configured module experiment database. Use --jobs 2 for up to two concurrent clang-tidy processes with diagnostics grouped in source order. The default remains one process. Optional --timings timings.json records total/per-unit wall time and exit codes; see the naming checker reference. Run python -m unittest tools.test_check_naming -v for the subprocess runner's toolchain-independent regression tests. The Linux CI naming job uses Clang/clang-tidy 20 and GCC 14's standard library; it uses two workers and installs the toolchain from Ubuntu 24.04's updated package repositories. Dependent template references and inactive preprocessor branches still require the normal build/test matrix; a naming pass alone is not a compilation guarantee.
See the primary clang-tidy naming documentation.
References: CTest, C++ steady clock, C++ integer parsing.
The opt-in Clang targets instrument the input decoder and Unicode implementation with libFuzzer, ASan and UBSan. See bounded fuzzing for build commands, seed corpora, checks, reproduction and limits. Ordinary builds leave PORTALS_BUILD_FUZZERS disabled.
tools/native_xterm.sh runs portals_terminal_cleanup in an actual xterm and records child exit, exact termios/file-flag restoration, viewport changes, driver stages, and owned-process cleanup. Native launchers are opt-in; ordinary CTest never opens a terminal emulator.
Both drivers use a private Xvfb display by default, so automated runs cannot open windows over the caller's desktop. -iconic alone does not guarantee this on WSLg. A none driver runs finite native programs and handled-error probes without synthesizing input. Both drivers need xterm, Xvfb, xauth and xkbcomp (used by Xvfb). A dashboard driver additionally needs the X11/XTest development libraries at configure time. CMake enables this fixture's input driver only when both X11::X11 and X11::Xtst are available; these are test dependencies, not dependencies of the Portals core. Without them, the supervisor still builds and none remains usable; dashboard fails before starting the application or sending input.
The log directory must not exist. By default, the launcher creates its own free nonzero Xvfb display with a private MIT-MAGIC-COOKIE-1 authority file, disables TCP listeners, and waits for that server's readiness. It ignores inherited isolation markers and replaces them with the created display and window title. The driver requires exact matching markers, a nonzero local display, private authority, the owned xterm window title and the XTest extension before mapping, focusing or sending input. It never drives display :0 or the caller's desktop. Unicode F8 translation belongs only to this xterm instance; no desktop keymap or clipboard is modified. PORTALS_XVFB may name an alternative Xvfb executable, and PORTALS_XVFB_WORKDIR its required working directory for a local test installation; both default to normal system behavior.
For deliberate interactive inspection only, PORTALS_NATIVE_VISIBLE=1 lets a none driver use the caller's DISPLAY and authority instead of Xvfb. This explicit choice may display a window over the desktop; it is rejected for dashboard so synthetic input remains isolated. The default is 0; any other value is rejected. launch.log records the choice and actual display. Private Xvfb timings describe an offscreen X11 server and must not be labelled as WSLg desktop timings.
XTest provides server-side keyboard, pointer motion and button press/release. The fixture does not enable allowSendEvents or relax allowMouseOps: xterm's allowSendEvents disables allowXXXOps and would suppress mouse reporting even when the application correctly enables modes 1000/1006. A green driver stage proves request submission; confirm actual mouse delivery in the dashboard trace (two event=input ... input=mouse records) and inspect the exported selection, Unicode note, theme and resize data for the complete acceptance gate.
The launcher stops only its own terminal/server and supervised child PIDs, removes only its private authority/readiness files, and records cleanup. A child watchdog, forced terminal termination, failed driver stage or remaining process fails the run; cleanup does not convert a deadline into a pass.
Primary references: XTest, xterm security resources, CMake FindX11.
With the build/docs build directory from the build guide, build portals_docs, then run python tools/docs/check_links.py build/docs/docs/html. Run python -m unittest discover -s tools/docs -p test_*.py -v for the HTML-processing regressions. Build the public guide programs with cmake -S docs/examples -B build/guide-examples -G Ninja -DCMAKE_BUILD_TYPE=Release and cmake --build build/guide-examples.
User guides describe operations and their public contracts. Replay transports, fault injection, pointer-retirement checks and scheduler/decoder stress cases belong to the test suite and developer documentation. The documented program sources stay separate from that harness. PR CI stores the generated help as the documentation-preview artifact; it does not deploy Pages.
PORTALS_PACKAGE_CONSUMER_MINIMAL_DEBUG_INFO defaults to OFF. Set it to ON with GCC to use -g1 for the fresh installed-package consumer's Debug configuration:
This opt-in changes debug-information detail only. Debug configuration, assertions, standalone-header translation units, runtime tests and their individual limits stay in place. The SDK producer and ordinary SDK users keep their existing flags. Other compilers reject this opt-in; Release and other configurations are unaffected. GCC retains backtrace information with fewer variable/type details; use the default for interactive debugging. See GCC debugging options.
Linux CI enables the option to reduce nested compilation cost. Failed native jobs retain completed Ninja action timings, compiler commands and CTest logs as a native-failure-* artifact. A killed build has no final aggregate resource report; completed-action timings do not describe unfinished commands or establish a cause.