[Impeller] started asserting golden test runner has fatal impeller validations (flutter/engine#51357)

fixes https://github.com/flutter/flutter/issues/145017

This works by removing the conditional compilation for validation and
turning them to be fatal in the test runner's main.

## Pre-launch Checklist

- [x] I read the [Contributor Guide] and followed the process outlined
there for submitting PRs.
- [x] I read the [Tree Hygiene] wiki page, which explains my
responsibilities.
- [x] I read and followed the [Flutter Style Guide] and the [C++,
Objective-C, Java style guides].
- [x] I listed at least one issue that this PR fixes in the description
above.
- [x] I added new tests to check the change I am making or feature I am
adding, or the PR is [test-exempt]. See [testing the engine] for
instructions on writing and running engine tests.
- [x] I updated/added relevant documentation (doc comments with `///`).
- [x] I signed the [CLA].
- [x] All existing and new tests are passing.

If you need help, consider asking for advice on the #hackers-new channel
on [Discord].

<!-- Links -->
[Contributor Guide]:
https://github.com/flutter/flutter/wiki/Tree-hygiene#overview
[Tree Hygiene]: https://github.com/flutter/flutter/wiki/Tree-hygiene
[test-exempt]:
https://github.com/flutter/flutter/wiki/Tree-hygiene#tests
[Flutter Style Guide]:
https://github.com/flutter/flutter/wiki/Style-guide-for-Flutter-repo
[C++, Objective-C, Java style guides]:
https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
[testing the engine]:
https://github.com/flutter/flutter/wiki/Testing-the-engine
[CLA]: https://cla.developers.google.com/
[flutter/tests]: https://github.com/flutter/tests
[breaking change policy]:
https://github.com/flutter/flutter/wiki/Tree-hygiene#handling-breaking-changes
[Discord]: https://github.com/flutter/flutter/wiki/Chat
This commit is contained in:
gaaclarke
2024-03-14 09:05:34 -07:00
committed by GitHub
parent 31b0fb1ea3
commit 74ed8ebed6
3 changed files with 18 additions and 9 deletions

View File

@@ -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

View File

@@ -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 {
@@ -39,6 +33,8 @@ void ImpellerValidationBreak(const char* message);
void ImpellerValidationErrorsSetFatal(bool fatal);
bool ImpellerValidationErrorsAreFatal();
struct ScopedValidationDisable {
ScopedValidationDisable();

View File

@@ -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);