private void setUpEnvironment(
      boolean generateAssertions, boolean generateParamAssertions, File... extraClassPath) {
    CompilerConfiguration configuration =
        JetTestUtils.compilerConfigurationForTests(
            ConfigurationKind.JDK_ONLY, TestJdkKind.MOCK_JDK, extraClassPath);

    configuration.put(JVMConfigurationKeys.GENERATE_NOT_NULL_ASSERTIONS, generateAssertions);
    configuration.put(
        JVMConfigurationKeys.GENERATE_NOT_NULL_PARAMETER_ASSERTIONS, generateParamAssertions);

    myEnvironment = new JetCoreEnvironment(getTestRootDisposable(), configuration);
  }
    public void doTest(String path) throws Exception {
      File dir = new File(path);

      CompilerConfiguration configuration =
          JetTestUtils.compilerConfigurationForTests(
              ConfigurationKind.JDK_ONLY, TestJdkKind.MOCK_JDK, new File(dir, "java"));
      configuration.put(
          CommonConfigurationKeys.SOURCE_ROOTS_KEY,
          Arrays.asList(new File(dir, "kotlin").getAbsolutePath()));
      JetCoreEnvironment environment =
          new JetCoreEnvironment(getTestRootDisposable(), configuration);

      ModuleDescriptor moduleDescriptor = new ModuleDescriptor(Name.special("<test module>"));

      // we need the same binding trace for resolve from Java and Kotlin
      BindingTrace trace =
          CliLightClassGenerationSupport.getInstanceForCli(environment.getProject()).getTrace();

      InjectorForJavaDescriptorResolver injectorForJava =
          new InjectorForJavaDescriptorResolver(environment.getProject(), trace, moduleDescriptor);

      InjectorForTopDownAnalyzerForJvm injectorForAnalyzer =
          new InjectorForTopDownAnalyzerForJvm(
              environment.getProject(),
              new TopDownAnalysisParameters(
                  Predicates.<PsiFile>alwaysFalse(),
                  false,
                  false,
                  Collections.<AnalyzerScriptParameter>emptyList()),
              trace,
              moduleDescriptor);

      injectorForAnalyzer
          .getTopDownAnalyzer()
          .analyzeFiles(
              environment.getSourceFiles(), Collections.<AnalyzerScriptParameter>emptyList());

      JavaDescriptorResolver javaDescriptorResolver = injectorForJava.getJavaDescriptorResolver();
      NamespaceDescriptor namespaceDescriptor =
          javaDescriptorResolver.resolveNamespace(
              LoadDescriptorUtil.TEST_PACKAGE_FQNAME, DescriptorSearchRule.INCLUDE_KOTLIN);
      assert namespaceDescriptor != null;

      compareNamespaceWithFile(
          namespaceDescriptor,
          NamespaceComparator.DONT_INCLUDE_METHODS_OF_OBJECT,
          new File(dir, "expected.txt"));

      ExpectedLoadErrorsUtil.checkForLoadErrors(namespaceDescriptor, trace.getBindingContext());
    }
  private void blackBoxFileAgainstJavaByFullPath(@NotNull String ktFileFullPath) {
    String ktFile = relativePath(new File(ktFileFullPath));
    File javaClassesTempDirectory = compileJava(ktFile.replaceFirst("\\.kt$", ".java"));

    myEnvironment =
        JetCoreEnvironment.createForTests(
            getTestRootDisposable(),
            JetTestUtils.compilerConfigurationForTests(
                ConfigurationKind.ALL,
                TestJdkKind.FULL_JDK,
                JetTestUtils.getAnnotationsJar(),
                javaClassesTempDirectory));

    loadFile(ktFile);
    blackBox();
  }
  private void blackBoxFileWithJavaByFullPath(@NotNull String directory) throws Exception {
    File dirFile = new File(directory);

    final List<String> javaFilePaths = new ArrayList<String>();
    final List<String> ktFilePaths = new ArrayList<String>();
    FileUtil.processFilesRecursively(
        dirFile,
        new Processor<File>() {
          @Override
          public boolean process(File file) {
            String path = relativePath(file);
            if (path.endsWith(".kt")) {
              ktFilePaths.add(path);
            } else if (path.endsWith(".java")) {
              javaFilePaths.add(path);
            }
            return true;
          }
        });

    CompilerConfiguration configuration =
        JetTestUtils.compilerConfigurationForTests(
            ConfigurationKind.ALL, TestJdkKind.FULL_JDK, JetTestUtils.getAnnotationsJar());
    configuration.add(JVMConfigurationKeys.CLASSPATH_KEY, dirFile);
    myEnvironment = JetCoreEnvironment.createForTests(getTestRootDisposable(), configuration);
    loadFiles(ArrayUtil.toStringArray(ktFilePaths));
    classFileFactory =
        GenerationUtils.compileManyFilesGetGenerationStateForTest(
                myEnvironment.getProject(), myFiles.getPsiFiles())
            .getFactory();
    File kotlinOut = JetTestUtils.tmpDir(toString());
    OutputUtilsPackage.writeAllTo(classFileFactory, kotlinOut);

    // TODO: support several Java sources
    File javaOut = compileJava(KotlinPackage.single(javaFilePaths), kotlinOut.getPath());
    // Add javac output to classpath so that the created class loader can find generated Java
    // classes
    configuration.add(JVMConfigurationKeys.CLASSPATH_KEY, javaOut);

    blackBox();
  }
  public void testNoAssertionsForKotlinFromBinary() throws Exception {
    CompilerConfiguration configuration =
        JetTestUtils.compilerConfigurationForTests(
            ConfigurationKind.JDK_ONLY, TestJdkKind.MOCK_JDK);
    JetCoreEnvironment tmpEnvironment =
        new JetCoreEnvironment(getTestRootDisposable(), configuration);
    GenerationState state =
        generateCommon(
            ClassBuilderFactories.TEST,
            tmpEnvironment,
            CodegenTestFiles.create(
                tmpEnvironment.getProject(),
                new String[] {"notNullAssertions/noAssertionsForKotlin.kt"}));
    File compiledDirectory = new File(FileUtil.getTempDirectory(), "kotlin-classes");
    CompileEnvironmentUtil.writeToOutputDirectory(state.getFactory(), compiledDirectory);

    setUpEnvironment(true, false, compiledDirectory);

    loadFile("notNullAssertions/noAssertionsForKotlinMain.kt");

    assertNoIntrinsicsMethodIsCalled(PackageClassUtils.getPackageClassName(FqName.ROOT));
  }