| // Copyright (c) 2017, the R8 project authors. Please see the AUTHORS file | |
| // for details. All rights reserved. Use of this source code is governed by a | |
| // BSD-style license that can be found in the LICENSE file. | |
| package com.android.tools.r8; | |
| import com.android.tools.r8.origin.EmbeddedOrigin; | |
| import com.android.tools.r8.utils.AndroidApiLevel; | |
| import java.nio.file.Path; | |
| import java.util.Collections; | |
| import org.junit.Test; | |
| import org.junit.runner.RunWith; | |
| import org.junit.runners.Parameterized; | |
| import org.junit.runners.Parameterized.Parameter; | |
| import org.junit.runners.Parameterized.Parameters; | |
| @RunWith(Parameterized.class) | |
| public class R8IgnoreMissingClassesTest extends TestBase { | |
| @Parameter(0) | |
| public TestParameters parameters; | |
| @Parameters(name = "{0}") | |
| public static TestParametersCollection data() { | |
| return getTestParameters().withNoneRuntime().build(); | |
| } | |
| private static final AndroidApiLevel MIN_API = AndroidApiLevel.O; | |
| private static final Path LIBRARY = ToolHelper.getAndroidJar(MIN_API); | |
| private R8Command.Builder config() { | |
| return R8Command.builder() | |
| .addProgramFiles(TestDeps.getExamplesPath("usestdlib.jar")) | |
| .setDisableTreeShaking(true) | |
| .setMinApiLevel(MIN_API.getMajor()) | |
| .setProgramConsumer(DexIndexedConsumer.emptyConsumer()); | |
| } | |
| @Test(expected = CompilationFailedException.class) | |
| public void testFailsWithoutLibrary() throws CompilationFailedException { | |
| R8.run(config().build()); | |
| } | |
| @Test | |
| public void testPassesWithLibrary() throws CompilationFailedException { | |
| R8.run(config().addLibraryFiles(LIBRARY).build()); | |
| } | |
| @Test | |
| public void testPassesWithIgnoreWarnings() throws CompilationFailedException { | |
| R8.run( | |
| config() | |
| .addProguardConfiguration( | |
| Collections.singletonList("-dontwarn"), EmbeddedOrigin.INSTANCE) | |
| .build()); | |
| } | |
| } |