blob: cb305d22de3f56b4713a33bce33c4f02ac883e20 [file] [log] [blame]
// Copyright (c) 2023, 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.examples.hello;
import com.android.tools.r8.TestParameters;
import com.android.tools.r8.TestParametersCollection;
import com.android.tools.r8.examples.ExamplesTestBase;
import com.android.tools.r8.utils.StringUtils;
import java.io.IOException;
import java.nio.file.Path;
import org.junit.Test;
import org.junit.rules.TemporaryFolder;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
@RunWith(Parameterized.class)
public class HelloTestRunner extends ExamplesTestBase {
@Parameterized.Parameters(name = "{0}")
public static TestParametersCollection data() {
return getTestParameters().withAllRuntimesAndApiLevels().enableApiLevelsForCf().build();
}
// The "hello" program is reused in various tests via these static methods.
public static Class<?> getHelloClass() {
return Hello.class;
}
public static String getExpectedOutput() {
return StringUtils.lines("Hello, world");
}
public static Path writeHelloProgramJar(TemporaryFolder temp) throws IOException {
Path jar = temp.newFolder().toPath().resolve("hello.jar");
writeClassesToJar(jar, Hello.class);
return jar;
}
public HelloTestRunner(TestParameters parameters) {
super(parameters);
}
@Override
public Class<?> getMainClass() {
return getHelloClass();
}
@Override
public String getExpected() {
return getExpectedOutput();
}
@Test
public void testDesugaring() throws Exception {
runTestDesugaring();
}
@Test
public void testR8() throws Exception {
runTestR8();
}
@Test
public void testDebug() throws Exception {
runTestDebugComparator();
}
}