@NotNull
  public static Project createProject(@NotNull String path, String creationPlace) {
    String fileName = PathUtilRt.getFileName(path);
    String projectName = FileUtilRt.getNameWithoutExtension(fileName);
    VirtualFile projectBase =
        LocalFileSystem.getInstance()
            .findFileByPath(
                FileUtil.toSystemIndependentName(
                    fileName.endsWith(ProjectFileType.DOT_DEFAULT_EXTENSION)
                        ? PathUtilRt.getParentPath(path)
                        : path));
    if (projectBase != null) {
      // must be leftovers from the previous test run
      for (VirtualFile file : ((NewVirtualFile) projectBase).iterInDbChildren()) {
        delete(file);
      }
    }

    try {
      Project project =
          ProjectManagerEx.getInstanceEx().newProject(projectName, path, false, false);
      assert project != null;

      project.putUserData(CREATION_PLACE, creationPlace);
      return project;
    } catch (TooManyProjectLeakedException e) {
      StringBuilder leakers = new StringBuilder();
      leakers.append("Too many projects leaked: \n");
      for (Project project : e.getLeakedProjects()) {
        String presentableString = getCreationPlace(project);
        leakers.append(presentableString);
        leakers.append("\n");
      }

      fail(leakers.toString());
      return null;
    }
  }
  @Override
  protected void tearDown() throws Exception {
    List<Throwable> exceptions = new SmartList<Throwable>();
    Project project = myProject;
    if (project != null) {
      try {
        LightPlatformTestCase.doTearDown(project, ourApplication, false, exceptions);
      } catch (Throwable e) {
        exceptions.add(e);
      }

      disposeProject(exceptions);
    }

    try {
      checkForSettingsDamage(exceptions);
    } catch (Throwable e) {
      exceptions.add(e);
    }
    try {
      if (project != null) {
        try {
          InjectedLanguageManagerImpl.checkInjectorsAreDisposed(project);
        } catch (AssertionError e) {
          exceptions.add(e);
        }
      }
      try {
        for (final File fileToDelete : myFilesToDelete) {
          delete(fileToDelete);
        }
        LocalFileSystem.getInstance().refreshIoFiles(myFilesToDelete);
      } catch (Throwable e) {
        exceptions.add(e);
      }

      if (!myAssertionsInTestDetected) {
        if (IdeaLogger.ourErrorsOccurred != null) {
          exceptions.add(IdeaLogger.ourErrorsOccurred);
        }
      }

      try {
        super.tearDown();
      } catch (Throwable e) {
        exceptions.add(e);
      }

      try {
        if (myEditorListenerTracker != null) {
          myEditorListenerTracker.checkListenersLeak();
        }
      } catch (AssertionError error) {
        exceptions.add(error);
      }
      try {
        if (myThreadTracker != null) {
          myThreadTracker.checkLeak();
        }
      } catch (AssertionError error) {
        exceptions.add(error);
      }
      try {
        LightPlatformTestCase.checkEditorsReleased(exceptions);
      } catch (Throwable error) {
        exceptions.add(error);
      }
    } finally {
      myProjectManager = null;
      myProject = null;
      myModule = null;
      myFilesToDelete.clear();
      myEditorListenerTracker = null;
      myThreadTracker = null;
      ourTestCase = null;
    }
    CompoundRuntimeException.throwIfNotEmpty(exceptions);
  }