Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Testing

CommandWhat it runs
./task testUnit tests for rt-core, rt-config, rt-storage, rt-adblock and rt-cef (modes, keys, commands, settings, config files, paths for all three platforms, history, marks, sessions, and the CEF layer's decisions); no browser needed. rt-cef's tests link CEF, so they run on Linux only.
./task e2eEnd-to-end tests in crates/rt-e2e: real browsers, each on its own Xvfb display (or headless sway, for the Wayland tests), driven through the test channel. ./task e2e -- tabs runs only the tests whose names contain tabs.
./task smokeA short check with real X11 input (xdotool keys and clicks, window focus) that the e2e tests can't give: typing into a field, a trusted click, tab keys, a second window, the bundled help page, and :wq with a restart. build-release.yml also runs it against the release packages, installed on Ubuntu, Debian, Fedora and openSUSE Tumbleweed. It stops early if no fonts are installed, since Chromium then aborts and typed text never appears, which looks like a key-handling bug.
./task lintcargo fmt --check, clippy -D warnings, ShellCheck on the scripts, actionlint on the workflows, and cargo-deny (below)
./task checkAll of the above

The e2e and smoke tests use temporary profiles, so they never touch your browsing data or your browser.

End-to-end tests

Debug builds (and release builds with --features test-control) answer test requests on the command socket. Release builds refuse them. The requests:

RequestDoes
keysPresses keys such as 5j, <Escape> or :open x<Return>. They go through the same engine path as typed keys, and to the page when the engine doesn't use them.
runRuns a command line, as : would.
stateReturns JSON with the mode, windows (with their bounds), tabs (URL, title, pinned, loading, mode), the status bar, completion and the prompt.
evalRuns JavaScript in a tab and returns its string result.
evalbarRuns JavaScript in the window's tabbar, statusbar or completion overlay page (Browser::eval_bar).
setwindowboundsMoves and sizes the current window, as a window manager would (Browser::set_window_bounds). state reports each window's bounds.

crates/rt-e2e wraps them in a Browser that starts riptide with a scratch --basedir, its own Xvfb display, runtime directory and command socket, and a local HTTP server for the fixture pages in crates/rt-e2e/pages/. It stops only its own processes when the test ends. Its browsers run without the desktop's session bus and keep plugins' secrets in memory (RIPTIDE_SECRET_STORE=memory), so a test never touches your keyring. A test that sets RIPTIDE_SECRET_STORE to empty uses the kernel keyring, as Linux does without a Secret Service. Its secrets are kept under its own service name (RIPTIDE_SECRET_SERVICE), and it takes them out again even if it fails. When a test fails, the end of the browser log is printed and the profile is kept in /tmp/rt-e2e-* for a look.

#![allow(unused)]
fn main() {
#[test]
#[ignore = "starts a browser; run with ./task e2e"]
fn d_closes_the_tab() {
    let b = Browser::start("page.html");
    b.run(&format!("open -t {}", b.url("second.html")));
    b.wait_until("the second tab loads", |s| s.tabs().len() == 2 && s.tab().title == "second");
    b.keys("d");
    b.wait_until("one tab is left", |s| s.tabs().len() == 1);
}
}
  • Wait, don't sleep: wait_until, wait_mode and wait_eval poll until the state matches, and fail with the last state after 15 seconds. Use s.tab().is_loaded(&url) to wait for a page: a new tab knows its URL before it starts loading, so checking the URL alone isn't enough.
  • Start options: Browser::launch().toml("…").lua("…").file("data/greasemonkey/x.user.js", "…").script("config/userscripts/us", "…").start("page.html") writes the profile before the browser starts (script makes the file executable). .env("NAME", "value") sets an environment variable that stays across restarts. Test builds read RIPTIDE_EXTENSION_UPDATE_URL as the extension update check's address. Config and files can use {server} (the fixture server), {pages} (the fixture directory) and {scratch} (an empty directory for the test's own files, also b.scratch()).
  • Files and second invocations: wait_file(path) polls until a file has content, e.g. a download or a userscript's output. invoke(&[url, ":cmd"]) runs riptide again on the same profile, which hands its arguments to the running browser.
  • Restarts: config_dir() and data_dir() give the profile's paths. After :quit and wait_exit(), a crash() (SIGKILL) or a terminate() (SIGTERM), restart() starts the browser again on the same profile, for testing sessions and crash recovery.
  • Hints: follow_hint("hint links tab", |h| h.url.as_deref() == Some(&url)) starts hints and presses the label of the element you pick by its text or link. state().hints lists the labels on screen.
  • Painting: start() and open() wait until the page has drawn a frame. Under load Chromium drops keys sent to a page that has loaded but not painted, so call wait_painted() after navigating some other way.
  • Every test is #[ignore]d, so a plain cargo test never starts browsers. ./task e2e runs them with --ignored, two at a time (E2E_THREADS changes that).
  • Clicks that should count as the user's go through hints (follow_hint). Insert mode ignores a script's focus(), so pages can't switch it on, and that includes test scripts.
  • Wayland: Browser::launch().desktop(Desktop::XWayland) runs the browser in a headless sway on its Xwayland, as riptide runs on a Wayland desktop by default; Desktop::Wayland runs it as a native Wayland client (--ozone-platform=wayland). b.client("wl-paste") gives a Command with the session's WAYLAND_DISPLAY, DISPLAY and SWAYSOCK, for checking what Wayland apps see. tests/wayland.rs checks the clipboard both ways with wl-copy/wl-paste, keys typed through the compositor with wtype, and the window's app ID with swaymsg. sway's headless backend works without a GPU (WLR_RENDERER=pixman) and has no input devices, so each wtype waits half a second for riptide to bind the keyboard it adds. It needs wtype 0.5 or newer: 0.4 (Ubuntu 24.04's) gives its keys low key codes, and Chromium, which reads Wayland keys by their key code, sees every one as Escape. CI builds v0.5 from source. wtype isn't usable against Xwayland: it sends each run with its own keymap, which Chromium's X11 backend doesn't pick up (: arrives as 1). GNOME (mutter), weston and Hyprland don't fit this harness: the first two lack the data-control protocol wl-paste reads through without a keyboard, and Hyprland needs a GPU.
  • The smoke test stays for what needs real X11 input (xdotool) and for checking the release packages. New behaviour gets an e2e test.
  • Spell checking needs a dictionary, which tests don't download. tests/spell.rs copies an installed one (RT_E2E_DICTIONARY=<file>.bdic, or en-US-*.bdic from ~/.local/share/riptide/Dictionaries) and passes without checking anything when there is none, as on CI.

