Skip to content

Commit dbdfbda

Browse files
committed
Update report templates for changes to earl-reports.
(cherry picked from commit 4db43444b3a534599d249608ccd48c956ddffc04)
1 parent 9fe9cae commit dbdfbda

File tree

5 files changed

+91
-171
lines changed

5 files changed

+91
-171
lines changed

nquads/reports/template.md

Lines changed: 18 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,13 @@
4242

4343
!!! 5
4444
%html{:prefix => "earl: http://www.w3.org/ns/earl# doap: http://usefulinc.com/ns/doap# mf: http://www.w3.org/2001/sw/DataAccess/tests/test-manifest#"}
45-
- subjects = tests['testSubjects']
45+
- test_info = {}
46+
- test_refs = {}
47+
- subject_refs = {}
48+
- passed_tests = []
49+
- subjects = tests['testSubjects'].sort_by {|s| s['name'].to_s.downcase}
50+
- subjects.each_with_index do |subject, index|
51+
- subject_refs[subject['@id']] = "subj_#{index}"
4652
%head
4753
%meta{"http-equiv" => "Content-Type", :content => "text/html;charset=utf-8"}
4854
%link{:rel => "alternate", :href => "earl.ttl"}
@@ -227,12 +233,9 @@
227233
See [Turtle Test Suite Wiki](http://www.w3.org/2011/rdf-wg/wiki/Turtle_Test_Suite)
228234
for more information.
229235
%section
230-
- test_info = {}
231-
- test_refs = {}
232-
- subject_refs = {}
233236
%h2
234237
Test Manifests
235-
- tests['entries'].each do |manifest|
238+
- tests['entries'].each_with_index do |manifest, ndx2|
236239
- test_cases = manifest['entries']
237240
%section{:typeof => manifest['@type'].join(" "), :resource => manifest['@id']}
238241
%h2<=manifest['title']
@@ -241,17 +244,16 @@
241244
~ CGI.escapeHTML desc.to_s
242245
%table.report
243246
- skip_subject = {}
244-
- passed_tests = []
247+
- passed_tests[ndx2] = []
245248
%tr
246249
%th
247250
Test
248251
- subjects.each_with_index do |subject, index|
249-
- subject_refs[subject['@id']] = "subj_#{index}"
250252
-# If subject is untested for every test in this manifest, skip it
251253
- skip_subject[subject['@id']] = manifest['entries'].all? {|t| t['assertions'][index]['result']['outcome'] == 'earl:untested'}
252254
- unless skip_subject[subject['@id']]
253255
%th
254-
%a{:href => '#' + subject_refs[subject['@id']]}<=subject['name']
256+
%a{:href => '#' + subject_refs[subject['@id']]}<=Array(subject['name']).first
255257
- test_cases.each do |test|
256258
- tid = 'test_' + (test['@id'][0,2] == '_:' ? test['@id'][2..-1] : test['@id'].split('#').last)
257259
- (test_info[tid] ||= []) << test
@@ -260,10 +262,11 @@
260262
%td
261263
%a{:href => "##{tid}"}<
262264
~ CGI.escapeHTML test['title'].to_s
263-
- test['assertions'].each_with_index do |assertion, ndx|
264-
- next if skip_subject[assertion['subject']]
265+
- subjects.each_with_index do |subject, ndx|
266+
- next if skip_subject[subject['@id']]
267+
- assertion = test['assertions'].detect {|a| a['subject'] == subject['@id']}
265268
- pass_fail = assertion['result']['outcome'].split(':').last.upcase.sub(/(PASS|FAIL)ED$/, '\1')
266-
- passed_tests[ndx] = (passed_tests[ndx] || 0) + (pass_fail == 'PASS' ? 1 : 0)
269+
- passed_tests[ndx2][ndx] = (passed_tests[ndx2][ndx] || 0) + (pass_fail == 'PASS' ? 1 : 0)
267270
%td{:class => pass_fail, :property => "earl:assertions", :typeof => assertion['@type'], :inlist => true}
268271
- if assertion['assertedBy']
269272
%link{:property => "earl:assertedBy", :href => assertion['assertedBy']}
@@ -277,7 +280,7 @@
277280
%tr.summary
278281
%td
279282
= "Percentage passed out of #{manifest['entries'].length} Tests"
280-
- passed_tests.compact.each do |r|
283+
- passed_tests[ndx2].compact.each do |r|
281284
- pct = (r * 100.0) / manifest['entries'].length
282285
%td{:class => (pct == 100.0 ? 'passed-all' : (pct >= 95.0 ? 'passed-most' : 'passed-some'))}
283286
= "#{'%.1f' % pct}%"
@@ -290,7 +293,7 @@
290293
- subjects.each_with_index do |subject, index|
291294
%dt{:id => subject_refs[subject['@id']]}
292295
%a{:href => subject['@id']}
293-
%span{:about => subject['@id'], :property => "doap:name"}<= subject['name']
296+
%span{:about => subject['@id'], :property => "doap:name"}<= Array(subject['name']).first
294297
%dd{:property => "earl:testSubjects", :resource => subject['@id'], :typeof => [subject['@type']].flatten.join(" "), :inlist => true}
295298
%dl
296299
- if subject['doapDesc']
@@ -323,8 +326,8 @@
323326
%dd
324327
%table.report
325328
%tbody
326-
- tests['entries'].each do |manifest|
327-
- passed = manifest['entries'].select {|t| t['assertions'][index]['result']['outcome'] == 'earl:passed' }.length
329+
- tests['entries'].each_with_index do |manifest, ndx|
330+
- passed = passed_tests[ndx][index].to_i
328331
- next if passed == 0
329332
- total = manifest['entries'].length
330333
- pct = (passed * 100.0) / total
@@ -341,25 +344,6 @@
341344
- tests['assertions'].each do |file|
342345
%li
343346
%a.source{:href => file}<= file
344-
%section.appendix
345-
%h2
346-
Test Definitions
347-
%dl
348-
- tests['entries'].each do |manifest|
349-
%div{:property => "mf:entries", :inlist => true, :resource => manifest['@id']}
350-
- manifest['entries'].each do |test|
351-
%dt{:id => test_refs[test['@id']], :resource => test['@id']}
352-
Test
353-
%span{:property => "dc:title mf:name"}<
354-
~ CGI.escapeHTML test['title'].to_s
355-
%dd{:resource => test['@id']}
356-
%p{:property => "dc:description", :lang => 'en'}<
357-
~ CGI.escapeHTML test['description'].to_s
358-
%pre{:class => "example actionDoc", :property => "mf:action", :resource => test['testAction'], :title => "#{test['title']} Input"}<
359-
~ Kernel.open(test['testAction']) {|f| f.set_encoding(Encoding::UTF_8); CGI.escapeHTML(f.read).to_s.gsub(/\n/, '<br/>')} rescue "#{test['testAction']} not loaded"
360-
- if test['testResult']
361-
%pre{:class => "example resultDoc", :property => "mf:result", :resource => test['testResult'], :title => "#{test['title']} Result"}<
362-
~ Kernel.open(test['testResult']) {|f| f.set_encoding(Encoding::UTF_8); CGI.escapeHTML(f.read).to_s.gsub(/\n/, '<br/>')} rescue "#{test['testResult']} not loaded"
363347
%section#appendix{:property => "earl:generatedBy", :resource => tests['generatedBy']['@id'], :typeof => tests['generatedBy']['@type']}
364348
%h2
365349
Report Generation Software

ntriples/reports/template.md

Lines changed: 18 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,13 @@
4242

4343
!!! 5
4444
%html{:prefix => "earl: http://www.w3.org/ns/earl# doap: http://usefulinc.com/ns/doap# mf: http://www.w3.org/2001/sw/DataAccess/tests/test-manifest#"}
45-
- subjects = tests['testSubjects']
45+
- test_info = {}
46+
- test_refs = {}
47+
- subject_refs = {}
48+
- passed_tests = []
49+
- subjects = tests['testSubjects'].sort_by {|s| s['name'].to_s.downcase}
50+
- subjects.each_with_index do |subject, index|
51+
- subject_refs[subject['@id']] = "subj_#{index}"
4652
%head
4753
%meta{"http-equiv" => "Content-Type", :content => "text/html;charset=utf-8"}
4854
%title
@@ -219,12 +225,9 @@
219225
See [Turtle Test Suite Wiki](http://www.w3.org/2011/rdf-wg/wiki/Turtle_Test_Suite)
220226
for more information.
221227
%section
222-
- test_info = {}
223-
- test_refs = {}
224-
- subject_refs = {}
225228
%h2
226229
Test Manifests
227-
- tests['entries'].each do |manifest|
230+
- tests['entries'].each_with_index do |manifest, ndx2|
228231
- test_cases = manifest['entries']
229232
%section{:typeof => manifest['@type'].join(" "), :resource => manifest['@id']}
230233
%h2<=manifest['title']
@@ -233,17 +236,16 @@
233236
~ CGI.escapeHTML desc
234237
%table.report
235238
- skip_subject = {}
236-
- passed_tests = []
239+
- passed_tests[ndx2] = []
237240
%tr
238241
%th
239242
Test
240243
- subjects.each_with_index do |subject, index|
241-
- subject_refs[subject['@id']] = "subj_#{index}"
242244
-# If subject is untested for every test in this manifest, skip it
243245
- skip_subject[subject['@id']] = manifest['entries'].all? {|t| t['assertions'][index]['result']['outcome'] == 'earl:untested'}
244246
- unless skip_subject[subject['@id']]
245247
%th
246-
%a{:href => '#' + subject_refs[subject['@id']]}<=subject['name']
248+
%a{:href => '#' + subject_refs[subject['@id']]}<=Array(subject['name']).first
247249
- test_cases.each do |test|
248250
- tid = 'test_' + (test['@id'][0,2] == '_:' ? test['@id'][2..-1] : test['@id'].split('#').last)
249251
- (test_info[tid] ||= []) << test
@@ -252,10 +254,11 @@
252254
%td
253255
%a{:href => "##{tid}"}<
254256
~ CGI.escapeHTML test['title']
255-
- test['assertions'].each_with_index do |assertion, ndx|
256-
- next if skip_subject[assertion['subject']]
257+
- subjects.each_with_index do |subject, ndx|
258+
- next if skip_subject[subject['@id']]
259+
- assertion = test['assertions'].detect {|a| a['subject'] == subject['@id']}
257260
- pass_fail = assertion['result']['outcome'].split(':').last.upcase.sub(/(PASS|FAIL)ED$/, '\1')
258-
- passed_tests[ndx] = (passed_tests[ndx] || 0) + (pass_fail == 'PASS' ? 1 : 0)
261+
- passed_tests[ndx2][ndx] = (passed_tests[ndx2][ndx] || 0) + (pass_fail == 'PASS' ? 1 : 0)
259262
%td{:class => pass_fail, :property => "earl:assertions", :typeof => assertion['@type'], :inlist => true}
260263
- if assertion['assertedBy']
261264
%link{:property => "earl:assertedBy", :href => assertion['assertedBy']}
@@ -269,7 +272,7 @@
269272
%tr.summary
270273
%td
271274
= "Percentage passed out of #{manifest['entries'].length} Tests"
272-
- passed_tests.compact.each do |r|
275+
- passed_tests[ndx2].compact.each do |r|
273276
- pct = (r * 100.0) / manifest['entries'].length
274277
%td{:class => (pct == 100.0 ? 'passed-all' : (pct >= 95.0 ? 'passed-most' : 'passed-some'))}
275278
= "#{'%.1f' % pct}%"
@@ -282,7 +285,7 @@
282285
- subjects.each_with_index do |subject, index|
283286
%dt{:id => subject_refs[subject['@id']]}
284287
%a{:href => subject['@id']}
285-
%span{:about => subject['@id'], :property => "doap:name"}<= subject['name']
288+
%span{:about => subject['@id'], :property => "doap:name"}<= Array(subject['name']).first
286289
%dd{:property => "earl:testSubjects", :resource => subject['@id'], :typeof => [subject['@type']].flatten.join(" "), :inlist => true}
287290
%dl
288291
- if subject['doapDesc']
@@ -321,8 +324,8 @@
321324
%dd
322325
%table.report
323326
%tbody
324-
- tests['entries'].each do |manifest|
325-
- passed = manifest['entries'].select {|t| t['assertions'][index]['result']['outcome'] == 'earl:passed' }.length
327+
- tests['entries'].each_with_index do |manifest, ndx|
328+
- passed = passed_tests[ndx][index].to_i
326329
- next if passed == 0
327330
- total = manifest['entries'].length
328331
- pct = (passed * 100.0) / total
@@ -339,25 +342,6 @@
339342
- tests['assertions'].each do |file|
340343
%li
341344
%a.source{:href => file}<= file
342-
%section.appendix
343-
%h2
344-
Test Definitions
345-
%dl
346-
- tests['entries'].each do |manifest|
347-
%div{:property => "mf:entries", :inlist => true, :resource => manifest['@id']}
348-
- manifest['entries'].each do |test|
349-
%dt{:id => test_refs[test['@id']], :resource => test['@id']}
350-
Test
351-
%span{:property => "dc:title mf:name"}<
352-
~ CGI.escapeHTML test['title']
353-
%dd{:resource => test['@id']}
354-
%p{:property => "dc:description", :lang => 'en'}<
355-
~ CGI.escapeHTML test['description']
356-
%pre{:class => "example actionDoc", :property => "mf:action", :resource => test['testAction'], :title => "#{test['title']} Input"}<
357-
~ Kernel.open(test['testAction']) {|f| f.set_encoding(Encoding::UTF_8); CGI.escapeHTML(f.read).gsub(/\n/, '<br/>')} rescue "#{test['testAction']} not loaded"
358-
- if test['testResult']
359-
%pre{:class => "example resultDoc", :property => "mf:result", :resource => test['testResult'], :title => "#{test['title']} Result"}<
360-
~ Kernel.open(test['testResult']) {|f| f.set_encoding(Encoding::UTF_8); CGI.escapeHTML(f.read).gsub(/\n/, '<br/>')} rescue "#{test['testResult']} not loaded"
361345
%section#appendix{:property => "earl:generatedBy", :resource => tests['generatedBy']['@id'], :typeof => tests['generatedBy']['@type']}
362346
%h2
363347
Report Generation Software

rdf-mt/reports/template.md

Lines changed: 18 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,13 @@
4242

4343
!!! 5
4444
%html{:prefix => "earl: http://www.w3.org/ns/earl# doap: http://usefulinc.com/ns/doap# mf: http://www.w3.org/2001/sw/DataAccess/tests/test-manifest#"}
45-
- subjects = tests['testSubjects']
45+
- test_info = {}
46+
- test_refs = {}
47+
- subject_refs = {}
48+
- passed_tests = []
49+
- subjects = tests['testSubjects'].sort_by {|s| s['name'].to_s.downcase}
50+
- subjects.each_with_index do |subject, index|
51+
- subject_refs[subject['@id']] = "subj_#{index}"
4652
%head
4753
%meta{"http-equiv" => "Content-Type", :content => "text/html;charset=utf-8"}
4854
%link{:rel => "alternate", :href => "earl.ttl"}
@@ -222,12 +228,9 @@
222228
foaf:homepage <http://greggkellogg.net/> .
223229

224230
%section
225-
- test_info = {}
226-
- test_refs = {}
227-
- subject_refs = {}
228231
%h2
229232
Test Manifests
230-
- tests['entries'].each do |manifest|
233+
- tests['entries'].each_with_index do |manifest, ndx2|
231234
- test_cases = manifest['entries']
232235
%section{:typeof => manifest['@type'].join(" "), :resource => manifest['@id']}
233236
%h2<=manifest['title']
@@ -236,17 +239,16 @@
236239
~ CGI.escapeHTML desc
237240
%table.report
238241
- skip_subject = {}
239-
- passed_tests = []
242+
- passed_tests[ndx2] = []
240243
%tr
241244
%th
242245
Test
243246
- subjects.each_with_index do |subject, index|
244-
- subject_refs[subject['@id']] = "subj_#{index}"
245247
-# If subject is untested for every test in this manifest, skip it
246248
- skip_subject[subject['@id']] = manifest['entries'].all? {|t| t['assertions'][index]['result']['outcome'] == 'earl:untested'}
247249
- unless skip_subject[subject['@id']]
248250
%th
249-
%a{:href => '#' + subject_refs[subject['@id']]}<=subject['name']
251+
%a{:href => '#' + subject_refs[subject['@id']]}<=Array(subject['name']).first
250252
- test_cases.each do |test|
251253
- tid = 'test_' + (test['@id'][0,2] == '_:' ? test['@id'][2..-1] : test['@id'].split('#').last)
252254
- (test_info[tid] ||= []) << test
@@ -255,10 +257,11 @@
255257
%td
256258
%a{:href => "##{tid}"}<
257259
~ CGI.escapeHTML test['title']
258-
- test['assertions'].each_with_index do |assertion, ndx|
259-
- next if skip_subject[assertion['subject']]
260+
- subjects.each_with_index do |subject, ndx|
261+
- next if skip_subject[subject['@id']]
262+
- assertion = test['assertions'].detect {|a| a['subject'] == subject['@id']}
260263
- pass_fail = assertion['result']['outcome'].split(':').last.upcase.sub(/(PASS|FAIL)ED$/, '\1')
261-
- passed_tests[ndx] = (passed_tests[ndx] || 0) + (pass_fail == 'PASS' ? 1 : 0)
264+
- passed_tests[ndx2][ndx] = (passed_tests[ndx2][ndx] || 0) + (pass_fail == 'PASS' ? 1 : 0)
262265
%td{:class => pass_fail, :property => "earl:assertions", :typeof => assertion['@type'], :inlist => true}
263266
- if assertion['assertedBy']
264267
%link{:property => "earl:assertedBy", :href => assertion['assertedBy']}
@@ -272,7 +275,7 @@
272275
%tr.summary
273276
%td
274277
= "Percentage passed out of #{manifest['entries'].length} Tests"
275-
- passed_tests.compact.each do |r|
278+
- passed_tests[ndx2].compact.each do |r|
276279
- pct = (r * 100.0) / manifest['entries'].length
277280
%td{:class => (pct == 100.0 ? 'passed-all' : (pct >= 95.0 ? 'passed-most' : 'passed-some'))}
278281
= "#{'%.1f' % pct}%"
@@ -285,7 +288,7 @@
285288
- subjects.each_with_index do |subject, index|
286289
%dt{:id => subject_refs[subject['@id']]}
287290
%a{:href => subject['@id']}
288-
%span{:about => subject['@id'], :property => "doap:name"}<= subject['name']
291+
%span{:about => subject['@id'], :property => "doap:name"}<= Array(subject['name']).first
289292
%dd{:property => "earl:testSubjects", :resource => subject['@id'], :typeof => [subject['@type']].flatten.join(" "), :inlist => true}
290293
%dl
291294
- if subject['doapDesc']
@@ -324,8 +327,8 @@
324327
%dd
325328
%table.report
326329
%tbody
327-
- tests['entries'].each do |manifest|
328-
- passed = manifest['entries'].select {|t| t['assertions'][index]['result']['outcome'] == 'earl:passed' }.length
330+
- tests['entries'].each_with_index do |manifest, ndx|
331+
- passed = passed_tests[ndx][index].to_i
329332
- next if passed == 0
330333
- total = manifest['entries'].length
331334
- pct = (passed * 100.0) / total
@@ -342,25 +345,6 @@
342345
- tests['assertions'].each do |file|
343346
%li
344347
%a.source{:href => file}<= file
345-
%section.appendix
346-
%h2
347-
Test Definitions
348-
%dl
349-
- tests['entries'].each do |manifest|
350-
%div{:property => "mf:entries", :inlist => true, :resource => manifest['@id']}
351-
- manifest['entries'].each do |test|
352-
%dt{:id => test_refs[test['@id']], :resource => test['@id']}
353-
Test
354-
%span{:property => "dc:title mf:name"}<
355-
~ CGI.escapeHTML test['title']
356-
%dd{:resource => test['@id']}
357-
%p{:property => "dc:description", :lang => 'en'}<
358-
~ CGI.escapeHTML test['description']
359-
%pre{:class => "example actionDoc", :property => "mf:action", :resource => test['testAction'], :title => "#{test['title']} Input"}<
360-
~ Kernel.open(test['testAction']) {|f| f.set_encoding(Encoding::UTF_8); CGI.escapeHTML(f.read).gsub(/\n/, '<br/>')} rescue "#{test['testAction']} not loaded"
361-
- if test['testResult']
362-
%pre{:class => "example resultDoc", :property => "mf:result", :resource => test['testResult'], :title => "#{test['title']} Result"}<
363-
~ Kernel.open(test['testResult']) {|f| f.set_encoding(Encoding::UTF_8); CGI.escapeHTML(f.read).gsub(/\n/, '<br/>')} rescue "#{test['testResult']} not loaded"
364348
%section#appendix{:property => "earl:generatedBy", :resource => tests['generatedBy']['@id'], :typeof => tests['generatedBy']['@type']}
365349
%h2
366350
Report Generation Software

0 commit comments

Comments
 (0)