Skip to content

Commit

Permalink
Opt final children of AndroidBuildViewTestCase into platforms.
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 348649300
  • Loading branch information
gregestren authored and copybara-github committed Dec 22, 2020
1 parent 798b4e5 commit 4369cc9
Show file tree
Hide file tree
Showing 5 changed files with 69 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,27 @@
import com.google.devtools.build.lib.rules.android.AndroidLocalTestTest;
import org.junit.Before;
import org.junit.Test;
import org.junit.experimental.runners.Enclosed;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;

/**
* Bazel-only android_local_test tests.
*/
public class BazelAndroidLocalTestTest extends AndroidLocalTestTest {
/** Bazel-only android_local_test tests. */
@RunWith(Enclosed.class)
public abstract class BazelAndroidLocalTestTest extends AndroidLocalTestTest {
/** Use legacy toolchain resolution. */
@RunWith(JUnit4.class)
public static class WithoutPlatforms extends BazelAndroidLocalTestTest {}

// TODO(b/161709111): With platforms, all tests fail with
// "no attribute `$android_sdk_toolchain_type`" on AspectAwareAttributeMapper.
/** Use platform-based toolchain resolution. */
/* @RunWith(JUnit4.class)
public static class WithPlatforms extends GoogleAndroidLocalTestTest {
@Override
protected boolean platformBasedToolchains() {
return true;
}
} */

@Before
@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,26 @@
import com.google.devtools.build.lib.collect.nestedset.Order;
import com.google.devtools.build.lib.vfs.PathFragment;
import org.junit.Test;
import org.junit.experimental.runners.Enclosed;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;

/** Tests {@link AndroidAssets} */
@RunWith(JUnit4.class)
public class AndroidAssetsTest extends ResourceTestBase {
@RunWith(Enclosed.class)
public abstract class AndroidAssetsTest extends ResourceTestBase {
/** Use legacy toolchain resolution. */
@RunWith(JUnit4.class)
public static class WithoutPlatforms extends AndroidAssetsTest {}

/** Use platform-based toolchain resolution. */
@RunWith(JUnit4.class)
public static class WithPlatforms extends AndroidAssetsTest {
@Override
protected boolean platformBasedToolchains() {
return true;
}
}

@Test
public void testParseAapt2() throws Exception {
RuleContext ruleContext = getRuleContext();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,26 @@
import java.util.Set;
import org.junit.Before;
import org.junit.Test;
import org.junit.experimental.runners.Enclosed;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;

/** Tests {@link AndroidResources} */
@RunWith(JUnit4.class)
public class AndroidResourcesTest extends ResourceTestBase {
@RunWith(Enclosed.class)
public abstract class AndroidResourcesTest extends ResourceTestBase {
/** Use legacy toolchain resolution. */
@RunWith(JUnit4.class)
public static class WithoutPlatforms extends AndroidResourcesTest {}

/** Use platform-based toolchain resolution. */
@RunWith(JUnit4.class)
public static class WithPlatforms extends AndroidResourcesTest {
@Override
protected boolean platformBasedToolchains() {
return true;
}
}

private static final PathFragment DEFAULT_RESOURCE_ROOT = PathFragment.create(RESOURCE_ROOT);
private static final ImmutableList<PathFragment> RESOURCES_ROOTS =
ImmutableList.of(DEFAULT_RESOURCE_ROOT);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,25 @@
import com.google.devtools.build.lib.analysis.ConfiguredTarget;
import org.junit.Before;
import org.junit.Test;
import org.junit.experimental.runners.Enclosed;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;

/** Tests {@link ResourceFilterFactory}. */
@RunWith(JUnit4.class)
@RunWith(Enclosed.class)
public class ResourceFilterFactoryTest extends ResourceTestBase {
/** Use legacy toolchain resolution. */
@RunWith(JUnit4.class)
public static class WithoutPlatforms extends ResourceFilterFactoryTest {}

/** Use platform-based toolchain resolution. */
@RunWith(JUnit4.class)
public static class WithPlatforms extends ResourceFilterFactoryTest {
@Override
protected boolean platformBasedToolchains() {
return true;
}
}

@Before
public void setupCcToolchain() throws Exception {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@
import java.util.stream.Collectors;
import org.junit.After;
import org.junit.Before;
import org.junit.experimental.runners.Enclosed;
import org.junit.runner.RunWith;

/** Base class for tests that work with resource artifacts. */
public abstract class ResourceTestBase extends AndroidBuildViewTestCase {
Expand Down Expand Up @@ -77,6 +79,7 @@ public abstract class ResourceTestBase extends AndroidBuildViewTestCase {
};

/** A faked {@link RuleErrorConsumer} that validates that only expected errors were reported. */
@RunWith(Enclosed.class)
public static final class FakeRuleErrorConsumer implements RuleErrorConsumer {
private String ruleErrorMessage = null;
private String attributeErrorAttribute = null;
Expand Down

0 comments on commit 4369cc9

Please sign in to comment.