Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adsk Contrib - Fix warning/errors log in unit test #1786

2 changes: 1 addition & 1 deletion src/OpenColorIO/Config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1996,7 +1996,7 @@ void Config::validate() const
{
std::ostringstream os;
os << "Inactive '" << name << "' is neither a color space nor a named transform.";
LogWarning(os.str());
LogInfo(os.str());
}
}
}
Expand Down
3 changes: 3 additions & 0 deletions src/apps/ociocheck/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@ int main(int argc, const char **argv)
return 1;
}

// Set the logging level to INFO.
OCIO::SetLoggingLevel(OCIO::LOGGING_LEVEL_INFO);

try
{
OCIO::ConstConfigRcPtr srcConfig;
Expand Down
126 changes: 45 additions & 81 deletions tests/cpu/Config_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -357,51 +357,19 @@ OCIO_ADD_TEST(Config, required_roles_for_version_2_2)
}

{
// Test that all errors appears when all required roles are missing.
// Test that all errors appear when all required roles are missing.

OCIO::LogGuard logGuard;
OCIO_CHECK_NO_THROW(config->validate());

StringUtils::StringVec svec = StringUtils::SplitByLines(logGuard.output());
OCIO_CHECK_ASSERT(
StringUtils::Contain(
svec,
"[OpenColorIO Error]: The scene_linear role is required for a config version 2.2 "\
"or higher."
)
);

OCIO_CHECK_ASSERT(
StringUtils::Contain(
svec,
"[OpenColorIO Error]: The compositing_log role is required for a config version "\
"2.2 or higher."
)
);

OCIO_CHECK_ASSERT(
StringUtils::Contain(
svec,
"[OpenColorIO Error]: The color_timing role is required for a config version 2.2 "\
"or higher."
)
);

OCIO_CHECK_ASSERT(
StringUtils::Contain(
svec,
"[OpenColorIO Error]: The aces_interchange role is required when there are "\
"scene-referred color spaces and the config version is 2.2 or higher."
)
);

OCIO_CHECK_ASSERT(
StringUtils::Contain(
svec,
"[OpenColorIO Error]: The cie_xyz_d65_interchange role is required when there are"\
" display-referred color spaces and the config version is 2.2 or higher."
)
);
// Check that the log contains the expected error messages for the missing roles and mute
// them so that (only) those messages don't appear in the test output.
OCIO_CHECK_ASSERT(OCIO::checkAndMuteSceneLinearRoleError(logGuard));
OCIO_CHECK_ASSERT(OCIO::checkAndMuteCompositingLogRoleError(logGuard));
OCIO_CHECK_ASSERT(OCIO::checkAndMuteColorTimingRoleError(logGuard));
OCIO_CHECK_ASSERT(OCIO::checkAndMuteAcesInterchangeRoleError(logGuard));
OCIO_CHECK_ASSERT(OCIO::checkAndMuteDisplayInterchangeRoleError(logGuard));
// If there are any unexpected log messages, print them to the shell.
logGuard.print();
}

// Set colorspace for all required roles.
Expand All @@ -416,11 +384,7 @@ OCIO_ADD_TEST(Config, required_roles_for_version_2_2)

OCIO::LogGuard logGuard;
OCIO_CHECK_NO_THROW(config->validate());

StringUtils::StringVec svec = StringUtils::SplitByLines(logGuard.output());
OCIO_CHECK_ASSERT(
!StringUtils::Contain(svec, "[OpenColorIO Error]")
);
OCIO_CHECK_ASSERT(logGuard.empty());
}

{
Expand Down Expand Up @@ -454,12 +418,7 @@ OCIO_ADD_TEST(Config, required_roles_for_version_2_2)
OCIO_CHECK_NO_THROW(config->validate());

StringUtils::StringVec svec = StringUtils::SplitByLines(logGuard.output());
OCIO_CHECK_ASSERT(
StringUtils::Contain(
svec,
"[OpenColorIO Error]: The compositing_log role is required for a config version 2.2 "\
"or higher.")
);
checkAndMuteCompositingLogRoleError(logGuard);

// Set compositing_log for next test.
config->setRole(OCIO::ROLE_COMPOSITING_LOG, dcs->getName());
Expand All @@ -475,12 +434,7 @@ OCIO_ADD_TEST(Config, required_roles_for_version_2_2)
OCIO_CHECK_NO_THROW(config->validate());

StringUtils::StringVec svec = StringUtils::SplitByLines(logGuard.output());
OCIO_CHECK_ASSERT(
StringUtils::Contain(
svec,
"[OpenColorIO Error]: The color_timing role is required for a config version 2.2 or "\
"higher.")
);
checkAndMuteColorTimingRoleError(logGuard);

// Set color_timing for next test.
config->setRole(OCIO::ROLE_COLOR_TIMING, dcs->getName());
Expand All @@ -494,13 +448,7 @@ OCIO_ADD_TEST(Config, required_roles_for_version_2_2)

OCIO::LogGuard logGuard;
OCIO_CHECK_NO_THROW(config->validate());
OCIO_CHECK_ASSERT(
StringUtils::StartsWith(
logGuard.output(),
"[OpenColorIO Error]: The aces_interchange role is required when there are "\
"scene-referred color spaces and the config version is 2.2 or higher."
)
);
OCIO::checkAndMuteAcesInterchangeRoleError(logGuard);

// Set aces_interchange for next test.
config->setRole(OCIO::ROLE_INTERCHANGE_SCENE, scs->getName());
Expand All @@ -514,21 +462,14 @@ OCIO_ADD_TEST(Config, required_roles_for_version_2_2)

OCIO::LogGuard logGuard;
OCIO_CHECK_NO_THROW(config->validate());

StringUtils::StringVec svec = StringUtils::SplitByLines(logGuard.output());
OCIO_CHECK_ASSERT(
StringUtils::Contain(
svec,
"[OpenColorIO Error]: The cie_xyz_d65_interchange role is required when there are "\
"display-referred color spaces and the config version is 2.2 or higher.")
);
OCIO::checkAndMuteDisplayInterchangeRoleError(logGuard);

// Set cie_xyz_d65_interchange for next test.
config->setRole(OCIO::ROLE_INTERCHANGE_DISPLAY, dcs->getName());
}

