diff --git a/impeller/base/validation.cc b/impeller/base/validation.cc index d68aa6d888bc6..d95a84c811c89 100644 --- a/impeller/base/validation.cc +++ b/impeller/base/validation.cc @@ -46,17 +46,22 @@ std::ostream& ValidationLog::GetStream() { } void ImpellerValidationBreak(const char* message) { -// Nothing to do. Exists for the debugger. -#ifdef IMPELLER_ENABLE_VALIDATION std::stringstream stream; +#if FLUTTER_RELEASE + stream << "Impeller validation: " << message; +#else stream << "Break on '" << __FUNCTION__ << "' to inspect point of failure: " << message; +#endif if (sValidationLogsAreFatal > 0) { FML_LOG(FATAL) << stream.str(); } else { FML_LOG(ERROR) << stream.str(); } -#endif // IMPELLER_ENABLE_VALIDATION +} + +bool ImpellerValidationErrorsAreFatal() { + return sValidationLogsAreFatal; } } // namespace impeller diff --git a/impeller/base/validation.h b/impeller/base/validation.h index a015686c06851..6d3ca3a52d19f 100644 --- a/impeller/base/validation.h +++ b/impeller/base/validation.h @@ -5,12 +5,6 @@ #ifndef FLUTTER_IMPELLER_BASE_VALIDATION_H_ #define FLUTTER_IMPELLER_BASE_VALIDATION_H_ -#ifndef IMPELLER_ENABLE_VALIDATION -#ifdef IMPELLER_DEBUG -#define IMPELLER_ENABLE_VALIDATION 1 -#endif -#endif - #include namespace impeller { @@ -39,6 +33,8 @@ void ImpellerValidationBreak(const char* message); void ImpellerValidationErrorsSetFatal(bool fatal); +bool ImpellerValidationErrorsAreFatal(); + struct ScopedValidationDisable { ScopedValidationDisable(); diff --git a/impeller/golden_tests/main.cc b/impeller/golden_tests/main.cc index e1ed2a8c4eccc..4791f3818a9f0 100644 --- a/impeller/golden_tests/main.cc +++ b/impeller/golden_tests/main.cc @@ -8,6 +8,7 @@ #include "flutter/fml/build_config.h" #include "flutter/fml/command_line.h" #include "flutter/fml/logging.h" +#include "flutter/impeller/base/validation.h" #include "flutter/impeller/golden_tests/golden_digest.h" #include "flutter/impeller/golden_tests/working_directory.h" #include "gtest/gtest.h" @@ -24,7 +25,14 @@ void print_usage() { } } // namespace +namespace impeller { +TEST(ValidationTest, IsFatal) { + EXPECT_TRUE(ImpellerValidationErrorsAreFatal()); +} +} // namespace impeller + int main(int argc, char** argv) { + impeller::ImpellerValidationErrorsSetFatal(true); fml::InstallCrashHandler(); testing::InitGoogleTest(&argc, argv); fml::CommandLine cmd = fml::CommandLineFromPlatformOrArgcArgv(argc, argv);