43 std::vector<std::string> expectedErrors;
44 constexpr char kExpectedErrorsStart[] =
"/*%%*";
45 constexpr char kExpectedErrorsEnd[] =
"*%%*/";
46 if (
const char* startPtr = strstr(shaderString, kExpectedErrorsStart)) {
47 startPtr += strlen(kExpectedErrorsStart);
48 if (
const char* endPtr = strstr(startPtr, kExpectedErrorsEnd)) {
50 std::stringstream
stream{std::string{startPtr, endPtr}};
52 expectedErrors.push_back({});
53 std::getline(
stream, expectedErrors.back(),
'\n');
54 if (expectedErrors.back().empty()) {
55 expectedErrors.pop_back();
61 return expectedErrors;
66 const std::vector<std::string>& expectedErrors,
67 std::string reportedErrors) {
70 std::string originalErrors = reportedErrors;
71 bool reportOriginalErrors =
false;
72 for (
const std::string& expectedError : expectedErrors) {
74 size_t pos = reportedErrors.find(expectedError.c_str());
75 if (
pos == std::string::npos) {
76 ERRORF(r,
"%s: Expected an error that wasn't reported:\n%s\n",
78 reportOriginalErrors =
true;
83 reportedErrors.erase(0,
pos + expectedError.size());
87 if (reportOriginalErrors) {
88 ERRORF(r,
"%s: The following errors were reported:\n%s\n",
99 "sksl/errors/InvalidBackendBindingFlagsGL.sksl",
100 "sksl/errors/InvalidThreadgroupRTS.rts",
101 "sksl/errors/LastFragColorWithoutCaps.sksl",
102 "sksl/errors/MeshFragmentWithShader.mfrag",
103 "sksl/errors/MeshFragmentWithBlender.mfrag",
104 "sksl/errors/MeshFragmentWithColorFilter.mfrag",
105 "sksl/errors/StaticIfTest.sksl",
106 "sksl/errors/StaticSwitchConditionalBreak.sksl",
107 "sksl/errors/StaticSwitchTest.sksl",
108 "sksl/errors/StaticSwitchWithConditionalBreak.sksl",
109 "sksl/errors/StaticSwitchWithConditionalContinue.sksl",
110 "sksl/errors/StaticSwitchWithConditionalReturn.sksl",
112 "sksl/errors/ComputeUniform.compute",
113 "sksl/errors/DuplicateBinding.compute",
114 "sksl/errors/InvalidThreadgroupCompute.compute",
115 "sksl/errors/UnspecifiedBinding.compute",
117 "sksl/runtime_errors/ReservedNameISampler2D.rts",
119#ifdef SK_ENABLE_OPTIMIZE_SIZE
120 "sksl/errors/ArrayInlinedIndexOutOfRange.sksl",
121 "sksl/errors/MatrixInlinedIndexOutOfRange.sksl",
122 "sksl/errors/OverflowInlinedLiteral.sksl",
123 "sksl/errors/VectorInlinedIndexOutOfRange.sksl",
126 if (kTestsToSkip->contains(testFile)) {
127 INFOF(r,
"%s: skipped in SK_ENABLE_OPTIMIZE_SIZE mode", testFile);
137 std::string shaderString{
reinterpret_cast<const char*
>(shaderData->
bytes()),
145 std::unique_ptr<SkSL::Program> program =
compiler.convertProgram(kind, std::move(shaderString),
150 ERRORF(r,
"%s: Expected failure, but compiled successfully",
159 const char* extension,
208 iterate_dir(
"sksl/runtime_errors/",
".privrts", [&](
const char*
path) {
sk_sp< SkData > GetResourceAsData(const char *resource)
SkString GetResourcePath(const char *resource)
static void iterate_dir(const char *directory, const char *extension, const std::function< void(const char *)> &run)
static void check_expected_errors(skiatest::Reporter *r, const char *testFile, const std::vector< std::string > &expectedErrors, std::string reportedErrors)
static void test_expect_fail(skiatest::Reporter *r, const char *testFile, SkSL::ProgramKind kind)
static std::vector< std::string > get_expected_errors(const char *shaderString)
DEF_TEST(SkSLErrorTest, r)
#define INFOF(REPORTER,...)
const uint8_t * bytes() const
SK_SPI bool next(SkString *name, bool getDir=false)
static SkString Join(const char *rootPath, const char *relativePath)
static SkString Basename(const char *fullPath)
const char * c_str() const
Dart_NativeFunction function
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot The VM snapshot data that will be memory mapped as read only SnapshotAssetPath must be present isolate snapshot The isolate snapshot data that will be memory mapped as read only SnapshotAssetPath must be present cache dir path
DEF_SWITCHES_START aot vmservice shared library name