Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions src/rawtoaces_core/rawtoaces_core.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
6 changes: 6 additions & 0 deletions src/rawtoaces_util/image_converter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,12 @@ std::vector<std::string> 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";
Expand Down
62 changes: 61 additions & 1 deletion tests/test_image_converter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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" );
Expand Down Expand Up @@ -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<double> WB_multipliers = { 1.5, 1.0, 1.2, 1.0 };
std::vector<std::vector<double>> IDT_matrix;
std::vector<std::vector<double>> 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()
{
Expand Down Expand Up @@ -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();
Expand Down
Loading