Unit tests in the CEF layer

Code in crates/rt-cef that decides something without needing CEF, such as where the tab bar goes, what a setting says to do, or which download a count means, is written as a plain function next to the code that uses it, and tested there. The CEF callback then only gathers its inputs and acts on the answer:

#![allow(unused)]
fn main() {
fn decide(setting: &str) -> Decision { … }        // pure, tested in this file

pub fn certificate_error(…, callback: Callback) -> bool {
    match decide(&setting) {                        // CEF glue around it
        Decision::Load => callback.cont(),
        …
    }
}
}

When the logic isn't specific to CEF and other crates could use it, it goes in rt-core instead (for example rt_core::html::escape).

Linters

./task lint runs pinned versions of each tool through scripts/tool.sh, which downloads them into .bin/ and checks their checksums. That way a new upstream release never adds warnings to CI without warning. To upgrade one, change its version and checksums there.

ToolChecksConfig
rustfmt, clippyRust formatting and lints, with warnings as errors. Every crate also takes the shared lints in [workspace.lints]: no dbg!, todo! or unimplemented!, and a // SAFETY: comment on each unsafe blockCargo.toml
ShellCheckscripts/*.sh and task# shellcheck disable=… comments, each with its reason
actionlint.github/workflows/*.yml, including ShellCheck on their run: blocks—
typosSpelling in code, docs, scripts and pages_typos.toml, for words that are right where they are
Biomecrates/rt-cef/js/*.js, the scripts riptide runs in pages, with warnings as errors; lint only, no formattingbiome.json
cargo-denyDependency licenses (each must be GPL-3.0-compatible), RustSec security advisories, yanked crates, and where crates come fromdeny.toml

A dependency with a license that isn't in deny.toml fails the check. Add the license only after checking that it's compatible with GPL-3.0.

Security advisories aren't part of ./task lint, because a new one can appear any day without anything in the repository changing. .github/workflows/audit.yml checks them daily and whenever Cargo.lock or deny.toml changes; run it yourself with scripts/tool.sh cargo-deny check advisories. A failing advisory is fixed by updating the crate, or listed in deny.toml's ignore with a reason.

Testing by hand

The local-testing skill describes how to drive the browser on a separate Xvfb display with a scratch --basedir, without touching a browser you're running yourself.

CI

.github/workflows/check.yml runs on every push to main and every pull request:

JobRuns
commit messagesscripts/check-commits.sh on the new commits
linux./task lint, ./task test, ./task smoke and ./task e2e (Xvfb and headless sway, cached CEF download)
macos, windowscargo build, the unit tests, and --version/--paths; then crates/riptide/tests/desktop_start.rs starts the browser, waits for its window over the named pipe or socket, checks that riptide's renderer code runs (in riptide-helper on macOS) and quits it
docsbuilds this book and checks its internal links and anchors with lychee

The Windows job copies CEF's runtime next to riptide.exe first, since a restored cache skips cef-dll-sys's own copy. The macOS job builds target/debug/riptide.app with scripts/bundle-macos.sh and points the test at the binary inside it with RIPTIDE_EXE.

.github/workflows/docs.yml publishes the book to GitHub Pages on every push to main, and checks its external links weekly.

Other scheduled jobs:

WorkflowWhenDoes
audit.ymldaily, and when Cargo.lock or deny.toml changesRustSec security advisories (cargo-deny)
cef-update.ymldailyOpens an "Update CEF to X" pull request when crates.io has a newer cef than Cargo.lock pins, as a GitHub App so that check.yml runs on it (secrets CEF_UPDATE_APP_ID and CEF_UPDATE_APP_KEY), and closes any older one. Opens an issue when CEF has a newer stable build than the newest cef crate binds, since Chromium's security fixes wait on that crate, and closes the issue about any older build
cef-automerge.ymlwhen check or audit finishesMerges that pull request as the app once every check on its newest commit has passed. It skips one that changes more than Cargo.toml, Cargo.lock and packaging/nix/source.nix, or that someone else opened. The app is on the "Protect main" ruleset's bypass list. The merge opens the release pull request, which is still merged by hand
notify.ymlwhen a release or CEF workflow finishesA push notification when one fails (see Notifications)
nightly.ymldailyThe rolling nightly pre-release (see Releasing)
DependabotweeklyPull requests that update the GitHub Actions the workflows use