Files
kotlin-fork/compiler/tests/org/jetbrains/kotlin/integration/AntTaskBaseTest.java
T
Alexander Udalov 89408f45bb Ant task: pass kotlin-runtime to javac's classpath; simplify tests
'kotlinCompiler' test is deleted because it's a very roundabout way to compile
Kotlin and Java sources, and there's no point in testing it.

'javacCompiler' test is deleted for similar reasons: using javac's "compiler"
option is not an advertised way to use Kotlin Ant task, and anyway it will work
with any CompilerAdapter instance, so it's hard to break it (apart from
deleting "withKotlin" adapter).

There are tests which check compilation/running of the same code but with the
recommended method. The pretext for deletion of these tests is to make Ant
tests generated, and that would be easier if they wouldn't depend on any outer
variables
2015-06-05 15:55:58 +03:00

63 lines
2.2 KiB
Java

/*
* Copyright 2010-2015 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.kotlin.integration;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.kotlin.cli.CliBaseTest;
import java.io.File;
import static org.junit.Assert.assertEquals;
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 FAILED = 1;
protected void doAntTest(int expectedExitCode) throws Exception {
assertEquals("Compilation failed", expectedExitCode, runAnt("build.log", "build.xml"));
}
@Override
protected String normalizeOutput(String content) {
return CliBaseTest.removePerfOutput(super.normalizeOutput(content))
.replaceAll("Total time: .+\n", "Total time: [time]\n");
}
private int runAnt(@NotNull String logName, @NotNull String scriptName) throws Exception {
return runJava(
logName,
"-jar", getAntHome() + File.separator + "lib" + File.separator + "ant-launcher.jar",
"-Dkotlin.lib=" + getCompilerLib(),
"-Dtest.data=" + getTestDataDir(),
"-Dtemp=" + tmpdir.getTmpDir(),
"-f", scriptName
);
}
@NotNull
private static String getAntHome() {
return getKotlinProjectHome().getAbsolutePath() + File.separator + "dependencies" + File.separator + "ant-1.8";
}
@NotNull
protected File getOutputFileByName(@NotNull String name) {
return new File(tmpdir.getTmpDir(), name);
}
}