Skip to content

armgit / Cap

Public Imported from GitHub
0

Open source Loom alternative. Beautiful, shareable screen recordings.

test: build the pending-fragment bound in its own test, drop divider comments

Richie McIlroy36bbe51ec196
diff --git a/apps/desktop-gpui/src/transcription/verify_tests.rs b/apps/desktop-gpui/src/transcription/verify_tests.rs
index f5f3e3058..39a2af3be 100644
--- a/apps/desktop-gpui/src/transcription/verify_tests.rs
+++ b/apps/desktop-gpui/src/transcription/verify_tests.rs
@@ -51,10 +51,6 @@ fn finish(case: Case) {
}
}
-// ---------------------------------------------------------------------------
-// Reference segmentation
-// ---------------------------------------------------------------------------
-
const ATTACHING: &str = ",.!?;:%)]}'’、。!?;:,";
const WEAK: [&str; 20] = [
"an", "as", "at", "be", "by", "do", "he", "if", "in", "is", "it", "me", "my", "of", "on", "or",
@@ -186,10 +182,6 @@ fn compare_segments(
problems
}
-// ---------------------------------------------------------------------------
-// Fake transcriber over real projects
-// ---------------------------------------------------------------------------
-
fn marker_word(source: AudioSource, index: u32) -> String {
format!("{}{index}", source.name())
}
@@ -550,10 +542,6 @@ fn instant_project_is_refused() {
finish(case);
}
-// ---------------------------------------------------------------------------
-// Segmentation properties
-// ---------------------------------------------------------------------------
-
const ASCII_WORDS: [&str; 22] = [
"hello", "world", "is", "a", "river", "cloud", "it", "to", "so", "screen", "record", "of",
"we", "on", "capture", "edit", "timeline", "in", "up", "my", "an", "I",
diff --git a/apps/desktop-gpui/src/upload/verify_tests.rs b/apps/desktop-gpui/src/upload/verify_tests.rs
index d03443041..7d13956be 100644
--- a/apps/desktop-gpui/src/upload/verify_tests.rs
+++ b/apps/desktop-gpui/src/upload/verify_tests.rs
@@ -36,10 +36,6 @@ const INSTANT_PAIRS: u32 = 8;
const INSTANT_VIDEO_ID: &str = "instantverify01";
const RETRY_WINDOW: Duration = Duration::from_secs(5 * 60);
-// ---------------------------------------------------------------------------
-// Virtual clock
-// ---------------------------------------------------------------------------
-
const SETTLE: Duration = Duration::from_millis(50);
const WORKED: Duration = Duration::from_micros(200);
@@ -119,10 +115,6 @@ pub(super) fn virtual_time<F: Future>(future: F) -> F::Output {
output
}
-// ---------------------------------------------------------------------------
-// Fault plan
-// ---------------------------------------------------------------------------
-
#[derive(Clone, Copy, Debug)]
pub(super) enum Route {
Part(u32),
@@ -191,10 +183,6 @@ impl Rule {
}
}
-// ---------------------------------------------------------------------------
-// Mock Cap API + object store
-// ---------------------------------------------------------------------------
-
#[derive(Default)]
struct Multipart {
video_id: String,
@@ -1058,10 +1046,6 @@ async fn respond(
stream.write_all(&bytes).await
}
-// ---------------------------------------------------------------------------
-// Fixtures
-// ---------------------------------------------------------------------------
-
fn to_hex(bytes: &[u8]) -> String {
bytes.iter().map(|byte| format!("{byte:02x}")).collect()
}
@@ -1275,10 +1259,6 @@ pub(super) fn assert_segments_stored(
assert_eq!(manifest, expected_manifest(video, audio));
}
-// ---------------------------------------------------------------------------
-// Studio share: multipart upload of the exported MP4
-// ---------------------------------------------------------------------------
-
struct StudioRun {
result: Result<UploadResult, String>,
progress: Vec<f64>,
@@ -1525,10 +1505,6 @@ fn studio_share_cancel_then_resume_reuses_the_persisted_video() {
});
}
-// ---------------------------------------------------------------------------
-// Instant: live segment upload while recording
-// ---------------------------------------------------------------------------
-
/// Feeds the recorder's segment events on a fixed virtual schedule: both init
/// segments at 0 s, then audio segment k at 2k s and video segment k at
/// 2k + 0.6 s, so no two segments are in flight at the same moment unless a
diff --git a/crates/verify/tests/captions.rs b/crates/verify/tests/captions.rs
index 026256ba9..8d34a8e0b 100644
--- a/crates/verify/tests/captions.rs
+++ b/crates/verify/tests/captions.rs
@@ -85,10 +85,6 @@ fn seeds(fast: u64, full: u64) -> u64 {
}
}
-// ---------------------------------------------------------------------------
-// Reference model
-// ---------------------------------------------------------------------------
-
fn attaches_to_previous(text: &str) -> bool {
const ATTACHING: &str = ",.!?;:%)]}'’、。!?;:,";
text.trim()
@@ -353,10 +349,6 @@ fn compare_track(product: &[CaptionTrackSegment], model: &[Piece]) -> Vec<String
problems
}
-// ---------------------------------------------------------------------------
-// Random captions
-// ---------------------------------------------------------------------------
-
const VOCABULARY: [&str; 24] = [
"hello", "world", "is", "a", "river", "cloud", "it", "to", "über", "café", "日本", "so",
"screen", "record", "of", "we", "on", "capture", "edit", "timeline", "in", "up", "my", "an",
@@ -468,10 +460,6 @@ fn random_overrides(rng: &mut Rng, config: &mut ProjectConfiguration, per_source
}
}
-// ---------------------------------------------------------------------------
-// Projection and migration properties
-// ---------------------------------------------------------------------------
-
fn projection_problems(
base: &ProjectConfiguration,
ops: &[Op],
@@ -891,10 +879,6 @@ fn legacy_migration() {
finish(case);
}
-// ---------------------------------------------------------------------------
-// On-disk round trips
-// ---------------------------------------------------------------------------
-
fn styled_settings(rng: &mut Rng) -> CaptionSettings {
CaptionSettings {
enabled: true,
@@ -1044,10 +1028,6 @@ fn walk(dir: &Path) -> Vec<std::path::PathBuf> {
out
}
-// ---------------------------------------------------------------------------
-// Transcription input + fake transcriber
-// ---------------------------------------------------------------------------
-
/// Two takes; every track starts at a different time, so the clip offsets
/// matter (mic 0.25 s late, system audio 0.1 s early, display 0.05 s late).
fn transcription_fixture() -> FixtureSpec {
@@ -1340,10 +1320,6 @@ fn transcription_audio_words() {
finish(case);
}
-// ---------------------------------------------------------------------------
-// Rendered captions
-// ---------------------------------------------------------------------------
-
/// Caption style that is easy to find: an opaque green box with white text,
/// no fades, animation or word highlight.
fn render_settings() -> CaptionSettings {
@@ -1789,10 +1765,6 @@ fn render_multi_clip() {
common::assert_passed(failures);
}
-// ---------------------------------------------------------------------------
-// Opening a project in the editor
-// ---------------------------------------------------------------------------
-
/// Opens a copy of `project` whose stored config is `config` in the editor
/// engine and returns the config it settles on.
fn open_in_editor(
diff --git a/crates/verify/tests/crash.rs b/crates/verify/tests/crash.rs
index 1e9a4e86c..33c3b8c20 100644
--- a/crates/verify/tests/crash.rs
+++ b/crates/verify/tests/crash.rs
@@ -112,10 +112,6 @@ struct Run {
display: PathBuf,
}
-// ---------------------------------------------------------------------------
-// Recording (shared by the in-test runs and the child recorder)
-// ---------------------------------------------------------------------------
-
#[cfg(target_os = "macos")]
mod source {
use super::*;
@@ -469,10 +465,6 @@ fn secs_complete(line: &str) -> bool {
.is_some_and(|d| d.len() == 6)
}
-// ---------------------------------------------------------------------------
-// The child recorder (a SIGKILL target)
-// ---------------------------------------------------------------------------
-
/// Runs only as a child of `crash_safety` (`CAP_VERIFY_CRASH_CHILD` set):
/// records into the given directory until it is killed or finishes.
#[test]
@@ -647,10 +639,6 @@ fn wait_for_exit(pids: &[u32], case: &mut Case) {
}
}
-// ---------------------------------------------------------------------------
-// What is physically on disk
-// ---------------------------------------------------------------------------
-
/// Top-level ISO BMFF boxes span the file exactly and include moof + mdat:
/// the writer finished this fragment (independent of recovery.rs).
fn fragment_complete(path: &Path) -> bool {
@@ -909,10 +897,6 @@ fn check_open_fragment(case: &mut Case, display: &Path) {
}
}
-// ---------------------------------------------------------------------------
-// Oracles
-// ---------------------------------------------------------------------------
-
/// The recovered display: the app's display finalization
/// (`RecoveryManager::finalize_to_progressive_mp4`, the same call for a clean
/// stop and for crash recovery).
@@ -1094,10 +1078,6 @@ fn check_recovery(
}
}
-// ---------------------------------------------------------------------------
-// Cases
-// ---------------------------------------------------------------------------
-
fn scratch_root() -> PathBuf {
std::env::var_os("CAP_VERIFY_SCRATCH")
.map(PathBuf::from)
@@ -1712,11 +1692,19 @@ fn pending_fragment_bound_rejects_other_complete_frame_loss() {
},
];
let physical = vec![(0, 0.0), (1, 1.0 / f64::from(FPS))];
- let entries = cap_verify_expect::parse(include_str!("../expectations.toml")).unwrap();
- let entry = entries
- .iter()
- .find(|entry| entry.case == "crash/recorder-kill/inproc/*")
- .unwrap();
+ // The bound the pending-fragment (#2640) entry used: frames inside
+ // complete pending fragments only.
+ let bound = cap_verify_expect::Bound::from([
+ ("count".into(), cap_verify_expect::Range::at(1.0)),
+ (
+ "frames".into(),
+ cap_verify_expect::Range {
+ min: 1.0,
+ max: 60.0,
+ },
+ ),
+ ("outside-pending".into(), cap_verify_expect::Range::at(0.0)),
+ ]);
for (outside, accepted) in [(0.0, true), (1.0, false)] {
let metrics = BTreeMap::from([
("count".into(), cap_verify_expect::Range::at(1.0)),
@@ -1727,7 +1715,7 @@ fn pending_fragment_bound_rejects_other_complete_frame_loss() {
),
]);
assert_eq!(
- cap_verify_expect::within(&entry.bound, Some(&metrics)).is_ok(),
+ cap_verify_expect::within(&bound, Some(&metrics)).is_ok(),
accepted
);
}