david_williams | ba5e1f5 | 2007-07-29 21:11:08 +0000 | [diff] [blame] | 1 | |
| 2 | <?php |
| 3 | |
| 4 | function parse2_testResults($filename) |
| 5 | { |
| 6 | $junitFailures = -1; |
| 7 | if (is_file($filename)) { |
| 8 | $handle = @fopen($filename, "r"); |
| 9 | if ($handle) |
| 10 | { |
| 11 | $junitFailures = 0; |
| 12 | $size = filesize($filename); |
| 13 | $content = fread($handle, $size); |
| 14 | fclose($handle); |
| 15 | $junitStart = strpos($content, "Errors & Failures"); |
| 16 | $junitEnd = strpos($content, "</table>", $junitStart); |
| 17 | $junitInfo = substr($content, $junitStart, $junitEnd - $junitStart); |
| 18 | $start = strpos($junitInfo, "<td><b><font color=\"#ff0000\">"); |
| 19 | while ($start !== false) |
| 20 | { |
| 21 | $start += 29; |
| 22 | $stop = strpos($junitInfo, "</font></b></td>", $start); |
| 23 | if ($stop !== false) |
| 24 | { |
| 25 | $result = substr($junitInfo, $start, $stop - $start); |
| 26 | if (is_numeric($result)) |
| 27 | { |
| 28 | $junitFailures += $result; |
| 29 | } |
| 30 | else if (strcmp($result, "DNF") == 0) |
| 31 | { |
| 32 | $junitFailures++; |
| 33 | } |
| 34 | } |
| 35 | $start = strpos($junitInfo, "<td><b><font color=\"#ff0000\">", $stop); |
| 36 | } |
| 37 | $results = array($junitFailures); |
| 38 | return $results; |
| 39 | } |
| 40 | } |
| 41 | } |
| 42 | |
| 43 | function parse2_compileResults($filename) |
| 44 | { |
| 45 | $compileErrors = 0; |
| 46 | $compileAccessWarnings = 0; |
| 47 | $compileOtherWarnings = 0; |
| 48 | if (is_file($filename)) { |
| 49 | //echo "$filename<br />"; |
| 50 | $handle = @fopen($filename, "r"); |
| 51 | if ($handle) |
| 52 | { |
| 53 | $size = filesize($filename); |
| 54 | //echo "size: $size<br />"; |
| 55 | $content = fread($handle, $size); |
| 56 | fclose($handle); |
| 57 | |
| 58 | //echo "$content"; |
| 59 | $compileStart = strpos($content, "<table id=tabledata"); |
| 60 | $compileEnd = strpos($content, "</table", $compileStart); |
| 61 | $compileInfo = substr($content, $compileStart, $compileEnd - $compileStart); |
| 62 | //echo "compileInfo: $compileInfo<br />"; |
| 63 | $rowStart = strpos($compileInfo, "<tr>"); |
| 64 | $rowStart = strpos($compileInfo, "<tr>"); |
| 65 | $start = $rowStart+4; |
| 66 | while ($rowStart !== false) |
| 67 | { |
| 68 | |
| 69 | $start += 4; |
| 70 | $rowStop = strpos($compileInfo, "</tr>", $rowStart); |
| 71 | //if ($rowStop !== false) |
| 72 | //{ |
| 73 | $row = substr($compileInfo, $rowStart, $rowStop - $rowStart); |
| 74 | //echo "$row"; |
| 75 | //while ($cellStart !== false) |
| 76 | //{ |
| 77 | // this parsing logic got a bit more complicated in M5_33 basebuild, as the |
| 78 | // a whole different structure was used. |
| 79 | // we'll try to quick fix this, but need our own index task |
| 80 | $cellStart = strpos($row, "#ERROR"); |
| 81 | $cellStart = strpos($row, ">", $cellStart); |
| 82 | $cellStart = $cellStart + 1; |
| 83 | $cellStop = strpos($row, "<", $cellStart); |
| 84 | if ($cellStop !== false) |
| 85 | { |
| 86 | $cell = substr($row, $cellStart, $cellStop - $cellStart); |
| 87 | if (is_numeric($cell)) |
| 88 | { |
| 89 | $compileErrors += $cell; |
| 90 | } |
| 91 | $cellStart = strpos($row, "#ACCESSRULES_WARNINGS"); |
| 92 | $cellStart = strpos($row, ">", $cellStart); |
| 93 | $cellStart = $cellStart + 1; |
| 94 | $cellStop = strpos($row, "<", $cellStart); |
| 95 | $cell = substr($row, $cellStart, $cellStop - $cellStart); |
| 96 | if (is_numeric($cell)) |
| 97 | { |
| 98 | $compileAccessWarnings += $cell; |
| 99 | } |
| 100 | $cellStart = strpos($row, "#OTHER_WARNINGS"); |
| 101 | $cellStart = strpos($row, ">", $cellStart); |
| 102 | $cellStart = $cellStart + 1; |
| 103 | $cellStop = strpos($row, "<", $cellStart); |
| 104 | $cell = substr($row, $cellStart, $cellStop - $cellStart); |
| 105 | if (is_numeric($cell)) |
| 106 | { |
| 107 | $compileOtherWarnings += $cell; |
| 108 | } |
| 109 | } |
| 110 | // look for next row. |
| 111 | //$cellStart = strpos($row, "<tr", $cellStop); |
| 112 | //} |
| 113 | //} |
| 114 | $rowStart = strpos($compileInfo, "<tr>", $rowStop); |
| 115 | } |
| 116 | } |
| 117 | } |
| 118 | |
| 119 | $results = array($compileErrors, $compileAccessWarnings, $compileOtherWarnings); |
| 120 | return $results; |
| 121 | } |
| 122 | |
| 123 | |
| 124 | |
| 125 | ?> |
| 126 | |
| 127 | |