Skip to content

Commit d8c2e0d

Browse files
authored
Adds back links to specs for each test that used data-tests. (#178)
* Build test-map by scanning specs for `data-tests` attributes. * Update HAML templates to add "references" with back references to places in the spec that reference each test using `data-tests`. * Rename SPARQL1.0 to SPARQL 1.0. * Rename SPARQL1.1 to SPARQL 1.1. * Use relative locations of specs and their related test manifests and resolve the test links extracted from the spec. Also fixes some other inconsistencies in the templates. --------- Co-authored-by: gkellogg <[email protected]>
1 parent 5dbbb52 commit d8c2e0d

File tree

121 files changed

+1816
-1677
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

121 files changed

+1816
-1677
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/.byebug_history

Gemfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,4 @@ gem 'kramdown', '~> 2.5'
99
gem 'htmlbeautifier', '~> 1.4'
1010
gem 'logger', '~> 1.7'
1111
gem 'ostruct', '~> 0.6'
12+
gem 'nokogiri', '~> 1.18'

Gemfile.lock

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,12 @@ GEM
3232
logger (1.7.0)
3333
matrix (0.4.2)
3434
multi_json (1.15.0)
35+
nokogiri (1.18.8-arm64-darwin)
36+
racc (~> 1.4)
37+
nokogiri (1.18.8-x86_64-linux-gnu)
38+
racc (~> 1.4)
3539
ostruct (0.6.1)
40+
racc (1.8.1)
3641
rack (3.1.14)
3742
rake (13.2.1)
3843
rdf (3.3.2)
@@ -65,6 +70,7 @@ DEPENDENCIES
6570
json-ld
6671
kramdown (~> 2.5)
6772
logger (~> 1.7)
73+
nokogiri (~> 1.18)
6874
ostruct (~> 0.6)
6975
rake
7076
rdf-turtle

Rakefile

Lines changed: 97 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,110 @@ require 'rdf/turtle'
33
require 'json/ld'
44
require 'haml'
55
require 'htmlbeautifier'
6+
require 'nokogiri'
7+
require 'rake/clean'
68

79
task default: :index
810

911
MANIFESTS = Dir.glob("**/manifest*.ttl").reject {|f| f.include?('-az')}
1012

13+
SPECS = {
14+
"rdf-concepts/spec/index.html" => "FIXME",
15+
"rdf-n-quads/spec/index.html" => "rdf/rdf12/rdf-n-quads/",
16+
"rdf-n-triples/spec/index.html" => "rdf/rdf12/rdf-n-triples/",
17+
"rdf-schema/spec/index.html" => "FIXME",
18+
"rdf-semantics/spec/index.html" => "rdf/rdf12/rdf-semantics/",
19+
"rdf-trig/spec/index.html" => "rdf/rdf12/rdf-trig/",
20+
"rdf-turtle/spec/index.html" => "rdf/rdf12/rdf-turtle/",
21+
"rdf-xml/spec/index.html" => "rdf/rdf12/rdf-xml/",
22+
23+
"sparql-concepts/spec/index.html" => "",
24+
"sparql-entailment/spec/index.html" => "",
25+
"sparql-federated-query/spec/index.html" => "",
26+
"sparql-graph-store-protocol/spec/index.html" => "",
27+
"sparql-protocol/spec/index.html" => "",
28+
"sparql-query/spec/index.html" => "",
29+
"sparql-results-csv-tsv/spec/index.html" => "",
30+
"sparql-results-json/spec/index.html" => "",
31+
"sparql-results-xml/spec/index.html" => "",
32+
"sparql-service-description/spec/index.html" => "",
33+
"sparql-update/spec/index.html" => ""
34+
}
35+
36+
JSON_STATE = {
37+
:indent => " ",
38+
:space => " ",
39+
:space_before => "",
40+
:object_nl => "\n",
41+
:array_nl => "\n",
42+
:allow_nan => false,
43+
:ascii_only => false,
44+
:max_nesting => 100,
45+
:script_safe => false,
46+
:strict => false,
47+
:depth => 0,
48+
:buffer_initial_length => 1024
49+
}
50+
51+
CLOBBER.include("test-map.json")
52+
desc "Build map of test references"
53+
file "test-map.json" do
54+
puts "Generate test-map.json"
55+
# Test map will be like the following:
56+
# {
57+
# "rdf/rdf11/rdf-xml/index.html" => {
58+
# "xmlbase-test001" => [
59+
# "https://w3c.github.io/rdf-xml/spec/index.html#baseURIs-tests1"
60+
# ]
61+
# }
62+
# }
63+
test_map = {}
64+
failed = false
65+
SPECS.each do |spec, ts|
66+
spec = "https://w3c.github.io/#{spec}"
67+
ts = RDF::URI("https://w3c.github.io/rdf-tests/#{ts}")
68+
puts " Spec: #{spec}"
69+
RDF::Util::File.open_file(spec) do |f|
70+
dom = Nokogiri::HTML.parse(f)
71+
# Extract each referenced test from the data-tests attribute
72+
dom.css("*[data-tests]").each do |el|
73+
id = el['id']
74+
raise StandardError, "In #{spec}, data-tests found on element without an anchor" unless id
75+
76+
el.attributes['data-tests']
77+
.value
78+
.split(',')
79+
.map(&:strip)
80+
.each do |ref|
81+
82+
man, anchor = ref.split('#')
83+
man = ts.join(man).to_s.sub('https://w3c.github.io/rdf-tests/', '')
84+
((test_map[man] ||= {})[anchor] ||= []) << "#{spec}##{id}"
85+
end
86+
end
87+
end
88+
rescue IOError => e
89+
failed = true
90+
puts "Failed to open URL: #{e.message}"
91+
rescue StandardError => e
92+
failed = true
93+
puts "An error occurred: #{e.message}"
94+
end
95+
96+
unless failed
97+
File.open("test-map.json", "w") do |f|
98+
f.write(test_map.to_json(JSON_STATE))
99+
end
100+
end
101+
end
102+
11103
desc "Build HTML manifests"
12104
task index: MANIFESTS.
13105
select {|m| File.exist?(m)}.
14106
map {|m| m.sub(/manifest(.*)\.ttl$/, 'index\1.html')}
15107

108+
CLOBBER.include(MANIFESTS.map {|ttl| ttl.sub(/manifest(.*)\.ttl$/, 'index\1.html')})
109+
16110
MANIFESTS.each do |ttl|
17111
html = ttl.sub(/manifest(.*)\.ttl$/, 'index\1.html')
18112
base = 'https://w3c.github.io/rdf-tests/' + ttl.sub('manifest.ttl', '')
@@ -30,7 +124,7 @@ MANIFESTS.each do |ttl|
30124

31125
if template_path
32126
desc "Build #{html}"
33-
file html => [ttl, frame_path, template_path] do
127+
file html => [ttl, frame_path, template_path, 'test-map.json'] do
34128
puts "Generate #{html}"
35129
frame, template, man = File.read(frame_path), File.read(template_path), nil
36130

@@ -75,7 +169,8 @@ MANIFESTS.each do |ttl|
75169
rendered = haml_runner.render(self,
76170
man: man,
77171
haml_indent: true,
78-
ttl: ttl.split('/').last
172+
ttl: ttl.split('/').last,
173+
test_map: JSON.parse(File.read('test-map.json')).fetch(html, {})
79174
)
80175
beautified = HtmlBeautifier.beautify(rendered) + "\n"
81176
f.write(beautified)

local-biblio.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

ns/test-manifest.ttl

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -113,12 +113,12 @@
113113
rdfs:comment "A type of test specifically for syntax testing of SPARQL Update. Syntax tests are not required to have an associated result, only an action. Tests are expected to define their spec version." .
114114

115115
:PositiveSyntaxTest11 rdf:type rdfs:Class ;
116-
rdfs:label "Positive Syntax Test for SPARQL1.1 Query" ;
117-
rdfs:comment "A type of test specifically for syntax testing of new features in the SPARQL1.1 Query Language. Syntax tests are not required to have an associated result, only an action." .
116+
rdfs:label "Positive Syntax Test for SPARQL 1.1 Query" ;
117+
rdfs:comment "A type of test specifically for syntax testing of new features in the SPARQL 1.1 Query Language. Syntax tests are not required to have an associated result, only an action." .
118118

119119
:PositiveUpdateSyntaxTest11 rdf:type rdfs:Class ;
120-
rdfs:label "Positive Syntax Test for SPARQL1.1 Update" ;
121-
rdfs:comment "A type of test specifically for syntax testing of SPARQL1.1 Update. Syntax tests are not required to have an associated result, only an action." .
120+
rdfs:label "Positive Syntax Test for SPARQL 1.1 Update" ;
121+
rdfs:comment "A type of test specifically for syntax testing of SPARQL 1.1 Update. Syntax tests are not required to have an associated result, only an action." .
122122

123123

124124
:NegativeSyntaxTest rdf:type rdfs:Class ;
@@ -130,12 +130,12 @@
130130
rdfs:comment "A type of test specifically for syntax testing of SPARQL Update. Syntax tests are not required to have an associated result, only an action. Negative syntax tests are tests of which the result should be a parser error. Tests are expected to define their spec version." .
131131

132132
:NegativeSyntaxTest11 rdf:type rdfs:Class ;
133-
rdfs:label "Negative Syntax Test for SPARQL1.1 Query" ;
134-
rdfs:comment "A type of test specifically for syntax testing of new features in the SPARQL1.1 Query Language. Syntax tests are not required to have an associated result, only an action. Negative syntax tests are tests of which the result should be a parser error." .
133+
rdfs:label "Negative Syntax Test for SPARQL 1.1 Query" ;
134+
rdfs:comment "A type of test specifically for syntax testing of new features in the SPARQL 1.1 Query Language. Syntax tests are not required to have an associated result, only an action. Negative syntax tests are tests of which the result should be a parser error." .
135135

136136
:NegativeUpdateSyntaxTest11 rdf:type rdfs:Class ;
137-
rdfs:label "Negative Syntax Test for SPARQL1.1 Update" ;
138-
rdfs:comment "A type of test specifically for syntax testing of SPARQL1.1 Update. Syntax tests are not required to have an associated result, only an action. Negative syntax tests are tests of which the result should be a parser error." .
137+
rdfs:label "Negative Syntax Test for SPARQL 1.1 Update" ;
138+
rdfs:comment "A type of test specifically for syntax testing of SPARQL 1.1 Update. Syntax tests are not required to have an associated result, only an action. Negative syntax tests are tests of which the result should be a parser error." .
139139

140140

141141
:QueryEvaluationTest rdf:type rdfs:Class ;

rdf/rdf11/index.html

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<meta content='width=device-width, initial-scale=1.0' name='viewport'>
77
<link href='https://www.w3.org/StyleSheets/TR/base' rel='stylesheet' type='text/css'>
88
<style>
9-
body: {bacground-image: none;}
9+
body {background-image: none;}
1010
dl.editor>dd {
1111
margin: 0 0 0 40px;
1212
}
@@ -65,12 +65,14 @@ <h2 id='abstract'>Abstract</h2>
6565
<p property='rdfs:comment'>
6666
<p>These test suites are a product previous RDF working groups, and has been maintained by the <a href="https://www.w3.org/community/rdf-tests/">RDF Test Curation Community Group</a>. Community maintained at <a href="https://github.com/w3c/rdf-tests/tree/main/rdf/rdf11/">https://github.com/w3c/rdf-tests/tree/main/rdf/rdf11</a>. Conformance with RDF 1.1 specifications can be determined via successfully running the tests for relevant specifications.</p>
6767
</p>
68-
<p>This page describes W3C RDF 1.1 Working Group's test suite.</p>
69-
<h3 id="contributing-tests">Contributing Tests</h3>
68+
<p>
69+
This page describes W3C RDF 1.1 Working Group's test suite.
70+
</p>
71+
<h3 id='contributing-tests'>Contributing Tests</h3>
7072
<p>The test manifests and entries are built automatically from <a href="manifest.ttl">manifest.ttl</a> using a Rake task. Tests may be contributed via pull request to <a href="https://github.com/w3c/rdf-tests">https://github.com/w3c/rdf-tests</a> with suitable changes to the <a href="manifest.ttl">manifest.ttl</a> and referenced files.</p>
71-
<h3 id="distribution">Distribution</h3>
73+
<h3 id='distribution'>Distribution</h3>
7274
<p>Distributed under both the <a href="http://www.w3.org/Consortium/Legal/2008/04-testsuite-license">W3C Test Suite License</a> and the <a href="http://www.w3.org/Consortium/Legal/2008/03-bsd-license">W3C 3-clause BSD License</a>. To contribute to a W3C Test Suite, see the <a href="http://www.w3.org/2004/10/27-testcases">policies and contribution forms</a>.</p>
73-
<h3 id="disclaimer">Disclaimer</h3>
75+
<h3 id='disclaimer'>Disclaimer</h3>
7476
<p>UNDER BOTH MUTUALLY EXCLUSIVE LICENSES, THIS DOCUMENT AND ALL DOCUMENTS, TESTS AND SOFTWARE THAT LINK THIS STATEMENT ARE PROVIDED "AS IS," AND COPYRIGHT HOLDERS MAKE NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NON-INFRINGEMENT, OR TITLE; THAT THE CONTENTS OF THE DOCUMENT ARE SUITABLE FOR ANY PURPOSE; NOR THAT THE IMPLEMENTATION OF SUCH CONTENTS WILL NOT INFRINGE ANY THIRD PARTY PATENTS, COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS.
7577
COPYRIGHT HOLDERS WILL NOT BE LIABLE FOR ANY DIRECT, INDIRECT, SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF ANY USE OF THE DOCUMENT OR THE PERFORMANCE OR IMPLEMENTATION OF THE CONTENTS THEREOF.</p>
7678
</div>

rdf/rdf11/rdf-mt/index.html

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<meta content='width=device-width, initial-scale=1.0' name='viewport'>
66
<link href='https://www.w3.org/StyleSheets/TR/base' rel='stylesheet' type='text/css'>
77
<style>
8-
body: {bacground-image: none;}
8+
body {background-image: none;}
99
dl.editor>dd {
1010
margin: 0 0 0 40px;
1111
}
@@ -92,11 +92,11 @@ <h2 id='abstract'>Abstract</h2>
9292
<p>Tests can be run from the web or by downloading either a <a href="TESTS.tar.gz">tarball</a> or <a href="TESTS.zip">zip file</a>.</p>
9393
<p>The home of the test suite is <a href="http://www.w3.org/2013/rdf-mt-tests/">http://www.w3.org/2013/rdf-mt-tests/</a>.</p>
9494
<p>See <a href="http://www.w3.org/2011/rdf-wg/wiki/RDF_Test_Suites">http://www.w3.org/2011/rdf-wg/wiki/RDF_Test_Suites</a> for more details. Per RFC 3986 section 5.1.3, the base IRI for parsing each file is the retrieval IRI for that file, but changing base IRIs should not affect any testing results.</p>
95-
<h3 id="contributing-tests">Contributing Tests</h3>
95+
<h3 id='contributing-tests'>Contributing Tests</h3>
9696
<p>The test manifests and entries are built automatically from <a href="manifest.ttl">manifest.ttl</a> using a Rake task. Tests may be contributed via pull request to <a href="https://github.com/w3c/rdf-tests">https://github.com/w3c/rdf-tests</a> with suitable changes to the <a href="manifest.ttl">manifest.ttl</a> and referenced files.</p>
97-
<h3 id="distribution">Distribution</h3>
97+
<h3 id='distribution'>Distribution</h3>
9898
<p>Distributed under both the <a href="http://www.w3.org/Consortium/Legal/2008/04-testsuite-license">W3C Test Suite License</a> and the <a href="http://www.w3.org/Consortium/Legal/2008/03-bsd-license">W3C 3-clause BSD License</a>. To contribute to a W3C Test Suite, see the <a href="http://www.w3.org/2004/10/27-testcases">policies and contribution forms</a>.</p>
99-
<h3 id="disclaimer">Disclaimer</h3>
99+
<h3 id='disclaimer'>Disclaimer</h3>
100100
<p>UNDER BOTH MUTUALLY EXCLUSIVE LICENSES, THIS DOCUMENT AND ALL DOCUMENTS, TESTS AND SOFTWARE THAT LINK THIS STATEMENT ARE PROVIDED "AS IS," AND COPYRIGHT HOLDERS MAKE NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NON-INFRINGEMENT, OR TITLE; THAT THE CONTENTS OF THE DOCUMENT ARE SUITABLE FOR ANY PURPOSE; NOR THAT THE IMPLEMENTATION OF SUCH CONTENTS WILL NOT INFRINGE ANY THIRD PARTY PATENTS, COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS.
101101
COPYRIGHT HOLDERS WILL NOT BE LIABLE FOR ANY DIRECT, INDIRECT, SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF ANY USE OF THE DOCUMENT OR THE PERFORMANCE OR IMPLEMENTATION OF THE CONTENTS THEREOF.</p>
102102
</div>
@@ -831,7 +831,7 @@ <h2>
831831
</dt>
832832
<dd inlist='true' property='mf:entry' resource='#rdfs-container-membership-superProperty-test001' typeof='mf:NegativeEntailmentTest'>
833833
<div property='rdfs:comment'>
834-
<p>While it is a superproperty, _:a &lt;rdfs:contains (@@member?)&gt; _:b . does NOT entail _:a <rdf:_n> _:b . for any _n.</rdf:_n></p>
834+
<p>While it is a superproperty, <code>_:a &lt;rdfs:contains (@@member?)&gt; _:b .</code> does NOT entail <code>_:a &lt;rdf:_n&gt; _:b . for any _n.</code></p>
835835
</div>
836836
<dl class='test-detail'>
837837
<dt>type</dt>

rdf/rdf11/rdf-mt/manifest.ttl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -370,8 +370,8 @@
370370
<#rdfs-container-membership-superProperty-test001> a mf:NegativeEntailmentTest;
371371
mf:name "rdfs-container-membership-superProperty-test001";
372372
rdfs:comment """
373-
While it is a superproperty, _:a <rdfs:contains (@@member?)>
374-
_:b . does NOT entail _:a <rdf:_n> _:b . for any _n.
373+
While it is a superproperty, `_:a <rdfs:contains (@@member?)> _:b .`
374+
does NOT entail `_:a <rdf:_n> _:b . for any _n.`
375375
""";
376376
rdft:approval rdft:Approved;
377377
mf:entailmentRegime "RDFS" ;

rdf/rdf11/rdf-mt/reports/index.html

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)