K2JS: add ed outputPrefix and outputPostfix compiler arguments to K2JSCompiler.

This commit is contained in:
Zalim Bashorov
2013-10-18 19:21:59 +04:00
parent d02e53c812
commit 0d322fe8bc
20 changed files with 352 additions and 14 deletions
@@ -31,6 +31,7 @@ import java.io.File;
import java.io.PrintStream;
public class CliBaseTest {
protected static final String NOT_EXISTING_PATH = "not/existing/path";
@Rule
public final Tmpdir tmpdir = new Tmpdir();
@@ -0,0 +1,57 @@
/*
* Copyright 2010-2013 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.jet.cli.jvm;
import com.google.common.collect.Lists;
import com.intellij.util.ArrayUtil;
import junit.framework.Assert;
import org.junit.Test;
import java.io.File;
import java.util.Collections;
import java.util.List;
public class K2JsCliTest extends CliBaseTest {
@Test
public void simple() {
doSimpleTest(/*expectedOutFile =*/ true);
}
@Test
public void outputPrefixFileNotFound() {
doSimpleTest(/*expectedOutFile =*/ false,
"-outputPrefix", NOT_EXISTING_PATH);
}
@Test
public void outputPostfixFileNotFound() {
doSimpleTest(/*expectedOutFile =*/ false,
"-outputPostfix", NOT_EXISTING_PATH);
}
private void doSimpleTest(boolean expectedOutFile, String... additionalArgs) {
File outputFile = new File(tmpdir.getTmpDir(), "out.js");
List<String> args = Lists.newArrayList(
"-sourceFiles", "compiler/testData/cli/simple2js.kt",
"-output", outputFile.getPath());
Collections.addAll(args, additionalArgs);
executeCompilerCompareOutputJS(ArrayUtil.toStringArray(args));
Assert.assertEquals(expectedOutFile, outputFile.isFile());
}
}
@@ -24,6 +24,9 @@ import org.junit.Test;
import java.io.File;
public class K2JvmCliTest extends CliBaseTest {
protected static final String ANOTHER_NOT_EXISTING_PATH = "yet/another/not/existing/path";
@Test
public void wrongKotlinSignature() throws Exception {
String[] args = {
@@ -46,8 +49,8 @@ public class K2JvmCliTest extends CliBaseTest {
public void nonExistingClassPathAndAnnotationsPath() {
String[] args = {
"-src", "compiler/testData/cli/simple.kt",
"-classpath", "not/existing/path",
"-annotations", "yet/another/not/existing/path",
"-classpath", NOT_EXISTING_PATH,
"-annotations", ANOTHER_NOT_EXISTING_PATH,
"-output", tmpdir.getTmpDir().getPath()};
executeCompilerCompareOutputJVM(args);
@@ -57,7 +60,7 @@ public class K2JvmCliTest extends CliBaseTest {
@Test
public void nonExistingSourcePath() {
String[] args = {
"-src", "not/existing/path",
"-src", NOT_EXISTING_PATH,
"-output", tmpdir.getTmpDir().getPath()};
executeCompilerCompareOutputJVM(args);
}