rant 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/COPYING +504 -0
- data/README +203 -0
- data/Rantfile +104 -0
- data/TODO +19 -0
- data/bin/rant +12 -0
- data/bin/rant-import +12 -0
- data/devel-notes +50 -0
- data/doc/configure.rdoc +40 -0
- data/doc/csharp.rdoc +74 -0
- data/doc/rant-import.rdoc +32 -0
- data/doc/rant.rdoc +24 -0
- data/doc/rantfile.rdoc +227 -0
- data/doc/rubyproject.rdoc +210 -0
- data/lib/rant.rb +9 -0
- data/lib/rant/cs_compiler.rb +334 -0
- data/lib/rant/import.rb +291 -0
- data/lib/rant/import/rubydoc.rb +125 -0
- data/lib/rant/import/rubypackage.rb +417 -0
- data/lib/rant/import/rubytest.rb +97 -0
- data/lib/rant/plugin/README +50 -0
- data/lib/rant/plugin/configure.rb +345 -0
- data/lib/rant/plugin/csharp.rb +275 -0
- data/lib/rant/plugin_methods.rb +41 -0
- data/lib/rant/rantenv.rb +217 -0
- data/lib/rant/rantfile.rb +664 -0
- data/lib/rant/rantlib.rb +1118 -0
- data/lib/rant/rantsys.rb +258 -0
- data/lib/rant/rantvar.rb +82 -0
- data/rantmethods.rb +79 -0
- data/run_import +7 -0
- data/run_rant +7 -0
- data/setup.rb +1360 -0
- data/test/Rantfile +2 -0
- data/test/plugin/configure/Rantfile +47 -0
- data/test/plugin/configure/test_configure.rb +58 -0
- data/test/plugin/csharp/Hello.cs +10 -0
- data/test/plugin/csharp/Rantfile +30 -0
- data/test/plugin/csharp/src/A.cs +8 -0
- data/test/plugin/csharp/src/B.cs +8 -0
- data/test/plugin/csharp/test_csharp.rb +99 -0
- data/test/project1/Rantfile +127 -0
- data/test/project1/test_project.rb +203 -0
- data/test/project2/buildfile +14 -0
- data/test/project2/rantfile.rb +20 -0
- data/test/project2/sub1/Rantfile +12 -0
- data/test/project2/test_project.rb +87 -0
- data/test/project_rb1/README +14 -0
- data/test/project_rb1/bin/wgrep +5 -0
- data/test/project_rb1/lib/wgrep.rb +56 -0
- data/test/project_rb1/rantfile.rb +30 -0
- data/test/project_rb1/test/tc_wgrep.rb +21 -0
- data/test/project_rb1/test/text +3 -0
- data/test/project_rb1/test_project_rb1.rb +153 -0
- data/test/test_env.rb +47 -0
- data/test/test_filetask.rb +57 -0
- data/test/test_lighttask.rb +49 -0
- data/test/test_metatask.rb +29 -0
- data/test/test_rant_interface.rb +65 -0
- data/test/test_sys.rb +61 -0
- data/test/test_task.rb +115 -0
- data/test/toplevel.rf +11 -0
- data/test/ts_all.rb +4 -0
- data/test/tutil.rb +95 -0
- metadata +133 -0
@@ -0,0 +1,20 @@
|
|
1
|
+
|
2
|
+
file "r_f1" do |t|
|
3
|
+
sys.touch t.name
|
4
|
+
end
|
5
|
+
|
6
|
+
file "r_f2" => "r_f1" do |t|
|
7
|
+
sys.touch t.name
|
8
|
+
end
|
9
|
+
|
10
|
+
file "r_f3" => ["r_f2", :r_f4] do |t|
|
11
|
+
sys.touch t.name
|
12
|
+
end
|
13
|
+
|
14
|
+
file "r_f4" => "r_f2" do |t|
|
15
|
+
sys.touch t.name
|
16
|
+
end
|
17
|
+
|
18
|
+
task :clean do
|
19
|
+
sys.rm_f Dir["r_f*"]
|
20
|
+
end
|
@@ -0,0 +1,87 @@
|
|
1
|
+
|
2
|
+
require 'test/unit'
|
3
|
+
require 'tutil'
|
4
|
+
|
5
|
+
# We require 'rant/rantlib' instead of 'rant',
|
6
|
+
# which would cause the rant.rb (which is ment as a Rantfile)
|
7
|
+
# to be loaded!
|
8
|
+
require 'rant/rantlib'
|
9
|
+
include Rant
|
10
|
+
include ::Rant::Sys
|
11
|
+
|
12
|
+
# Ensure we run in testproject directory.
|
13
|
+
$testProject2Dir = File.expand_path(File.dirname(__FILE__))
|
14
|
+
|
15
|
+
class TestProject2 < Test::Unit::TestCase
|
16
|
+
def app *args
|
17
|
+
@app = ::Rant::RantApp.new(*args)
|
18
|
+
end
|
19
|
+
def setup
|
20
|
+
Dir.chdir($testProject2Dir) unless Dir.pwd == $testProject2Dir
|
21
|
+
end
|
22
|
+
def teardown
|
23
|
+
capture_std do
|
24
|
+
assert_equal(app(%w(-f rantfile.rb -f buildfile clean)).run, 0)
|
25
|
+
end
|
26
|
+
assert(Dir["r_f*"].empty?,
|
27
|
+
"r_f* files should have been removed by `clean'")
|
28
|
+
assert(Dir["b_f*"].empty?,
|
29
|
+
"b_f* files should have been removed by `clean'")
|
30
|
+
assert(Dir["sub1/s*f*"].empty?,
|
31
|
+
"sub1/s*f* files should have been removed by `clean'")
|
32
|
+
end
|
33
|
+
def test_use_first_task
|
34
|
+
capture_std do
|
35
|
+
assert_equal(app.run, 0,
|
36
|
+
"run method of RantApp should return 0 on success")
|
37
|
+
end
|
38
|
+
assert(File.exist?("r_f1"))
|
39
|
+
end
|
40
|
+
def test_deps
|
41
|
+
capture_std do
|
42
|
+
assert_equal(app("r_f4").run, 0)
|
43
|
+
end
|
44
|
+
assert(File.exist?("r_f4"))
|
45
|
+
assert(File.exist?("r_f2"))
|
46
|
+
assert(File.exist?("r_f1"))
|
47
|
+
assert(!File.exist?("r_f3"))
|
48
|
+
end
|
49
|
+
def test_load_rantfile
|
50
|
+
capture_std do
|
51
|
+
app("b_f2")
|
52
|
+
assert(@app.source("buildfile"),
|
53
|
+
"source should return a true value on success")
|
54
|
+
assert_equal(@app.run, 0)
|
55
|
+
end
|
56
|
+
assert(File.exist?("b_f2"))
|
57
|
+
end
|
58
|
+
def test_subdirs
|
59
|
+
capture_std do
|
60
|
+
assert_equal(app(%w(-f buildfile create_s1f1)).run, 0)
|
61
|
+
end
|
62
|
+
assert(File.exist?("sub1/s1f1"))
|
63
|
+
end
|
64
|
+
def test_opt_directory
|
65
|
+
app %w(insub1_s1f1 -C sub1)
|
66
|
+
capture_std do
|
67
|
+
assert_equal(@app.run, 0)
|
68
|
+
end
|
69
|
+
assert(Dir.pwd !~ /sub1$/,
|
70
|
+
"rant should cd to original dir before returning from `run'")
|
71
|
+
assert(test(?f, "sub1/s1f1"),
|
72
|
+
"rant should cd to sub1 and run task insub1_s1f1")
|
73
|
+
end
|
74
|
+
def test_opth_directory
|
75
|
+
app %w(insub1_s1f1)
|
76
|
+
#Rant[:directory] = "sub1"
|
77
|
+
@app[:verbose] = 2
|
78
|
+
@app[:directory] = "sub1"
|
79
|
+
capture_std do
|
80
|
+
assert_equal(@app.run, 0)
|
81
|
+
end
|
82
|
+
assert(Dir.pwd !~ /sub1$/,
|
83
|
+
"rant should cd to original dir before returning from `run'")
|
84
|
+
assert(test(?f, "sub1/s1f1"),
|
85
|
+
"rant should cd to sub1 and run task insub1_s1f1")
|
86
|
+
end
|
87
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
|
2
|
+
= wgrep
|
3
|
+
|
4
|
+
wgrep is a simple grep utility written in Ruby. It searches for
|
5
|
+
one word in one or more files or in standard input and prints each
|
6
|
+
line which contains the word.
|
7
|
+
|
8
|
+
== Usage
|
9
|
+
|
10
|
+
wgrep WORD [FILE(s)]
|
11
|
+
|
12
|
+
== Running the tests
|
13
|
+
|
14
|
+
Type `rant test' to run the unit tests.
|
@@ -0,0 +1,56 @@
|
|
1
|
+
|
2
|
+
module WGrep
|
3
|
+
|
4
|
+
class CommandError < StandardError
|
5
|
+
end
|
6
|
+
|
7
|
+
class WGrep
|
8
|
+
attr_reader :word
|
9
|
+
attr_reader :files
|
10
|
+
attr_reader :count
|
11
|
+
def initialize
|
12
|
+
@word = nil
|
13
|
+
@files = []
|
14
|
+
@count = 0
|
15
|
+
end
|
16
|
+
|
17
|
+
def run(args = ARGV)
|
18
|
+
process_args args
|
19
|
+
@count = 0
|
20
|
+
if @files.empty?
|
21
|
+
self.grep(@word, $stdin) { |line|
|
22
|
+
print line
|
23
|
+
@count += 1
|
24
|
+
}
|
25
|
+
else
|
26
|
+
@files.each { |fn|
|
27
|
+
File.open(fn) { |file|
|
28
|
+
self.grep(@word, file) { |line|
|
29
|
+
print line
|
30
|
+
@count += 1
|
31
|
+
}
|
32
|
+
}
|
33
|
+
}
|
34
|
+
end
|
35
|
+
$stderr.puts "Found `#@word' in #{@count} lines."
|
36
|
+
0
|
37
|
+
rescue CommandError => e
|
38
|
+
$stderr.puts "Invalid commandline: #{e.message}"
|
39
|
+
1
|
40
|
+
end
|
41
|
+
|
42
|
+
def process_args(args)
|
43
|
+
if args.nil? || args.empty?
|
44
|
+
raise CommandError, "No word given."
|
45
|
+
end
|
46
|
+
args = [args] unless Array === args
|
47
|
+
@word, @files = args[0], args[1..-1]
|
48
|
+
end
|
49
|
+
|
50
|
+
def grep(word, stream)
|
51
|
+
stream.each { |rec|
|
52
|
+
yield(rec) if rec =~ /\b#{Regexp.escape(word)}\b/
|
53
|
+
}
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
import %w(rubytest rubydoc rubypackage)
|
2
|
+
|
3
|
+
lib_files = Dir["lib/**/*.rb"]
|
4
|
+
dist_files = lib_files + %w(rantfile.rb README test_project_rb1.rb) + Dir["{test,bin}/*"]
|
5
|
+
|
6
|
+
desc "Run unit tests."
|
7
|
+
gen RubyTest do |t|
|
8
|
+
t.test_dir = "test"
|
9
|
+
t.pattern = "tc_*.rb"
|
10
|
+
end
|
11
|
+
|
12
|
+
desc "Generate html documentation."
|
13
|
+
gen RubyDoc do |t|
|
14
|
+
t.opts = %w(--title wgrep --main README README)
|
15
|
+
end
|
16
|
+
|
17
|
+
desc "Create packages."
|
18
|
+
gen RubyPackage, :wgrep do |t|
|
19
|
+
t.version = "1.0.0"
|
20
|
+
t.summary = "Simple grep program."
|
21
|
+
t.files = dist_files
|
22
|
+
t.bindir = "bin"
|
23
|
+
t.executable = "wgrep"
|
24
|
+
t.pkg_dir = "packages"
|
25
|
+
t.package_task "pkg"
|
26
|
+
end
|
27
|
+
|
28
|
+
task :clean do
|
29
|
+
sys.rm_rf %w(doc packages)
|
30
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
|
2
|
+
require 'test/unit'
|
3
|
+
require 'wgrep'
|
4
|
+
require 'fileutils'
|
5
|
+
|
6
|
+
class TestWGrep < Test::Unit::TestCase
|
7
|
+
def test_run
|
8
|
+
stdout = $stdout
|
9
|
+
output = File.new "wgrep_out", "w"
|
10
|
+
$stdout = output
|
11
|
+
assert_equal(WGrep::WGrep.new.run(%w(Hello text)), 0,
|
12
|
+
"Input to wgrep is ok, so `run' should return 0.")
|
13
|
+
output.close
|
14
|
+
$stdout = stdout
|
15
|
+
lines = File.read("wgrep_out").split("\n")
|
16
|
+
assert_equal(lines.size, 1)
|
17
|
+
ensure
|
18
|
+
FileUtils.rm_f "wgrep_out"
|
19
|
+
$stdout = stdout
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,153 @@
|
|
1
|
+
|
2
|
+
require 'test/unit'
|
3
|
+
require 'rant/rantlib'
|
4
|
+
require 'tutil'
|
5
|
+
|
6
|
+
$testProjectRb1Dir = File.expand_path(File.dirname(__FILE__))
|
7
|
+
|
8
|
+
class TestProjectRb1 < Test::Unit::TestCase
|
9
|
+
def setup
|
10
|
+
@manifest = %w(bin lib test bin/wgrep lib/wgrep.rb
|
11
|
+
test/text test/tc_wgrep.rb README test_project_rb1.rb
|
12
|
+
rantfile.rb)
|
13
|
+
# Ensure we run in test directory.
|
14
|
+
Dir.chdir($testProjectRb1Dir) unless Dir.pwd == $testProjectRb1Dir
|
15
|
+
end
|
16
|
+
def teardown
|
17
|
+
capture_std do
|
18
|
+
assert_equal(Rant.run(%w(clean)), 0)
|
19
|
+
end
|
20
|
+
manifest = @manifest.dup
|
21
|
+
check_manifest "after clean: "
|
22
|
+
end
|
23
|
+
def check_manifest(msg_prefix = "")
|
24
|
+
manifest = @manifest.dup
|
25
|
+
Dir["**/*"].each { |e|
|
26
|
+
assert(manifest.reject! { |mf| mf == e } ,
|
27
|
+
"#{msg_prefix}#{e} shouldn't exist according to manifest")
|
28
|
+
}
|
29
|
+
manifest.each { |e|
|
30
|
+
assert(false, "#{msg_prefix}#{e} missing according to manifest")
|
31
|
+
}
|
32
|
+
end
|
33
|
+
def test_doc
|
34
|
+
capture_std do
|
35
|
+
assert_equal(Rant.run(%w(doc)), 0)
|
36
|
+
end
|
37
|
+
assert(test(?d, "doc"),
|
38
|
+
"RDoc task should generate dir `doc'")
|
39
|
+
assert(test(?f, "doc/index.html"),
|
40
|
+
"doc/index.html should exist after `doc'")
|
41
|
+
fl = Dir["doc/files/**/*"]
|
42
|
+
assert(fl.find { |f| f =~ /wgrep/ },
|
43
|
+
"lib/wgrep.rb should get documented")
|
44
|
+
assert(fl.find { |f| f =~ /README/ },
|
45
|
+
"README should be in html docs")
|
46
|
+
end
|
47
|
+
def test_test
|
48
|
+
capture_std do
|
49
|
+
assert_equal(Rant.run(%w(test)), 0)
|
50
|
+
end
|
51
|
+
end
|
52
|
+
def test_package
|
53
|
+
capture_std do
|
54
|
+
assert_equal(Rant.run(%w(pkg)), 0)
|
55
|
+
end
|
56
|
+
assert(test(?d, "packages"),
|
57
|
+
"task `pkg' should create dir `packages'")
|
58
|
+
begin
|
59
|
+
have_tar = !`tar --help`.empty?
|
60
|
+
rescue
|
61
|
+
have_tar = false
|
62
|
+
end
|
63
|
+
begin
|
64
|
+
have_zip = !`zip -help`.empty?
|
65
|
+
rescue
|
66
|
+
have_zip = false
|
67
|
+
end
|
68
|
+
have_gem = false
|
69
|
+
pkg_base = "packages/wgrep-1.0.0"
|
70
|
+
begin
|
71
|
+
require 'rubygems'
|
72
|
+
have_gem = true
|
73
|
+
rescue LoadError
|
74
|
+
end
|
75
|
+
if have_tar
|
76
|
+
tar_fn = pkg_base + ".tar.gz"
|
77
|
+
assert(test(?f, tar_fn),
|
78
|
+
"tar is available, so a tar.gz should have been built")
|
79
|
+
verify_tar "packages", "wgrep-1.0.0", ".tar.gz"
|
80
|
+
else
|
81
|
+
puts "*** tar not available ***"
|
82
|
+
end
|
83
|
+
if have_zip
|
84
|
+
assert(test(?f, pkg_base + ".zip"),
|
85
|
+
"zip is available, so a zip should have been built")
|
86
|
+
verify_zip "packages", "wgrep-1.0.0", ".zip"
|
87
|
+
else
|
88
|
+
puts "*** zip not available ***"
|
89
|
+
end
|
90
|
+
if have_gem
|
91
|
+
assert(test(?f, pkg_base + ".gem"),
|
92
|
+
"gem is available, so a gem should have been built")
|
93
|
+
else
|
94
|
+
puts "*** gem not available ***"
|
95
|
+
end
|
96
|
+
end
|
97
|
+
def verify_tar(dir, pkg_base, ext)
|
98
|
+
tar_fn = pkg_base + ext
|
99
|
+
old_pwd = Dir.pwd
|
100
|
+
FileUtils.cd dir
|
101
|
+
tmp_dir = "_tmp_tar"
|
102
|
+
tmp_dir.freeze
|
103
|
+
FileUtils.mkdir tmp_dir
|
104
|
+
FileUtils.cp tar_fn, tmp_dir
|
105
|
+
FileUtils.cd tmp_dir do
|
106
|
+
`tar xzf #{tar_fn}`
|
107
|
+
assert(test(?d, pkg_base),
|
108
|
+
"`#{pkg_base}' should be root directory of all files in tar")
|
109
|
+
FileUtils.cd pkg_base do
|
110
|
+
check_manifest "tar content: "
|
111
|
+
end
|
112
|
+
end
|
113
|
+
ensure
|
114
|
+
FileUtils.cd old_pwd unless Dir.pwd == old_pwd
|
115
|
+
FileUtils.rm_rf tmp_dir
|
116
|
+
end
|
117
|
+
def verify_zip(dir, pkg_base, ext)
|
118
|
+
zip_fn = pkg_base + ext
|
119
|
+
old_pwd = Dir.pwd
|
120
|
+
FileUtils.cd dir
|
121
|
+
tmp_dir = "_tmp_zip"
|
122
|
+
tmp_dir.freeze
|
123
|
+
FileUtils.mkdir tmp_dir
|
124
|
+
FileUtils.cp zip_fn, tmp_dir
|
125
|
+
FileUtils.cd tmp_dir do
|
126
|
+
`unzip -q #{zip_fn}`
|
127
|
+
assert(test(?d, pkg_base),
|
128
|
+
"`#{pkg_base}' should be root directory of all files in zip")
|
129
|
+
FileUtils.cd pkg_base do
|
130
|
+
check_manifest "zip content: "
|
131
|
+
end
|
132
|
+
end
|
133
|
+
ensure
|
134
|
+
FileUtils.cd old_pwd unless Dir.pwd == old_pwd
|
135
|
+
FileUtils.rm_rf tmp_dir
|
136
|
+
end
|
137
|
+
def test_rant_import
|
138
|
+
require 'rant/import'
|
139
|
+
out, err = capture_std do
|
140
|
+
assert_equal(0, Rant::RantImport.run(%w(--auto make)))
|
141
|
+
end
|
142
|
+
# TODO: some out, err checking
|
143
|
+
|
144
|
+
# run the monolithic rant script
|
145
|
+
out = `#{Rant::Env::RUBY} make -T`
|
146
|
+
assert_equal(0, $?,
|
147
|
+
"imported `rant -T' should return 0")
|
148
|
+
assert_match(/\bpkg\b/, out,
|
149
|
+
"imported `rant -T' should list described task `pkg'")
|
150
|
+
ensure
|
151
|
+
File.delete "make" if File.exist? "make"
|
152
|
+
end
|
153
|
+
end
|
data/test/test_env.rb
ADDED
@@ -0,0 +1,47 @@
|
|
1
|
+
|
2
|
+
require 'test/unit'
|
3
|
+
require 'rant/rantlib'
|
4
|
+
|
5
|
+
$testDir ||= File.expand_path(File.dirname(__FILE__))
|
6
|
+
|
7
|
+
class TestRantEnv < Test::Unit::TestCase
|
8
|
+
def setup
|
9
|
+
# Ensure we run in test directory.
|
10
|
+
Dir.chdir($testDir) unless Dir.pwd == $testDir
|
11
|
+
end
|
12
|
+
def teardown
|
13
|
+
end
|
14
|
+
def test_on_windows
|
15
|
+
# rather primitive test, but should catch obvious programming
|
16
|
+
# errors when making changes in when in hurry ;)
|
17
|
+
if Rant::Env.on_windows?
|
18
|
+
assert(File::ALT_SEPARATOR,
|
19
|
+
"Env says we're on windows, but there is no ALT_SEPARATOR")
|
20
|
+
end
|
21
|
+
end
|
22
|
+
def test_find_bin
|
23
|
+
assert(Rant::Env.find_bin(Rant::Env::RUBY),
|
24
|
+
"RUBY_INSTALL_NAME should be found by Env.find_bin, " +
|
25
|
+
"doesn't need to be a bug of Rant")
|
26
|
+
# let's check for the `echo' command which should be on most
|
27
|
+
# systems:
|
28
|
+
have_echo = false
|
29
|
+
begin
|
30
|
+
have_echo = `echo hello` =~ /hello/
|
31
|
+
rescue Exception
|
32
|
+
end
|
33
|
+
if have_echo
|
34
|
+
=begin
|
35
|
+
# seems to be not so on windows...
|
36
|
+
echo_bin = Rant::Env.find_bin("echo")
|
37
|
+
assert(echo_bin,
|
38
|
+
"echo can be invoked, so find_bin should find it")
|
39
|
+
assert(echo_bin =~ /echo/i)
|
40
|
+
assert(`#{echo_bin} hello` =~ /hello/,
|
41
|
+
"echo should be invokable through `#{echo_bin}'")
|
42
|
+
=end
|
43
|
+
else
|
44
|
+
puts "*** echo not available, will not search with find_bin ***"
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|