Build fix attempt: got rid of SuiteBuilder class

This commit is contained in:
pTalanov
2012-03-06 21:12:24 +04:00
parent f6ad975269
commit 566f53d9d0
4 changed files with 38 additions and 85 deletions
@@ -18,21 +18,34 @@ package org.jetbrains.k2js.test.semantics;
import junit.framework.Test;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.k2js.test.BasicTest;
import org.jetbrains.k2js.test.SingleFileTranslationTest;
import org.jetbrains.k2js.test.utils.SuiteBuilder;
@SuppressWarnings("JUnitTestCaseWithNoTests")
public final class ExamplesTest extends SingleFileTranslationTest {
public ExamplesTest() {
@NotNull
private final String filename;
@SuppressWarnings("JUnitTestCaseWithNonTrivialConstructors")
public ExamplesTest(@NotNull String filename) {
super("examples/");
this.filename = filename;
}
@Override
public void runTest() throws Exception {
runFunctionOutputTest(filename, "Anonymous", "box", "OK");
}
public static Test suite() throws Exception {
return SuiteBuilder.suiteForTestClass(new ExamplesTest(), new SuiteBuilder.Tester() {
return TranslatorTestCaseBuilder.suiteForDirectory(BasicTest.pathToTestFilesRoot() + "examples/cases/", new TranslatorTestCaseBuilder.NamedTestFactory() {
@NotNull
@Override
public void performTest(@NotNull SingleFileTranslationTest test, @NotNull String filename) throws Exception {
test.runFunctionOutputTest(filename, "Anonymous", "box", "OK");
public Test createTest(@NotNull String filename) {
ExamplesTest examplesTest = new ExamplesTest(filename);
examplesTest.setName(filename);
return examplesTest;
}
});
}
@@ -18,8 +18,8 @@ package org.jetbrains.k2js.test.semantics;
import junit.framework.Test;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.k2js.test.BasicTest;
import org.jetbrains.k2js.test.SingleFileTranslationTest;
import org.jetbrains.k2js.test.utils.SuiteBuilder;
/**
* @author Pavel Talanov
@@ -27,15 +27,28 @@ import org.jetbrains.k2js.test.utils.SuiteBuilder;
@SuppressWarnings("JUnitTestCaseWithNoTests")
public final class SimpleTest extends SingleFileTranslationTest {
public SimpleTest() {
@NotNull
private final String filename;
@SuppressWarnings("JUnitTestCaseWithNonTrivialConstructors")
public SimpleTest(@NotNull String filename) {
super("simple/");
this.filename = filename;
}
@Override
public void runTest() throws Exception {
checkFooBoxIsTrue(filename);
}
public static Test suite() throws Exception {
return SuiteBuilder.suiteForTestClass(new SimpleTest(), new SuiteBuilder.Tester() {
return TranslatorTestCaseBuilder.suiteForDirectory(BasicTest.pathToTestFilesRoot() + "simple/cases/", new TranslatorTestCaseBuilder.NamedTestFactory() {
@NotNull
@Override
public void performTest(@NotNull SingleFileTranslationTest test, @NotNull String filename) throws Exception {
test.checkFooBoxIsTrue(filename);
public Test createTest(@NotNull String filename) {
SimpleTest examplesTest = new SimpleTest(filename);
examplesTest.setName(filename);
return examplesTest;
}
});
}
@@ -45,8 +45,8 @@ public abstract class TranslatorTestCaseBuilder {
@NotNull
public static TestSuite suiteForDirectory(@NotNull final String dataPath,
boolean recursive, @NotNull NamedTestFactory factory) {
return suiteForDirectory(dataPath, recursive, emptyFilter, factory);
@NotNull NamedTestFactory factory) {
return suiteForDirectory(dataPath, true, emptyFilter, factory);
}
@NotNull
@@ -1,73 +0,0 @@
/*
* Copyright 2000-2012 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jetbrains.k2js.test.utils;
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.semantics.TranslatorTestCaseBuilder;
/**
* @author Pavel Talanov
*/
@SuppressWarnings("JUnitTestCaseWithNoTests")
public abstract class SuiteBuilder {
public interface Tester {
void performTest(@NotNull SingleFileTranslationTest test, @NotNull String filename) throws Exception;
}
@SuppressWarnings("JUnitTestCaseWithNonTrivialConstructors")
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(actualTest, name);
}
}
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 new SingleFileTest(actualTest, name, testMethod);
}
});
}
}