{
// Test that aces_interchange role has the wrong colorspace type.
// Test detection of the aces_interchange role having the wrong colorspace type.

// Set a display-referred colorspace to both interchange roles.
config->setRole(OCIO::ROLE_INTERCHANGE_SCENE, dcs->getName());
Expand All @@ -544,7 +485,7 @@ OCIO_ADD_TEST(Config, required_roles_for_version_2_2)
}

{
// Test that cie_xyz_d65_interchange role has the wrong colorspace type.
// Test detection of the cie_xyz_d65_interchange role having the wrong colorspace type.

// Set a scene-referred colorspace to both interchange roles.
config->setRole(OCIO::ROLE_INTERCHANGE_SCENE, scs->getName());
Expand Down Expand Up @@ -574,8 +515,7 @@ OCIO_ADD_TEST(Config, required_roles_for_version_2_2)

OCIO::LogGuard logGuard;
OCIO_CHECK_NO_THROW(config->validate());
OCIO_CHECK_ASSERT(
StringUtils::StartsWith(logGuard.output(), ""));
OCIO_CHECK_ASSERT(logGuard.empty());
}
}

Expand Down Expand Up @@ -5906,7 +5846,7 @@ OCIO_ADD_TEST(Config, inactive_color_space_read_write)
OCIO::LogGuard log;
OCIO_CHECK_NO_THROW(config->validate());
OCIO_CHECK_EQUAL(log.output(),
"[OpenColorIO Warning]: Inactive 'unknown' is neither a color "
"[OpenColorIO Info]: Inactive 'unknown' is neither a color "
"space nor a named transform.\n");
}

Expand Down Expand Up @@ -6365,6 +6305,8 @@ OCIO_ADD_TEST(Config, display_view)
config->addColorSpace(cs);
}

config->setVersion(2, 1);

// Add a scene-referred and a display-referred color space.
auto cs = OCIO::ColorSpace::Create(OCIO::REFERENCE_SPACE_SCENE);
cs->setName("scs");
Expand Down Expand Up @@ -6406,7 +6348,7 @@ OCIO_ADD_TEST(Config, display_view)

std::stringstream os;
os << *config.get();
constexpr char expected[]{ R"(ocio_profile_version: 2.2
constexpr char expected[]{ R"(ocio_profile_version: 2.1

environment:
{}
Expand Down Expand Up @@ -9038,7 +8980,13 @@ OCIO_ADD_TEST(Config, create_builtin_config)
);
OCIO_REQUIRE_ASSERT(config);

OCIO::LogGuard logGuard;
OCIO_CHECK_NO_THROW(config->validate());
// Mute output related to a bug in the initial CG config where the inactive_colorspaces
// list has color spaces that don't exist.
OCIO::muteInactiveColorspaceInfo(logGuard);
logGuard.print();

OCIO_CHECK_EQUAL(
std::string(config->getName()),
cgConfigName
Expand All @@ -9055,7 +9003,11 @@ OCIO_ADD_TEST(Config, create_builtin_config)
OCIO_CHECK_NO_THROW(config = OCIO::Config::CreateFromEnv());
OCIO_REQUIRE_ASSERT(config);

OCIO::LogGuard logGuard;
OCIO_CHECK_NO_THROW(config->validate());
OCIO::muteInactiveColorspaceInfo(logGuard);
logGuard.print();

OCIO_CHECK_EQUAL(
std::string(config->getName()),
cgConfigName
Expand All @@ -9072,7 +9024,11 @@ OCIO_ADD_TEST(Config, create_builtin_config)
);
OCIO_REQUIRE_ASSERT(config);

OCIO::LogGuard logGuard;
OCIO_CHECK_NO_THROW(config->validate());
OCIO::muteInactiveColorspaceInfo(logGuard);
logGuard.print();

OCIO_CHECK_EQUAL(
std::string(config->getName()),
cgConfigName
Expand Down Expand Up @@ -9151,7 +9107,11 @@ OCIO_ADD_TEST(Config, create_builtin_config)
OCIO_CHECK_NO_THROW(config = OCIO::Config::CreateFromEnv());
OCIO_REQUIRE_ASSERT(config);

OCIO::LogGuard logGuard;
OCIO_CHECK_NO_THROW(config->validate());
OCIO::muteInactiveColorspaceInfo(logGuard);
logGuard.print();

OCIO_CHECK_EQUAL(
std::string(config->getName()),
std::string("cg-config-v1.0.0_aces-v1.3_ocio-v2.1")
Expand All @@ -9165,8 +9125,12 @@ OCIO_ADD_TEST(Config, create_builtin_config)
OCIO::ConstConfigRcPtr config;
OCIO_CHECK_NO_THROW(config = OCIO::Config::CreateFromFile("ocio://default"));
OCIO_REQUIRE_ASSERT(config);


OCIO::LogGuard logGuard;
OCIO_CHECK_NO_THROW(config->validate());
OCIO::muteInactiveColorspaceInfo(logGuard);
logGuard.print();

OCIO_CHECK_EQUAL(
std::string(config->getName()),
std::string("cg-config-v1.0.0_aces-v1.3_ocio-v2.1")
Expand Down
Loading