From 566f53d9d0cf609d3a26e1afdaff29af94877e35 Mon Sep 17 00:00:00 2001 From: pTalanov Date: Tue, 6 Mar 2012 21:12:24 +0400 Subject: [PATCH] Build fix attempt: got rid of SuiteBuilder class --- .../k2js/test/semantics/ExamplesTest.java | 23 ++++-- .../k2js/test/semantics/SimpleTest.java | 23 ++++-- .../semantics/TranslatorTestCaseBuilder.java | 4 +- .../k2js/test/utils/SuiteBuilder.java | 73 ------------------- 4 files changed, 38 insertions(+), 85 deletions(-) delete mode 100644 js/js.tests/test/org/jetbrains/k2js/test/utils/SuiteBuilder.java diff --git a/js/js.tests/test/org/jetbrains/k2js/test/semantics/ExamplesTest.java b/js/js.tests/test/org/jetbrains/k2js/test/semantics/ExamplesTest.java index 7a937342b64..75fa07f9a85 100644 --- a/js/js.tests/test/org/jetbrains/k2js/test/semantics/ExamplesTest.java +++ b/js/js.tests/test/org/jetbrains/k2js/test/semantics/ExamplesTest.java @@ -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; } }); } diff --git a/js/js.tests/test/org/jetbrains/k2js/test/semantics/SimpleTest.java b/js/js.tests/test/org/jetbrains/k2js/test/semantics/SimpleTest.java index a7c0f6eab9b..cc9ac544b25 100644 --- a/js/js.tests/test/org/jetbrains/k2js/test/semantics/SimpleTest.java +++ b/js/js.tests/test/org/jetbrains/k2js/test/semantics/SimpleTest.java @@ -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; } }); } diff --git a/js/js.tests/test/org/jetbrains/k2js/test/semantics/TranslatorTestCaseBuilder.java b/js/js.tests/test/org/jetbrains/k2js/test/semantics/TranslatorTestCaseBuilder.java index e9ec69038a8..9393961ef96 100644 --- a/js/js.tests/test/org/jetbrains/k2js/test/semantics/TranslatorTestCaseBuilder.java +++ b/js/js.tests/test/org/jetbrains/k2js/test/semantics/TranslatorTestCaseBuilder.java @@ -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 diff --git a/js/js.tests/test/org/jetbrains/k2js/test/utils/SuiteBuilder.java b/js/js.tests/test/org/jetbrains/k2js/test/utils/SuiteBuilder.java deleted file mode 100644 index c92fa5cb1bb..00000000000 --- a/js/js.tests/test/org/jetbrains/k2js/test/utils/SuiteBuilder.java +++ /dev/null @@ -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); - } - }); - } -}