1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

tests: add a teamcity output format for V's test runner (#16681)

This commit is contained in:
Makhnev Petr
2022-12-15 11:29:09 +04:00
committed by GitHub
parent 3fa23b789c
commit db2111235e
5 changed files with 201 additions and 4 deletions

View File

@ -292,6 +292,9 @@ fn (mut ts TestSession) handle_test_runner_option() {
'dump' {
ts.reporter = DumpReporter{}
}
'teamcity' {
ts.reporter = TeamcityReporter{}
}
else {
dump('just set ts.reporter to an instance of your own struct here')
}

View File

@ -0,0 +1,57 @@
module testing
// TeamcityReporter implements the interface `testing.Reporter`.
// It is used by `v -test-runner teamcity test .`
pub struct TeamcityReporter {
}
pub fn (r TeamcityReporter) session_start(message string, mut ts TestSession) {
}
pub fn (r TeamcityReporter) session_stop(message string, mut ts TestSession) {
}
pub fn (r TeamcityReporter) report(index int, message LogMessage) {
name := r.get_test_suite_name_by_file(message.file)
match message.kind {
.cmd_begin {
eprintln("##teamcity[testSuiteStarted name='${name}' flowId='${message.flow_id}']")
}
.cmd_end {
eprintln("##teamcity[testSuiteFinished name='${name}' flowId='${message.flow_id}' duration='${message.took}']")
}
else {}
}
}
pub fn (r TeamcityReporter) get_test_suite_name_by_file(path string) string {
file_name := path.replace('\\', '/').split('/').last()
return file_name.split('.').first()
}
pub fn (r TeamcityReporter) report_stop() {
}
pub fn (r TeamcityReporter) progress(index int, message string) {
}
pub fn (r TeamcityReporter) update_last_line(index int, message string) {
}
pub fn (r TeamcityReporter) update_last_line_and_move_to_next(index int, message string) {
}
pub fn (r TeamcityReporter) message(index int, message string) {
}
pub fn (r TeamcityReporter) divider() {
}
pub fn (r TeamcityReporter) worker_threads_start(files []string, mut ts TestSession) {
}
pub fn (r TeamcityReporter) worker_threads_finish(mut ts TestSession) {
}
pub fn (r TeamcityReporter) list_of_failed_commands(failed_cmds []string) {
}