Build fix attempt: reorganised test inheritance.

This commit is contained in:
pTalanov
2012-03-06 20:44:43 +04:00
parent ecdc8115f6
commit f6ad975269
4 changed files with 35 additions and 27 deletions
@@ -56,7 +56,7 @@ public abstract class BasicTest extends TestWithEnvironment {
}
@Override
protected void setUp() throws Exception {
public void setUp() throws Exception {
super.setUp();
if (!shouldCreateOut()) {
return;
@@ -114,7 +114,7 @@ public abstract class BasicTest extends TestWithEnvironment {
}
@NotNull
private String getInputPath() {
public String getInputPath() {
return pathToTestFiles() + casesDirectoryName();
}
@@ -16,17 +16,20 @@
package org.jetbrains.k2js.test.semantics;
import com.intellij.testFramework.UsefulTestCase;
import junit.framework.Test;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.k2js.test.SingleFileTranslationTest;
import org.jetbrains.k2js.test.utils.SuiteBuilder;
@SuppressWarnings("JUnitTestCaseWithNoTests")
public final class ExamplesTest extends UsefulTestCase {
public final class ExamplesTest extends SingleFileTranslationTest {
public ExamplesTest() {
super("examples/");
}
public static Test suite() throws Exception {
return SuiteBuilder.suiteForDirectory("examples/", new SuiteBuilder.Tester() {
return SuiteBuilder.suiteForTestClass(new ExamplesTest(), new SuiteBuilder.Tester() {
@Override
public void performTest(@NotNull SingleFileTranslationTest test, @NotNull String filename) throws Exception {
test.runFunctionOutputTest(filename, "Anonymous", "box", "OK");
@@ -16,7 +16,6 @@
package org.jetbrains.k2js.test.semantics;
import com.intellij.testFramework.UsefulTestCase;
import junit.framework.Test;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.k2js.test.SingleFileTranslationTest;
@@ -26,9 +25,14 @@ import org.jetbrains.k2js.test.utils.SuiteBuilder;
* @author Pavel Talanov
*/
@SuppressWarnings("JUnitTestCaseWithNoTests")
public final class SimpleTest extends UsefulTestCase {
public final class SimpleTest extends SingleFileTranslationTest {
public SimpleTest() {
super("simple/");
}
public static Test suite() throws Exception {
return SuiteBuilder.suiteForDirectory("simple/", new SuiteBuilder.Tester() {
return SuiteBuilder.suiteForTestClass(new SimpleTest(), new SuiteBuilder.Tester() {
@Override
public void performTest(@NotNull SingleFileTranslationTest test, @NotNull String filename) throws Exception {
test.checkFooBoxIsTrue(filename);
@@ -26,46 +26,47 @@ import org.jetbrains.k2js.test.semantics.TranslatorTestCaseBuilder;
* @author Pavel Talanov
*/
@SuppressWarnings("JUnitTestCaseWithNoTests")
public abstract class SuiteBuilder extends SingleFileTranslationTest {
private SuiteBuilder(@NotNull String pathToMain) {
super(pathToMain);
}
public abstract class SuiteBuilder {
public interface Tester {
void performTest(@NotNull SingleFileTranslationTest test, @NotNull String filename) throws Exception;
}
@SuppressWarnings("JUnitTestCaseWithNonTrivialConstructors")
private class SingleFileTest extends UsefulTestCase {
public SingleFileTest(@NotNull String name, @NotNull Tester tester) {
setName(name);
this.tester = tester;
this.name = name;
}
private static class SingleFileTest extends UsefulTestCase {
@NotNull
private final Tester tester;
@NotNull
private final String name;
@NotNull
private final SingleFileTranslationTest actualTest;
public SingleFileTest(@NotNull SingleFileTranslationTest actualTest, @NotNull String name, @NotNull Tester tester) {
setName(name);
this.tester = tester;
this.name = name;
this.actualTest = actualTest;
}
public void runTest() throws Exception {
tester.performTest(SuiteBuilder.this, name);
tester.performTest(actualTest, name);
}
}
public static Test suiteForDirectory(@NotNull final String main, @NotNull final SuiteBuilder.Tester testMethod) throws Exception {
final SuiteBuilder singleFileTest = new SuiteBuilder(main) {
};
singleFileTest.setUp();
return TranslatorTestCaseBuilder.suiteForDirectory(pathToTestFilesRoot() + main + casesDirectoryName(),
public static Test suiteForTestClass(@NotNull final SingleFileTranslationTest actualTest,
@NotNull final SuiteBuilder.Tester testMethod) throws Exception {
//TODO: tearDown not called
actualTest.setUp();
return TranslatorTestCaseBuilder.suiteForDirectory(actualTest.getInputPath(),
true,
new TranslatorTestCaseBuilder.NamedTestFactory() {
@NotNull
@Override
public Test createTest(@NotNull String name) {
return singleFileTest.new SingleFileTest(name, testMethod);
return new SingleFileTest(actualTest, name, testMethod);
}
});
}