private void setSessionOutputs(CliSessionState ss, File outf) throws Exception {
    OutputStream fo = new BufferedOutputStream(new FileOutputStream(outf));
    if (ss.out != null) {
      ss.out.flush();
    }
    if (ss.err != null) {
      ss.err.flush();
    }

    qTestResultProcessor.setOutputs(ss, fo);

    ss.err = new CachingPrintStream(fo, true, "UTF-8");
    ss.setIsSilent(true);
    ss.setIsQtestLogging(true);
  }
Clear out any side effects of running tests
itests/util/src/main/java/org/apache/hadoop/hive/ql/QTestUtil.java