david_williams | 4a022dd | 2009-05-26 04:13:39 +0000 | [diff] [blame] | 1 | |
| 2 | <?php |
| 3 | |
| 4 | function parse_testResults($filename) |
| 5 | { |
| 6 | $junitFailures = 0; |
| 7 | if (is_file($filename)) { |
| 8 | $handle = @fopen($filename, "r"); |
| 9 | if ($handle) |
| 10 | { |
| 11 | $size = filesize($filename); |
| 12 | $content = fread($handle, $size); |
| 13 | fclose($handle); |
| 14 | $junitStart = strpos($content, "Errors & Failures"); |
| 15 | $junitEnd = strpos($content, "</table>", $junitStart); |
| 16 | $junitInfo = substr($content, $junitStart, $junitEnd - $junitStart); |
| 17 | $start = strpos($junitInfo, "<td><b><font color=\"#ff0000\">"); |
| 18 | while ($start !== false) |
| 19 | { |
| 20 | $start += 29; |
| 21 | $stop = strpos($junitInfo, "</font></b></td>", $start); |
| 22 | if ($stop !== false) |
| 23 | { |
| 24 | $result = substr($junitInfo, $start, $stop - $start); |
| 25 | if (is_numeric($result)) |
| 26 | { |
| 27 | $junitFailures += $result; |
| 28 | } |
| 29 | else if (strcmp($result, "DNF") == 0) |
| 30 | { |
| 31 | $junitFailures++; |
| 32 | } |
| 33 | } |
| 34 | $start = strpos($junitInfo, "<td><b><font color=\"#ff0000\">", $stop); |
| 35 | } |
| 36 | $results = array($junitFailures); |
| 37 | return $results; |
| 38 | } |
| 39 | } |
| 40 | } |
| 41 | |
| 42 | |
| 43 | ?> |
| 44 | |
| 45 | |