<commit_before>package org.testng.xml;

import static org.testng.reporters.XMLReporterConfig.ATTR_DESC;
import static org.testng.reporters.XMLReporterConfig.ATTR_FINISHED_AT;
import static org.testng.reporters.XMLReporterConfig.ATTR_METHOD_SIG;
import static org.testng.reporters.XMLReporterConfig.ATTR_NAME;
import static org.testng.reporters.XMLReporterConfig.ATTR_STARTED_AT;
import static org.testng.reporters.XMLReporterConfig.ATTR_STATUS;
import static org.testng.reporters.XMLReporterConfig.TAG_CLASS;
import static org.testng.reporters.XMLReporterConfig.TAG_SUITE;
import static org.testng.reporters.XMLReporterConfig.TAG_TEST;
import static org.testng.reporters.XMLReporterConfig.TAG_TEST_METHOD;

import org.testng.ITestResult;
import org.testng.remote.strprotocol.GenericMessage;
import org.testng.remote.strprotocol.IRemoteSuiteListener;
import org.testng.remote.strprotocol.IRemoteTestListener;
import org.testng.remote.strprotocol.MessageHelper;
import org.testng.remote.strprotocol.SuiteMessage;
import org.testng.remote.strprotocol.TestMessage;
import org.testng.remote.strprotocol.TestResultMessage;
import org.testng.reporters.XMLReporterConfig;
import org.xml.sax.Attributes;
import org.xml.sax.helpers.DefaultHandler;

public class ResultContentHandler extends DefaultHandler {
  private int m_suiteMethodCount = 0;
  private int m_testMethodCount = 0;
  private SuiteMessage m_currentSuite;
  private TestMessage m_currentTest;
  private String m_className;
  private int m_passed;
  private int m_failed;
  private int m_skipped;
  private int m_invocationCount;
  private int m_currentInvocationCount;
  private TestResultMessage m_currentTestResult;
  private IRemoteSuiteListener m_suiteListener;
  private IRemoteTestListener m_testListener;

  public ResultContentHandler(IRemoteSuiteListener suiteListener,
      IRemoteTestListener testListener) {
    m_suiteListener = suiteListener;
    m_testListener = testListener;
  }

  @Override
  public void startElement (String uri, String localName,
      String qName, Attributes attributes) {
    p("Start " + qName);
    if (TAG_SUITE.equals(qName)) {
      m_suiteListener.onInitialization(new GenericMessage(MessageHelper.GENERIC_SUITE_COUNT));
      m_suiteMethodCount = 0;
      m_currentSuite = new SuiteMessage(attributes.getValue(ATTR_NAME),
          true /* start */, m_suiteMethodCount);
      m_suiteListener.onStart(m_currentSuite);
    } else if (TAG_TEST.equals(qName)) {
      m_passed = m_failed = m_skipped = 0;
      m_currentTest = new TestMessage(true /* start */, m_currentSuite.getSuiteName(),
          attributes.getValue(ATTR_NAME), m_testMethodCount,
          m_passed, m_failed, m_skipped, 0);
      m_testListener.onStart(m_currentTest);
    } else if (TAG_CLASS.equals(qName)) {
      m_className = attributes.getValue(ATTR_NAME);
    } else if (TAG_TEST_METHOD.equals(qName)) {
      Integer status = XMLReporterConfig.getStatus(attributes.getValue(ATTR_STATUS));
      m_currentTestResult = new TestResultMessage(status, m_currentSuite.getSuiteName(),
          m_currentTest.getTestName(), m_className, attributes.getValue(ATTR_NAME),
          attributes.getValue(ATTR_DESC), parseParameters(attributes.getValue(ATTR_METHOD_SIG)),
          XMLReporterConfig.convertDate(attributes.getValue(ATTR_STARTED_AT)),
          XMLReporterConfig.convertDate(attributes.getValue(ATTR_FINISHED_AT)),
          null /* stack trace, filled later */,
          m_invocationCount, m_currentInvocationCount);
      m_suiteMethodCount++;
      m_testMethodCount++;
      if (status == ITestResult.SUCCESS) m_passed++;
      else if (status == ITestResult.FAILURE) m_failed++;
      else if (status == ITestResult.SKIP) m_skipped++;
    }
  }<commit_msg>Display correct duration values for test methods.<commit_after>package org.testng.xml;

import static org.testng.reporters.XMLReporterConfig.ATTR_DESC;
import static org.testng.reporters.XMLReporterConfig.ATTR_DURATION_MS;
import static org.testng.reporters.XMLReporterConfig.ATTR_METHOD_SIG;
import static org.testng.reporters.XMLReporterConfig.ATTR_NAME;
import static org.testng.reporters.XMLReporterConfig.ATTR_STATUS;
import static org.testng.reporters.XMLReporterConfig.TAG_CLASS;
import static org.testng.reporters.XMLReporterConfig.TAG_SUITE;
import static org.testng.reporters.XMLReporterConfig.TAG_TEST;
import static org.testng.reporters.XMLReporterConfig.TAG_TEST_METHOD;

import org.testng.ITestResult;
import org.testng.remote.strprotocol.GenericMessage;
import org.testng.remote.strprotocol.IRemoteSuiteListener;
import org.testng.remote.strprotocol.IRemoteTestListener;
import org.testng.remote.strprotocol.MessageHelper;
import org.testng.remote.strprotocol.SuiteMessage;
import org.testng.remote.strprotocol.TestMessage;
import org.testng.remote.strprotocol.TestResultMessage;
import org.testng.reporters.XMLReporterConfig;
import org.xml.sax.Attributes;
import org.xml.sax.helpers.DefaultHandler;

public class ResultContentHandler extends DefaultHandler {
  private int m_suiteMethodCount = 0;
  private int m_testMethodCount = 0;
  private SuiteMessage m_currentSuite;
  private TestMessage m_currentTest;
  private String m_className;
  private int m_passed;
  private int m_failed;
  private int m_skipped;
  private int m_invocationCount;
  private int m_currentInvocationCount;
  private TestResultMessage m_currentTestResult;
  private IRemoteSuiteListener m_suiteListener;
  private IRemoteTestListener m_testListener;

