SkQP: fix Filterable.filter
Change-Id: Id50c24d16a3ba6810fbf49b91a7a93c3df5cb743 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/223296 Reviewed-by: Hal Canary <halcanary@google.com> Commit-Queue: Hal Canary <halcanary@google.com>
This commit is contained in:
parent
a885b89831
commit
8b23d0ee53
@ -29,6 +29,7 @@ import org.junit.runner.notification.RunNotifier;
|
|||||||
public class SkQPRunner extends Runner implements Filterable {
|
public class SkQPRunner extends Runner implements Filterable {
|
||||||
private int mShouldRunTestCount;
|
private int mShouldRunTestCount;
|
||||||
private Description[] mTests;
|
private Description[] mTests;
|
||||||
|
private Description mDescription;
|
||||||
private boolean[] mShouldSkipTest;
|
private boolean[] mShouldSkipTest;
|
||||||
private String mOutputDirectory;
|
private String mOutputDirectory;
|
||||||
private SkQP mImpl;
|
private SkQP mImpl;
|
||||||
@ -52,8 +53,9 @@ public class SkQPRunner extends Runner implements Filterable {
|
|||||||
AssetManager assetManager = context.getResources().getAssets();
|
AssetManager assetManager = context.getResources().getAssets();
|
||||||
mImpl.nInit(assetManager, mOutputDirectory);
|
mImpl.nInit(assetManager, mOutputDirectory);
|
||||||
|
|
||||||
mTests = new Description[this.testCount()];
|
int totalCount = mImpl.mUnitTests.length + mImpl.mGMs.length * mImpl.mBackends.length;
|
||||||
mShouldSkipTest = new boolean[mTests.length]; // = {false, false, ....};
|
mTests = new Description[totalCount];
|
||||||
|
mShouldSkipTest = new boolean[totalCount]; // = {false, false, ....};
|
||||||
int index = 0;
|
int index = 0;
|
||||||
for (int backend = 0; backend < mImpl.mBackends.length; backend++) {
|
for (int backend = 0; backend < mImpl.mBackends.length; backend++) {
|
||||||
for (int gm = 0; gm < mImpl.mGMs.length; gm++) {
|
for (int gm = 0; gm < mImpl.mGMs.length; gm++) {
|
||||||
@ -65,37 +67,35 @@ public class SkQPRunner extends Runner implements Filterable {
|
|||||||
mTests[index++] = Description.createTestDescription(SkQPRunner.class,
|
mTests[index++] = Description.createTestDescription(SkQPRunner.class,
|
||||||
"unitTest_" + mImpl.mUnitTests[unitTest]);
|
"unitTest_" + mImpl.mUnitTests[unitTest]);
|
||||||
}
|
}
|
||||||
assert(index == mTests.length);
|
assert(index == totalCount);
|
||||||
mShouldRunTestCount = mTests.length;
|
this.updateDescription(null);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void updateDescription(Filter filter) {
|
||||||
|
mShouldRunTestCount = 0;
|
||||||
|
mDescription = Description.createSuiteDescription(SkQP.class);
|
||||||
|
assert(mTests.length == mShouldSkipTest.length);
|
||||||
|
for (int i = 0; i < mTests.length; ++i) {
|
||||||
|
boolean doRunTest = filter != null ? filter.shouldRun(mTests[i]) : true;
|
||||||
|
mShouldSkipTest[i] = !doRunTest;
|
||||||
|
if (doRunTest) {
|
||||||
|
mDescription.addChild(mTests[i]);
|
||||||
|
++mShouldRunTestCount;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void filter(Filter filter) throws NoTestsRemainException {
|
public void filter(Filter filter) throws NoTestsRemainException {
|
||||||
int count = 0;
|
this.updateDescription(filter);
|
||||||
for (int i = 0; i < mTests.length; ++i) {
|
if (0 == mShouldRunTestCount) {
|
||||||
mShouldSkipTest[i] = !filter.shouldRun(mTests[i]);
|
|
||||||
if (!mShouldSkipTest[i]) {
|
|
||||||
++count;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
mShouldRunTestCount = count;
|
|
||||||
if (0 == count) {
|
|
||||||
throw new NoTestsRemainException();
|
throw new NoTestsRemainException();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Description getDescription() {
|
public Description getDescription() {
|
||||||
Description d = Description.createSuiteDescription(SkQP.class);
|
return mDescription;
|
||||||
for (int i = 0; i < mTests.length; ++i) {
|
|
||||||
d.addChild(mTests[i]);
|
|
||||||
}
|
|
||||||
return d;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int testCount() {
|
|
||||||
return mImpl.mUnitTests.length + mImpl.mGMs.length * mImpl.mBackends.length;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
Loading…
Reference in New Issue
Block a user