skia2/dm/DMTestTask.cpp
mtklein 008f1ea581 Store DM failures in an array, not a single string.
This should fix the problem where a repeatedly failing test causes this assertion:
  ../../src/core/SkString.cpp:572: failed assertion "length >= 0 && length < SkToInt(kBufferSize)"

Example output:

0 GMs x 7 configs, 2 tests, 0 pictures
0 tasks left, 100 failed
Failures:
  test RTree: ../../tests/RTreeTest.cpp:77	0 != rtree.getCount()
  test RTree: ../../tests/RTreeTest.cpp:77	0 != rtree.getCount()
  test RTree: ../../tests/RTreeTest.cpp:77	0 != rtree.getCount()
  test RTree: ../../tests/RTreeTest.cpp:77	0 != rtree.getCount()
  < 95 lines elided >
  test RTree: ../../tests/RTreeTest.cpp:77	0 != rtree.getCount()
100 failures.

BUG=skia:

Review URL: https://codereview.chromium.org/741833002
2014-11-19 13:36:19 -08:00

62 lines
1.7 KiB
C++

#include "DMTestTask.h"
#include "DMUtil.h"
#include "SkCommandLineFlags.h"
#include "SkCommonFlags.h"
DEFINE_bool2(pathOpsExtended, x, false, "Run extended pathOps tests.");
namespace DM {
bool TestReporter::allowExtendedTest() const { return FLAGS_pathOpsExtended; }
bool TestReporter::verbose() const { return FLAGS_veryVerbose; }
static SkString test_name(const char* name) {
SkString result("test ");
result.append(name);
return result;
}
CpuTestTask::CpuTestTask(Reporter* reporter,
TaskRunner* taskRunner,
skiatest::TestRegistry::Factory factory)
: CpuTask(reporter, taskRunner)
, fTest(factory(NULL))
, fName(test_name(fTest->getName())) {}
GpuTestTask::GpuTestTask(Reporter* reporter,
TaskRunner* taskRunner,
skiatest::TestRegistry::Factory factory)
: GpuTask(reporter, taskRunner)
, fTest(factory(NULL))
, fName(test_name(fTest->getName())) {}
void CpuTestTask::draw() {
fTest->setReporter(&fTestReporter);
fTest->run();
if (!fTest->passed()) {
const SkTArray<SkString>& failures = fTestReporter.failures();
for (int i = 0; i < failures.count(); i++) {
this->fail(failures[i].c_str());
}
}
}
void GpuTestTask::draw(GrContextFactory* grFactory) {
fTest->setGrContextFactory(grFactory);
fTest->setReporter(&fTestReporter);
fTest->run();
if (!fTest->passed()) {
const SkTArray<SkString>& failures = fTestReporter.failures();
for (int i = 0; i < failures.count(); i++) {
this->fail(failures[i].c_str());
}
}
}
bool GpuTestTask::shouldSkip() const {
return kGPUDisabled;
}
} // namespace DM