mirror of
https://github.com/storytold/lightcraft.git
synced 2026-10-28 03:57:57 -06:00
* CI: dev profile keeps line tables for workspace crates and no debug info for dependencies * Control server tests: persistent_requests_and_slow_replies_outlive_the_idle_read_timeout no longer races the idle timeout Each request (and the closing half-shutdown) reaches the socket before the worker reads, so on a slow machine only the reply waits outlast the 100 ms idle timeout, as the test intends. The idle test sends its input the same way, and the no-frames test allows 5 s instead of 2 s to give up. * CI: one integration-test binary per crate Each crate's tests/*.rs become modules of tests/it/main.rs (51 test files into 13 binaries, plus 6 that stay their own). Inner #![cfg] attributes move to the mod lines. Files that change state for the whole process keep a binary of their own: codecs jxl_tail_heap and raw sr2_heap (dhat global allocator), gpu shutdown, shutdown_first and memory, ui-egui shutdown. Docs, comments and the GPU probe name the new paths and targets (--test it <module>::); the CI report names an it binary's skips after the crate. * CI: tests under nextest, doctests apart, one wasm check xtask ci runs the tests with cargo nextest run --lib --bins --tests when cargo-nextest is installed, else cargo test with the same targets and a one-line notice; doctests run after them with cargo test --workspace --doc. The heif and hardware GPU steps use the same runner. Examples stay out of the test build (clippy --all-targets still checks them). Concurrent tests under nextest follow the RUST_TEST_THREADS cap (NEXTEST_TEST_THREADS). The wasm check is one cargo check --keep-going over the same crates, and clippy runs with --keep-going. * CI: tests run under cargo test by default, nextest with LIGHTCRAFT_NEXTEST=1 (per-process scene cache)
50 lines
2.1 KiB
Rust
50 lines
2.1 KiB
Rust
//! Opt-in test of the embedded-preview read path on a **real file the user has** — typically one on a
|
|
//! network share, which is where reading only the header instead of the whole raw matters:
|
|
//!
|
|
//! LC_PREVIEW_RAW="/run/user/1000/gvfs/smb-share:.../DSCF0001.RAF" \
|
|
//! cargo test --release -p lightcraft-engine --test it preview_read:: -- --ignored --nocapture
|
|
//!
|
|
//! It reports what the preview cost and fails when the read is not the small part of the file the
|
|
//! header path promises. Skipped without `LC_PREVIEW_RAW` (there is no committed raw fixture: media
|
|
//! is never committed, see AGENTS.md).
|
|
use std::time::Instant;
|
|
|
|
#[test]
|
|
#[ignore = "needs LC_PREVIEW_RAW pointing at a real raw file"]
|
|
fn a_preview_reads_only_the_header_and_the_preview() {
|
|
let Ok(path) = std::env::var("LC_PREVIEW_RAW") else {
|
|
lightcraft_testkit::skip!(Input, "set LC_PREVIEW_RAW=<path to a raw file>");
|
|
return;
|
|
};
|
|
let file_len = std::fs::metadata(&path).expect("the file exists").len();
|
|
assert!(file_len > 0, "empty file");
|
|
|
|
let started = Instant::now();
|
|
let window = lightcraft_engine::files::preview_window(&path, usize::MAX)
|
|
.expect("the file reads")
|
|
.expect("it carries an embedded preview the header can point at");
|
|
let elapsed = started.elapsed();
|
|
let (_, preview, read) = window;
|
|
|
|
let frac = read.fraction();
|
|
println!(
|
|
"preview of {path}\n read {} of {} bytes ({:.1} %) in {:.2} s{}",
|
|
read.read,
|
|
read.total,
|
|
frac * 100.0,
|
|
elapsed.as_secs_f64(),
|
|
if read.planned {
|
|
" [plan]"
|
|
} else if read.header_path {
|
|
" [header path]"
|
|
} else {
|
|
" [whole file]"
|
|
}
|
|
);
|
|
|
|
assert!(read.header_path, "the header or the plan must answer for a raw whose preview is not the whole file");
|
|
assert_eq!(read.total, file_len, "the report covers the whole file");
|
|
assert!(frac < 0.5, "a preview must not cost most of the file: read {} of {} bytes", read.read, read.total);
|
|
assert!(preview.starts_with(&[0xff, 0xd8]), "the preview bytes are a JPEG: {:?}", preview.get(..4));
|
|
}
|