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.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/spectre/reporter/vstest.rb +56 -58
  3. metadata +5 -22
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d053b6759cb2f87556b4a4163804f927f3a6b2d9bc68c038953905a99f7a0d27
4
- data.tar.gz: d50e42462846b6832a6f7d7ba6993365861f47ecb9506d91140ebef1b4c67683
3
+ metadata.gz: 654ee03d02ff5cb85a974f9f927d5f368288af6c94ecbe3e9dda1c5faf7fcc54
4
+ data.tar.gz: fc371e8cdf6f904ed2460c2d7bb7127ba17cb5ca16b6ca4f3d27d3f21192199d
5
5
  SHA512:
6
- metadata.gz: bbe6029d5708cd812dd233954f8159bd2c8391965ef111df8b3895f1c113a52575ca37b77fe309b301ffbcca2bda5e7b9b653e4dac4a8393192c25b50d326d3f
7
- data.tar.gz: 634b41c6a50742313d9af6e5435ac0979c0beb8f0ff5a26835a22fffac52b92e8159cf36739de2b6debd0b78de0daf0abdd6897e90176530d6320a0fce021032
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 += %{<TestRun xmlns="http://microsoft.com/schemas/VisualStudio/TeamTest/2010">}
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 += %{<Times start="#{started.strftime(@date_format)}" finish="#{finished.strftime(@date_format)}" />}
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
- xml_str += %{<ResultFile path="#{File.absolute_path(@config['log_file'])}"></ResultFile>} if File.exist? @config['log_file']
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 += %{<ResultFile path="#{File.absolute_path(report_file)}"></ResultFile>}
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.spec.name }
51
- .map { |x| [SecureRandom.uuid(), SecureRandom.uuid(), x] }
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 += %{<UnitTest name="#{CGI::escapeHTML get_name(run_info)}" storage="#{CGI::escapeHTML(run_info.spec.file.to_s)}" id="#{test_id}">}
56
- xml_str += %{<Execution id="#{execution_id}" />}
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.duration).gmtime.strftime('%T.%L')
66
-
67
- if run_info.failed?
68
- outcome = 'Failed'
69
- elsif run_info.error?
70
- outcome = 'Failed'
71
- elsif run_info.skipped?
72
- outcome = 'Skipped'
73
- else
74
- outcome = 'Passed'
75
- end
76
-
77
- xml_str += %{<UnitTestResult executionId="#{execution_id}" testId="#{test_id}" testName="#{CGI::escapeHTML get_name(run_info)}" computerName="#{computer_name}" duration="#{duration_str}" startTime="#{run_info.started.strftime(@date_format)}" endTime="#{run_info.finished.strftime(@date_format)}" outcome="#{outcome}">}
78
-
79
- if run_info.log.any? or run_info.failed? or run_info.error?
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 > 0
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.log.each do |timestamp, message, level, name|
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("ISO-8859-1")
103
- .encode!("UTF-8")
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 += %{#{timestamp.strftime(@date_format)} #{level.to_s.upcase} -- #{name}: #{CGI::escapeHTML(log_text)}\n}
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 run_info.failed? or run_info.error?
119
+ if [:failed, :error].include? run_info.status
116
120
  xml_str += '<ErrorInfo>'
117
121
 
118
- if run_info.failed? and not run_info.failure.cause
122
+ if run_info.status == :failed
119
123
  xml_str += '<Message>'
120
124
 
121
- failure_message = "Expected #{run_info.failure.expectation}"
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
- xml_str += CGI::escapeHTML(failure_message)
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.error or (run_info.failed? and run_info.failure.cause)
132
- error = run_info.error || run_info.failure.cause
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::escapeHTML(failure_message)
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::escapeHTML(stack_trace)
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
- run_name = "[#{run_info.spec.name}] #{run_info.spec.subject.desc}"
174
- run_name += " - #{run_info.spec.context.__desc} -" unless run_info.spec.context.__desc.nil?
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: 1.0.8
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-01-20 00:00:00.000000000 Z
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.0.0
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.4.19
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: []