fix error reporting for doc examples
Switching parts of bookmaker to use SkJSONCPP.h introduced a couple of bugs. Fix them. Report errors found when parsing fiddleout.json, the results of compiling doc examples. Parse status.json correctly for spell checking. TBR=fmalita@chromium.org Bug: skia:8376 Change-Id: I86d92b0613ece54495efb43424b8fca56aa2cdaf Reviewed-on: https://skia-review.googlesource.com/154623 Reviewed-by: Cary Clark <caryclark@skia.org> Commit-Queue: Cary Clark <caryclark@skia.org> Auto-Submit: Cary Clark <caryclark@skia.org>
This commit is contained in:
parent
0495f7aec3
commit
7724d3f494
@ -7,6 +7,13 @@
|
||||
|
||||
#include "bookmaker.h"
|
||||
|
||||
// could make this more elaborate and look up the example definition in the bmh file;
|
||||
// see if a simpler hint provided is sufficient
|
||||
static bool report_error(const char* blockName, const char* errorMessage) {
|
||||
SkDebugf("%s: %s\n", blockName, errorMessage);
|
||||
return false;
|
||||
}
|
||||
|
||||
bool FiddleBase::parseFiddles() {
|
||||
if (fStack.empty()) {
|
||||
return false;
|
||||
@ -17,35 +24,35 @@ bool FiddleBase::parseFiddles() {
|
||||
Definition* example = nullptr;
|
||||
string textString;
|
||||
if (!status->fObject.isObject()) {
|
||||
return this->reportError<bool>("expected object");
|
||||
return report_error(blockName, "expected object");
|
||||
}
|
||||
for (auto iter = status->fIter->begin(); status->fIter->end() != iter; ++iter) {
|
||||
const char* memberName = iter.memberName();
|
||||
if (!strcmp("compile_errors", memberName)) {
|
||||
if (!iter->isArray()) {
|
||||
return this->reportError<bool>("expected array");
|
||||
return report_error(blockName, "expected array");
|
||||
}
|
||||
if (iter->size()) {
|
||||
return this->reportError<bool>("fiddle compiler error");
|
||||
return report_error(blockName, "fiddle compiler error");
|
||||
}
|
||||
continue;
|
||||
}
|
||||
if (!strcmp("runtime_error", memberName)) {
|
||||
if (!iter->isString()) {
|
||||
return this->reportError<bool>("expected string 1");
|
||||
return report_error(blockName, "expected string 1");
|
||||
}
|
||||
if (iter->asString().length()) {
|
||||
return this->reportError<bool>("fiddle runtime error");
|
||||
return report_error(blockName, "fiddle runtime error");
|
||||
}
|
||||
continue;
|
||||
}
|
||||
if (!strcmp("fiddleHash", memberName)) {
|
||||
if (!iter->isString()) {
|
||||
return this->reportError<bool>("expected string 2");
|
||||
return report_error(blockName, "expected string 2");
|
||||
}
|
||||
example = this->findExample(blockName);
|
||||
if (!example) {
|
||||
return this->reportError<bool>("missing example");
|
||||
return report_error(blockName, "missing example");
|
||||
}
|
||||
if (example->fHash.length() && example->fHash != iter->asString()) {
|
||||
return example->reportError<bool>("mismatched hash");
|
||||
@ -55,15 +62,15 @@ bool FiddleBase::parseFiddles() {
|
||||
}
|
||||
if (!strcmp("text", memberName)) {
|
||||
if (!iter->isString()) {
|
||||
return this->reportError<bool>("expected string 3");
|
||||
return report_error(blockName, "expected string 3");
|
||||
}
|
||||
textString = iter->asString();
|
||||
continue;
|
||||
}
|
||||
return this->reportError<bool>("unexpected key");
|
||||
return report_error(blockName, "unexpected key");
|
||||
}
|
||||
if (!example) {
|
||||
return this->reportError<bool>("missing fiddleHash");
|
||||
return report_error(blockName, "missing fiddleHash");
|
||||
}
|
||||
size_t strLen = textString.length();
|
||||
if (strLen) {
|
||||
|
@ -111,6 +111,8 @@ void BmhParser::spellCheck(const char* match, SkCommandLineFlags::StringArray re
|
||||
void BmhParser::spellStatus(const char* statusFile, SkCommandLineFlags::StringArray report) const {
|
||||
SpellCheck checker(*this);
|
||||
StatusIter iter(statusFile, ".bmh", StatusFilter::kInProgress);
|
||||
string file;
|
||||
iter.next(&file);
|
||||
string match = iter.baseDir();
|
||||
checker.check(match.c_str());
|
||||
checker.report(report);
|
||||
|
Loading…
Reference in New Issue
Block a user