Reorganize integration test data

This commit is contained in:
Alexander Udalov
2014-07-30 21:10:33 -07:00
parent 8e17557f5c
commit 3ca6c8615b
101 changed files with 69 additions and 40 deletions
@@ -24,9 +24,11 @@ import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.List; import java.util.List;
import static junit.framework.Assert.assertEquals; import static org.junit.Assert.assertEquals;
public abstract class AntTaskBaseTest extends KotlinIntegrationTestBase { public abstract class AntTaskBaseTest extends KotlinIntegrationTestBase {
protected static final File ANT_TASK_TEST_DATA_BASE_DIR = new File(INTEGRATION_TEST_DATA_BASE_DIR, "ant");
protected static final int SUCCESSFUL = 0; protected static final int SUCCESSFUL = 0;
protected static final int FAILED = 1; protected static final int FAILED = 1;
@@ -43,7 +45,7 @@ public abstract class AntTaskBaseTest extends KotlinIntegrationTestBase {
String[] basicArgs = { String[] basicArgs = {
"-jar", getAntHome() + File.separator + "lib" + File.separator + "ant-launcher.jar", "-jar", getAntHome() + File.separator + "lib" + File.separator + "ant-launcher.jar",
"-Dkotlin.lib=" + getCompilerLib(), "-Dkotlin.lib=" + getCompilerLib(),
"-Dtest.data=" + testDataDir, "-Dtest.data=" + getTestDataDir(),
"-Dtemp=" + tmpdir.getTmpDir(), "-Dtemp=" + tmpdir.getTmpDir(),
"-f", scriptName "-f", scriptName
}; };
@@ -22,7 +22,9 @@ import org.jetbrains.annotations.Nullable;
import org.jetbrains.jet.utils.fileUtils.FileUtilsPackage; import org.jetbrains.jet.utils.fileUtils.FileUtilsPackage;
import org.jetbrains.k2js.test.rhino.RhinoFunctionResultChecker; import org.jetbrains.k2js.test.rhino.RhinoFunctionResultChecker;
import org.jetbrains.k2js.test.rhino.RhinoUtils; import org.jetbrains.k2js.test.rhino.RhinoUtils;
import org.junit.Rule;
import org.junit.Test; import org.junit.Test;
import org.junit.rules.TestName;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
@@ -33,6 +35,15 @@ import static org.junit.Assert.assertTrue;
public class AntTaskJsTest extends AntTaskBaseTest { public class AntTaskJsTest extends AntTaskBaseTest {
private static final String JS_OUT_FILE = "out.js"; private static final String JS_OUT_FILE = "out.js";
@Rule
public final TestName name = new TestName();
@NotNull
@Override
protected File getTestDataDir() {
return new File(new File(ANT_TASK_TEST_DATA_BASE_DIR, "js"), name.getMethodName());
}
private void doJsAntTest() throws Exception { private void doJsAntTest() throws Exception {
doAntTest(SUCCESSFUL); doAntTest(SUCCESSFUL);
@@ -45,8 +56,8 @@ public class AntTaskJsTest extends AntTaskBaseTest {
doJsAntTest(); doJsAntTest();
File outputFile = getOutputFileByName(JS_OUT_FILE); File outputFile = getOutputFileByName(JS_OUT_FILE);
File prefixFile = prefix != null ? new File(testDataDir, prefix) : null; File prefixFile = prefix != null ? new File(getTestDataDir(), prefix) : null;
File postfixFile = postfix != null ? new File(testDataDir, postfix) : null; File postfixFile = postfix != null ? new File(getTestDataDir(), postfix) : null;
checkFilePrefixPostfix(outputFile, prefixFile, postfixFile); checkFilePrefixPostfix(outputFile, prefixFile, postfixFile);
} }
@@ -62,57 +73,57 @@ public class AntTaskJsTest extends AntTaskBaseTest {
} }
@Test @Test
public void k2jsSimple() throws Exception { public void simple() throws Exception {
doJsAntTest(); doJsAntTest();
} }
@Test @Test
public void k2jsWithMain() throws Exception { public void simpleWithMain() throws Exception {
doJsAntTest(); doJsAntTest();
} }
@Test @Test
public void k2jsWithMainFQArgs() throws Exception { public void simpleWithMainFQArgs() throws Exception {
doJsAntTest(); doJsAntTest();
} }
@Test @Test
public void k2jsWithMainVarargs() throws Exception { public void simpleWithVarargMain() throws Exception {
doJsAntTest(); doJsAntTest();
} }
@Test @Test
public void k2jsManySources() throws Exception { public void manySources() throws Exception {
doJsAntTest(); doJsAntTest();
} }
@Test @Test
public void k2jsWithoutSrcParam() throws Exception { public void noSrcParam() throws Exception {
doAntTest(FAILED); doAntTest(FAILED);
} }
@Test @Test
public void k2jsWithoutOutputParam() throws Exception { public void noOutputParam() throws Exception {
doAntTest(FAILED); doAntTest(FAILED);
} }
@Test @Test
public void k2jsWithPrefix() throws Exception { public void outputPrefix() throws Exception {
doJsAntTestForPostfixPrefix("prefix", null); doJsAntTestForPostfixPrefix("prefix", null);
} }
@Test @Test
public void k2jsWithPostfix() throws Exception { public void outputPostfix() throws Exception {
doJsAntTestForPostfixPrefix(null, "postfix"); doJsAntTestForPostfixPrefix(null, "postfix");
} }
@Test @Test
public void k2jsWithPrefixAndPostfix() throws Exception { public void bothPrefixAndPostfix() throws Exception {
doJsAntTestForPostfixPrefix("prefix", "postfix"); doJsAntTestForPostfixPrefix("prefix", "postfix");
} }
@Test @Test
public void k2jsWithSourcemap() throws Exception { public void sourcemap() throws Exception {
doJsAntTest(); doJsAntTest();
File sourcemap = getOutputFileByName(JS_OUT_FILE + ".map"); File sourcemap = getOutputFileByName(JS_OUT_FILE + ".map");
@@ -16,13 +16,25 @@
package org.jetbrains.kotlin; package org.jetbrains.kotlin;
import org.jetbrains.annotations.NotNull;
import org.junit.Rule;
import org.junit.Test; import org.junit.Test;
import org.junit.rules.TestName;
import java.io.File; import java.io.File;
public class AntTaskJvmTest extends AntTaskBaseTest { public class AntTaskJvmTest extends AntTaskBaseTest {
private static final String JVM_OUT_FILE = "hello.jar"; private static final String JVM_OUT_FILE = "hello.jar";
@Rule
public final TestName name = new TestName();
@NotNull
@Override
protected File getTestDataDir() {
return new File(new File(ANT_TASK_TEST_DATA_BASE_DIR, "jvm"), name.getMethodName());
}
private void doJvmAntTest(String... extraJavaArgs) throws Exception { private void doJvmAntTest(String... extraJavaArgs) throws Exception {
doAntTest(SUCCESSFUL, extraJavaArgs); doAntTest(SUCCESSFUL, extraJavaArgs);
@@ -40,17 +52,17 @@ public class AntTaskJvmTest extends AntTaskBaseTest {
} }
@Test @Test
public void antTaskJvm() throws Exception { public void helloWorld() throws Exception {
doJvmAntTest(); doJvmAntTest();
} }
@Test @Test
public void antAdditionalArguments() throws Exception { public void additionalArguments() throws Exception {
doJvmAntTest(); doJvmAntTest();
} }
@Test @Test
public void antWrongArguments() throws Exception { public void wrongArguments() throws Exception {
doAntTest(FAILED); doAntTest(FAILED);
} }
@@ -60,7 +72,7 @@ public class AntTaskJvmTest extends AntTaskBaseTest {
} }
@Test @Test
public void antTaskJvmManyRoots() throws Exception { public void manySourceRoots() throws Exception {
doJvmAntTest(); doJvmAntTest();
} }
@@ -16,15 +16,27 @@
package org.jetbrains.kotlin; package org.jetbrains.kotlin;
import org.jetbrains.annotations.NotNull;
import org.junit.Rule;
import org.junit.Test; import org.junit.Test;
import org.junit.rules.TestName;
import java.io.File; import java.io.File;
import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertEquals;
public class CompilerSmokeTest extends KotlinIntegrationTestBase { public class CompilerSmokeTest extends KotlinIntegrationTestBase {
@Rule
public final TestName name = new TestName();
@NotNull
@Override
protected File getTestDataDir() {
return new File(new File(INTEGRATION_TEST_DATA_BASE_DIR, "smoke"), name.getMethodName());
}
@Test @Test
public void compileAndRunHelloApp() throws Exception { public void helloApp() throws Exception {
String jar = tmpdir.getTmpDir().getAbsolutePath() + File.separator + "hello.jar"; String jar = tmpdir.getTmpDir().getAbsolutePath() + File.separator + "hello.jar";
assertEquals("compilation failed", 0, runCompiler("hello.compile", "-includeRuntime", "hello.kt", "-d", jar)); assertEquals("compilation failed", 0, runCompiler("hello.compile", "-includeRuntime", "hello.kt", "-d", jar));
@@ -32,7 +44,7 @@ public class CompilerSmokeTest extends KotlinIntegrationTestBase {
} }
@Test @Test
public void compileAndRunHelloAppFQMain() throws Exception { public void helloAppFQMain() throws Exception {
String jar = tmpdir.getTmpDir().getAbsolutePath() + File.separator + "hello.jar"; String jar = tmpdir.getTmpDir().getAbsolutePath() + File.separator + "hello.jar";
assertEquals("compilation failed", 0, runCompiler("hello.compile", "-includeRuntime", "hello.kt", "-d", jar)); assertEquals("compilation failed", 0, runCompiler("hello.compile", "-includeRuntime", "hello.kt", "-d", jar));
@@ -40,7 +52,7 @@ public class CompilerSmokeTest extends KotlinIntegrationTestBase {
} }
@Test @Test
public void compileAndRunHelloAppVarargMain() throws Exception { public void helloAppVarargMain() throws Exception {
String jar = tmpdir.getTmpDir().getAbsolutePath() + File.separator + "hello.jar"; String jar = tmpdir.getTmpDir().getAbsolutePath() + File.separator + "hello.jar";
assertEquals("compilation failed", 0, runCompiler("hello.compile", "-includeRuntime", "hello.kt", "-d", jar)); assertEquals("compilation failed", 0, runCompiler("hello.compile", "-includeRuntime", "hello.kt", "-d", jar));
@@ -30,13 +30,11 @@ import com.intellij.util.ArrayUtil;
import kotlin.Function1; import kotlin.Function1;
import kotlin.KotlinPackage; import kotlin.KotlinPackage;
import org.intellij.lang.annotations.Language; import org.intellij.lang.annotations.Language;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.jet.JetTestUtils; import org.jetbrains.jet.JetTestUtils;
import org.jetbrains.jet.test.Tmpdir; import org.jetbrains.jet.test.Tmpdir;
import org.junit.ComparisonFailure; import org.junit.ComparisonFailure;
import org.junit.Rule; import org.junit.Rule;
import org.junit.rules.TestRule;
import org.junit.rules.TestWatcher;
import org.junit.runner.Description;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
@@ -49,25 +47,19 @@ import java.util.regex.Pattern;
import static org.junit.Assert.*; import static org.junit.Assert.*;
public abstract class KotlinIntegrationTestBase { public abstract class KotlinIntegrationTestBase {
protected File testDataDir; protected static final File INTEGRATION_TEST_DATA_BASE_DIR =
new File(getKotlinProjectHome(), "compiler" + File.separator + "integration-tests" + File.separator + "testData");
@Rule @Rule
public final Tmpdir tmpdir = new Tmpdir(); public final Tmpdir tmpdir = new Tmpdir();
@Rule
public TestRule watchman = new TestWatcher() {
@Override
protected void starting(Description description) {
File baseTestDataDir =
new File(getKotlinProjectHome(), "compiler" + File.separator + "integration-tests" + File.separator + "testData");
testDataDir = new File(baseTestDataDir, description.getMethodName());
}
};
static { static {
System.setProperty("java.awt.headless", "true"); System.setProperty("java.awt.headless", "true");
} }
@NotNull
protected abstract File getTestDataDir();
protected int runCompiler(String logName, String... arguments) throws Exception { protected int runCompiler(String logName, String... arguments) throws Exception {
File lib = getCompilerLib(); File lib = getCompilerLib();
@@ -86,7 +78,7 @@ public abstract class KotlinIntegrationTestBase {
protected int runJava(String logName, String... arguments) throws Exception { protected int runJava(String logName, String... arguments) throws Exception {
GeneralCommandLine commandLine = new GeneralCommandLine(); GeneralCommandLine commandLine = new GeneralCommandLine();
commandLine.setWorkDirectory(testDataDir); commandLine.setWorkDirectory(getTestDataDir());
commandLine.setExePath(getJavaRuntime().getAbsolutePath()); commandLine.setExePath(getJavaRuntime().getAbsolutePath());
commandLine.addParameters(arguments); commandLine.addParameters(arguments);
@@ -118,7 +110,7 @@ public abstract class KotlinIntegrationTestBase {
} }
protected String normalizeOutput(String content) { protected String normalizeOutput(String content) {
content = normalizePath(content, testDataDir, "[TestData]"); content = normalizePath(content, getTestDataDir(), "[TestData]");
content = normalizePath(content, tmpdir.getTmpDir(), "[Temp]"); content = normalizePath(content, tmpdir.getTmpDir(), "[Temp]");
content = normalizePath(content, getCompilerLib(), "[CompilerLib]"); content = normalizePath(content, getCompilerLib(), "[CompilerLib]");
content = StringUtil.convertLineSeparators(content); content = StringUtil.convertLineSeparators(content);
@@ -126,8 +118,8 @@ public abstract class KotlinIntegrationTestBase {
} }
protected void check(String baseName, String content) throws IOException { protected void check(String baseName, String content) throws IOException {
File actualFile = new File(testDataDir, baseName + ".actual"); File actualFile = new File(getTestDataDir(), baseName + ".actual");
File expectedFile = new File(testDataDir, baseName + ".expected"); File expectedFile = new File(getTestDataDir(), baseName + ".expected");
String normalizedContent = normalizeOutput(content); String normalizedContent = normalizeOutput(content);

Some files were not shown because too many files have changed in this diff Show More