-
Notifications
You must be signed in to change notification settings - Fork 37
Expand file tree
/
Copy pathRakefile
More file actions
59 lines (49 loc) · 1.5 KB
/
Copy pathRakefile
File metadata and controls
59 lines (49 loc) · 1.5 KB
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
require "bundler/gem_tasks"
require "rake/testtask"
require "rdoc/task"
name = "io/console"
if RUBY_ENGINE == "ruby" || RUBY_ENGINE == "truffleruby"
require 'rake/extensiontask'
extask = Rake::ExtensionTask.new(name) do |x|
x.lib_dir.sub!(%r[(?:\A|/)\Klib(?=/|\z)], ".libs/#{RUBY_VERSION}/#{x.platform}")
end
task :test => :compile
end
ffi_version_file = "lib/ffi/#{name}/version.rb"
task ffi_version_file => "#{name.tr('/', '-')}.gemspec" do |t|
version = <<~RUBY
class IO
module Console
VERSION = "#{Bundler::GemHelper.instance.gemspec.version}"
end
end
RUBY
unless (File.read(t.name) rescue nil) == version
File.binwrite(t.name, version)
end
end
task :build => ffi_version_file
task :test => ffi_version_file if RUBY_ENGINE == "jruby"
Rake::TestTask.new(:test) do |t|
if extask
t.libs = [extask.lib_dir.chomp("/"+File.dirname(name))]
end
t.libs.unshift "lib/ffi" if RUBY_ENGINE == "jruby"
t.libs << "test/lib"
t.ruby_opts << "-rhelper"
t.options = "--ignore-name=TestIO_Console#test_bad_keyword" if RUBY_ENGINE == "jruby"
t.test_files = FileList["test/**/test_*.rb"]
end
RDoc::Task.new
task :default => :test
task "build" => %w[rdoc:coverage build:java]
task "build:java" => "date_epoch"
task "coverage" do
cov = []
e = IO.popen([FileUtils::RUBY, "-S", "rdoc", "-C"], &:read)
e.scan(/^ *# in file (?<loc>.*)\n *(?<code>.*)|^ *(?<code>.*\S) *# in file (?<loc>.*)/) do
cov << "%s: %s\n" % $~.values_at(:loc, :code)
end
cov.sort!
puts cov
end