TODO §70: the tests are portable to Linux (macOS-verified), and §71's queue
Test code only. The suite had only ever run on macOS; the first Linux trial
found clippy red on three unused imports and 11 failing tests.
- Unused imports (lucisv_server hover.rs, includes.rs test modules): they now
carry the same cfg as the macOS/Windows-only tests that use them.
- Eight permission-denied tests (lucisv cli, lucisv_core walk, lucisv_mcp
apply/cache/qa_m6, lucisv_server filelist): each first probes that the
mode it relies on is enforced and says 'skipped' if not (root ignores
modes); std only, no uid check.
- file_ops' case-mismatched include test probes the filesystem's case
sensitivity first.
- large.rs' two linear-time tests bound growth (8x input <= 24x time, best
of five) instead of wall-clock; shown to fail at ~60-74x on a quadratic
implementation by dev and QA independently.
- scan_trace's stage-sum lower bound is asserted on the best of three
sessions (reproduced flaky on macOS under load: 2.21 ms of 5.10 ms).
- walk.rs' TempTree test helper gains the Drop its doc promised.
- tools/linux_check.sh runs the working tree in the luhpe-linux-x64 runner's
job image, as root or --user, without a push.
Linux: root green and --user green but for the scan_trace flake were seen
once, on 88546c8 plus round 1 of this lane. Nothing since has run there (the
owner's ssh key expired), so TODO §70's Linux line and the ci.yml linux job
stay open. Dev, QA (mutation table) and lead review:
docs/features/linux-test-portability/README.md.
TODO.md also gains §71, the owner's eight-feature queue, with its waves.
Gates: tools/gates.sh PASS on this tree (0.65.4 + this), lucisv_server 1977/0.
Co-Authored-By: Claude Mythos 5.2 <[email protected]>
This commit is contained in:
1 parent
d57496978f
commit
7408face90
14 files changed
+978
-87
No files matched your search
@@ -7263,3 +7263,127 @@ Feature README: `docs/features/instantiation-highlighting/README.md`. Files:
|
||||
- [x] `configurationDefaults` enables `editor.semanticHighlighting.enabled` and
|
||||
`semanticTokenScopes` maps `verilog`/`systemverilog` roles to distinct,
|
||||
non-white TextMate scopes across themes.
|
||||
|
||||
## 70. The tests pass on Linux, and one cleaning round (2026-11-19, owner's order)
|
||||
|
||||
Every suite had only ever run on macOS arm64; the Linux and Windows binaries
|
||||
ship unexecuted. A `linux-x64` Actions runner now exists (`luhpe-linux-x64`,
|
||||
a resource-capped Docker-in-Docker container on the Gitea host), and the
|
||||
first trial of the suite in its job image found: clippy red on three unused
|
||||
imports in `lucisv_server` test modules (their only users are tests compiled
|
||||
on macOS/Windows alone), and 11 distinct failing tests out of ~5 300 — eight
|
||||
that set up an unreadable/unwritable path and so cannot fail as root (the
|
||||
job image's user), one that assumes a case-insensitive filesystem, two
|
||||
`…_in_linear_time` timing assertions. No product failure among them as far
|
||||
as the trial shows. One lane, `docs/features/linux-test-portability`;
|
||||
`tools/linux_check.sh` runs the working tree in that image without a push.
|
||||
|
||||
- [x] `cargo clippy --all-targets -- -D warnings` clean on Linux and on
|
||||
macOS (`crates/lucisv_server/src/hover.rs`, `includes.rs` test modules,
|
||||
and whatever else the Linux build names).
|
||||
- [x] The permission-denied tests (`crates/lucisv/tests/cli.rs`,
|
||||
`crates/lucisv_core/src/walk.rs`, `crates/lucisv_mcp/src/apply.rs` and
|
||||
`tests/cache.rs`, `tests/qa_m6.rs`, `crates/lucisv_server/src/state/tests/filelist.rs`)
|
||||
pass both as root and as an unprivileged user: where the platform does
|
||||
not enforce the permission the test says so and stops, it does not
|
||||
assert the opposite.
|
||||
- [x] `crates/lucisv_server/src/file_ops.rs`
|
||||
`a_case_mismatched_include_spelling_still_narrows_in_and_rewrites`
|
||||
holds on a case-sensitive filesystem or is scoped to the insensitive
|
||||
ones, with the reason written at the test.
|
||||
- [x] `crates/lucisv_server/src/large.rs` — the two `…_in_linear_time`
|
||||
tests pass on the runner **and still fail when the conversion is
|
||||
quadratic** (shown, not asserted).
|
||||
- [x] The cleaning round: test code only, driven by what the tools report on
|
||||
either platform — unused imports and dead helpers, platform assumptions
|
||||
left implicit, assertions on wall-clock or environment that the runner
|
||||
shows to be fragile. No test is deleted and the test count does not
|
||||
drop; no production code and nothing in `verify.rs` changes.
|
||||
- [ ] `cargo test --workspace` green on Linux as root and with `--user`,
|
||||
and `tools/gates.sh` green on macOS.
|
||||
- [ ] (lead) `.gitea/workflows/ci.yml` gains a `linux` job on `linux-x64`;
|
||||
`docs/topo.md` and `tools/RELEASING.md` updated.
|
||||
|
||||
## 71. The overnight queue (2026-11-19, owner's order) — eight features, one release each
|
||||
|
||||
Ordered by the owner on 2026-11-19, to be done unattended after §70 lands:
|
||||
each item goes through the dev → QA → lead-review loop, is committed, and
|
||||
ships as its own release — `0.65.2`, `0.65.3`, … `0.65.n` in the order they
|
||||
finish — and once all are done, `0.66.0`. The lead has the owner's standing
|
||||
go-ahead to commit, tag and push for this queue. Every feature is tried on
|
||||
the OpenTitan tree (not only on unit fixtures) before it is called done.
|
||||
The items are the owner's words, lightly condensed; each gets its own
|
||||
subsection, plan and `docs/features/<name>/README.md` when its turn comes.
|
||||
|
||||
- [ ] **71.1 An edit does not re-index the whole database.** Today every
|
||||
file edit re-indexes everything. A change to a `define` may have to;
|
||||
a typical, localized edit must not.
|
||||
- [ ] **71.2 Actions stay fast on a huge, heavily-dependent tree.** Do the
|
||||
work dynamically: answer first from what is already in the same file
|
||||
(hover to a definition in this file), and use the relationship map to
|
||||
load completion candidates on demand.
|
||||
- [ ] **71.3 Highlighting does not wait for the index.** Always run a
|
||||
localized, viewport-only highlight; it may be imperfect and be
|
||||
corrected later, but basic colours must not wait for the whole
|
||||
database.
|
||||
- [x] **71.4 `` `ifdef `` / `` `else `` blocks fold** (0.65.4, `docs/features/ifdef-folding`), and take part in the
|
||||
sticky-scroll ("floating") bars.
|
||||
- [ ] **71.5 The formatter adapts to the file's own style** — where lines
|
||||
break, what is grouped, how ports align. If inferring that is too
|
||||
ambiguous, a setting with a drop-down of named styles instead (ANSI,
|
||||
Google, Microsoft, NXP — educated guesses), with the rules easy to
|
||||
read in the source.
|
||||
- [x] **71.6 The module view shows where you are.** (0.65.2, `docs/features/hierarchy-current-path`; not yet seen in a running editor.)
|
||||
Highlight the open
|
||||
file's instance and its parents in different shades — bright light
|
||||
orange for the instance, dimmer the further up — or anything in that
|
||||
spirit that makes the hierarchy easy to read.
|
||||
- [ ] **71.7 Find References sometimes answers "not found"** on a
|
||||
port/signal, then works after clicking elsewhere and back. VS Code or
|
||||
the server? Investigate, then fix what is ours.
|
||||
- [x] **71.8 Comments: no code colours inside them** (0.65.3, `docs/features/comment-highlighting`; the bracket colour is VS Code's, explained not changed)
|
||||
(the `[]` of
|
||||
`signal[]` gets highlighted today), **but do highlight `TODO`,
|
||||
`FIXME`, `FIX_ME`, `TBD`**, plus a user setting for custom words that
|
||||
are highlighted only in comments.
|
||||
- [ ] **71.9 Release `0.66.0`** once 71.1–71.8 have each shipped.
|
||||
|
||||
### 71 — wave 1 (lead, 2026-11-19): 71.6 runs beside §70
|
||||
|
||||
The owner asked not to wait for §70's Linux runs. §70 is test code in the
|
||||
Rust crates and touches no contract; 71.6 is the extension's hierarchy view
|
||||
(`editors/vscode/hierarchy*.js`, `package.json`, the extension README and
|
||||
changelog). Disjoint file sets, and the one edge between the two areas
|
||||
(`editors/vscode ◀──▶ lucisv_server`, the spawn contract) is touched by
|
||||
neither — so they run as two lanes: §70 on trunk's tree (already in flight
|
||||
there), 71.6 in the worktree `../lucisv-wt/71.6` on `lane/71.6-module-view`,
|
||||
branched from `88546c8`. 71.1–71.3 all live in `lucisv_server`'s state and
|
||||
indexing, collide with each other and with §70's test files, and wait for
|
||||
§70 to merge.
|
||||
|
||||
- Lane 71.6 owns: `editors/vscode/hierarchyView.js`, `hierarchyModel.js`,
|
||||
`hierarchySections.js` and their `_test.js` files, new
|
||||
`editors/vscode/*.js` modules it adds, `editors/vscode/package.json`
|
||||
(`contributes` only — not `version`), `editors/vscode/.vscodeignore`,
|
||||
`tools/release.sh`'s runtime-module checks if a new module needs listing,
|
||||
`docs/features/hierarchy-current-path/README.md`.
|
||||
|
||||
- Wave 2 (lead, 2026-11-19): 71.6 shipped as 0.65.2 (`e9f5090`). §70 is still
|
||||
in flight on trunk's tree, so the next lane is again one that stays out of
|
||||
the Rust test files: **71.8** (comments), in `../lucisv-wt/71.8` on
|
||||
`lane/71.8-comments` from `e9f5090`. It owns
|
||||
`editors/vscode/syntaxes/*`, `language-configuration.json`, new
|
||||
`editors/vscode/*.js` modules and tests, `extension.js` wiring,
|
||||
`package.json` `contributes`, `.vscodeignore`, the extension README, and —
|
||||
only if the stray colour turns out to come from the server's semantic
|
||||
tokens — `crates/lucisv_server/src/tokens.rs` and `tokens/`, which §70
|
||||
does not touch. `docs/features/comment-highlighting/README.md`.
|
||||
|
||||
- Wave 3 (lead, 2026-11-19): 71.8 shipped as 0.65.3 (`948f8a0`) and 71.4 as
|
||||
0.65.4 (`d574969`), each from its own worktree; both tagged locally and
|
||||
**not pushed** — the owner's ssh key left the agent at about 05:00 (its
|
||||
`AddKeysToAgent 1h`), which also stops `tools/linux_check.sh`. §70 is
|
||||
committed on macOS evidence with its Linux line left open. 71.5 (formatter
|
||||
styles) runs in `../lucisv-wt/71.5` from `d574969`. Owed once ssh is back,
|
||||
in this order: push master and the tags one at a time; re-run §70 on Linux
|
||||
(root twice, `--user`); add the `linux` job to `ci.yml`.
|
||||
@@ -2241,11 +2241,33 @@ fn unlock(dir: &TempDir) {
|
||||
std::fs::set_permissions(dir.path.join("locked"), std::fs::Permissions::from_mode(0o755));
|
||||
}
|
||||
|
||||
/// Whether file modes bind this process: a mode-000 directory refuses to be
|
||||
/// listed. Root lists it anyway (Linux CI jobs run as root), and there a
|
||||
/// directory the walk cannot read cannot be built, so the tests below say so
|
||||
/// and stop instead of asserting a warning that cannot happen.
|
||||
#[cfg(unix)]
|
||||
fn listing_is_refused() -> bool {
|
||||
use std::os::unix::fs::PermissionsExt;
|
||||
let probe = TempDir::new("mode-probe");
|
||||
let shut = probe.path.join("shut");
|
||||
std::fs::create_dir(&shut).expect("probe dir");
|
||||
std::fs::set_permissions(&shut, std::fs::Permissions::from_mode(0o000)).expect("chmod");
|
||||
let refused = std::fs::read_dir(&shut).is_err();
|
||||
let _ = std::fs::set_permissions(&shut, std::fs::Permissions::from_mode(0o755));
|
||||
if !refused {
|
||||
eprintln!("skipped: a mode-000 directory is readable by this user (root?)");
|
||||
}
|
||||
refused
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(unix)]
|
||||
fn an_unreadable_directory_is_a_warning_and_the_rest_of_the_tree_is_formatted() {
|
||||
// The finding TODO §45.2 closes: one permission-denied directory used to
|
||||
// propagate `read_dir`'s error and fail the whole run.
|
||||
if !listing_is_refused() {
|
||||
return;
|
||||
}
|
||||
let dir = unwalkable_tree("walk-warn");
|
||||
let out = run(&[&dir.root()]);
|
||||
unlock(&dir);
|
||||
@@ -2262,6 +2284,9 @@ fn an_unreadable_directory_is_a_warning_and_the_rest_of_the_tree_is_formatted()
|
||||
#[test]
|
||||
#[cfg(unix)]
|
||||
fn the_walks_warnings_leave_check_modes_exit_code_alone() {
|
||||
if !listing_is_refused() {
|
||||
return;
|
||||
}
|
||||
let dir = unwalkable_tree("walk-warn-check");
|
||||
let out = run(&["--check", &dir.root()]);
|
||||
unlock(&dir);
|
||||
|
||||
@@ -731,6 +731,13 @@ mod tests {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(unix)]
|
||||
impl Drop for TempTree {
|
||||
fn drop(&mut self) {
|
||||
let _ = std::fs::remove_dir_all(&self.path);
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(unix)]
|
||||
fn a_directory_linking_to_itself_is_entered_once() {
|
||||
@@ -794,12 +801,41 @@ mod tests {
|
||||
assert_eq!(warnings, ["a/gone.sv: broken symbolic link"]);
|
||||
}
|
||||
|
||||
/// Whether file modes bind this process: a mode-000 `rel` (a directory
|
||||
/// when `rel` ends in `/`, else a file) refuses to be read. Root reads it
|
||||
/// anyway (Linux CI jobs run as root), so the unreadable-path tests below
|
||||
/// cannot build their path there; they say so and stop.
|
||||
#[cfg(unix)]
|
||||
fn reading_is_refused(rel: &str) -> bool {
|
||||
let probe = TempTree::new("mode-probe");
|
||||
let path = probe.path.join(rel);
|
||||
if rel.ends_with('/') {
|
||||
std::fs::create_dir(&path).expect("probe dir");
|
||||
} else {
|
||||
probe.write(rel, "");
|
||||
}
|
||||
probe.chmod(rel, 0o000);
|
||||
let refused = if rel.ends_with('/') {
|
||||
std::fs::read_dir(&path).is_err()
|
||||
} else {
|
||||
std::fs::File::open(&path).is_err()
|
||||
};
|
||||
probe.chmod(rel, 0o755);
|
||||
if !refused {
|
||||
eprintln!("skipped: a mode-000 `{rel}` is readable by this user (root?)");
|
||||
}
|
||||
refused
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(unix)]
|
||||
fn an_unreadable_directory_is_skipped_and_the_walk_goes_on() {
|
||||
// The finding this channel exists for: one permission-denied directory
|
||||
// used to propagate `read_dir`'s error out of the whole walk, dropping
|
||||
// every file already found and failing the run.
|
||||
if !reading_is_refused("shut/") {
|
||||
return;
|
||||
}
|
||||
let tree = TempTree::new("unreadable");
|
||||
tree.source("a.sv");
|
||||
tree.source("locked/hidden.sv");
|
||||
@@ -815,6 +851,9 @@ mod tests {
|
||||
#[test]
|
||||
#[cfg(unix)]
|
||||
fn an_unreadable_ignore_file_is_said_and_the_directory_is_still_walked() {
|
||||
if !reading_is_refused("shut") {
|
||||
return;
|
||||
}
|
||||
let tree = TempTree::new("lockedignore");
|
||||
tree.write(".gitignore", "build\n");
|
||||
tree.source("keep.sv");
|
||||
|
||||
@@ -274,6 +274,25 @@ mod tests {
|
||||
fs::remove_dir_all(dir).unwrap();
|
||||
}
|
||||
|
||||
/// Whether file modes bind this process: a mode-555 directory under `dir`
|
||||
/// refuses a new file. Root writes it anyway (Linux CI jobs run as root),
|
||||
/// so there the half of the test below that needs a directory refusing
|
||||
/// the temp file cannot be built; it says so and stops.
|
||||
#[cfg(unix)]
|
||||
fn creating_is_refused(dir: &Path) -> bool {
|
||||
use std::os::unix::fs::PermissionsExt;
|
||||
let shut = dir.join("mode-probe");
|
||||
fs::create_dir(&shut).unwrap();
|
||||
fs::set_permissions(&shut, fs::Permissions::from_mode(0o555)).unwrap();
|
||||
let refused = fs::write(shut.join("x"), "").is_err();
|
||||
fs::set_permissions(&shut, fs::Permissions::from_mode(0o755)).unwrap();
|
||||
fs::remove_dir_all(&shut).unwrap();
|
||||
if !refused {
|
||||
eprintln!("skipped: a mode-555 directory takes new files from this user (root?)");
|
||||
}
|
||||
refused
|
||||
}
|
||||
|
||||
#[cfg(unix)]
|
||||
#[test]
|
||||
fn a_write_that_fails_after_another_landed_says_what_was_written() {
|
||||
@@ -290,6 +309,10 @@ mod tests {
|
||||
let refused = commit(&[&first, &second], name).unwrap_err();
|
||||
assert_eq!(refused, "`b.sv` is read-only; nothing written.");
|
||||
assert_eq!(fs::read_to_string(&a).unwrap(), "a\n");
|
||||
if !creating_is_refused(&dir) {
|
||||
fs::remove_dir_all(dir).unwrap();
|
||||
return;
|
||||
}
|
||||
// … but a directory that will not take the temp file fails only at
|
||||
// the write, after `a.sv` landed: said, not hidden.
|
||||
fs::set_permissions(&b, fs::Permissions::from_mode(0o644)).unwrap();
|
||||
|
||||
@@ -242,11 +242,32 @@ fn a_missing_directory_starts_cold_and_its_own_store_serves_the_next_start() {
|
||||
assert!(stderr.contains(&reused(0, FILES - 1)), "{stderr}");
|
||||
}
|
||||
|
||||
/// Whether file modes bind this process: a mode-555 directory refuses a new
|
||||
/// file. Root writes it anyway (Linux CI jobs run as root), so there an
|
||||
/// unwritable cache directory cannot be built; the test says so and stops.
|
||||
#[cfg(unix)]
|
||||
fn creating_is_refused(scratch: &Scratch) -> bool {
|
||||
use std::os::unix::fs::PermissionsExt;
|
||||
let shut = scratch.0.join("mode-probe");
|
||||
fs::create_dir_all(&shut).unwrap();
|
||||
fs::set_permissions(&shut, fs::Permissions::from_mode(0o555)).unwrap();
|
||||
let refused = fs::write(shut.join("x"), "").is_err();
|
||||
fs::set_permissions(&shut, fs::Permissions::from_mode(0o755)).unwrap();
|
||||
fs::remove_dir_all(&shut).unwrap();
|
||||
if !refused {
|
||||
eprintln!("skipped: a mode-555 directory takes new files from this user (root?)");
|
||||
}
|
||||
refused
|
||||
}
|
||||
|
||||
#[cfg(unix)]
|
||||
#[test]
|
||||
fn an_unwritable_cache_directory_still_answers_and_says_so_on_exit() {
|
||||
use std::os::unix::fs::PermissionsExt;
|
||||
let scratch = Scratch::new();
|
||||
if !creating_is_refused(&scratch) {
|
||||
return;
|
||||
}
|
||||
fs::create_dir_all(scratch.cache()).unwrap();
|
||||
fs::set_permissions(scratch.cache(), fs::Permissions::from_mode(0o555)).unwrap();
|
||||
let stderr = whole_session(&scratch);
|
||||
|
||||
@@ -444,6 +444,24 @@ fn qa_index_cache_naming_a_file_answers_and_leaves_the_file_alone() {
|
||||
assert_eq!(fs::read_to_string(&file).unwrap(), "keep me\n");
|
||||
}
|
||||
|
||||
/// Whether file modes bind this process: a mode-000 directory refuses to be
|
||||
/// listed. Root lists it anyway (Linux CI jobs run as root), so there a cache
|
||||
/// directory without permission cannot be built; the test says so and stops.
|
||||
#[cfg(unix)]
|
||||
fn listing_is_refused(scratch: &Scratch) -> bool {
|
||||
use std::os::unix::fs::PermissionsExt;
|
||||
let shut = scratch.0.join("mode-probe");
|
||||
fs::create_dir_all(&shut).unwrap();
|
||||
fs::set_permissions(&shut, fs::Permissions::from_mode(0o000)).unwrap();
|
||||
let refused = fs::read_dir(&shut).is_err();
|
||||
fs::set_permissions(&shut, fs::Permissions::from_mode(0o755)).unwrap();
|
||||
fs::remove_dir_all(&shut).unwrap();
|
||||
if !refused {
|
||||
eprintln!("skipped: a mode-000 directory is readable by this user (root?)");
|
||||
}
|
||||
refused
|
||||
}
|
||||
|
||||
/// A cache directory with no permissions at all (mode 000, holding a whole
|
||||
/// honest editor store): nothing can be read, so the start is cold; the
|
||||
/// answers are right; the exit says it could not write, once; the store in
|
||||
@@ -453,6 +471,9 @@ fn qa_index_cache_naming_a_file_answers_and_leaves_the_file_alone() {
|
||||
fn qa_a_cache_directory_without_permission_is_a_cold_start_that_answers() {
|
||||
use std::os::unix::fs::PermissionsExt;
|
||||
let scratch = Scratch::new();
|
||||
if !listing_is_refused(&scratch) {
|
||||
return;
|
||||
}
|
||||
let (cold, _) = probe(&scratch, None);
|
||||
scratch.write_editor_store(&honest_store(&scratch));
|
||||
let before = hash_file(&scratch.editor_store());
|
||||
|
||||
@@ -708,10 +708,19 @@ mod tests {
|
||||
/// therefore in `includers()`/`include_sources()` — the narrowing must not
|
||||
/// accidentally depend on the include's target spelling matching the
|
||||
/// disk's.
|
||||
///
|
||||
/// Only a case-insensitive filesystem (macOS, Windows by default) resolves
|
||||
/// the mismatched spelling at all; on a case-sensitive one (Linux) there
|
||||
/// is no include to narrow in, so the test checks which it is on and stops
|
||||
/// there, saying so.
|
||||
#[test]
|
||||
fn a_case_mismatched_include_spelling_still_narrows_in_and_rewrites() {
|
||||
let tree = Tree::new("case_mismatch");
|
||||
tree.write("rtl/defs.svh", "`define W 8\n");
|
||||
if !tree.path.join("rtl/DEFS.svh").is_file() {
|
||||
eprintln!("skipped: this filesystem is case-sensitive; `DEFS.svh` names no file");
|
||||
return;
|
||||
}
|
||||
let top = tree.write("rtl/top.sv", "`include \"DEFS.svh\"\nmodule t;\nendmodule\n");
|
||||
tree.write("files.f", "rtl/top.sv\nrtl/defs.svh\n");
|
||||
let ws = tree.workspace();
|
||||
|
||||
@@ -1572,6 +1572,8 @@ mod qa_hover_declarations {
|
||||
use crate::uri::path_to_uri;
|
||||
use std::fs;
|
||||
use std::path::PathBuf;
|
||||
// Its one user is the case-insensitive-filesystem test below.
|
||||
#[cfg(any(target_os = "macos", target_os = "windows"))]
|
||||
use std::str::FromStr;
|
||||
|
||||
fn temp_dir(tag: &str) -> PathBuf {
|
||||
|
||||
@@ -952,7 +952,10 @@ mod qa_scope_probe {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
/// Both probes need `is_file` to succeed for a spelling the file does not
|
||||
/// have, which only a case-insensitive filesystem does — macOS's and
|
||||
/// Windows' defaults — so the module is scoped to them.
|
||||
#[cfg(all(test, any(target_os = "macos", target_os = "windows")))]
|
||||
mod qa_round2 {
|
||||
use super::*;
|
||||
use std::fs;
|
||||
@@ -963,7 +966,6 @@ mod qa_round2 {
|
||||
/// unconditionally once a collision exists, so a third colliding entry is
|
||||
/// a no-op over an already-`None` slot rather than something that could
|
||||
/// re-arm it — confirmed here rather than only read off the source.
|
||||
#[cfg(any(target_os = "macos", target_os = "windows"))]
|
||||
#[test]
|
||||
fn three_files_colliding_on_one_folded_spelling_stay_ambiguous() {
|
||||
let dir =
|
||||
@@ -995,7 +997,6 @@ mod qa_round2 {
|
||||
/// must come back exactly as before this fix — `folded` only ever learns
|
||||
/// about in-scope files, so an out-of-scope collision has no entry to
|
||||
/// find and falls through to the "no match" arm, unchanged.
|
||||
#[cfg(any(target_os = "macos", target_os = "windows"))]
|
||||
#[test]
|
||||
fn a_case_mismatch_on_a_file_outside_the_graphs_scope_is_unchanged() {
|
||||
let dir =
|
||||
|
||||
@@ -354,6 +354,7 @@ mod tests {
|
||||
use super::*;
|
||||
use lsp_types::{Position, Range};
|
||||
use std::path::PathBuf;
|
||||
use std::time::{Duration, Instant};
|
||||
|
||||
/// A fast-path document over `text`.
|
||||
fn large(text: &str) -> Document {
|
||||
@@ -793,51 +794,44 @@ mod tests {
|
||||
/// on it. The same four sizes are **1.7 / 3.3 / 6.4 / 13.2 ms** — 2x for
|
||||
/// 2x, and 596x faster at the top.
|
||||
///
|
||||
/// The bound is wall-clock, loose, and in debug (this test runs in the
|
||||
/// normal suite): ~4x the measured debug cost of the largest size, which
|
||||
/// the quadratic version overshoots by more than two orders of magnitude.
|
||||
/// A regression in *kind* fails it; a slow CI box does not.
|
||||
/// The bound is on the **shape** of the cost, not its size: the fastest
|
||||
/// of five timings at each size, and the largest size (8x the tokens of
|
||||
/// the smallest) may cost at most [`GROWTH_SLACK`] times 8x the smallest.
|
||||
/// Linear is ~8x; the quadratic version is ~64x (73x in the release
|
||||
/// numbers above). A wall-clock ceiling was here first and failed on the
|
||||
/// CPU-capped Linux runner in debug, where everything is ~15x slower but
|
||||
/// still 2x for 2x; a ratio holds on any machine. Shown to trip, with the
|
||||
/// per-call converter put back into `tokens::flatten`, in
|
||||
/// `docs/features/linux-test-portability/README.md`.
|
||||
#[test]
|
||||
fn a_window_of_many_tokens_on_one_line_colours_in_linear_time() {
|
||||
use std::time::Instant;
|
||||
for count in [5_000u32, 10_000, 20_000, 40_000] {
|
||||
// One line: `module m; wire a0,a1,...,last;` — realistic in shape
|
||||
// (a wide declaration), synthetic only in how wide.
|
||||
let mut text = String::from("module m; wire ");
|
||||
for n in 0..count {
|
||||
text.push_str(&format!("a{n},"));
|
||||
}
|
||||
text.push_str("last;\nendmodule\n");
|
||||
let doc = large(&text);
|
||||
let clock = Instant::now();
|
||||
let window = window(&doc, range(0, 1));
|
||||
let lex_elapsed = clock.elapsed();
|
||||
assert!(!window.tokens.is_empty());
|
||||
let clock2 = Instant::now();
|
||||
let data = crate::tokens::semantic_tokens_in_window(&doc, range(0, 1));
|
||||
let colour_elapsed = clock2.elapsed();
|
||||
eprintln!(
|
||||
"{count} tokens, {}-byte line: lex {lex_elapsed:?}, colour {colour_elapsed:?}, \
|
||||
{} tokens answered",
|
||||
text.len(),
|
||||
data.len() / 5
|
||||
);
|
||||
assert!(!data.is_empty(), "the window really did colour something");
|
||||
assert!(
|
||||
colour_elapsed.as_millis() < COLOUR_BUDGET_MS,
|
||||
"colouring {count} tokens on one line cost {colour_elapsed:?} — \
|
||||
the quadratic conversion is back"
|
||||
);
|
||||
let sizes = [5_000u32, 10_000, 20_000, 40_000];
|
||||
let docs: Vec<Document> = sizes
|
||||
.iter()
|
||||
.map(|&count| {
|
||||
// One line: `module m; wire a0,a1,...,last;` — realistic in
|
||||
// shape (a wide declaration), synthetic only in how wide.
|
||||
let mut text = String::from("module m; wire ");
|
||||
for n in 0..count {
|
||||
text.push_str(&format!("a{n},"));
|
||||
}
|
||||
text.push_str("last;\nendmodule\n");
|
||||
large(&text)
|
||||
})
|
||||
.collect();
|
||||
for doc in &docs {
|
||||
assert!(!window(doc, range(0, 1)).tokens.is_empty());
|
||||
}
|
||||
let costs = fastest_of_five(&docs, |doc| {
|
||||
let clock = Instant::now();
|
||||
let data = crate::tokens::semantic_tokens_in_window(doc, range(0, 1));
|
||||
let elapsed = clock.elapsed();
|
||||
assert!(!data.is_empty(), "the window really did colour something");
|
||||
elapsed
|
||||
});
|
||||
assert_grows_linearly(&sizes, &costs, "colouring tokens on one line");
|
||||
}
|
||||
|
||||
/// The wall-clock ceiling the test above holds the colourer to, in a
|
||||
/// **debug** build: 4.5x the slowest of the four sizes as measured on the
|
||||
/// machine this was written on (77 ms at 40,000 tokens, ±0.5 ms over
|
||||
/// four runs), where the quadratic version this replaced would need tens
|
||||
/// of seconds.
|
||||
const COLOUR_BUDGET_MS: u128 = 350;
|
||||
|
||||
/// **QA finding 1 (2026-08-27), fixed and now a gate**, on the *other*
|
||||
/// fast-path consumer of `Positions`: `references`' hits still have to
|
||||
/// become `lsp_types::Location`s (`Server::large_scan`, `server.rs`), one
|
||||
@@ -848,50 +842,82 @@ mod tests {
|
||||
///
|
||||
/// `large_scan` now walks the hits with one `Positions::walker`, which
|
||||
/// they are already in ascending order for. This runs at an eighth of the
|
||||
/// original probe's line lengths so it can live in the normal suite; the
|
||||
/// bound is debug wall-clock and ~4x the measured cost, which a return of
|
||||
/// the per-hit rescan overshoots by two orders of magnitude.
|
||||
/// original probe's line lengths so it can live in the normal suite. The
|
||||
/// hits and the line both grow with `width`, so the walker's work (each
|
||||
/// byte of the line once) is linear in it and the per-hit rescan's (the
|
||||
/// line once per hit) quadratic; the bound is the same shape check as the
|
||||
/// colour test's above, and shown to trip the same way.
|
||||
#[test]
|
||||
fn references_on_one_giant_line_locate_their_hits_in_linear_time() {
|
||||
use std::time::Instant;
|
||||
for width in [100u32, 200, 400, 800] {
|
||||
// One line: `wire sig;` filler `sig` filler `sig` ... — `width`
|
||||
// occurrences of the needle spread over one line, all comfortably
|
||||
// under REFERENCE_LIMIT so the cap is not what is being timed.
|
||||
let mut text = String::from("wire sig;");
|
||||
for _ in 0..width {
|
||||
text.push_str(&" filler_word ".repeat(250));
|
||||
text.push_str("sig");
|
||||
}
|
||||
text.push('\n');
|
||||
let doc = large(&text);
|
||||
let clock = Instant::now();
|
||||
let hits = references(&doc, 5, true);
|
||||
let scan_elapsed = clock.elapsed();
|
||||
assert_eq!(hits.len() as u32, width + 1, "the declaration plus every use");
|
||||
let sizes = [100u32, 200, 400, 800];
|
||||
let docs: Vec<(Document, Vec<TextRange>)> = sizes
|
||||
.iter()
|
||||
.map(|&width| {
|
||||
// One line: `wire sig;` filler `sig` filler `sig` ... —
|
||||
// `width` occurrences of the needle spread over one line, all
|
||||
// comfortably under REFERENCE_LIMIT so the cap is not what is
|
||||
// being timed.
|
||||
let mut text = String::from("wire sig;");
|
||||
for _ in 0..width {
|
||||
text.push_str(&" filler_word ".repeat(250));
|
||||
text.push_str("sig");
|
||||
}
|
||||
text.push('\n');
|
||||
let doc = large(&text);
|
||||
let hits = references(&doc, 5, true);
|
||||
assert_eq!(hits.len() as u32, width + 1, "the declaration plus every use");
|
||||
(doc, hits)
|
||||
})
|
||||
.collect();
|
||||
let costs = fastest_of_five(&docs, |(doc, hits)| {
|
||||
let positions = doc.positions();
|
||||
let clock2 = Instant::now();
|
||||
let clock = Instant::now();
|
||||
// Exactly what `Server::large_scan` does with them.
|
||||
let mut walker = positions.walker();
|
||||
for hit in &hits {
|
||||
for hit in hits {
|
||||
std::hint::black_box(walker.range(*hit));
|
||||
}
|
||||
let locate_elapsed = clock2.elapsed();
|
||||
eprintln!(
|
||||
"{width} hits on one {}-byte line: scan {scan_elapsed:?}, locate {locate_elapsed:?}",
|
||||
text.len()
|
||||
);
|
||||
assert!(
|
||||
locate_elapsed.as_millis() < LOCATE_BUDGET_MS,
|
||||
"locating {width} hits on one line cost {locate_elapsed:?} — \
|
||||
the per-hit line rescan is back"
|
||||
);
|
||||
}
|
||||
clock.elapsed()
|
||||
});
|
||||
assert_grows_linearly(&sizes, &costs, "locating hits on one line");
|
||||
}
|
||||
|
||||
/// The wall-clock ceiling for the locator above, in a **debug** build:
|
||||
/// 4.7x the slowest of the four sizes as measured on the machine this was
|
||||
/// written on (32 ms at 800 hits on a 2.6 MB line, ±0.2 ms over four
|
||||
/// runs).
|
||||
const LOCATE_BUDGET_MS: u128 = 150;
|
||||
/// How much faster than its input a linear-time test's cost may grow
|
||||
/// before it fails: 3x, so 24x for an 8x input, where linear measures
|
||||
/// ~8x (macOS and the Linux runner alike) and quadratic ~64x.
|
||||
const GROWTH_SLACK: f64 = 3.0;
|
||||
|
||||
/// The fastest of five timings of `run` on each input. The rounds go over
|
||||
/// all the inputs in turn, so a burst of load from the tests running
|
||||
/// beside this one slows one sample of each size rather than every sample
|
||||
/// of one. Five, not three: QA saw 18.2x of the 24x limit at three under
|
||||
/// 2x CPU oversubscription, and more rounds is the margin that does not
|
||||
/// loosen what the test can see.
|
||||
fn fastest_of_five<T>(inputs: &[T], mut run: impl FnMut(&T) -> Duration) -> Vec<Duration> {
|
||||
let mut fastest = vec![Duration::MAX; inputs.len()];
|
||||
for _ in 0..5 {
|
||||
for (best, input) in fastest.iter_mut().zip(inputs) {
|
||||
*best = (*best).min(run(input));
|
||||
}
|
||||
}
|
||||
fastest
|
||||
}
|
||||
|
||||
/// Fails unless the cost at the largest size is within [`GROWTH_SLACK`]
|
||||
/// of linear growth from the smallest.
|
||||
#[track_caller]
|
||||
fn assert_grows_linearly(sizes: &[u32], costs: &[Duration], what: &str) {
|
||||
for (size, cost) in sizes.iter().zip(costs) {
|
||||
eprintln!("{what}: {size} → {cost:?}");
|
||||
}
|
||||
let (first, last) = (sizes[0], sizes[sizes.len() - 1]);
|
||||
let input = f64::from(last) / f64::from(first);
|
||||
let growth =
|
||||
costs[costs.len() - 1].as_secs_f64() / costs[0].as_secs_f64().max(f64::MIN_POSITIVE);
|
||||
assert!(
|
||||
growth <= GROWTH_SLACK * input,
|
||||
"{what}: {input}x the input cost {growth:.1}x the time ({costs:?}) — \
|
||||
more than {GROWTH_SLACK}x linear, the quadratic conversion is back"
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -128,10 +128,29 @@ fn the_stages_add_up_to_the_scan_they_describe() {
|
||||
// the progress callbacks, the per-file word `Vec`, the staging pushes —
|
||||
// which is deliberately unattributed rather than silently folded into a
|
||||
// neighbouring stage.
|
||||
//
|
||||
// That slack is about a third of an unloaded scan, so one stall landing in
|
||||
// it (the 4-CPU Linux runner throttles for tens of ms; QA caught 0.43 on
|
||||
// macOS beside a looping suite) grows `total` and no stage. The upper
|
||||
// bound is structural — the stages are disjoint pieces of the scan — and
|
||||
// holds on every scan; the lower bound is a claim about an undisturbed
|
||||
// scan, so it is asserted on the best of three: a stall spoils one
|
||||
// sample, not all of them.
|
||||
let tree = trace_tree("tracesums", 40);
|
||||
let session = Session::verbose_wide(vec![tree.path.clone()], None);
|
||||
let stages = line_of(&scan_lines(&session), "stages");
|
||||
let total = number(&stages, "total");
|
||||
let mut best = 0.0f64;
|
||||
for _ in 0..3 {
|
||||
let session = Session::verbose_wide(vec![tree.path.clone()], None);
|
||||
let stages = line_of(&scan_lines(&session), "stages");
|
||||
let (sum, total) = (named_stage_sum(&stages), number(&stages, "total"));
|
||||
assert!(total > 0.0, "a scan of 40 files takes measurable time: {stages}");
|
||||
assert!(sum <= total * 1.02, "the stages cannot exceed the scan: {sum} of {total}");
|
||||
best = best.max(sum / total);
|
||||
}
|
||||
assert!(best >= 0.5, "the stages must account for most of it: at best {best:.2} of the scan");
|
||||
}
|
||||
|
||||
/// The sum of every stage a scan's `stages` line names, `total` aside.
|
||||
fn named_stage_sum(stages: &str) -> f64 {
|
||||
let named = [
|
||||
"discovery",
|
||||
"order",
|
||||
@@ -157,10 +176,7 @@ fn the_stages_add_up_to_the_scan_they_describe() {
|
||||
"includes",
|
||||
"overlay",
|
||||
];
|
||||
let sum: f64 = named.iter().map(|key| number(&stages, key)).sum();
|
||||
assert!(total > 0.0, "a scan of 40 files takes measurable time: {stages}");
|
||||
assert!(sum <= total * 1.02, "the stages cannot exceed the scan: {sum} of {total}");
|
||||
assert!(sum >= total * 0.5, "the stages must account for most of it: {sum} of {total}");
|
||||
named.iter().map(|key| number(stages, key)).sum()
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
@@ -61,6 +61,24 @@ fn a_filelist_that_cannot_be_read_falls_back_to_the_walk_and_says_so() {
|
||||
assert!(warnings[0].contains("indexing the workspace instead"), "{warnings:?}");
|
||||
}
|
||||
|
||||
/// Whether file modes bind this process: a mode-000 directory refuses to be
|
||||
/// listed. Root lists it anyway (Linux CI jobs run as root), so there the
|
||||
/// directory the scan cannot read cannot be built; the test says so and stops.
|
||||
#[cfg(unix)]
|
||||
fn listing_is_refused() -> bool {
|
||||
use std::os::unix::fs::PermissionsExt;
|
||||
let probe = Tree::new("modeprobe");
|
||||
let shut = probe.path.join("shut");
|
||||
fs::create_dir(&shut).expect("probe dir");
|
||||
fs::set_permissions(&shut, fs::Permissions::from_mode(0o000)).expect("chmod");
|
||||
let refused = fs::read_dir(&shut).is_err();
|
||||
let _ = fs::set_permissions(&shut, fs::Permissions::from_mode(0o755));
|
||||
if !refused {
|
||||
eprintln!("skipped: a mode-000 directory is readable by this user (root?)");
|
||||
}
|
||||
refused
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(unix)]
|
||||
fn an_unreadable_directory_is_said_once_per_scan_and_the_rest_is_indexed() {
|
||||
@@ -69,6 +87,9 @@ fn an_unreadable_directory_is_said_once_per_scan_and_the_rest_is_indexed() {
|
||||
// existed the walk returned an error the index simply dropped, so a
|
||||
// permission-denied directory cost every file after it silently.
|
||||
use std::os::unix::fs::PermissionsExt;
|
||||
if !listing_is_refused() {
|
||||
return;
|
||||
}
|
||||
let tree = Tree::new("walkwarn");
|
||||
tree.package("rtl/a.sv", "a");
|
||||
tree.package("rtl/z.sv", "z");
|
||||
|
||||
@@ -0,0 +1,449 @@
|
||||
# linux-test-portability
|
||||
|
||||
## Goal
|
||||
|
||||
Every suite had only ever run on macOS arm64. Make `cargo clippy --all-targets
|
||||
-- -D warnings` and `cargo test --workspace` pass on Linux x86-64 — in the CI
|
||||
job image, as root (how the runner's jobs run) and as an unprivileged user —
|
||||
while staying green on macOS, and do one cleaning round on the test code that
|
||||
the Linux runs drive (TODO §70). Test code only: where a platform or user
|
||||
genuinely cannot exercise what a test is about, the test detects it at run
|
||||
time and stops with a message; it never asserts the opposite and never weakens
|
||||
the assertion where it *can* run.
|
||||
|
||||
## Assumptions
|
||||
|
||||
- Root (CAP_DAC_OVERRIDE / CAP_DAC_READ_SEARCH) ignores file modes, so the
|
||||
unreadable- and unwritable-path tests cannot build their path as root.
|
||||
Not assumed from the uid: each test probes the exact behaviour it needs
|
||||
(a mode-000 directory refuses `read_dir`, a mode-000 file refuses `open`,
|
||||
a mode-555 directory refuses a new file) in a scratch path of its own,
|
||||
then restores the mode.
|
||||
- Case sensitivity is a property of the filesystem, not the OS. The one
|
||||
runtime-probed case test (`file_ops.rs`) asks the filesystem
|
||||
(`DEFS.svh` is a file when only `defs.svh` was written); the existing
|
||||
`#[cfg(any(target_os = "macos", target_os = "windows"))]` case tests keep
|
||||
their compile-time scope, whose reason is written at each.
|
||||
- A skipped test still reports `ok` in `cargo test`; the `skipped: …` line
|
||||
on stderr (visible with `--nocapture`) is how a run says so. std has no
|
||||
runtime-skip outcome, and no dependency is added for one.
|
||||
- The linear-time tests' bound is a ratio between sizes measured in the
|
||||
same process moments apart, so it does not depend on the machine's speed;
|
||||
it does assume load from the tests running beside it does not inflate the
|
||||
largest size's *fastest of five* by more than ~3x relative to the
|
||||
smallest's.
|
||||
|
||||
## Handshakes
|
||||
|
||||
- Consumes nothing new from production code. No production file, no
|
||||
`verify.rs`, no workflow, version file or changelog changes.
|
||||
- `tools/linux_check.sh` (the lead's): used as written in round 1; changed
|
||||
in the fix round (QA finding 5, see the work log). Its usage line gained
|
||||
`--dry-run`; the single-string form is unchanged.
|
||||
- Scope extension granted by the lead in the fix round:
|
||||
`crates/lucisv_server/src/server/tests/scan_trace.rs` (test file only).
|
||||
- Requests: none.
|
||||
|
||||
## Status / TODO
|
||||
|
||||
- [x] Clippy clean on Linux and macOS: the three unused imports were the
|
||||
only reports.
|
||||
- [x] The eight permission-denied tests probe whether modes bind and stop
|
||||
with a message when they do not.
|
||||
- [x] The case-mismatch test probes the filesystem's case sensitivity.
|
||||
- [x] The two linear-time tests bound growth, not wall-clock; shown to trip
|
||||
on the quadratic conversion on macOS and on the Linux runner.
|
||||
- [x] Cleaning round (see work log).
|
||||
- [ ] Linux suite green as root (twice) and as `--user`. Observed: root
|
||||
once green; `--user` once with one failure, the new flake
|
||||
`scan_trace::the_stages_add_up_to_the_scan_they_describe` (open, see
|
||||
the work log); the second root run and the flake's diagnosis were cut
|
||||
off when ssh to luhpe stopped working.
|
||||
- [x] `tools/gates.sh` green on macOS (see the work log for each run).
|
||||
- [x] Fix round: `scan_trace` lower bound on the best of three sessions;
|
||||
linear-time tests best of five; `tools/linux_check.sh` hardened.
|
||||
- [ ] Open follow-up (QA finding 4, not changed on purpose):
|
||||
`large.rs` `references_on_one_giant_line_locate_their_hits_in_linear_time`
|
||||
times a copy of the `Server::large_scan` loop, not the production loop
|
||||
at `server/large_file.rs:151`, so a per-hit rescan reintroduced there
|
||||
would not be caught. Needs a test that drives the production path.
|
||||
- [ ] Re-run on Linux once ssh to luhpe is back: everything in the fix round
|
||||
and everything since 0.65.2 is unverified there (list in the work log).
|
||||
|
||||
## Work log
|
||||
|
||||
**2026-11-19 (dev).**
|
||||
|
||||
Baselines at 88546c8 (before any change). macOS `cargo test --workspace`:
|
||||
93 result lines, **5307 passed, 0 failed, 57 ignored** (5364). Linux as uid
|
||||
1001 (`tools/linux_check.sh --user`): **5298 passed, 3 failed, 57 ignored** —
|
||||
the case-mismatch test and the two linear-time tests; every permission test
|
||||
passed, which confirms the lead's hypothesis 1 (they fail only as root). The
|
||||
Linux total is 6 lower than macOS's because six tests are compiled only on
|
||||
macOS/Windows.
|
||||
|
||||
Causes, per failure:
|
||||
|
||||
1. *Clippy, three unused imports* (`hover.rs` `qa_hover_declarations`:
|
||||
`FromStr`; `includes.rs` `qa_round2`: `super::*`, `fs`): their only users
|
||||
are `#[cfg(any(target_os = "macos", target_os = "windows"))]` tests.
|
||||
`qa_round2` holds nothing else, so the cfg moved onto the module (with the
|
||||
reason as its doc comment) and off its two tests; in `hover.rs` the
|
||||
`FromStr` import carries the same cfg as its one user.
|
||||
2. *Eight permission tests* (hypothesis 1, confirmed): root opens, lists and
|
||||
writes whatever the mode says. Each gets a probe of the behaviour it
|
||||
relies on and returns early, saying `skipped: …`, when the probe is not
|
||||
refused:
|
||||
- `crates/lucisv/tests/cli.rs` — `listing_is_refused()` (mode-000 dir),
|
||||
used by both walk-warning tests.
|
||||
- `crates/lucisv_core/src/walk.rs` — `reading_is_refused(rel)` (mode-000
|
||||
directory or file), used by the unreadable-directory and
|
||||
unreadable-`.gitignore` tests.
|
||||
- `crates/lucisv_mcp/src/apply.rs` — `creating_is_refused(dir)` (mode-555
|
||||
dir). Only the *second* half of
|
||||
`a_write_that_fails_after_another_landed_says_what_was_written` needs it:
|
||||
the read-only-file refusal before it is decided from the mode bits
|
||||
(`Permissions::readonly`), holds as root, and is still asserted there.
|
||||
The same file is compiled into `tests/qa_m3.rs` via `#[path]`, so the
|
||||
fix covers both targets.
|
||||
- `crates/lucisv_mcp/tests/cache.rs` — `creating_is_refused` (mode 555,
|
||||
the unwritable cache directory).
|
||||
- `crates/lucisv_mcp/tests/qa_m6.rs` — `listing_is_refused` (mode 000).
|
||||
- `crates/lucisv_server/src/state/tests/filelist.rs` —
|
||||
`listing_is_refused()` (mode 000).
|
||||
3. *Case-mismatch include* (hypothesis 2, confirmed: "must narrow in: []" on
|
||||
Linux): on a case-sensitive filesystem `DEFS.svh` names no file, so there
|
||||
is nothing to narrow in. The test now writes `defs.svh`, asks whether
|
||||
`DEFS.svh` is a file, and stops with a message when it is not; the reason
|
||||
is in its doc comment. On macOS it runs in full as before.
|
||||
4. *Two `…_in_linear_time` tests* (hypothesis 3, confirmed, with a
|
||||
correction). Not superlinear product code: run alone on the Linux runner
|
||||
both are exactly 2x per 2x (locate 13.5 / 27.0 / 54.3 / 108.7 ms, colour
|
||||
22.1 / 44.2 / 89.5 / 182.1 ms; three runs within 3%), and on macOS the
|
||||
same (locate 3.4 / 6.7 / 13.6 / 26.2 ms, colour 5.6 / 11.0 / 22.6 /
|
||||
44.7 ms). The trial's 4x for 100 → 200 hits (20.6 → 81.4 ms) and its
|
||||
781 ms colour sample came from the full suite: the tests ran beside ~1 900
|
||||
others on a 4-CPU cap, and a single sample per size took whatever load it
|
||||
landed on. Alone on the runner they would even have met the old budgets
|
||||
(108 < 150, 182 < 350 ms); in the suite they do not. The references test's
|
||||
input grows hits *and* line length together, so the walker's work (each
|
||||
byte once) is linear in `width` and the per-hit rescan's quadratic — the
|
||||
test bounds the right thing.
|
||||
|
||||
Rewrite (`crates/lucisv_server/src/large.rs`): the fixtures are built
|
||||
first; `fastest_of_three` times every size in three interleaved rounds and
|
||||
keeps each size's minimum (load slows one sample of each size, not every
|
||||
sample of one); `assert_grows_linearly` fails when the largest size (8x the
|
||||
input) costs more than `GROWTH_SLACK` (3) × 8 = 24x the smallest. The
|
||||
absolute `COLOUR_BUDGET_MS`/`LOCATE_BUDGET_MS` constants are gone. The
|
||||
per-size `eprintln!` stays (the lex timing it also printed is dropped —
|
||||
it was never asserted).
|
||||
|
||||
**Shown to trip.** Temporarily put the per-call converter back —
|
||||
`positions.position(..)` for `walker.position(..)` at both sites in
|
||||
`tokens::flatten` (`tokens.rs`), and `positions.range(*hit)` for
|
||||
`walker.range(*hit)` in the references test's loop — and ran
|
||||
`cargo test -p lucisv_server --bin lucisv-server large::tests:: -- --nocapture`:
|
||||
- macOS: both FAILED — locate 6.3 / 24.9 / 99.1 / 395.8 ms, **62.8x**;
|
||||
colour 34.3 / 129.2 / 511.9 / 2 060 ms, **60.0x** (limit 24x).
|
||||
- Linux runner (root): both FAILED — locate 87.1 / 346.6 / 1 368.5 /
|
||||
5 507.7 ms, **63.2x**; colour 383.9 / 1 539.2 / 6 503.1 / 27 667.6 ms,
|
||||
**72.1x**.
|
||||
Then restored both files from copies taken before the edit;
|
||||
`git status` shows `tokens.rs` unmodified. With the walker: 8.0x / 8.0x on
|
||||
macOS, 8.0x / 8.2x on Linux. Margin: ~3x on each side of the limit.
|
||||
|
||||
Cleaning round (test code only, driven by the tool reports):
|
||||
- The unused imports above were everything clippy reported on either
|
||||
platform; `cargo build`/`cargo test` reported no other test warnings.
|
||||
- `walk.rs`'s `TempTree` was documented "removed on drop" but had no `Drop`
|
||||
impl, so every walk test left its tree in the temp dir; added the
|
||||
three-line `Drop` the comment describes (the test trees restore their
|
||||
modes before returning, so removal succeeds).
|
||||
- The other wall-clock assertions in the suites (`server/tests/startup.rs`,
|
||||
`tests/e2e.rs`'s grace checks, `vlog_semantic/tests/workspace.rs`'s 5 s
|
||||
build bound) passed on every Linux run here and are left as they are;
|
||||
`large.rs`'s hundred-megabyte probe is `#[ignore]`d.
|
||||
|
||||
Final runs, all against the finished tree (every change above, including
|
||||
`#[track_caller]` on `assert_grows_linearly`; nothing in `crates/` changed
|
||||
after them, only this README and TODO.md):
|
||||
- macOS `cargo test --workspace` (guarded): 93 result lines, **5307 passed,
|
||||
0 failed, 57 ignored** — the baseline's count exactly.
|
||||
- Linux root, then `--user` (2026-11-19, both finished before the ~05:00 ssh
|
||||
outage), root: `cargo clippy --all-targets -- -D warnings`
|
||||
exit 0, no diagnostics; `cargo test --workspace --no-fail-fast`: 93
|
||||
result lines, **5301 passed, 0 failed, 57 ignored**.
|
||||
- Linux `--user` (right after): clippy exit 0, no diagnostics; tests **5300
|
||||
passed, 1 failed, 57 ignored** — the failure is
|
||||
`server::tests::scan_trace::the_stages_add_up_to_the_scan_they_describe`
|
||||
at `crates/lucisv_server/src/server/tests/scan_trace.rs:163`, the
|
||||
`sum >= total * 0.5` assertion (the stages a `--verbose` scan's trace
|
||||
names must cover at least half its wall-clock total). It passed in the
|
||||
root run, in the lead's 88546c8 `--user` run, and 15 times out of 15 run
|
||||
alone as `--user`; a repeat of the whole `lucisv_server` binary to catch
|
||||
its numbers was cut off by the ssh outage (exit 137 from the ssh side, not
|
||||
a guard kill). Reading: a wall-clock ratio over a ~20 ms scan, where a
|
||||
preemption landing in the deliberately unattributed loop time (progress
|
||||
callbacks, staging pushes) on the 4-CPU runner under the full suite's load
|
||||
can tip it below half. **Open, not changed**: without its failing numbers
|
||||
any change to the 0.5 would be a weakening without evidence.
|
||||
- Not done: the second Linux root run the brief asks for.
|
||||
- macOS after trunk's fast-forward to 0.65.2 (e9f5090; touched no file
|
||||
this lane edits): `cargo fmt --all -- --check` exit 0, clippy clean,
|
||||
`tools/gates.sh` **PASS** (`target/gates/20261119-050602/`: every step
|
||||
pass; suites vlog_parser 521, vlog_semantic 418, vlog_refactor 743,
|
||||
vlog_formatter 352, vlog_linter 672, lucisv_core 117, lucisv 143,
|
||||
lucisv_server 1957, lucisv_mcp 383, all 0 failed; corpus 814/6, node
|
||||
12/0). An earlier gates run (03:58) was cut off mid-`lucisv_mcp` when the
|
||||
session restarted — not a guard kill — and is not counted. The Linux runs
|
||||
above were against 88546c8 + this lane, not against 0.65.2.
|
||||
|
||||
**2026-11-19 (dev, fix round after QA's PASS WITH FINDINGS).** Tree: trunk
|
||||
948f8a0 (0.65.3) + this lane. ssh to luhpe is down, so nothing in this
|
||||
round ran on Linux.
|
||||
|
||||
1. *scan_trace flake* (QA finding 2). `the_stages_add_up_to_the_scan_they_describe`
|
||||
now runs three verbose sessions over the same 40-file tree. It asserts
|
||||
`total > 0` and `sum <= total * 1.02` on **every** session (structural:
|
||||
the stages are disjoint pieces of the scan), and `sum/total >= 0.5` on
|
||||
the **best** of the three (a stall in the ~35% unattributed loop time
|
||||
spoils one sample, not all three). The reason is in the test's comment.
|
||||
The stage list moved to a helper, `named_stage_sum`.
|
||||
- Unmutated, macOS: 3 sample ratios 0.64 / 0.68 / 0.69.
|
||||
- *Does it still bite?* Temporary production mutations, each built into a
|
||||
copied test binary and then restored from a copy (`git status` clean for
|
||||
both files after):
|
||||
- `scan_trace.rs:321`, the `read` stage not recorded: 30/30 runs of the
|
||||
copied binary FAILED (best 0.41–0.47). Of 3 runs through cargo, one
|
||||
passed: the first, run just after the build.
|
||||
- `state/rescan.rs:358`, the `parse` stage not recorded: **27/30** FAILED
|
||||
(best 0.38–0.49), 3 passed. A per-sample count of the same mutant
|
||||
(what the old single-session assertion would have checked):
|
||||
87/90 samples under 0.5. So best of three trades some sensitivity to
|
||||
one dropped mid-sized stage (~97% → 90% for `parse`, about a fifth of
|
||||
the scan) for not flaking under load. A dropped stage under ~17% of
|
||||
the scan is invisible to a 0.5 bound either way, as before.
|
||||
- *Under load*, the way QA did it (guarded; the test binary looped 200x
|
||||
while the whole `lucisv_server` binary looped beside it): 0/200 failed;
|
||||
a second 200x run, with 8 full-suite iterations counted alongside: 0/200.
|
||||
2. *`tools/linux_check.sh`* (QA finding 5).
|
||||
- `set -o pipefail`, and tar's stderr is no longer hidden.
|
||||
- One argument is a command line as before. Several are quoted with
|
||||
`printf '%q '`, so `linux_check.sh grep -rn "two words" crates` keeps
|
||||
`two words` whole.
|
||||
- A fixed container name, `--name lucisv-linux-check`, so a second
|
||||
concurrent run is refused by Docker; exit 125 prints a hint.
|
||||
- The header says that untracked non-ignored files are sent and that
|
||||
runs are one at a time.
|
||||
- New `--dry-run`: builds the archive locally, prints its size and the
|
||||
remote command, and contacts nothing.
|
||||
|
||||
Tested locally:
|
||||
- `bash -n` ok (shellcheck is not installed).
|
||||
- `--help` prints the whole header.
|
||||
- `--dry-run` with one string and with several arguments: the remote
|
||||
`CMD` shows the quoting kept.
|
||||
- `LUCISV_LINUX_HOST=nonexistent.invalid`: exit 255, ssh's error shown.
|
||||
- In a throwaway git repo with a tracked file deleted: `--dry-run` exit 1
|
||||
and the real path exit non-zero, with `tar: b.txt: Cannot stat` shown;
|
||||
restoring the file makes the dry run pass.
|
||||
|
||||
**The remote half is untested since this change**: the `--name`
|
||||
refusal, the 125 hint, and the multi-argument `CMD` reaching
|
||||
`bash -c` on luhpe.
|
||||
3. *Linear-time headroom* (QA finding 3). `fastest_of_three` → `fastest_of_five`;
|
||||
`GROWTH_SLACK` unchanged. QA's loaded loop (30 runs, 36 busy loops on 18
|
||||
CPUs, load average ~40, guarded): 30/30 passed. Worst ratios: colour
|
||||
**10.8x**, locate **8.5x** (limit 24x; QA saw 18.2x at three rounds).
|
||||
Cost: on the quadratic code a failing run now takes 5/3 as long (Linux
|
||||
root colour ~3 min, from the round-1 measurements).
|
||||
|
||||
Checks this round (macOS, tree 948f8a0 + lane):
|
||||
- `cargo fmt --all -- --check` exit 0.
|
||||
- `cargo clippy --all-targets -- -D warnings` exit 0.
|
||||
- `tools/guard.sh -- cargo test -p lucisv_server`: 1848 + 106 + 3 + 0
|
||||
passed, 0 failed (36 + 3 + 0 + 2 ignored).
|
||||
- `tools/gates.sh` **PASS** (`target/gates/20261119-053236/`): every step
|
||||
pass; suites 521/418/743/352/672/117/143/1957/383, all 0 failed; corpus
|
||||
814/6; node 37/0.
|
||||
|
||||
Unverified on Linux (all of it rests on round 1, against 88546c8 + lane):
|
||||
- the `scan_trace.rs` rewrite;
|
||||
- best of five in `large.rs`;
|
||||
- the new `linux_check.sh`;
|
||||
- QA's `qa_m6.rs` doc-comment move;
|
||||
- everything trunk added in 0.65.2 and 0.65.3;
|
||||
- the second root run, which never happened in round 1 either.
|
||||
|
||||
## QA log
|
||||
|
||||
**2026-11-19 (QA, macOS arm64, 18 CPUs; tree = 948f8a0 + this lane).**
|
||||
Verdict: **PASS WITH FINDINGS.** Linux was **not** independently verified.
|
||||
|
||||
*Scope.* Every hunk of `git diff -- crates/` is inside a `#[cfg(test)]`
|
||||
module or a `tests/` file: `cli.rs`, `cache.rs`, `qa_m6.rs` (integration
|
||||
tests), `walk.rs`/`apply.rs`/`file_ops.rs`/`large.rs` (inside `mod tests`),
|
||||
`filelist.rs` (under `state/tests/`), `hover.rs` (an import in the
|
||||
`#[cfg(test)] mod qa_hover_declarations`), `includes.rs` (the
|
||||
`#[cfg(test)] mod qa_round2` attribute widened to
|
||||
`all(test, any(macos, windows))`, the two per-test cfgs dropped — same
|
||||
compiled set). `walk.rs`'s new `Drop for TempTree` sits in `mod tests`
|
||||
(the struct is test-only). No `verify.rs`, no production line, `tokens.rs`
|
||||
and `convert.rs` unmodified.
|
||||
|
||||
*No skip on macOS.* All 11 tests (plus `apply`'s copy in `tests/qa_m3.rs`
|
||||
and `--bin lucisv-mcp`) run with `--nocapture`: all `ok`, no `skipped:`
|
||||
line.
|
||||
|
||||
*Mutations* (copies in the scratchpad, restored with `cp`; `git diff --stat`
|
||||
and the full `git diff` compared byte-for-byte with the pre-mutation
|
||||
capture: identical):
|
||||
|
||||
| test | mutation | failed? | restored |
|
||||
|---|---|---|---|
|
||||
| cli `an_unreadable_directory_is_a_warning…` | `walk.rs` `entries`: `Err(_) => return` (no warning) | yes, cli.rs:2277 | yes |
|
||||
| cli `the_walks_warnings_leave_check_modes…` | same | yes, cli.rs:2296 | yes |
|
||||
| walk `an_unreadable_directory_is_skipped…` | same | yes, walk.rs:847 | yes |
|
||||
| filelist `an_unreadable_directory_is_said_once…` | same | yes, filelist.rs:106 | yes |
|
||||
| walk `an_unreadable_ignore_file_is_said…` | `walk.rs` `push_ignore`: drop the `say` | yes, walk.rs:864 | yes |
|
||||
| apply `a_write_that_fails_after…` (bin + qa_m3) | `apply.rs:192` message `written`→`wrote` | yes, both targets, apply.rs:322 (the post-probe half) | yes |
|
||||
| cache `an_unwritable_cache_directory…` | asserted count 1→2 | yes, cache.rs:276 | yes |
|
||||
| qa_m6 `qa_a_cache_directory_without_permission…` | asserted count 1→2 | yes, qa_m6.rs:485 | yes |
|
||||
| file_ops `a_case_mismatched_include…` | `read.contains` inverted | yes, file_ops.rs:729 | yes |
|
||||
| large colour / locate | own mutation: a fresh walker per piece in `tokens::flatten`, a fresh walker per hit in the test's loop | yes: **74.0x** and **64.5x** (limit 24x) | yes; `tokens.rs` no diff; pass again at 8.1x/8.1x |
|
||||
|
||||
*Probe attacks.* No false skip found: every probe builds its scratch path
|
||||
next to (same filesystem as) the test's own, under a pid(+counter)-unique
|
||||
name (`filelist.rs`'s `modeprobe` is pid-only but has one caller); a setup
|
||||
failure panics (`expect`/`unwrap`) instead of returning "not refused"; a
|
||||
spurious error can only read as "refused", which runs the test (a loud
|
||||
failure, not a masked one); there is no panic path between the chmod and
|
||||
its restore; probes remove their paths (Drop or `remove_dir_all`). Root
|
||||
with DAC capabilities gets "not refused" (dev-observed on Linux, not
|
||||
re-run). 20 loops of the eight affected targets (cli walk, core walk,
|
||||
mcp bin + qa_m3 apply, cache, qa_m6, server filelist, server file_ops):
|
||||
**0/160 failures**, and no `lucisv*` temp dir or mode-000/555 path left
|
||||
behind (walk.rs's new `Drop` works; before it, 18 walk dirs per run were
|
||||
left in `$TMPDIR`).
|
||||
|
||||
*Linear-time tests.* Under load, best of three interleaved: 30 runs while
|
||||
a release `cargo build` ran: 0/30 failed, ratios 7.9–8.5x; 30 runs with 36
|
||||
busy loops on 18 CPUs (load ~30) as well: 0/30 failed, ratios **up to 18.2x
|
||||
(colour) and 13.9x (locate)**, so only ~1.3x left under the 24x limit at
|
||||
2x oversubscription. Judgement: a constant-factor regression of any size
|
||||
(2.9x or 100x) passes by design: the ratio cannot see it, and the old
|
||||
absolute budgets that could were dropped on purpose. n·log n passes
|
||||
(~9.9x). A mixed cost slips through when its quadratic part is under ~28%
|
||||
of the smallest size's cost (`8(1-q)+64q ≤ 24`). That is acceptable for a
|
||||
test named "linear time" that guards against the per-call converter
|
||||
coming back (60–74x).
|
||||
|
||||
*scan_trace flake (dev's open item) — reproduced on macOS.* I built an
|
||||
instrumented test binary (a temporary `eprintln!` of sum/total, source
|
||||
restored at once, `git diff` clean) and ran the test 200x under 36 busy
|
||||
loops: 0/200 failed, sum/total 0.62–0.69, total 2.1–4.4 ms. Then 200x while
|
||||
the whole `lucisv_server` suite looped beside it: **1/200 failed**: stages
|
||||
**2.21 ms of total 5.10 ms (0.43)**. Two more runs came in at 0.54 and 0.67
|
||||
with totals of 4.8 and 2.7 ms. Analysis: `total_ms` runs from
|
||||
`ScanTrace::new` in `begin_scan` to `landed`. The named stages are disjoint
|
||||
sub-intervals of it, so `sum ≤ total` is deterministic (up to `{:.2}`
|
||||
rounding, 19 × 0.005 ms). But ~35% of an unloaded scan is deliberately
|
||||
unattributed: the server's per-step `watching` callbacks, progress/log
|
||||
sends and loop overhead in `server/index.rs` `scan_once`. A stall that
|
||||
lands there grows `total` and no stage. The failing sample is exactly that:
|
||||
the stage sum is normal (2.21 ms) and the 2.9 ms extra sits outside every
|
||||
stage. With U≈0.35·T, one stall longer than ~0.3·T in unattributed code
|
||||
trips the bound: ~0.75 ms on macOS, ~6 ms on the Linux runner's ~20 ms
|
||||
scan, where CFS quota throttling under `--cpus` gives stalls of tens of
|
||||
ms. So the lower bound is a statistical claim and is unsound under load on
|
||||
any machine. **Recommended change** (outside this lane's files, not made
|
||||
here): keep `sum <= total * 1.02` per scan, and assert the lower bound on
|
||||
the best of three sessions. Run `Session::verbose_wide` three times and
|
||||
require `max(sum/total) >= 0.5`, the same "load slows one sample, not
|
||||
every sample" argument as `fastest_of_three`. The alternative is to drop
|
||||
the lower bound and assert only that the CPU-bound stages (`discovery`,
|
||||
`read`, `parse`) are each > 0.
|
||||
|
||||
*Gates (macOS, `tools/gates.sh`, `target/gates/20261119-052309/`):* PASS —
|
||||
fmt, clippy, build, docs pass; suites vlog_parser 521/0, vlog_semantic
|
||||
418/0, vlog_refactor 743/0, vlog_formatter 352/0, vlog_linter 672/0,
|
||||
lucisv_core 117/0, lucisv 143/0, lucisv_server 1957/0, lucisv_mcp 383/0;
|
||||
corpus 814/6; node 37/0. Separately `cargo fmt --all -- --check` exit 0,
|
||||
`cargo clippy --all-targets -- -D warnings` exit 0 (only cargo's
|
||||
pre-existing manifest `authors` notice), guarded `cargo test --workspace
|
||||
--no-fail-fast`: 93 result lines, **5307 passed, 0 failed, 57 ignored**,
|
||||
the dev's count exactly.
|
||||
|
||||
*Linux: NOT verified by QA.* `tools/linux_check.sh 'echo ok'` (once):
|
||||
`Permission denied (publickey)`, exit 255; not retried. These results rest
|
||||
on the dev's word alone: root clippy clean and 5301 passed/0 failed;
|
||||
`--user` clippy clean and 5300 passed/1 failed (the scan_trace flake,
|
||||
which is now reproduced on macOS). The second root run was never done.
|
||||
Nothing here has run on Linux since the 0.65.2/0.65.3 fast-forwards.
|
||||
|
||||
*Findings.*
|
||||
1. (low, fixed by QA) `crates/lucisv_mcp/tests/qa_m6.rs:447`: the new
|
||||
helper was inserted between the test's doc comment and the test, so
|
||||
`qa_a_cache_directory_without_permission…`'s four-line doc comment had
|
||||
become the head of `listing_is_refused`'s doc. I moved it back above the
|
||||
test; the diff now only adds the helper and the guard.
|
||||
2. (medium, open, outside scope) `server/tests/scan_trace.rs:163`: the
|
||||
flake above, with its reproduction and the recommended change.
|
||||
3. (low) `large.rs` linear-time margin under heavy oversubscription:
|
||||
18.2x of 24x seen. Watch it on the 4-CPU runner; if it flakes, raise
|
||||
the number of rounds, not `GROWTH_SLACK`.
|
||||
4. (low, pre-existing) `large.rs` `references_on_one_giant_line…` times a
|
||||
copy of the `Server::large_scan` loop (`server/large_file.rs:151`), not
|
||||
the production code, so a regression there is not caught. The mutation
|
||||
had to go into the test's own loop.
|
||||
5. (low) `tools/linux_check.sh` review:
|
||||
- The pipeline has no `pipefail`, and tar's stderr goes to
|
||||
`/dev/null`. A local `git ls-files`/tar failure, or a file that
|
||||
vanished, gives a silently partial tree, and the run is judged on it.
|
||||
A missing archive does fail remotely (`tar xzf` under `set -e`).
|
||||
- `cmd=$*` drops argument quoting (`linux_check.sh grep "a b" f` runs
|
||||
`grep a b f`). The documented single-string form is fine.
|
||||
- `--others --exclude-standard` ships any untracked, non-ignored file
|
||||
(a stray `.env`, key or dump) to luhpe, though only into a `--rm`
|
||||
container, not the volume. Today that is just this README and the
|
||||
script itself (16 KiB).
|
||||
- Not safe to run concurrently: two runs share the
|
||||
`lucisv-linux-check` volume, so they race on a cold rustup install
|
||||
into `/cache`. A `--user` run's `chown -R /cache` flips ownership
|
||||
under a running root build, and one run can execute test binaries
|
||||
the other rebuilt from a different tree. A host-side `flock`, or a
|
||||
fixed `docker run --name` so a second run fails fast, would close
|
||||
this.
|
||||
- The remote quoting is right: one `%q` for the one shell level on the
|
||||
host, and `docker exec`/`docker run` pass argv with no shell. Exit
|
||||
status propagates through ssh → docker → `bash -c`.
|
||||
|
||||
*Fixed by QA:* finding 1 only. *Unverified:* everything on Linux, as
|
||||
above.
|
||||
|
||||
## Review
|
||||
|
||||
**Lead, 2026-11-19.** Accepted on macOS evidence; Linux line left open.
|
||||
|
||||
- Test code only, and QA checked every hunk for that. The risk in a lane like
|
||||
this is a test that passes by no longer testing: QA's mutation table (every
|
||||
modified test made to fail, every file restored byte-identically) and the
|
||||
"none prints `skipped:` on macOS" run are what make it acceptable.
|
||||
- I was wrong about the references test: I read 100→200 hits costing 4x as a
|
||||
possible superlinear product bug and told the dev so. Measured alone it
|
||||
doubles per doubling on both platforms; the 4x was the parallel suite. The
|
||||
ratio assertion that replaced the wall-clock budget is the better test, and
|
||||
it was shown to trip at ~60–74x on a quadratic implementation by dev and QA
|
||||
independently.
|
||||
- `scan_trace` was a pre-existing fragile test that Linux exposed and QA then
|
||||
reproduced on macOS (2.21 ms of 5.10 ms). I extended scope to fix it. The
|
||||
best-of-three lower bound costs sensitivity (the dev measured ~97% → ~90%
|
||||
on a dropped `parse` stage) — accepted and written down, not hidden.
|
||||
- **Not verified on Linux**: everything since round 1 — the `scan_trace`
|
||||
rewrite, best-of-five in `large.rs`, the rewritten `tools/linux_check.sh`
|
||||
(its remote half has never run), and all of 0.65.2–0.65.4. The owner's ssh
|
||||
key expired mid-lane. TODO §70's Linux line and the `ci.yml` job stay
|
||||
unticked until that run happens; the Linux job is not added blind.
|
||||
- Open follow-up, recorded under Status: the references linear-time test
|
||||
times a copy of `Server::large_scan`'s loop, not the production code.
|
||||
Executable
+114
@@ -0,0 +1,114 @@
|
||||
#!/usr/bin/env bash
|
||||
# Run a command against this working tree on Linux, inside the same job image
|
||||
# the luhpe-linux-x64 Actions runner uses, without pushing anything.
|
||||
#
|
||||
# The tree is streamed over ssh into a throwaway container started by the
|
||||
# runner's own Docker daemon on luhpe, so it runs under the runner's cpu and
|
||||
# memory limits. What is sent: every tracked file as it is on disk, plus every
|
||||
# UNTRACKED file git does not ignore (a stray .env or key file included -
|
||||
# check `git status` first). A tracked file deleted from the working tree, or
|
||||
# any other local tar error, fails the run before anything is judged; a
|
||||
# partial tree is never shipped. The Rust toolchain and the cargo target
|
||||
# directory are kept in a Docker volume between runs, so only the first run
|
||||
# is a cold build.
|
||||
#
|
||||
# One run at a time: the runs share that volume (toolchain install, target
|
||||
# dirs, a --user run's chown), so the container has a fixed name and a second
|
||||
# run while one is in flight is refused by Docker ("name ... already in use").
|
||||
# A run whose ssh dropped keeps its container until its command ends.
|
||||
#
|
||||
# Usage: tools/linux_check.sh [--user] [--dry-run] [--] <command...>
|
||||
# tools/linux_check.sh 'cargo clippy --all-targets -- -D warnings'
|
||||
# tools/linux_check.sh --user cargo test -p lucisv_core
|
||||
# tools/linux_check.sh grep -rn "two words" crates
|
||||
#
|
||||
# One argument is a shell command line, run as written (pipes, ;, quotes).
|
||||
# Several arguments are one command and its arguments, each kept whole.
|
||||
# By default the command runs as root, which is how the runner's jobs run and
|
||||
# so what CI will see. --user runs it as an unprivileged user instead: file
|
||||
# permissions are enforced there, which root ignores. --dry-run builds the
|
||||
# archive locally (to check the local half), prints its size and the remote
|
||||
# command, and contacts nothing.
|
||||
#
|
||||
# Needs: ssh access to the host `luhpe` (LUCISV_LINUX_HOST overrides) and the
|
||||
# gitea-runner container on it (docs: tools/RELEASING.md, "CI releases").
|
||||
# Exit status is the command's, or non-zero if the archive or the
|
||||
# connection failed.
|
||||
|
||||
set -eu -o pipefail
|
||||
|
||||
host=${LUCISV_LINUX_HOST:-luhpe}
|
||||
image=docker.gitea.com/runner-images:ubuntu-latest
|
||||
name=lucisv-linux-check
|
||||
as_user=0
|
||||
dry_run=0
|
||||
|
||||
while [ $# -gt 0 ]; do
|
||||
case $1 in
|
||||
--user) as_user=1; shift ;;
|
||||
--dry-run) dry_run=1; shift ;;
|
||||
--) shift; break ;;
|
||||
-h|--help) sed -n '2,37p' "$0" | sed 's/^# \{0,1\}//'; exit 0 ;;
|
||||
*) break ;;
|
||||
esac
|
||||
done
|
||||
[ $# -ge 1 ] || { echo "usage: $0 [--user] [--dry-run] [--] <command...>" >&2; exit 2; }
|
||||
if [ $# -eq 1 ]; then
|
||||
cmd=$1
|
||||
else
|
||||
cmd=$(printf '%q ' "$@")
|
||||
fi
|
||||
|
||||
repo_root=$(CDPATH= cd -- "$(dirname -- "$0")/.." && pwd)
|
||||
cd "$repo_root"
|
||||
|
||||
# Inside the container: unpack stdin to /w, make sure the toolchain is in the
|
||||
# cache volume, then run the command as root or as uid 1001.
|
||||
inner='
|
||||
set -eu
|
||||
export RUSTUP_HOME=/cache/rustup CARGO_HOME=/cache/cargo
|
||||
mkdir -p /w && tar xzf - -C /w
|
||||
if [ ! -x "$CARGO_HOME/bin/cargo" ]; then
|
||||
curl --proto =https --tlsv1.2 -sSf https://sh.rustup.rs \
|
||||
| sh -s -- -y --profile minimal -c clippy,rustfmt --no-modify-path >/dev/null 2>&1
|
||||
fi
|
||||
export PATH="$CARGO_HOME/bin:$PATH"
|
||||
if [ "$AS_USER" = 1 ]; then
|
||||
export CARGO_TARGET_DIR=/cache/target-user HOME=/tmp/home
|
||||
mkdir -p "$CARGO_TARGET_DIR" "$HOME"
|
||||
chown -R 1001:1001 /w /cache "$HOME"
|
||||
cd /w && exec setpriv --reuid 1001 --regid 1001 --clear-groups bash -c "$CMD"
|
||||
fi
|
||||
export CARGO_TARGET_DIR=/cache/target-root
|
||||
# An earlier --user run leaves the cache owned by uid 1001; root does not mind.
|
||||
cd /w && exec bash -c "$CMD"
|
||||
'
|
||||
|
||||
remote="docker exec -i gitea-runner docker run --rm -i --name $name \
|
||||
-v lucisv-linux-check:/cache \
|
||||
-e AS_USER=$as_user -e CMD=$(printf '%q' "$cmd") \
|
||||
$image bash -c $(printf '%q' "$inner")"
|
||||
|
||||
# The tree as a gzipped tar on stdout. COPYFILE_DISABLE and --no-xattrs keep
|
||||
# macOS tar from adding ._* entries and extended-attribute headers that GNU
|
||||
# tar on the other side warns about. Errors are not hidden: with pipefail a
|
||||
# file tar cannot read fails the whole run.
|
||||
archive() {
|
||||
git ls-files -z --cached --others --exclude-standard \
|
||||
| COPYFILE_DISABLE=1 tar czf - --no-xattrs --null -T -
|
||||
}
|
||||
|
||||
if [ "$dry_run" = 1 ]; then
|
||||
bytes=$(archive | wc -c)
|
||||
echo "archive: $((bytes)) bytes; would run on $host:"
|
||||
echo "$remote"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
status=0
|
||||
archive | ssh -o BatchMode=yes "$host" "$remote" || status=$?
|
||||
if [ "$status" = 125 ]; then
|
||||
echo "linux_check: docker refused to start the container; if it says the name" \
|
||||
"\"$name\" is in use, another run is in flight - wait for it." >&2
|
||||
fi
|
||||
exit "$status"
|
||||
Reference in new issue
Block a user