Exemple #1
0
  @NotNull
  public static CompilerConfiguration compilerConfigurationForTests(
      @NotNull ConfigurationKind configurationKind,
      @NotNull TestJdkKind jdkKind,
      @NotNull List<File> classpath,
      @NotNull List<File> javaSource) {
    CompilerConfiguration configuration = new CompilerConfiguration();
    JvmContentRootsKt.addJavaSourceRoots(configuration, javaSource);
    if (jdkKind == TestJdkKind.MOCK_JDK) {
      JvmContentRootsKt.addJvmClasspathRoot(configuration, findMockJdkRtJar());
    } else if (jdkKind == TestJdkKind.ANDROID_API) {
      JvmContentRootsKt.addJvmClasspathRoot(configuration, findAndroidApiJar());
    } else {
      JvmContentRootsKt.addJvmClasspathRoots(configuration, PathUtil.getJdkClassesRoots());
    }

    if (configurationKind.getWithRuntime()) {
      JvmContentRootsKt.addJvmClasspathRoot(
          configuration, ForTestCompileRuntime.runtimeJarForTests());
    }
    if (configurationKind.getWithReflection()) {
      JvmContentRootsKt.addJvmClasspathRoot(
          configuration, ForTestCompileRuntime.reflectJarForTests());
    }

    JvmContentRootsKt.addJvmClasspathRoots(configuration, classpath);

    configuration.put(MODULE_NAME, "compilerConfigurationForTests");

    return configuration;
  }
  public void testKotlinJavaScriptProjectWithDirectoryAsStdlib() {
    initProject();
    File jslibJar = PathUtil.getKotlinPathsForDistDirectory().getJsStdLibJarPath();
    File jslibDir = new File(workDir, "KotlinJavaScript");
    try {
      ZipUtil.extract(jslibJar, jslibDir, null);
    } catch (IOException ex) {
      throw new IllegalStateException(ex.getMessage());
    }
    addKotlinJavaScriptDependency("KotlinJavaScript", jslibDir);
    makeAll().assertSuccessful();

    assertEquals(EXPECTED_JS_FILES_IN_OUTPUT_FOR_STDLIB_ONLY, contentOfOutputDir(PROJECT_NAME));
    checkWhen(touch("src/test1.kt"), null, k2jsOutput(PROJECT_NAME));
  }
Exemple #3
0
 @NotNull
 public static String getHomeDirectory() {
   File resourceRoot = PathUtil.getResourcePathForClass(KotlinTestUtils.class);
   return FileUtil.toSystemIndependentName(
       resourceRoot.getParentFile().getParentFile().getParent());
 }