|
24 | 24 | '() ; exclude tests |
25 | 25 | '() ; exclude capabilities |
26 | 26 | '() ; expected failures |
| 27 | + "" ; bridge name |
27 | 28 | ))) |
28 | 29 |
|
29 | 30 | (define (suite-name suite) |
|
46 | 47 | (list-ref suite 9)) |
47 | 48 | (define (suite-expected-failures suite) |
48 | 49 | (list-ref suite 10)) |
| 50 | + (define (suite-bridge-name suite) |
| 51 | + (list-ref suite 11)) |
49 | 52 | (define (suite-set-only-tests! suite only-tests) |
50 | 53 | (list-set! suite 6 only-tests)) |
51 | 54 | (define (suite-set-only-capabilities! suite only-capabilities) |
|
56 | 59 | (list-set! suite 9 exclude-capabilities)) |
57 | 60 | (define (suite-set-expected-failures! suite expected-failures) |
58 | 61 | (list-set! suite 10 expected-failures)) |
| 62 | + (define (suite-set-bridge-name! suite bridge-name) |
| 63 | + (list-set! suite 11 bridge-name)) |
59 | 64 |
|
60 | 65 | (define (suite-all-tests suite) |
61 | 66 | (capability-all-tests (suite-root-capability suite))) |
|
92 | 97 |
|
93 | 98 | (define (display-run-options-help) |
94 | 99 | (display "Options:\n") |
95 | | - (display " --full-report: Write a full report of suite results to file [suite-name]-[suite-version]-results.xml.\n") |
| 100 | + (display " --full-report: Write a full report of suite results to file [suite-name]-[suite-version]-results.json.\n") |
96 | 101 | (display " --help: Display this help message.\n")) |
97 | 102 |
|
| 103 | + ; Writes full report to .json file |
| 104 | + ; Full report includes: |
| 105 | + ; - Hierarchical structure of capabilities and tests |
| 106 | + ; - Test results (success, failure, error, expected failure, unexpected pass, skipped) |
| 107 | + ; - Capabilities skipped |
98 | 108 | (define (write-full-report suite test-results expected-failures) |
99 | | - (display "Writing full report not implemented yet\n")) |
| 109 | + (let |
| 110 | + ((test-results-hash (alist->hash-table (map |
| 111 | + (lambda (test-result) (list (test-full-name (test-result-test test-result)) test-result)) |
| 112 | + test-results)))) |
| 113 | + (call-with-output-file |
| 114 | + (string-append (suite-name suite) "-" (suite-version suite) "-results.json") |
| 115 | + (lambda (out) |
| 116 | + (write-string |
| 117 | + (string-append |
| 118 | + "{" |
| 119 | + " \"suite\": {\n" |
| 120 | + " \"name\": \"" (suite-name suite) "\",\n" |
| 121 | + " \"version\": \"" (suite-version suite) "\",\n" |
| 122 | + " \"host\": \"" (rosetta-test-host) "\",\n" |
| 123 | + " \"bridge\": \"" (suite-bridge-name suite) "\",\n" |
| 124 | + " \"capabilities\": [\n" |
| 125 | + (full-capability-report (suite-root-capability suite) test-results-hash suite expected-failures) |
| 126 | + "\n ]" |
| 127 | + " }" |
| 128 | + "}") |
| 129 | + out))))) |
| 130 | + |
| 131 | + (define (full-capability-report capability test-results-hash suite expected-failures) |
| 132 | + (let |
| 133 | + ((capability-name (capability-name capability)) |
| 134 | + (capability-child-capabilities (capability-child-capabilities capability)) |
| 135 | + (capability-tests (capability-tests capability))) |
| 136 | + (string-append |
| 137 | + " {" |
| 138 | + " \"name\": \"" capability-name "\",\n" |
| 139 | + " \"state\": \"" (if (member capability-name (suite-exclude-capabilities suite)) "skipped" "run") "\",\n" ; TODO: This is not perfect, the capability might have been in the only list |
| 140 | + " \"capabilities\": [\n" |
| 141 | + (if (null? capability-child-capabilities) |
| 142 | + "" |
| 143 | + (string-join |
| 144 | + (map |
| 145 | + (lambda (child-capability) |
| 146 | + (full-capability-report child-capability test-results-hash suite expected-failures)) |
| 147 | + capability-child-capabilities) |
| 148 | + ",\n")) |
| 149 | + " ],\n" |
| 150 | + " \"tests\": [\n" |
| 151 | + (full-test-report capability-tests test-results-hash expected-failures) |
| 152 | + " ]\n" |
| 153 | + " }"))) |
| 154 | + |
| 155 | + ; Write out json array of test result objects with state (success, failure, error, expected failure, unexpected pass, skipped) |
| 156 | + (define (full-test-report tests test-results-hash expected-failures) |
| 157 | + (let |
| 158 | + ((selected-test-results (alist->hash-table (map |
| 159 | + (lambda (test) |
| 160 | + (if (member (test-full-name test) (hash-keys test-results-hash)) |
| 161 | + (list |
| 162 | + (test-full-name test) |
| 163 | + (short-hand-test-result (hash-ref test-results-hash (test-full-name test)) expected-failures)) |
| 164 | + (list (test-full-name test) "skipped"))) |
| 165 | + tests)))) |
| 166 | + (string-join |
| 167 | + (map |
| 168 | + (lambda (test) |
| 169 | + (string-append |
| 170 | + " {\n" |
| 171 | + " \"name\": \"" (test-name test) "\",\n" |
| 172 | + " \"state\": \"" (hash-ref selected-test-results (test-full-name test)) "\"" |
| 173 | + (if (= "E" (hash-ref selected-test-results (test-full-name test))) ",\n \"exception\": \"some error\"\n" "\n") |
| 174 | + " }")) |
| 175 | + tests) |
| 176 | + ",\n"))) |
100 | 177 |
|
101 | 178 | (define (suite-run suite options) |
102 | 179 | (display (string-append "Running suite: " (suite-name suite) " " (suite-version suite) "\n")) |
|
341 | 418 | ; Executing suites |
342 | 419 | ; |
343 | 420 |
|
344 | | - |
345 | | - |
346 | 421 | (define (expected-failures-test-result? test-result expected-failures) |
347 | 422 | (member (test-full-name (test-result-test test-result)) expected-failures)) |
348 | 423 |
|
|
0 commit comments