From 40fe33045d7b682d6858dfd92a6005549e5343f1 Mon Sep 17 00:00:00 2001 From: Stepan Koltsov Date: Thu, 14 Jun 2012 15:29:17 +0400 Subject: [PATCH] cli test template --- compiler/testData/cli/simple.kt | 1 + compiler/testData/cli/simple.out | 1 + .../org/jetbrains/jet/cli/jvm/CliTest.java | 53 +++++++++++++++++++ 3 files changed, 55 insertions(+) create mode 100644 compiler/testData/cli/simple.kt create mode 100644 compiler/testData/cli/simple.out create mode 100644 compiler/tests/org/jetbrains/jet/cli/jvm/CliTest.java diff --git a/compiler/testData/cli/simple.kt b/compiler/testData/cli/simple.kt new file mode 100644 index 00000000000..9b7592664fb --- /dev/null +++ b/compiler/testData/cli/simple.kt @@ -0,0 +1 @@ +fun main(args: Array) = println("hello world") diff --git a/compiler/testData/cli/simple.out b/compiler/testData/cli/simple.out new file mode 100644 index 00000000000..d86bac9de59 --- /dev/null +++ b/compiler/testData/cli/simple.out @@ -0,0 +1 @@ +OK diff --git a/compiler/tests/org/jetbrains/jet/cli/jvm/CliTest.java b/compiler/tests/org/jetbrains/jet/cli/jvm/CliTest.java new file mode 100644 index 00000000000..c703c923c11 --- /dev/null +++ b/compiler/tests/org/jetbrains/jet/cli/jvm/CliTest.java @@ -0,0 +1,53 @@ +/* + * Copyright 2010-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.jet.cli.jvm; + +import com.intellij.openapi.util.io.FileUtil; +import junit.framework.Assert; +import org.jetbrains.jet.cli.common.ExitCode; +import org.jetbrains.jet.test.Tmpdir; +import org.junit.Rule; +import org.junit.Test; + +import java.io.ByteArrayOutputStream; +import java.io.File; +import java.io.PrintStream; + +/** + * @author Stepan Koltsov + */ +public class CliTest { + + @Rule + public final Tmpdir tmpdir = new Tmpdir(); + + @Test + public void simple() throws Exception { + ByteArrayOutputStream bytes = new ByteArrayOutputStream(); + ExitCode exitCode = new K2JVMCompiler().exec(new PrintStream(bytes), + "-src", "compiler/testData/cli/simple.kt", + "-output", tmpdir.getTmpDir().getPath()); + String actual = bytes.toString("utf-8") + exitCode + "\n"; + + String expected = FileUtil.loadFile(new File("compiler/testData/cli/simple.out")); + + Assert.assertEquals(expected, actual); + + Assert.assertTrue(new File(tmpdir.getTmpDir(), "namespace.class").isFile()); + } + +}