Skip to content

Commit 18a6be3

Browse files
committed
ci: skip camera-dependent rust tests in CI
1 parent 7fdaebd commit 18a6be3

2 files changed

Lines changed: 17 additions & 0 deletions

File tree

.github/workflows/rust.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ on:
2020

2121
env:
2222
CARGO_TERM_COLOR: always
23+
CCAP_SKIP_CAMERA_TESTS: 1
2324

2425
permissions:
2526
contents: read

bindings/rust/tests/integration_tests.rs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@
44
55
use ccap::{CcapError, PixelFormat, Provider, Result};
66

7+
fn skip_camera_tests() -> bool {
8+
std::env::var("CCAP_SKIP_CAMERA_TESTS").is_ok()
9+
}
10+
711
#[test]
812
fn test_provider_creation() -> Result<()> {
913
let provider = Provider::new()?;
@@ -22,6 +26,10 @@ fn test_library_version() -> Result<()> {
2226

2327
#[test]
2428
fn test_device_listing() -> Result<()> {
29+
if skip_camera_tests() {
30+
eprintln!("Skipping device_listing due to CCAP_SKIP_CAMERA_TESTS");
31+
return Ok(());
32+
}
2533
let provider = Provider::new()?;
2634
let devices = provider.list_devices()?;
2735
// In test environment we might not have cameras, so just check it doesn't crash
@@ -49,6 +57,10 @@ fn test_error_types() {
4957

5058
#[test]
5159
fn test_provider_with_index() {
60+
if skip_camera_tests() {
61+
eprintln!("Skipping provider_with_index due to CCAP_SKIP_CAMERA_TESTS");
62+
return;
63+
}
5264
// This might fail if no device at index 0, but should not crash
5365
match Provider::with_device(0) {
5466
Ok(_provider) => {
@@ -62,6 +74,10 @@ fn test_provider_with_index() {
6274

6375
#[test]
6476
fn test_device_operations_without_camera() {
77+
if skip_camera_tests() {
78+
eprintln!("Skipping device_operations_without_camera due to CCAP_SKIP_CAMERA_TESTS");
79+
return;
80+
}
6581
// Test that operations work regardless of camera presence
6682
let provider = Provider::new().expect("Failed to create provider");
6783

0 commit comments

Comments
 (0)