-
Notifications
You must be signed in to change notification settings - Fork 14
/
Rakefile
executable file
·145 lines (124 loc) · 3.61 KB
/
Rakefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
#!/usr/bin/env ruby
$:.unshift(File.expand_path(File.join(File.dirname(__FILE__), 'lib')))
require 'rubygems'
require 'yard'
require 'rspec/core/rake_task'
task default: :spec
task specs: :spec
namespace :gem do
desc "Build the sparql-#{File.read('VERSION').chomp}.gem file"
task :build do
sh "gem build sparql.gemspec && mv sparql-#{File.read('VERSION').chomp}.gem pkg/"
end
desc "Release the sparql-#{File.read('VERSION').chomp}.gem file"
task :release do
sh "gem push pkg/sparql-#{File.read('VERSION').chomp}.gem"
end
end
RSpec::Core::RakeTask.new(:spec)
desc "Run specs through RCov"
RSpec::Core::RakeTask.new("spec:rcov") do |spec|
spec.rcov = true
spec.rcov_opts = %q[--exclude "spec"]
end
namespace :spec do
desc "Generate test caches"
task :prepare do
$:.unshift(File.join(File.dirname(__FILE__), 'spec'))
require 'suite_helper'
puts "load 1.0 tests"
SPARQL::Spec.sparql_11_tests(true)
puts "load 1.0 syntax tests"
SPARQL::Spec.sparql_11_syntax_tests(true)
puts "load 1.1 tests"
SPARQL::Spec.sparql_11_tests(true)
end
end
namespace :doc do
YARD::Rake::YardocTask.new
desc "Generate HTML report specs"
RSpec::Core::RakeTask.new("spec") do |spec|
spec.rspec_opts = ["--format", "html", "-o", "doc/spec.html"]
end
end
desc "Create concatenated test manifests"
file "etc/manifest-cache.nt" do
require 'rdf'
require 'rdf/turtle'
require 'rdf/ntriples'
graph = RDF::Graph.new do |g|
{
"http://w3c.github.io/rdf-tests/sparql/" => "../w3c-rdf-tests/sparql/",
"https://w3c.github.io/sparql-dev/tests/" => "../w3c-sparql-dev/tests/"
}.each do |base, path|
Dir.glob("#{path}**/manifest.ttl").each do |man|
puts "load #{man}"
g.load(man, unique_bnodes: true, base_uri: man.sub(path, base))
end
end
end
puts "write"
RDF::NTriples::Writer.open("etc/manifest-cache.nt", unique_bnodes: true, validate: false) {|w| w << graph}
end
desc 'Create versions of ebnf files in etc'
task etc: %w{etc/sparql12.sxp etc/sparql12.html etc/sparql12.peg.sxp}
desc 'Build first, follow and branch tables'
task meta: "lib/sparql/grammar/meta.rb"
file "lib/sparql/grammar/meta.rb" => "etc/sparql12.bnf" do |t|
sh %{
ebnf --peg --format rb \
--mod-name SPARQL::Grammar::Meta \
--output lib/sparql/grammar/meta.rb \
etc/sparql12.bnf
}
end
file "etc/sparql12.sxp" => "etc/sparql12.bnf" do |t|
sh %{
ebnf --bnf --format sxp \
--output etc/sparql12.sxp \
etc/sparql12.bnf
}
end
file "etc/sparql12.peg.sxp" => "etc/sparql12.bnf" do |t|
sh %{
ebnf --peg --format sxp \
--output etc/sparql12.peg.sxp \
etc/sparql12.bnf
}
end
file "etc/sparql12.html" => "etc/sparql12.bnf" do |t|
sh %{
ebnf --format html \
--output etc/sparql12.html \
--renumber \
etc/sparql12.bnf
}
end
sse_files = Dir.glob("./spec/dawg/**/*.rq").map do |f|
f.sub(".rq", ".sse")
end
ssu_files = Dir.glob("./spec/dawg/**/*.ru").map do |f|
f.sub(".ru", ".sse")
end
desc "Build SSE versions of test '.rq' and '.ru' files using Jena ARQ"
task sse: sse_files + ssu_files
# Rule to create SSE files from .rq
rule ".sse" => %w{.rq} do |t|
puts "build #{t.name}"
sse = `qparse --print op --file #{t.source} 2> /dev/null` rescue nil
if $? == 0
File.open(t.name, "w") {|f| f.write(sse)}
else
puts "skipped #{t.source}"
end
end
# Rule to create SSE files from .ru
rule ".sse" => %w{.ru} do |t|
puts "build #{t.name}"
sse = `uparse --print op --file #{t.source} 2> /dev/null` rescue nil
if $? == 0
File.open(t.name, "w") {|f| f.write(sse)}
else
puts "skipped #{t.source}"
end
end