44
55use 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]
812fn test_provider_creation ( ) -> Result < ( ) > {
913 let provider = Provider :: new ( ) ?;
@@ -22,6 +26,10 @@ fn test_library_version() -> Result<()> {
2226
2327#[ test]
2428fn 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]
5159fn 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]
6476fn 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