/
Rakefile
73 lines (62 loc) · 1.95 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
# encoding: utf-8
require 'bundler'
Bundler::GemHelper.install_tasks
require 'rake/clean'
CLEAN.include "**/*.rbc", ".rbx"
desc "Regenerate Noscript's lexer and parser."
task :regenerate do
has_rex = `which rex`
has_racc = `which racc`
if has_rex && has_racc
`rex lib/noscript/parser/noscript.rex -o lib/noscript/parser/lexer.rb`
`racc lib/noscript/parser/noscript.y -o lib/noscript/parser/parser.rb`
else
puts "You need both Rexical and Racc to do that. Install them by doing:"
puts
puts "\t\tgem install rexical"
puts "\t\tgem install racc"
puts
puts "Or just type `bundle install`."
end
end
desc "regenerates lib/noscript/bootstrap/signature.rb"
task :signature do
require 'digest/sha1'
digest = Digest::SHA1.new
files = Dir.glob('lib/noscript/{bootstrap,compiler}.rb')
files.each do |name|
File.open name, "r" do |file|
while chunk = file.read(1024)
digest << chunk
end
end
end
# Collapse the digest to a 64bit quantity
hd = digest.hexdigest
signature_hash = hd[0, 16].to_i(16) ^ hd[16,16].to_i(16) ^ hd[32,8].to_i(16)
File.open "lib/noscript/signature.rb", "wb" do |file|
file.puts "# This file is generated by `rake signature`. The signature"
file.puts "# is used to ensure that only current compiled files are loaded."
file.puts "Noscript::Signature = Rubinius::Signature ^ #{signature_hash}"
end
end
require 'rake/testtask'
Rake::TestTask.new do |t|
t.libs << "test"
t.test_files = FileList['test/**/*_test.rb'] - FileList['test/integration_test.rb']
t.verbose = true
end
require 'rake/testtask'
Rake::TestTask.new(:integration) do |t|
t.libs << "test"
t.test_files = FileList['test/integration_test.rb']
t.verbose = true
end
desc 'Run Noscript native tests'
task :native do
tests = FileList['test/kernel/*.ns']
tests.each do |test|
system("./bin/noscript #{test}")
end
end
task :default => [:regenerate, :test, :integration] #, :integration, :native]