Ejemplo n.º 1
0
Archivo: rq3.py Proyecto: jineli/websee
def process(testpath):
  with open(testpath + '/description\'.txt') as f:
    result = []
    total = 0
    fail = 0
    skip = 0
    total_acccept = 0
    total_exact = 0
    total_time = 0
    for line in f:
      total += 1
      accept = 0
      exact = 0
      split = line.strip().split('\t')
      eid = split[1]
      expected_attribute = split[2].lower()
      expected_value = split[5].lower()
      path = split[8]
      expected_xpath = split[7]
      sys.stdout.write("Test Case: {0}\n".format(path))
      sys.stdout.write("Expected: {0}\t{1}\t{2}\n".format(expected_xpath, expected_attribute, expected_value))
      if eid == 'no seeding':
        sys.stdout.write('Skip.\n')
        rc = 2
        time = 0
        skip += 1
      else:
        (rc, rca_time) = parse_file(testpath +'/' + path + '/RCA_results.txt')
        #sys.stdout.write("Actual: {0}\t{1}\t{2}\n".format(actual_xpath, actual_attribute, actual_value))
        sys.stdout.write("Root Cause (0: wrong; 1:exact; 2:acceptable): {0}\n".format(rc))
        sys.stdout.write("RCA Time: {0} seconds\n".format(rca_time))
        (xpaths, time) = parse_test_report(testpath + '/' + path + '/test_report.txt')
        sys.stdout.write("Time: {0} seconds\n".format(time))
        tried = False
        if xpaths:
          for xpath in xpaths:
            if common.xpath_equal(expected_xpath, xpath):
              tried = True
        sys.stdout.write('Tried element: {0}\n'.format(tried))

        total_time += float(time)
        if time == '0':
          sys.stdout.write('Fail!\n')
          rc = -1
          fail += 1
        if rc == 1:
          sys.stdout.write('Acceptable fix\n')
        elif rc == 2:
          sys.stdout.write('Exact fix\n')
      if rc == 1: 
        total_acccept += 1
      elif rc == 2:
        total_exact += 1
      sys.stdout.write('\n')
      result.append((rc, float(time), float(rca_time)))

    sys.stdout.write('\n')
    sys.stdout.write('Acceptable Fix: {0}\n'.format(total_acccept))
    sys.stdout.write('Exact Fix: {0}\n'.format(total_exact))
    sys.stdout.write('Skipped Test Case: {0}\n'.format(skip))
    sys.stdout.write('Failed Test Case: {0}\n'.format(fail))
    sys.stdout.write('Total Test Case: {0}\n'.format(total))
    count = total - fail
    sys.stdout.write('Average Running Time: {0:.2f} seconds\n'.format(total_time/count))
    accrate = total_acccept * 1.0 / count
    exactrate = total_exact * 1.0 / count 
    sys.stdout.write('Acceptable Rate: {0} / {1} = {2:.2f} \n'.format(total_acccept, count, accrate))
    sys.stdout.write('Exact Rate: {0} / {1} = {2:.2f} \n'.format(total_exact, count, exactrate))
    return result
Ejemplo n.º 2
0
Archivo: s3.py Proyecto: jineli/websee
def process(testpath):
  with open(testpath + '/description.txt') as f:
    total = 0
    fail = 0
    skip = 0
    correct_element = 0
    correct_attribute = 0
    acceptable_number = 0
    fix_number = 0
    total_time = 0
    for line in f:
      total += 1
      split = line.strip().split('\t')
      eid = split[1]
      expected_attribute = split[2].lower()
      expected_value = split[5].lower()
      path = split[8]
      expected_xpath = split[7]
      sys.stdout.write("Test Case: {0}\n".format(path))
      sys.stdout.write("Expected: {0}\t{1}\t{2}\n".format(expected_xpath, expected_attribute, expected_value))
      if eid == 'no seeding':
        sys.stdout.write('Skip.\n')
        skip += 1
      else:
        (fix, actual_xpath, actual_attribute, actual_value, time) = parse_file(testpath + '/' + path + '/RCA_results.txt')
        sys.stdout.write("Actual: {0}\t{1}\t{2}\n".format(actual_xpath, actual_attribute, actual_value))
        sys.stdout.write("Same Image: {0}\n".format(fix))
        sys.stdout.write("Time: {0} seconds\n".format(time))
  
        if not actual_xpath:
          sys.stdout.write('Fail!\n')
          fail += 1
        if time:
          total_time += float(time)
        if fix:
          acceptable_number += 1
        if common.xpath_equal(actual_xpath, expected_xpath):
          correct_element += 1
          if actual_attribute == expected_attribute:
            correct_attribute += 1
          if fix and common.equal(expected_attribute, expected_value, actual_attribute, actual_value):
            fix_number += 1
            sys.stdout.write('Exact fix\n')
      sys.stdout.write('\n')
    sys.stdout.write('\n')
    sys.stdout.write('Correct Element: {0}\n'.format(correct_element))
    sys.stdout.write('Correct Attribute: {0}\n'.format(correct_attribute))
    sys.stdout.write('Acceptable Fix: {0}\n'.format(acceptable_number - fix_number))
    sys.stdout.write('Exact Fix: {0}\n'.format(fix_number))
    sys.stdout.write('Skipped Test Case: {0}\n'.format(skip))
    sys.stdout.write('Failed Test Case: {0}\n'.format(fail))
    sys.stdout.write('Total Test Case: {0}\n'.format(total))
    sys.stdout.write('Average Running Time: {0:.2f} seconds\n'.format(total_time / (total - fail - skip)))
    count = total - fail - skip
    elerate = correct_element * 1.0 / count
    attrate = correct_attribute * 1.0 / count
    accrate = (acceptable_number - fix_number) * 1.0 / count
    fixrate = fix_number * 1.0 / count 
    sys.stdout.write('Correct Element Rate: {0} / {1} = {2:.2f} \n'.format(correct_element, count, correct_element * 1.0 / count))
    sys.stdout.write('Correct Attribute Rate: {0} / {1} = {2:.2f} \n'.format(correct_attribute, count, correct_attribute * 1.0 / count))
    sys.stdout.write('Acceptable Rate: {0} / {1} = {2:.2f} \n'.format(acceptable_number - fix_number, count, (acceptable_number - fix_number) * 1.0 / count))
    sys.stdout.write('Exact Rate: {0} / {1} = {2:.2f} \n'.format(fix_number, count, fix_number * 1.0 / count))
    return (acceptable_number - fix_number, fix_number, (total - fail - skip), total_time / (total - fail - skip))