spectre-reporter-vstest 1.0.8 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/spectre/reporter/vstest.rb +56 -58
- metadata +5 -22
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 654ee03d02ff5cb85a974f9f927d5f368288af6c94ecbe3e9dda1c5faf7fcc54
|
4
|
+
data.tar.gz: fc371e8cdf6f904ed2460c2d7bb7127ba17cb5ca16b6ca4f3d27d3f21192199d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 821a27e0ba6740b7ed329b862aef1c9072348d943b70f649ec09cf1f0f9afcd3e38992c01de049f6fbb3a06cfdee948dcf977d469643fc1f415973253841d9ea
|
7
|
+
data.tar.gz: a75c71ee98631f814e98b341e4d422ab64780b26d471f921d16861c51fad2fa973e45260248ac49b81704903cb31e0e192278b88955c6d6d961fe9a140fc3bb4
|
@@ -1,8 +1,6 @@
|
|
1
1
|
require 'cgi'
|
2
2
|
require 'socket'
|
3
3
|
require 'securerandom'
|
4
|
-
require 'spectre'
|
5
|
-
require 'spectre/reporter'
|
6
4
|
|
7
5
|
# Azure mappings: https://docs.microsoft.com/en-us/azure/devops/pipelines/tasks/test/publish-test-results?view=azure-devops&tabs=trx%2Cyaml
|
8
6
|
|
@@ -18,72 +16,77 @@ module Spectre
|
|
18
16
|
now = Time.now.getutc
|
19
17
|
|
20
18
|
xml_str = '<?xml version="1.0" encoding="UTF-8" ?>'
|
21
|
-
xml_str += %
|
19
|
+
xml_str += %(<TestRun xmlns="http://microsoft.com/schemas/VisualStudio/TeamTest/2010">)
|
22
20
|
|
23
21
|
started = run_infos[0].started
|
24
22
|
finished = run_infos[-1].finished
|
25
23
|
|
26
24
|
computer_name = Socket.gethostname
|
27
25
|
|
28
|
-
xml_str += %
|
29
|
-
|
26
|
+
xml_str += %(<Times start="#{started.strftime(@date_format)}" finish="#{finished.strftime(@date_format)}" />)
|
30
27
|
|
31
28
|
# Write summary with file attachments
|
32
29
|
xml_str += '<ResultSummary>'
|
33
30
|
xml_str += '<ResultFiles>'
|
34
|
-
|
31
|
+
if File.exist? @config['log_file']
|
32
|
+
xml_str += %(<ResultFile path="#{File.absolute_path(@config['log_file'])}"></ResultFile>)
|
33
|
+
end
|
35
34
|
|
36
35
|
report_files = Dir[File.join(@config['out_path'], '*')]
|
37
36
|
|
38
37
|
if report_files.any?
|
39
38
|
report_files.each do |report_file|
|
40
|
-
xml_str += %
|
39
|
+
xml_str += %(<ResultFile path="#{File.absolute_path(report_file)}"></ResultFile>)
|
41
40
|
end
|
42
41
|
end
|
43
42
|
|
44
43
|
xml_str += '</ResultFiles>'
|
45
44
|
xml_str += '</ResultSummary>'
|
46
45
|
|
47
|
-
|
48
46
|
# Write test definitions
|
49
47
|
test_definitions = run_infos
|
50
|
-
.sort_by { |x| x.
|
51
|
-
.map { |x| [SecureRandom.uuid
|
48
|
+
.sort_by { |x| x.parent.name }
|
49
|
+
.map { |x| [SecureRandom.uuid, SecureRandom.uuid, x] }
|
52
50
|
|
53
51
|
xml_str += '<TestDefinitions>'
|
54
52
|
test_definitions.each do |test_id, execution_id, run_info|
|
55
|
-
xml_str += %
|
56
|
-
|
53
|
+
xml_str += %(<UnitTest name="#{CGI.escapeHTML get_name(run_info)}" \
|
54
|
+
storage="#{CGI.escapeHTML(run_info.parent.file.to_s)}" id="#{test_id}">)
|
55
|
+
xml_str += %(<Execution id="#{execution_id}" />)
|
57
56
|
xml_str += '</UnitTest>'
|
58
57
|
end
|
59
58
|
xml_str += '</TestDefinitions>'
|
60
59
|
|
61
|
-
|
62
60
|
# Write test results
|
63
61
|
xml_str += '<Results>'
|
64
62
|
test_definitions.each do |test_id, execution_id, run_info|
|
65
|
-
duration_str = Time.at(run_info.
|
66
|
-
|
67
|
-
if run_info.
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
63
|
+
duration_str = Time.at(run_info.finished - run_info.started).gmtime.strftime('%T.%L')
|
64
|
+
|
65
|
+
outcome = if [:failed, :error].include? run_info.status
|
66
|
+
'Failed'
|
67
|
+
elsif run_info.status == :skipped
|
68
|
+
'Skipped'
|
69
|
+
else
|
70
|
+
'Passed'
|
71
|
+
end
|
72
|
+
|
73
|
+
xml_str += %(<UnitTestResult executionId="#{execution_id}" \
|
74
|
+
testId="#{test_id}" \
|
75
|
+
testName="#{CGI.escapeHTML get_name(run_info)}" \
|
76
|
+
computerName="#{computer_name}" \
|
77
|
+
duration="#{duration_str}" \
|
78
|
+
startTime="#{run_info.started.strftime(@date_format)}" \
|
79
|
+
endTime="#{run_info.finished.strftime(@date_format)}" \
|
80
|
+
outcome="#{outcome}">)
|
81
|
+
|
82
|
+
if run_info.logs.any?
|
80
83
|
xml_str += '<Output>'
|
81
84
|
|
82
85
|
# Write log entries
|
83
86
|
xml_str += '<StdOut>'
|
84
87
|
log_str = ''
|
85
88
|
|
86
|
-
if run_info.properties.count
|
89
|
+
if run_info.properties.count.positive?
|
87
90
|
run_info.properties.each do |key, val|
|
88
91
|
log_str += "#{key}: #{val}\n"
|
89
92
|
end
|
@@ -95,52 +98,56 @@ module Spectre
|
|
95
98
|
log_str += "data: #{data_str}\n"
|
96
99
|
end
|
97
100
|
|
98
|
-
run_info.
|
99
|
-
log_text =
|
101
|
+
run_info.logs.each do |timestamp, level, progname, _corr_id, message|
|
102
|
+
log_text = ''
|
100
103
|
begin
|
101
104
|
log_text = message.dup.to_s
|
102
|
-
.force_encoding(
|
103
|
-
.encode!(
|
104
|
-
rescue
|
105
|
+
.force_encoding('ISO-8859-1')
|
106
|
+
.encode!('UTF-8')
|
107
|
+
rescue StandardError
|
105
108
|
puts "ERROR in VSTEST - see message : #{message}"
|
106
109
|
end
|
107
110
|
|
108
|
-
log_str += %
|
111
|
+
log_str += %(#{timestamp} #{level.to_s.upcase} -- \
|
112
|
+
#{progname}: #{CGI.escapeHTML(log_text)}\n)
|
109
113
|
end
|
110
114
|
|
111
115
|
xml_str += log_str
|
112
116
|
xml_str += '</StdOut>'
|
113
117
|
|
114
118
|
# Write error information
|
115
|
-
if
|
119
|
+
if [:failed, :error].include? run_info.status
|
116
120
|
xml_str += '<ErrorInfo>'
|
117
121
|
|
118
|
-
if run_info.
|
122
|
+
if run_info.status == :failed
|
119
123
|
xml_str += '<Message>'
|
120
124
|
|
121
|
-
failure_message =
|
122
|
-
failure_message += " with #{run_info.data}" if run_info.data
|
123
|
-
failure_message += " but it failed"
|
124
|
-
failure_message += " with message: #{run_info.failure.message}" if run_info.failure.message
|
125
|
+
failure_message = ''
|
125
126
|
|
126
|
-
|
127
|
+
run_info.evaluations.each do |evaluation|
|
128
|
+
evaluation.failures.each do |failure|
|
129
|
+
failure_message += "#{evaluation.desc}, but #{failure.message}<br/>"
|
130
|
+
end
|
131
|
+
end
|
132
|
+
|
133
|
+
xml_str += CGI.escapeHTML(failure_message)
|
127
134
|
|
128
135
|
xml_str += '</Message>'
|
129
136
|
end
|
130
137
|
|
131
|
-
if run_info.
|
132
|
-
error = run_info.error
|
138
|
+
if run_info.status == :error
|
139
|
+
error = run_info.error
|
133
140
|
|
134
141
|
failure_message = error.message
|
135
142
|
|
136
143
|
xml_str += '<Message>'
|
137
|
-
xml_str += CGI
|
144
|
+
xml_str += CGI.escapeHTML(failure_message)
|
138
145
|
xml_str += '</Message>'
|
139
146
|
|
140
147
|
stack_trace = error.backtrace.join "\n"
|
141
148
|
|
142
149
|
xml_str += '<StackTrace>'
|
143
|
-
xml_str += CGI
|
150
|
+
xml_str += CGI.escapeHTML(stack_trace)
|
144
151
|
xml_str += '</StackTrace>'
|
145
152
|
end
|
146
153
|
|
@@ -150,17 +157,14 @@ module Spectre
|
|
150
157
|
xml_str += '</Output>'
|
151
158
|
end
|
152
159
|
|
153
|
-
|
154
160
|
xml_str += '</UnitTestResult>'
|
155
161
|
end
|
156
162
|
xml_str += '</Results>'
|
157
163
|
|
158
|
-
|
159
164
|
# End report
|
160
165
|
xml_str += '</TestRun>'
|
161
166
|
|
162
|
-
|
163
|
-
Dir.mkdir(@config['out_path']) unless Dir.exist? @config['out_path']
|
167
|
+
FileUtils.mkdir_p(@config['out_path'])
|
164
168
|
|
165
169
|
file_path = File.join(@config['out_path'], "spectre-vstest_#{now.strftime('%s')}.trx")
|
166
170
|
|
@@ -170,14 +174,8 @@ module Spectre
|
|
170
174
|
private
|
171
175
|
|
172
176
|
def get_name run_info
|
173
|
-
|
174
|
-
|
175
|
-
run_name += " #{run_info.spec.desc}"
|
176
|
-
run_name
|
177
|
-
end
|
178
|
-
|
179
|
-
Spectre.register do |config|
|
180
|
-
Spectre::Reporter.add VSTest.new(config)
|
177
|
+
parent = run_info.parent
|
178
|
+
"[#{parent.name}] #{parent.full_desc}"
|
181
179
|
end
|
182
180
|
end
|
183
181
|
end
|
metadata
CHANGED
@@ -1,29 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: spectre-reporter-vstest
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 2.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Christian Neubauer
|
8
|
-
autorequire:
|
9
8
|
bindir: bin
|
10
9
|
cert_chain: []
|
11
|
-
date: 2025-
|
12
|
-
dependencies:
|
13
|
-
- !ruby/object:Gem::Dependency
|
14
|
-
name: spectre-core
|
15
|
-
requirement: !ruby/object:Gem::Requirement
|
16
|
-
requirements:
|
17
|
-
- - ">="
|
18
|
-
- !ruby/object:Gem::Version
|
19
|
-
version: 1.14.3
|
20
|
-
type: :runtime
|
21
|
-
prerelease: false
|
22
|
-
version_requirements: !ruby/object:Gem::Requirement
|
23
|
-
requirements:
|
24
|
-
- - ">="
|
25
|
-
- !ruby/object:Gem::Version
|
26
|
-
version: 1.14.3
|
10
|
+
date: 2025-03-21 00:00:00.000000000 Z
|
11
|
+
dependencies: []
|
27
12
|
description: Writes a VSTest report for spectre test run, which can be used in Azure
|
28
13
|
DevOps
|
29
14
|
email:
|
@@ -40,7 +25,6 @@ metadata:
|
|
40
25
|
homepage_uri: https://github.com/ionos-spectre/spectre-reporter-vstest
|
41
26
|
source_code_uri: https://github.com/ionos-spectre/spectre-reporter-vstest
|
42
27
|
changelog_uri: https://github.com/ionos-spectre/spectre-reporter-vstest/blob/master/CHANGELOG.md
|
43
|
-
post_install_message:
|
44
28
|
rdoc_options: []
|
45
29
|
require_paths:
|
46
30
|
- lib
|
@@ -48,15 +32,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
48
32
|
requirements:
|
49
33
|
- - ">="
|
50
34
|
- !ruby/object:Gem::Version
|
51
|
-
version: 3.
|
35
|
+
version: '3.4'
|
52
36
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
53
37
|
requirements:
|
54
38
|
- - ">="
|
55
39
|
- !ruby/object:Gem::Version
|
56
40
|
version: '0'
|
57
41
|
requirements: []
|
58
|
-
rubygems_version: 3.
|
59
|
-
signing_key:
|
42
|
+
rubygems_version: 3.6.6
|
60
43
|
specification_version: 4
|
61
44
|
summary: A VSTest reporter for spectre
|
62
45
|
test_files: []
|