Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

[Impeller] started asserting golden test runner has fatal impeller validations #51357

Merged
merged 7 commits into from
Mar 14, 2024
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
11 changes: 8 additions & 3 deletions impeller/base/validation.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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
8 changes: 2 additions & 6 deletions impeller/base/validation.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 <sstream>

namespace impeller {
Expand Down Expand Up @@ -39,6 +33,8 @@ void ImpellerValidationBreak(const char* message);

void ImpellerValidationErrorsSetFatal(bool fatal);

bool ImpellerValidationErrorsAreFatal();

struct ScopedValidationDisable {
ScopedValidationDisable();

Expand Down
8 changes: 8 additions & 0 deletions impeller/golden_tests/main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -24,7 +25,14 @@ void print_usage() {
}
} // namespace

namespace impeller {
TEST(ValidationTest, IsFatal) {
EXPECT_TRUE(ImpellerValidationErrorsAreFatal());
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried to use EXPECT_EXIT but I couldn't get it to stop killing the process.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You want to use EXPECT_DEATH?

That seems to work for me

}
} // namespace impeller

int main(int argc, char** argv) {
impeller::ImpellerValidationErrorsSetFatal(true);
fml::InstallCrashHandler();
testing::InitGoogleTest(&argc, argv);
fml::CommandLine cmd = fml::CommandLineFromPlatformOrArgcArgv(argc, argv);
Expand Down