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

Commit cc1e7d1

Browse files
authored
[Impeller] started asserting golden test runner has fatal impeller validations (#51357)
fixes flutter/flutter#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
1 parent 41fce3f commit cc1e7d1

File tree

3 files changed

+18
-9
lines changed

3 files changed

+18
-9
lines changed

impeller/base/validation.cc

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,17 +46,22 @@ std::ostream& ValidationLog::GetStream() {
4646
}
4747

4848
void ImpellerValidationBreak(const char* message) {
49-
// Nothing to do. Exists for the debugger.
50-
#ifdef IMPELLER_ENABLE_VALIDATION
5149
std::stringstream stream;
50+
#if FLUTTER_RELEASE
51+
stream << "Impeller validation: " << message;
52+
#else
5253
stream << "Break on '" << __FUNCTION__
5354
<< "' to inspect point of failure: " << message;
55+
#endif
5456
if (sValidationLogsAreFatal > 0) {
5557
FML_LOG(FATAL) << stream.str();
5658
} else {
5759
FML_LOG(ERROR) << stream.str();
5860
}
59-
#endif // IMPELLER_ENABLE_VALIDATION
61+
}
62+
63+
bool ImpellerValidationErrorsAreFatal() {
64+
return sValidationLogsAreFatal;
6065
}
6166

6267
} // namespace impeller

impeller/base/validation.h

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,6 @@
55
#ifndef FLUTTER_IMPELLER_BASE_VALIDATION_H_
66
#define FLUTTER_IMPELLER_BASE_VALIDATION_H_
77

8-
#ifndef IMPELLER_ENABLE_VALIDATION
9-
#ifdef IMPELLER_DEBUG
10-
#define IMPELLER_ENABLE_VALIDATION 1
11-
#endif
12-
#endif
13-
148
#include <sstream>
159

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

4034
void ImpellerValidationErrorsSetFatal(bool fatal);
4135

36+
bool ImpellerValidationErrorsAreFatal();
37+
4238
struct ScopedValidationDisable {
4339
ScopedValidationDisable();
4440

impeller/golden_tests/main.cc

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
#include "flutter/fml/build_config.h"
99
#include "flutter/fml/command_line.h"
1010
#include "flutter/fml/logging.h"
11+
#include "flutter/impeller/base/validation.h"
1112
#include "flutter/impeller/golden_tests/golden_digest.h"
1213
#include "flutter/impeller/golden_tests/working_directory.h"
1314
#include "gtest/gtest.h"
@@ -24,7 +25,14 @@ void print_usage() {
2425
}
2526
} // namespace
2627

28+
namespace impeller {
29+
TEST(ValidationTest, IsFatal) {
30+
EXPECT_TRUE(ImpellerValidationErrorsAreFatal());
31+
}
32+
} // namespace impeller
33+
2734
int main(int argc, char** argv) {
35+
impeller::ImpellerValidationErrorsSetFatal(true);
2836
fml::InstallCrashHandler();
2937
testing::InitGoogleTest(&argc, argv);
3038
fml::CommandLine cmd = fml::CommandLineFromPlatformOrArgcArgv(argc, argv);

0 commit comments

Comments
 (0)