Esempio n. 1
0
 public void testSmokeWithCompilerOutput() throws IOException {
   File tempDir = FileUtil.createTempDirectory("compilerTest", "compilerTest");
   try {
     File out = new File(tempDir, "out");
     File stdlib = ForTestCompileRuntime.runtimeJarForTests();
     File jdkAnnotations = ForTestPackJdkAnnotations.jdkAnnotationsForTests();
     ExitCode exitCode =
         new K2JVMCompiler()
             .exec(
                 System.out,
                 "-src",
                 JetParsingTest.getTestDataDir() + "/compiler/smoke/Smoke.kt",
                 "-output",
                 out.getAbsolutePath(),
                 "-noStdlib",
                 "-classpath",
                 stdlib.getAbsolutePath(),
                 "-noJdkAnnotations",
                 "-annotations",
                 jdkAnnotations.getAbsolutePath());
     Assert.assertEquals(ExitCode.OK, exitCode);
     assertEquals(1, out.listFiles().length);
     assertEquals(1, out.listFiles()[0].listFiles().length);
   } finally {
     FileUtil.delete(tempDir);
   }
 }
Esempio n. 2
0
  @NotNull
  public static File compileJava(@NotNull String filename) {
    try {
      File javaClassesTempDirectory = JetTestUtils.tmpDir("java-classes");
      String classPath =
          ForTestCompileRuntime.runtimeJarForTests()
              + File.pathSeparator
              + JetTestUtils.getAnnotationsJar().getPath();
      List<String> options =
          Arrays.asList("-classpath", classPath, "-d", javaClassesTempDirectory.getPath());

      File javaFile = new File("compiler/testData/codegen/" + filename);
      JetTestUtils.compileJavaFiles(Collections.singleton(javaFile), options);

      return javaClassesTempDirectory;
    } catch (IOException e) {
      throw UtilsPackage.rethrow(e);
    }
  }
Esempio n. 3
0
  public void testSmokeWithCompilerJar() throws IOException {
    File tempDir = FileUtil.createTempDirectory("compilerTest", "compilerTest");

    try {
      File stdlib = ForTestCompileRuntime.runtimeJarForTests();
      File jdkAnnotations = ForTestPackJdkAnnotations.jdkAnnotationsForTests();
      File resultJar = new File(tempDir, "result.jar");
      ExitCode rv =
          new K2JVMCompiler()
              .exec(
                  System.out,
                  "-module",
                  JetParsingTest.getTestDataDir() + "/compiler/smoke/Smoke.kts",
                  "-jar",
                  resultJar.getAbsolutePath(),
                  "-noStdlib",
                  "-classpath",
                  stdlib.getAbsolutePath(),
                  "-noJdkAnnotations",
                  "-annotations",
                  jdkAnnotations.getAbsolutePath());
      Assert.assertEquals("compilation completed with non-zero code", ExitCode.OK, rv);
      FileInputStream fileInputStream = new FileInputStream(resultJar);
      try {
        JarInputStream is = new JarInputStream(fileInputStream);
        try {
          final List<String> entries = listEntries(is);
          assertTrue(
              entries.contains(
                  "Smoke/"
                      + PackageClassUtils.getPackageClassName(new FqName("Smoke"))
                      + ".class"));
          assertEquals(1, entries.size());
        } finally {
          is.close();
        }
      } finally {
        fileInputStream.close();
      }
    } finally {
      FileUtil.delete(tempDir);
    }
  }