From 83459a4e8b13a1903f69c8e682ca9e6c6a80d20a Mon Sep 17 00:00:00 2001 From: Anton Dukhovnikov Date: Thu, 9 Apr 2026 12:58:24 +1200 Subject: [PATCH] add homebrew location to default DB search path Signed-off-by: Anton Dukhovnikov --- src/rawtoaces_core/rawtoaces_core.cpp | 12 ++++- src/rawtoaces_util/image_converter.cpp | 6 +++ tests/test_image_converter.cpp | 62 +++++++++++++++++++++++++- 3 files changed, 77 insertions(+), 3 deletions(-) diff --git a/src/rawtoaces_core/rawtoaces_core.cpp b/src/rawtoaces_core/rawtoaces_core.cpp index 0bef55c9..4483f68c 100644 --- a/src/rawtoaces_core/rawtoaces_core.cpp +++ b/src/rawtoaces_core/rawtoaces_core.cpp @@ -263,8 +263,16 @@ SpectralSolver::collect_data_files( const std::string &type ) const } else { - std::cerr << "Warning: Database location '" << directory - << "' is not a directory." << std::endl; + if ( std::filesystem::exists( directory ) ) + { + std::cerr << "Warning: Database location '" << directory + << "' is not a directory." << std::endl; + } + else + { + std::cerr << "Warning: Database location '" << directory + << "' does not exist." << std::endl; + } } } return result; diff --git a/src/rawtoaces_util/image_converter.cpp b/src/rawtoaces_util/image_converter.cpp index 9c2275eb..2d4dbfec 100644 --- a/src/rawtoaces_util/image_converter.cpp +++ b/src/rawtoaces_util/image_converter.cpp @@ -223,6 +223,12 @@ std::vector database_paths( const std::string &override_path = "" ) #if defined( WIN32 ) || defined( WIN64 ) const std::string separator = ";"; const std::string default_path = "."; +#elif defined( __APPLE__ ) + const std::string separator = ":"; + const std::string legacy_path = "/usr/local/include/rawtoaces/data"; + const std::string default_path = + "/usr/local/share/rawtoaces/data" + separator + + "/opt/homebrew/share/rawtoaces/data" + separator + legacy_path; #else const std::string separator = ":"; const std::string legacy_path = "/usr/local/include/rawtoaces/data"; diff --git a/tests/test_image_converter.cpp b/tests/test_image_converter.cpp index c60e72e0..5fff32cd 100644 --- a/tests/test_image_converter.cpp +++ b/tests/test_image_converter.cpp @@ -414,10 +414,15 @@ void test_database_paths_default() OIIO_CHECK_EQUAL( paths.empty(), false ); // On Unix systems, should have both new and legacy paths -#ifdef WIN32 +#if defined( WIN32 ) // On Windows, should have just the current directory OIIO_CHECK_EQUAL( paths.size(), 1 ); OIIO_CHECK_EQUAL( paths[0], "." ); +#elif defined( __APPLE__ ) + OIIO_CHECK_EQUAL( paths.size(), 3 ); + OIIO_CHECK_EQUAL( paths[0], "/usr/local/share/rawtoaces/data" ); + OIIO_CHECK_EQUAL( paths[1], "/opt/homebrew/share/rawtoaces/data" ); + OIIO_CHECK_EQUAL( paths[2], "/usr/local/include/rawtoaces/data" ); #else OIIO_CHECK_EQUAL( paths.size(), 2 ); OIIO_CHECK_EQUAL( paths[0], "/usr/local/share/rawtoaces/data" ); @@ -1501,6 +1506,60 @@ void test_database_location_not_directory_warning() std::filesystem::remove( file_path ); } +/// Tests that a warning is issued when a database location path does not exist. +void test_database_location_missing_warning() +{ + std::cout << "\n" << __FUNCTION__ << std::endl; + + // Create test directory + TestFixture fixture; + auto &test_dir = + fixture.with_camera( "Blackmagic", "Cinema Camera" ).build(); + + std::filesystem::path directory_path = + std::filesystem::temp_directory_path() / "missing_directory"; + + // Create a mock ImageSpec with camera metadata + auto image_spec = + ImageSpecBuilder().camera( "Blackmagic", "Cinema Camera" ).build(); + + // Configure settings with missing directory as database location + ImageConverter::Settings settings; + settings.database_directories = { directory_path.string(), + test_dir.get_database_path() }; + settings.illuminant = ""; // Empty to trigger auto-detection + settings.verbosity = 1; + + // Make sure the transform is not in the cache, otherwise DB look up + // will no be triggered. + settings.disable_cache = true; + + // Provide WB_multipliers + std::vector WB_multipliers = { 1.5, 1.0, 1.2, 1.0 }; + std::vector> IDT_matrix; + std::vector> CAT_matrix; + + bool success; + std::string error_message; + std::string output = capture_stderr( [&]() { + // This should succeed (using the valid database path) + // but should warn about the file path not being a directory + success = prepare_transform_spectral( + image_spec, + settings, + WB_multipliers, + IDT_matrix, + CAT_matrix, + error_message ); + } ); + + OIIO_CHECK_ASSERT( success ); + + // Assert on expected warning + ASSERT_CONTAINS( output, "Warning: Database location '" ); + ASSERT_CONTAINS( output, "' does not exist." ); +} + /// Tests that spectral data can be loaded using an absolute file path void test_load_spectral_data_absolute_path() { @@ -2979,6 +3038,7 @@ int main( int, char ** ) test_invalid_blackbody_cct_exits(); test_auto_detect_illuminant_with_wb_multipliers(); test_database_location_not_directory_warning(); + test_database_location_missing_warning(); test_load_spectral_data_absolute_path(); test_illuminant_file_load_failure(); test_illuminant_type_mismatch();