Skip to content

armgit / Cap

Public Imported from GitHub
0

Open source Loom alternative. Beautiful, shareable screen recordings.

build(verify): move the recording stimulus helper into its own crate

Richie McIlroy5b4657449694
diff --git a/.github/workflows/verify-recording.yml b/.github/workflows/verify-recording.yml
index 69828753f..e23087146 100644
--- a/.github/workflows/verify-recording.yml
+++ b/.github/workflows/verify-recording.yml
@@ -170,6 +170,7 @@ jobs:
- name: Build
run: |
start=$(date +%s)
+ cargo build --locked -p cap-verify-stimulus
cargo test --locked -p cap-verify --test recording --no-run
echo "build seconds: $(( $(date +%s) - start ))"
diff --git a/Cargo.lock b/Cargo.lock
index 1fade8024..ac9762d53 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -2167,21 +2167,17 @@ dependencies = [
"cap-timestamp",
"cap-verify-expect",
"cidre",
- "cpal 0.15.3 (git+https://github.com/CapSoftware/cpal?rev=6013cb5f8bd3)",
"ffmpeg-next",
"flume",
"futures",
- "objc2-foundation 0.3.1",
"relative-path",
"rustfft",
"scap-targets",
"serde",
"serde_json",
- "softbuffer",
"tempfile",
"tokio",
"tracing-subscriber",
- "winit",
"workspace-hack",
]
@@ -2194,6 +2190,21 @@ dependencies = [
"toml 0.8.2",
]
+[[package]]
+name = "cap-verify-stimulus"
+version = "0.1.0"
+dependencies = [
+ "anyhow",
+ "cap-verify",
+ "cidre",
+ "cpal 0.15.3 (git+https://github.com/CapSoftware/cpal?rev=6013cb5f8bd3)",
+ "objc2-foundation 0.3.1",
+ "serde_json",
+ "softbuffer",
+ "winit",
+ "workspace-hack",
+]
+
[[package]]
name = "cap-video-decode"
version = "0.1.0"
diff --git a/crates/verify-stimulus/Cargo.toml b/crates/verify-stimulus/Cargo.toml
new file mode 100644
index 000000000..aa2e8a70b
--- /dev/null
+++ b/crates/verify-stimulus/Cargo.toml
@@ -0,0 +1,26 @@
+[package]
+name = "cap-verify-stimulus"
+version = "0.1.0"
+edition = "2024"
+publish = false
+description = "Helper process of the real-capture recording oracle (crates/verify/tests/recording.rs): shows screen markers and plays system-audio markers"
+
+[lints]
+workspace = true
+
+[[bin]]
+name = "cap-verify-stimulus"
+path = "src/main.rs"
+
+[dependencies]
+cap-verify = { path = "../verify" }
+anyhow = { workspace = true }
+serde_json = "1"
+workspace-hack = { version = "0.1", path = "../workspace-hack" }
+
+[target.'cfg(target_os = "macos")'.dependencies]
+cidre = { workspace = true }
+cpal = { workspace = true }
+objc2-foundation = "0.3.1"
+softbuffer = "0.4"
+winit = "0.30"
diff --git a/crates/verify/src/bin/stimulus.rs b/crates/verify-stimulus/src/main.rs
similarity index 100%
rename from crates/verify/src/bin/stimulus.rs
rename to crates/verify-stimulus/src/main.rs
diff --git a/crates/verify/Cargo.toml b/crates/verify/Cargo.toml
index 4f16eeb83..4392a72d1 100644
--- a/crates/verify/Cargo.toml
+++ b/crates/verify/Cargo.toml
@@ -28,10 +28,6 @@ workspace-hack = { version = "0.1", path = "../workspace-hack" }
[target.'cfg(target_os = "macos")'.dependencies]
cap-enc-avfoundation = { path = "../enc-avfoundation" }
cidre = { workspace = true }
-cpal = { workspace = true }
-objc2-foundation = "0.3.1"
-softbuffer = "0.4"
-winit = "0.30"
[dev-dependencies]
cap-recording = { path = "../recording", features = ["test-utils"] }
@@ -44,8 +40,3 @@ tracing-subscriber = { version = "0.3", features = ["env-filter"] }
[target.'cfg(target_os = "macos")'.dev-dependencies]
scap-targets = { path = "../scap-targets" }
-
-[[bin]]
-name = "cap-verify-stimulus"
-path = "src/bin/stimulus.rs"
-test = false
diff --git a/crates/verify/tests/recording.rs b/crates/verify/tests/recording.rs
index 1e50fc8a7..7fd0454dd 100644
--- a/crates/verify/tests/recording.rs
+++ b/crates/verify/tests/recording.rs
@@ -700,7 +700,22 @@ fn studio_builder(
fn stimulus_binary() -> PathBuf {
std::env::var_os("CAP_VERIFY_STIMULUS_BIN")
.map(PathBuf::from)
- .unwrap_or_else(|| PathBuf::from(env!("CARGO_BIN_EXE_cap-verify-stimulus")))
+ .unwrap_or_else(|| {
+ // Built by `cargo build -p cap-verify-stimulus` into the same
+ // target directory as this test (target/<profile>/deps/..).
+ let exe = std::env::current_exe().expect("test executable path");
+ let path = exe
+ .parent()
+ .and_then(|deps| deps.parent())
+ .expect("target profile directory")
+ .join("cap-verify-stimulus");
+ assert!(
+ path.exists(),
+ "{} not found: build it first with `cargo build -p cap-verify-stimulus` (same profile), or set CAP_VERIFY_STIMULUS_BIN",
+ path.display()
+ );
+ path
+ })
}
fn find_window(title: &str) -> Option<scap_targets::WindowId> {