  public ResultContentHandler(IRemoteSuiteListener suiteListener,
      IRemoteTestListener testListener) {
    m_suiteListener = suiteListener;
    m_testListener = testListener;
  }

  @Override
  public void startElement (String uri, String localName,
      String qName, Attributes attributes) {
    p("Start " + qName);
    if (TAG_SUITE.equals(qName)) {
      m_suiteListener.onInitialization(new GenericMessage(MessageHelper.GENERIC_SUITE_COUNT));
      m_suiteMethodCount = 0;
      m_currentSuite = new SuiteMessage(attributes.getValue(ATTR_NAME),
          true /* start */, m_suiteMethodCount);
      m_suiteListener.onStart(m_currentSuite);
    } else if (TAG_TEST.equals(qName)) {
      m_passed = m_failed = m_skipped = 0;
      m_currentTest = new TestMessage(true /* start */, m_currentSuite.getSuiteName(),
          attributes.getValue(ATTR_NAME), m_testMethodCount,
          m_passed, m_failed, m_skipped, 0);
      m_testListener.onStart(m_currentTest);
    } else if (TAG_CLASS.equals(qName)) {
      m_className = attributes.getValue(ATTR_NAME);
    } else if (TAG_TEST_METHOD.equals(qName)) {
      Integer status = XMLReporterConfig.getStatus(attributes.getValue(ATTR_STATUS));
      m_currentTestResult = new TestResultMessage(status, m_currentSuite.getSuiteName(),
          m_currentTest.getTestName(), m_className, attributes.getValue(ATTR_NAME),
          attributes.getValue(ATTR_DESC),
          new String[0], /* no parameters, filled later */
          0, Long.parseLong(attributes.getValue(ATTR_DURATION_MS)),
          "" /* stack trace, filled later */,
          m_invocationCount, m_currentInvocationCount);
      m_suiteMethodCount++;
      m_testMethodCount++;
      if (status == ITestResult.SUCCESS) m_passed++;
      else if (status == ITestResult.FAILURE) m_failed++;
      else if (status == ITestResult.SKIP) m_skipped++;
    }
  }
{'fraction_non_alphanumeric': 0.08626068086260681, 'fraction_numerical': 0.0016275600162756001, 'mean_word_length': 4.9611964430072755, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 6}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4225933', 'n_tokens_mistral': 2222, 'n_tokens_neox': 2181, 'n_words': 407}