| 1 | module testing |
| 2 | |
| 3 | // TeamcityReporter implements the interface `testing.Reporter`. |
| 4 | // It is used by `v -test-runner teamcity test .` |
| 5 | pub struct TeamcityReporter { |
| 6 | } |
| 7 | |
| 8 | pub fn (r TeamcityReporter) session_start(message string, mut ts TestSession) { |
| 9 | } |
| 10 | |
| 11 | pub fn (r TeamcityReporter) session_stop(message string, mut ts TestSession) { |
| 12 | } |
| 13 | |
| 14 | pub fn (r TeamcityReporter) report(index int, message LogMessage) { |
| 15 | name := r.get_test_suite_name_by_file(message.file) |
| 16 | match message.kind { |
| 17 | .cmd_begin { |
| 18 | eprintln("##teamcity[testSuiteStarted name='${name}' flowId='${message.flow_id}']") |
| 19 | } |
| 20 | .cmd_end { |
| 21 | eprintln("##teamcity[testSuiteFinished name='${name}' flowId='${message.flow_id}' duration='${message.took}']") |
| 22 | } |
| 23 | .cannot_compile { |
| 24 | eprintln("##teamcity[testFailed name='${name}' message='${message.message}']") |
| 25 | } |
| 26 | else {} |
| 27 | } |
| 28 | } |
| 29 | |
| 30 | pub fn (r TeamcityReporter) get_test_suite_name_by_file(path string) string { |
| 31 | file_name := path.replace('\\', '/').split('/').last() |
| 32 | return file_name.split('.').first() |
| 33 | } |
| 34 | |
| 35 | pub fn (r TeamcityReporter) report_stop() { |
| 36 | } |
| 37 | |
| 38 | pub fn (r TeamcityReporter) progress(index int, message string) { |
| 39 | } |
| 40 | |
| 41 | pub fn (r TeamcityReporter) update_last_line(index int, message string) { |
| 42 | } |
| 43 | |
| 44 | pub fn (r TeamcityReporter) update_last_line_and_move_to_next(index int, message string) { |
| 45 | } |
| 46 | |
| 47 | pub fn (r TeamcityReporter) message(index int, message string) { |
| 48 | } |
| 49 | |
| 50 | pub fn (r TeamcityReporter) divider() { |
| 51 | } |
| 52 | |
| 53 | pub fn (r TeamcityReporter) worker_threads_start(files []string, mut ts TestSession) { |
| 54 | } |
| 55 | |
| 56 | pub fn (r TeamcityReporter) worker_threads_finish(mut ts TestSession) { |
| 57 | } |
| 58 | |
| 59 | pub fn (r TeamcityReporter) list_of_failed_commands(failed_cmds []string) { |
| 60 | } |
| 61 | |