public static void saveTestResults()

in src/com/intellij/rt/coverage/util/TestTrackingIOUtil.java [24:59]


  public static void saveTestResults(File tracesDirectory, String name, Map<Object, boolean[]> trace) throws IOException {
    final File traceFile = new File(tracesDirectory, name + ".tr");
    if (!traceFile.exists()) {
      traceFile.createNewFile();
    }
    DataOutputStream os = null;
    try {
      os = new DataOutputStream(new FileOutputStream(traceFile));
      final int size = trace.size();
      os.writeInt(size);
      int entries = 0;
      for (Map.Entry<Object, boolean[]> entry : trace.entrySet()) {
        // check how many classes were already written as the map size may be increased by another thread
        if (entries >= size) break;
        entries++;
        os.writeUTF(entry.getKey().toString());
        // copy lines array as it can be modified or cleared by another thread
        final boolean[] lines = ArrayUtil.copy(entry.getValue());
        int numberOfTraces = 0;
        for (int idx = 1; idx < lines.length; idx++) {
          if (lines[idx]) numberOfTraces++;
        }
        os.writeInt(numberOfTraces);
        for (int idx = 1; idx < lines.length; idx++) {
          final boolean incl = lines[idx];
          if (incl) {
            os.writeInt(idx);
          }
        }
      }
    } finally {
      if (os != null) {
        os.close();
      }
    }
  }