2014-02-26 16:31:22 +00:00
|
|
|
#ifndef DMTestTask_DEFINED
|
|
|
|
#define DMTestTask_DEFINED
|
|
|
|
|
|
|
|
#include "DMReporter.h"
|
When running DM, write test failures to json.
Add skiatest::Failure to keep track of data about a test failure.
Reporter::reportFailed and ::onReportFailed now take Failure as a
parameter. This allows the implementation to treat the failure as it
wishes. Provide a helper to format the failure the same as prior to
the change.
Update the macros for calling reportFailed (REPORTER_ASSERT etc) to
create a Failure object.
Convert a direct call to reportFailed to the macro ERRORF.
Write Failures to Json.
Sample output when running dm on the dummy test crrev.com/705723004:
{
"test_results" : {
"failures" : [
{
"condition" : "0 > 3",
"file_name" : "../../tests/DummyTest.cpp",
"line_no" : 10,
"message" : ""
},
{
"condition" : "false",
"file_name" : "../../tests/DummyTest.cpp",
"line_no" : 4,
"message" : ""
},
{
"condition" : "1 == 3",
"file_name" : "../../tests/DummyTest.cpp",
"line_no" : 5,
"message" : "I can too count!"
},
{
"condition" : "",
"file_name" : "../../tests/DummyTest.cpp",
"line_no" : 6,
"message" : "seven is 7"
},
{
"condition" : "1 == 3",
"file_name" : "../../tests/DummyTest.cpp",
"line_no" : 14,
"message" : "I can too count!"
}
]
}
}
Report all of the failures from one test.
Previously, if one test had multiple failures, only one was reportered.
e.g:
Failures:
test Dummy: ../../tests/DummyTest.cpp:6 seven is 7
test Dummy2: ../../tests/DummyTest.cpp:10 0 > 3
test Dummy3: ../../tests/DummyTest.cpp:14 I can too count!: 1 == 3
3 failures.
Now, we get all the messages:
Failures:
test Dummy: ../../tests/DummyTest.cpp:4 false
../../tests/DummyTest.cpp:5 I can too count!: 1 == 3
../../tests/DummyTest.cpp:6 seven is 7
test Dummy2: ../../tests/DummyTest.cpp:10 0 > 3
test Dummy3: ../../tests/DummyTest.cpp:14 I can too count!: 1 == 3
3 failures.
(Note that we still state "3 failures" because 3 DM::Tasks failed.)
BUG=skia:3082
BUG=skia:2454
Review URL: https://codereview.chromium.org/694703005
2014-11-07 14:07:32 +00:00
|
|
|
#include "DMJsonWriter.h"
|
2014-02-26 16:31:22 +00:00
|
|
|
#include "DMTask.h"
|
|
|
|
#include "DMTaskRunner.h"
|
|
|
|
#include "SkString.h"
|
|
|
|
#include "SkTemplates.h"
|
|
|
|
#include "Test.h"
|
|
|
|
|
|
|
|
// Runs a unit test.
|
|
|
|
namespace DM {
|
|
|
|
|
2014-02-28 20:31:31 +00:00
|
|
|
class TestReporter : public skiatest::Reporter {
|
2014-02-26 16:31:22 +00:00
|
|
|
public:
|
2014-02-28 20:31:31 +00:00
|
|
|
TestReporter() {}
|
|
|
|
|
2014-11-19 21:36:19 +00:00
|
|
|
const SkTArray<SkString>& failures() const { return fFailures; }
|
2014-02-28 20:31:31 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
virtual bool allowExtendedTest() const SK_OVERRIDE;
|
|
|
|
virtual bool verbose() const SK_OVERRIDE;
|
|
|
|
|
When running DM, write test failures to json.
Add skiatest::Failure to keep track of data about a test failure.
Reporter::reportFailed and ::onReportFailed now take Failure as a
parameter. This allows the implementation to treat the failure as it
wishes. Provide a helper to format the failure the same as prior to
the change.
Update the macros for calling reportFailed (REPORTER_ASSERT etc) to
create a Failure object.
Convert a direct call to reportFailed to the macro ERRORF.
Write Failures to Json.
Sample output when running dm on the dummy test crrev.com/705723004:
{
"test_results" : {
"failures" : [
{
"condition" : "0 > 3",
"file_name" : "../../tests/DummyTest.cpp",
"line_no" : 10,
"message" : ""
},
{
"condition" : "false",
"file_name" : "../../tests/DummyTest.cpp",
"line_no" : 4,
"message" : ""
},
{
"condition" : "1 == 3",
"file_name" : "../../tests/DummyTest.cpp",
"line_no" : 5,
"message" : "I can too count!"
},
{
"condition" : "",
"file_name" : "../../tests/DummyTest.cpp",
"line_no" : 6,
"message" : "seven is 7"
},
{
"condition" : "1 == 3",
"file_name" : "../../tests/DummyTest.cpp",
"line_no" : 14,
"message" : "I can too count!"
}
]
}
}
Report all of the failures from one test.
Previously, if one test had multiple failures, only one was reportered.
e.g:
Failures:
test Dummy: ../../tests/DummyTest.cpp:6 seven is 7
test Dummy2: ../../tests/DummyTest.cpp:10 0 > 3
test Dummy3: ../../tests/DummyTest.cpp:14 I can too count!: 1 == 3
3 failures.
Now, we get all the messages:
Failures:
test Dummy: ../../tests/DummyTest.cpp:4 false
../../tests/DummyTest.cpp:5 I can too count!: 1 == 3
../../tests/DummyTest.cpp:6 seven is 7
test Dummy2: ../../tests/DummyTest.cpp:10 0 > 3
test Dummy3: ../../tests/DummyTest.cpp:14 I can too count!: 1 == 3
3 failures.
(Note that we still state "3 failures" because 3 DM::Tasks failed.)
BUG=skia:3082
BUG=skia:2454
Review URL: https://codereview.chromium.org/694703005
2014-11-07 14:07:32 +00:00
|
|
|
virtual void onReportFailed(const skiatest::Failure& failure) SK_OVERRIDE {
|
|
|
|
JsonWriter::AddTestFailure(failure);
|
|
|
|
|
|
|
|
SkString newFailure;
|
|
|
|
failure.getFailureString(&newFailure);
|
2014-11-19 21:36:19 +00:00
|
|
|
fFailures.push_back(newFailure);
|
2014-02-28 20:31:31 +00:00
|
|
|
}
|
|
|
|
|
2014-11-19 21:36:19 +00:00
|
|
|
SkTArray<SkString> fFailures;
|
2014-02-28 20:31:31 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
class CpuTestTask : public CpuTask {
|
|
|
|
public:
|
|
|
|
CpuTestTask(Reporter*, TaskRunner*, skiatest::TestRegistry::Factory);
|
2014-02-26 16:31:22 +00:00
|
|
|
|
|
|
|
virtual void draw() SK_OVERRIDE;
|
|
|
|
virtual bool shouldSkip() const SK_OVERRIDE { return false; }
|
|
|
|
virtual SkString name() const SK_OVERRIDE { return fName; }
|
|
|
|
|
|
|
|
private:
|
2014-02-28 20:31:31 +00:00
|
|
|
TestReporter fTestReporter;
|
|
|
|
SkAutoTDelete<skiatest::Test> fTest;
|
|
|
|
const SkString fName;
|
|
|
|
};
|
2014-02-26 16:31:22 +00:00
|
|
|
|
2014-02-28 20:31:31 +00:00
|
|
|
class GpuTestTask : public GpuTask {
|
|
|
|
public:
|
|
|
|
GpuTestTask(Reporter*, TaskRunner*, skiatest::TestRegistry::Factory);
|
2014-02-26 16:31:22 +00:00
|
|
|
|
2014-02-28 20:31:31 +00:00
|
|
|
virtual void draw(GrContextFactory*) SK_OVERRIDE;
|
2014-03-26 21:26:15 +00:00
|
|
|
virtual bool shouldSkip() const SK_OVERRIDE;
|
2014-02-28 20:31:31 +00:00
|
|
|
virtual SkString name() const SK_OVERRIDE { return fName; }
|
2014-02-26 16:31:22 +00:00
|
|
|
|
2014-02-28 20:31:31 +00:00
|
|
|
private:
|
2014-02-26 16:31:22 +00:00
|
|
|
TestReporter fTestReporter;
|
|
|
|
SkAutoTDelete<skiatest::Test> fTest;
|
|
|
|
const SkString fName;
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace DM
|
|
|
|
|
|
|
|
#endif // DMTestTask_DEFINED
|