elliottcable-echoe 3.1.2 → 3.1.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (102) hide show
  1. data/CHANGELOG +3 -1
  2. data/Manifest +1 -93
  3. data/Rakefile +1 -2
  4. data/echoe.gemspec +7 -7
  5. data/lib/echoe.rb +50 -22
  6. data/lib/echoe/net.rb +7 -0
  7. data/lib/echoe/platform.rb +27 -25
  8. data/vendor/rake/lib/rake/contrib/sshpublisher.rb +0 -4
  9. metadata +7 -96
  10. data/vendor/rake/CHANGES +0 -400
  11. data/vendor/rake/README +0 -285
  12. data/vendor/rake/Rakefile +0 -418
  13. data/vendor/rake/TODO +0 -20
  14. data/vendor/rake/bin/rake +0 -31
  15. data/vendor/rake/doc/example/Rakefile1 +0 -38
  16. data/vendor/rake/doc/example/Rakefile2 +0 -35
  17. data/vendor/rake/doc/example/a.c +0 -6
  18. data/vendor/rake/doc/example/b.c +0 -6
  19. data/vendor/rake/doc/example/main.c +0 -11
  20. data/vendor/rake/doc/glossary.rdoc +0 -51
  21. data/vendor/rake/doc/jamis.rb +0 -591
  22. data/vendor/rake/doc/proto_rake.rdoc +0 -127
  23. data/vendor/rake/doc/rake.1.gz +0 -0
  24. data/vendor/rake/doc/rakefile.rdoc +0 -534
  25. data/vendor/rake/doc/rational.rdoc +0 -151
  26. data/vendor/rake/doc/release_notes/rake-0.4.14.rdoc +0 -23
  27. data/vendor/rake/doc/release_notes/rake-0.4.15.rdoc +0 -35
  28. data/vendor/rake/doc/release_notes/rake-0.5.0.rdoc +0 -53
  29. data/vendor/rake/doc/release_notes/rake-0.5.3.rdoc +0 -78
  30. data/vendor/rake/doc/release_notes/rake-0.5.4.rdoc +0 -46
  31. data/vendor/rake/doc/release_notes/rake-0.6.0.rdoc +0 -141
  32. data/vendor/rake/doc/release_notes/rake-0.7.0.rdoc +0 -119
  33. data/vendor/rake/doc/release_notes/rake-0.7.1.rdoc +0 -59
  34. data/vendor/rake/doc/release_notes/rake-0.7.2.rdoc +0 -121
  35. data/vendor/rake/doc/release_notes/rake-0.7.3.rdoc +0 -47
  36. data/vendor/rake/doc/release_notes/rake-0.8.0.rdoc +0 -114
  37. data/vendor/rake/doc/release_notes/rake-0.8.2.rdoc +0 -165
  38. data/vendor/rake/doc/release_notes/rake-0.8.3.rdoc +0 -112
  39. data/vendor/rake/install.rb +0 -88
  40. data/vendor/rake/lib/rake.rb +0 -2468
  41. data/vendor/rake/lib/rake/classic_namespace.rb +0 -8
  42. data/vendor/rake/lib/rake/clean.rb +0 -33
  43. data/vendor/rake/lib/rake/gempackagetask.rb +0 -103
  44. data/vendor/rake/lib/rake/loaders/makefile.rb +0 -35
  45. data/vendor/rake/lib/rake/packagetask.rb +0 -185
  46. data/vendor/rake/lib/rake/rake_test_loader.rb +0 -5
  47. data/vendor/rake/lib/rake/rdoctask.rb +0 -147
  48. data/vendor/rake/lib/rake/ruby182_test_unit_fix.rb +0 -23
  49. data/vendor/rake/lib/rake/runtest.rb +0 -23
  50. data/vendor/rake/lib/rake/tasklib.rb +0 -23
  51. data/vendor/rake/lib/rake/testtask.rb +0 -161
  52. data/vendor/rake/lib/rake/win32.rb +0 -54
  53. data/vendor/rake/test/capture_stdout.rb +0 -26
  54. data/vendor/rake/test/check_expansion.rb +0 -5
  55. data/vendor/rake/test/contrib/test_sys.rb +0 -47
  56. data/vendor/rake/test/data/chains/Rakefile +0 -15
  57. data/vendor/rake/test/data/default/Rakefile +0 -19
  58. data/vendor/rake/test/data/dryrun/Rakefile +0 -22
  59. data/vendor/rake/test/data/file_creation_task/Rakefile +0 -33
  60. data/vendor/rake/test/data/imports/Rakefile +0 -19
  61. data/vendor/rake/test/data/imports/deps.mf +0 -1
  62. data/vendor/rake/test/data/multidesc/Rakefile +0 -17
  63. data/vendor/rake/test/data/namespace/Rakefile +0 -57
  64. data/vendor/rake/test/data/rakelib/test1.rb +0 -3
  65. data/vendor/rake/test/data/rbext/rakefile.rb +0 -3
  66. data/vendor/rake/test/data/sample.mf +0 -12
  67. data/vendor/rake/test/data/statusreturn/Rakefile +0 -8
  68. data/vendor/rake/test/data/unittest/Rakefile +0 -1
  69. data/vendor/rake/test/filecreation.rb +0 -32
  70. data/vendor/rake/test/functional.rb +0 -15
  71. data/vendor/rake/test/in_environment.rb +0 -30
  72. data/vendor/rake/test/rake_test_setup.rb +0 -10
  73. data/vendor/rake/test/reqfile.rb +0 -3
  74. data/vendor/rake/test/reqfile2.rb +0 -3
  75. data/vendor/rake/test/session_functional.rb +0 -337
  76. data/vendor/rake/test/shellcommand.rb +0 -3
  77. data/vendor/rake/test/test_application.rb +0 -694
  78. data/vendor/rake/test/test_clean.rb +0 -14
  79. data/vendor/rake/test/test_definitions.rb +0 -82
  80. data/vendor/rake/test/test_earlytime.rb +0 -35
  81. data/vendor/rake/test/test_extension.rb +0 -63
  82. data/vendor/rake/test/test_file_creation_task.rb +0 -62
  83. data/vendor/rake/test/test_file_task.rb +0 -139
  84. data/vendor/rake/test/test_filelist.rb +0 -618
  85. data/vendor/rake/test/test_fileutils.rb +0 -250
  86. data/vendor/rake/test/test_ftp.rb +0 -59
  87. data/vendor/rake/test/test_invocation_chain.rb +0 -75
  88. data/vendor/rake/test/test_makefile_loader.rb +0 -25
  89. data/vendor/rake/test/test_multitask.rb +0 -45
  90. data/vendor/rake/test/test_namespace.rb +0 -36
  91. data/vendor/rake/test/test_package_task.rb +0 -116
  92. data/vendor/rake/test/test_pathmap.rb +0 -209
  93. data/vendor/rake/test/test_rake.rb +0 -41
  94. data/vendor/rake/test/test_require.rb +0 -33
  95. data/vendor/rake/test/test_rules.rb +0 -347
  96. data/vendor/rake/test/test_task_arguments.rb +0 -89
  97. data/vendor/rake/test/test_task_manager.rb +0 -170
  98. data/vendor/rake/test/test_tasklib.rb +0 -12
  99. data/vendor/rake/test/test_tasks.rb +0 -371
  100. data/vendor/rake/test/test_test_task.rb +0 -75
  101. data/vendor/rake/test/test_top_level_functions.rb +0 -84
  102. data/vendor/rake/test/test_win32.rb +0 -57
@@ -1,36 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- begin
4
- require 'rubygems'
5
- rescue LoadError
6
- # got no gems
7
- end
8
-
9
- require 'test/unit'
10
- require 'flexmock/test_unit'
11
- require 'rake'
12
-
13
- class TestNameSpace < Test::Unit::TestCase
14
-
15
- def test_namespace_creation
16
- mgr = flexmock("TaskManager")
17
- ns = Rake::NameSpace.new(mgr, [])
18
- assert_not_nil ns
19
- end
20
-
21
- def test_namespace_lookup
22
- mgr = flexmock("TaskManager")
23
- mgr.should_receive(:lookup).with(:t, ["a"]).
24
- and_return(:dummy).once
25
- ns = Rake::NameSpace.new(mgr, ["a"])
26
- assert_equal :dummy, ns[:t]
27
- end
28
-
29
- def test_namespace_reports_tasks_it_owns
30
- mgr = flexmock("TaskManager")
31
- mgr.should_receive(:tasks).with().
32
- and_return([:x, :y, :z]).once
33
- ns = Rake::NameSpace.new(mgr, ["a"])
34
- assert_equal [:x, :y, :z], ns.tasks
35
- end
36
- end
@@ -1,116 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- require 'test/unit'
4
- require 'rake/packagetask'
5
-
6
- class TestPackageTask < Test::Unit::TestCase
7
- include Rake
8
-
9
- def test_create
10
- pkg = Rake::PackageTask.new("pkgr", "1.2.3") { |p|
11
- p.package_files << "install.rb"
12
- p.package_files.include(
13
- '[A-Z]*',
14
- 'bin/**/*',
15
- 'lib/**/*.rb',
16
- 'test/**/*.rb',
17
- 'doc/**/*',
18
- 'build/rubyapp.rb',
19
- '*.blurb')
20
- p.package_files.exclude(/\bCVS\b/)
21
- p.package_files.exclude(/~$/)
22
- p.package_dir = 'pkg'
23
- p.need_tar = true
24
- p.need_tar_gz = true
25
- p.need_tar_bz2 = true
26
- p.need_zip = true
27
- }
28
- assert_equal "pkg", pkg.package_dir
29
- assert pkg.package_files.include?("bin/rake")
30
- assert "pkgr", pkg.name
31
- assert "1.2.3", pkg.version
32
- assert Task[:package]
33
- assert Task['pkg/pkgr-1.2.3.tgz']
34
- assert Task['pkg/pkgr-1.2.3.tar.gz']
35
- assert Task['pkg/pkgr-1.2.3.tar.bz2']
36
- assert Task['pkg/pkgr-1.2.3.zip']
37
- assert Task["pkg/pkgr-1.2.3"]
38
- assert Task[:clobber_package]
39
- assert Task[:repackage]
40
- end
41
-
42
- def test_missing_version
43
- assert_raises(RuntimeError) {
44
- pkg = Rake::PackageTask.new("pkgr") { |p| }
45
- }
46
- end
47
-
48
- def test_no_version
49
- pkg = Rake::PackageTask.new("pkgr", :noversion) { |p| }
50
- assert "pkgr", pkg.send(:package_name)
51
- end
52
-
53
- def test_clone
54
- pkg = Rake::PackageTask.new("x", :noversion)
55
- p2 = pkg.clone
56
- pkg.package_files << "y"
57
- p2.package_files << "x"
58
- assert_equal ["y"], pkg.package_files
59
- assert_equal ["x"], p2.package_files
60
- end
61
- end
62
-
63
-
64
- begin
65
- require 'rubygems'
66
- require 'rake/gempackagetask'
67
- rescue Exception
68
- puts "WARNING: RubyGems not installed"
69
- end
70
-
71
- if ! defined?(Gem)
72
- puts "WARNING: Unable to test GemPackaging ... requires RubyGems"
73
- else
74
- class TestGemPackageTask < Test::Unit::TestCase
75
- def test_gem_package
76
- gem = Gem::Specification.new do |g|
77
- g.name = "pkgr"
78
- g.version = "1.2.3"
79
- g.files = FileList["x"].resolve
80
- end
81
- pkg = Rake::GemPackageTask.new(gem) do |p|
82
- p.package_files << "y"
83
- end
84
- assert_equal ["x", "y"], pkg.package_files
85
- assert_equal "pkgr-1.2.3.gem", pkg.gem_file
86
- end
87
-
88
- def test_gem_package_with_current_platform
89
- gem = Gem::Specification.new do |g|
90
- g.name = "pkgr"
91
- g.version = "1.2.3"
92
- g.files = FileList["x"].resolve
93
- g.platform = Gem::Platform::CURRENT
94
- end
95
- pkg = Rake::GemPackageTask.new(gem) do |p|
96
- p.package_files << "y"
97
- end
98
- assert_equal ["x", "y"], pkg.package_files
99
- assert_match(/^pkgr-1\.2\.3-(\S+)\.gem$/, pkg.gem_file)
100
- end
101
-
102
- def test_gem_package_with_ruby_platform
103
- gem = Gem::Specification.new do |g|
104
- g.name = "pkgr"
105
- g.version = "1.2.3"
106
- g.files = FileList["x"].resolve
107
- g.platform = Gem::Platform::RUBY
108
- end
109
- pkg = Rake::GemPackageTask.new(gem) do |p|
110
- p.package_files << "y"
111
- end
112
- assert_equal ["x", "y"], pkg.package_files
113
- assert_equal "pkgr-1.2.3.gem", pkg.gem_file
114
- end
115
- end
116
- end
@@ -1,209 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- require 'test/unit'
4
- require 'rake'
5
-
6
- # ====================================================================
7
- class TestPathMap < Test::Unit::TestCase
8
-
9
- def test_returns_self_with_no_args
10
- assert_equal "abc.rb", "abc.rb".pathmap
11
- end
12
-
13
- def test_s_returns_file_separator
14
- sep = File::ALT_SEPARATOR || File::SEPARATOR
15
- assert_equal sep, "abc.rb".pathmap("%s")
16
- assert_equal sep, "".pathmap("%s")
17
- assert_equal "a#{sep}b", "a/b".pathmap("%d%s%f")
18
- end
19
-
20
- def test_f_returns_basename
21
- assert_equal "abc.rb", "abc.rb".pathmap("%f")
22
- assert_equal "abc.rb", "this/is/a/dir/abc.rb".pathmap("%f")
23
- assert_equal "abc.rb", "/this/is/a/dir/abc.rb".pathmap("%f")
24
- end
25
-
26
- def test_n_returns_basename_without_extension
27
- assert_equal "abc", "abc.rb".pathmap("%n")
28
- assert_equal "abc", "abc".pathmap("%n")
29
- assert_equal "abc", "this/is/a/dir/abc.rb".pathmap("%n")
30
- assert_equal "abc", "/this/is/a/dir/abc.rb".pathmap("%n")
31
- assert_equal "abc", "/this/is/a/dir/abc".pathmap("%n")
32
- end
33
-
34
- def test_d_returns_dirname
35
- assert_equal ".", "abc.rb".pathmap("%d")
36
- assert_equal "/", "/abc".pathmap("%d")
37
- assert_equal "this/is/a/dir", "this/is/a/dir/abc.rb".pathmap("%d")
38
- assert_equal "/this/is/a/dir", "/this/is/a/dir/abc.rb".pathmap("%d")
39
- end
40
-
41
- def test_9d_returns_partial_dirname
42
- assert_equal "this/is", "this/is/a/dir/abc.rb".pathmap("%2d")
43
- assert_equal "this", "this/is/a/dir/abc.rb".pathmap("%1d")
44
- assert_equal ".", "this/is/a/dir/abc.rb".pathmap("%0d")
45
- assert_equal "dir", "this/is/a/dir/abc.rb".pathmap("%-1d")
46
- assert_equal "a/dir", "this/is/a/dir/abc.rb".pathmap("%-2d")
47
- assert_equal "this/is/a/dir", "this/is/a/dir/abc.rb".pathmap("%100d")
48
- assert_equal "this/is/a/dir", "this/is/a/dir/abc.rb".pathmap("%-100d")
49
- end
50
-
51
- def test_x_returns_extension
52
- assert_equal "", "abc".pathmap("%x")
53
- assert_equal ".rb", "abc.rb".pathmap("%x")
54
- assert_equal ".rb", "abc.xyz.rb".pathmap("%x")
55
- assert_equal "", ".depends".pathmap("%x")
56
- assert_equal "", "dir/.depends".pathmap("%x")
57
- end
58
-
59
- def test_X_returns_everything_but_extension
60
- assert_equal "abc", "abc".pathmap("%X")
61
- assert_equal "abc", "abc.rb".pathmap("%X")
62
- assert_equal "abc.xyz", "abc.xyz.rb".pathmap("%X")
63
- assert_equal "ab.xyz", "ab.xyz.rb".pathmap("%X")
64
- assert_equal "a.xyz", "a.xyz.rb".pathmap("%X")
65
- assert_equal "abc", "abc.rb".pathmap("%X")
66
- assert_equal "ab", "ab.rb".pathmap("%X")
67
- assert_equal "a", "a.rb".pathmap("%X")
68
- assert_equal ".depends", ".depends".pathmap("%X")
69
- assert_equal "a/dir/.depends", "a/dir/.depends".pathmap("%X")
70
- assert_equal "/.depends", "/.depends".pathmap("%X")
71
- end
72
-
73
- def test_p_returns_entire_pathname
74
- assert_equal "abc.rb", "abc.rb".pathmap("%p")
75
- assert_equal "this/is/a/dir/abc.rb", "this/is/a/dir/abc.rb".pathmap("%p")
76
- assert_equal "/this/is/a/dir/abc.rb", "/this/is/a/dir/abc.rb".pathmap("%p")
77
- end
78
-
79
- def test_dash_returns_empty_string
80
- assert_equal "", "abc.rb".pathmap("%-")
81
- assert_equal "abc.rb", "abc.rb".pathmap("%X%-%x")
82
- end
83
-
84
- def test_percent_percent_returns_percent
85
- assert_equal "a%b", "".pathmap("a%%b")
86
- end
87
-
88
- def test_undefined_percent_causes_error
89
- ex = assert_raise(ArgumentError) {
90
- "dir/abc.rb".pathmap("%z")
91
- }
92
- end
93
-
94
- def test_pattern_returns_substitutions
95
- assert_equal "bin/org/osb",
96
- "src/org/osb/Xyz.java".pathmap("%{src,bin}d")
97
- end
98
-
99
- def test_pattern_can_use_backreferences
100
- assert_equal "dir/hi/is", "dir/this/is".pathmap("%{t(hi)s,\\1}p")
101
- end
102
-
103
- def test_pattern_with_star_replacement_string_uses_block
104
- assert_equal "src/ORG/osb",
105
- "src/org/osb/Xyz.java".pathmap("%{/org,*}d") { |d| d.upcase }
106
- assert_equal "Xyz.java",
107
- "src/org/osb/Xyz.java".pathmap("%{.*,*}f") { |f| f.capitalize }
108
- end
109
-
110
- def test_pattern_with_no_replacement_nor_block_substitutes_empty_string
111
- assert_equal "bc.rb", "abc.rb".pathmap("%{a}f")
112
- end
113
-
114
- def test_pattern_works_with_certain_valid_operators
115
- assert_equal "dir/xbc.rb", "dir/abc.rb".pathmap("%{a,x}p")
116
- assert_equal "d1r", "dir/abc.rb".pathmap("%{i,1}d")
117
- assert_equal "xbc.rb", "dir/abc.rb".pathmap("%{a,x}f")
118
- assert_equal ".Rb", "dir/abc.rb".pathmap("%{r,R}x")
119
- assert_equal "xbc", "dir/abc.rb".pathmap("%{a,x}n")
120
- end
121
-
122
- def test_multiple_patterns
123
- assert_equal "this/is/b/directory/abc.rb",
124
- "this/is/a/dir/abc.rb".pathmap("%{a,b;dir,\\0ectory}p")
125
- end
126
-
127
- def test_partial_directory_selection_works_with_patterns
128
- assert_equal "this/is/a/long",
129
- "this/is/a/really/long/path/ok.rb".pathmap("%{/really/,/}5d")
130
- end
131
-
132
- def test_pattern_with_invalid_operator
133
- ex = assert_raise(ArgumentError) do
134
- "abc.xyz".pathmap("%{src,bin}z")
135
- end
136
- assert_match(/unknown.*pathmap.*spec.*z/i, ex.message)
137
- end
138
-
139
- def test_works_with_windows_separators
140
- if File::ALT_SEPARATOR
141
- assert_equal "abc", 'dir\abc.rb'.pathmap("%n")
142
- assert_equal 'this\is\a\dir',
143
- 'this\is\a\dir\abc.rb'.pathmap("%d")
144
- end
145
- end
146
-
147
- def test_complex_patterns
148
- sep = "".pathmap("%s")
149
- assert_equal "dir/abc.rb", "dir/abc.rb".pathmap("%d/%n%x")
150
- assert_equal "./abc.rb", "abc.rb".pathmap("%d/%n%x")
151
- assert_equal "Your file extension is '.rb'",
152
- "dir/abc.rb".pathmap("Your file extension is '%x'")
153
- assert_equal "bin/org/onstepback/proj/A.class",
154
- "src/org/onstepback/proj/A.java".pathmap("%{src,bin}d/%n.class")
155
- assert_equal "src_work/bin/org/onstepback/proj/A.class",
156
- "src_work/src/org/onstepback/proj/A.java".pathmap('%{\bsrc\b,bin}X.class')
157
- assert_equal ".depends.bak", ".depends".pathmap("%X.bak")
158
- assert_equal "d#{sep}a/b/c#{sep}file.txt", "a/b/c/d/file.txt".pathmap("%-1d%s%3d%s%f")
159
- end
160
- end
161
-
162
- class TestPathMapExplode < Test::Unit::TestCase
163
- def setup
164
- String.class_eval { public :pathmap_explode }
165
- end
166
-
167
- def teardown
168
- String.class_eval { protected :pathmap_explode }
169
- end
170
-
171
- def test_explode
172
- assert_equal ['a'], 'a'.pathmap_explode
173
- assert_equal ['a', 'b'], 'a/b'.pathmap_explode
174
- assert_equal ['a', 'b', 'c'], 'a/b/c'.pathmap_explode
175
- assert_equal ['/', 'a'], '/a'.pathmap_explode
176
- assert_equal ['/', 'a', 'b'], '/a/b'.pathmap_explode
177
- assert_equal ['/', 'a', 'b', 'c'], '/a/b/c'.pathmap_explode
178
- if File::ALT_SEPARATOR
179
- assert_equal ['c:.', 'a'], 'c:a'.pathmap_explode
180
- assert_equal ['c:.', 'a', 'b'], 'c:a/b'.pathmap_explode
181
- assert_equal ['c:.', 'a', 'b', 'c'], 'c:a/b/c'.pathmap_explode
182
- assert_equal ['c:/', 'a'], 'c:/a'.pathmap_explode
183
- assert_equal ['c:/', 'a', 'b'], 'c:/a/b'.pathmap_explode
184
- assert_equal ['c:/', 'a', 'b', 'c'], 'c:/a/b/c'.pathmap_explode
185
- end
186
- end
187
- end
188
-
189
- class TestPathMapPartial < Test::Unit::TestCase
190
- def test_pathmap_partial
191
- @path = "1/2/file"
192
- def @path.call(n)
193
- pathmap_partial(n)
194
- end
195
- assert_equal("1", @path.call(1))
196
- assert_equal("1/2", @path.call(2))
197
- assert_equal("1/2", @path.call(3))
198
- assert_equal(".", @path.call(0))
199
- assert_equal("2", @path.call(-1))
200
- assert_equal("1/2", @path.call(-2))
201
- assert_equal("1/2", @path.call(-3))
202
- end
203
- end
204
-
205
- class TestFileListPathMap < Test::Unit::TestCase
206
- def test_file_list_supports_pathmap
207
- assert_equal ['a', 'b'], FileList['dir/a.rb', 'dir/b.rb'].pathmap("%n")
208
- end
209
- end
@@ -1,41 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- require 'test/unit'
4
- require 'rake'
5
-
6
- class TestRake < Test::Unit::TestCase
7
- def test_each_dir_parent
8
- assert_equal ['a'], alldirs('a')
9
- assert_equal ['a/b', 'a'], alldirs('a/b')
10
- assert_equal ['/a/b', '/a', '/'], alldirs('/a/b')
11
- if File.dirname("c:/foo") == "c:"
12
- # Under Unix
13
- assert_equal ['c:/a/b', 'c:/a', 'c:'], alldirs('c:/a/b')
14
- assert_equal ['c:a/b', 'c:a'], alldirs('c:a/b')
15
- else
16
- # Under Windows
17
- assert_equal ['c:/a/b', 'c:/a', 'c:/'], alldirs('c:/a/b')
18
- assert_equal ['c:a/b', 'c:a'], alldirs('c:a/b')
19
- end
20
- end
21
-
22
- def alldirs(fn)
23
- result = []
24
- Rake.each_dir_parent(fn) { |d| result << d }
25
- result
26
- end
27
-
28
- def test_can_override_application
29
- old_app = Rake.application
30
- fake_app = Object.new
31
- Rake.application = fake_app
32
- assert_equal fake_app, Rake.application
33
- ensure
34
- Rake.application = old_app
35
- end
36
-
37
- def test_original_dir_reports_current_dir
38
- assert_equal Dir.pwd, Rake.original_dir
39
- end
40
-
41
- end
@@ -1,33 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- require 'test/unit'
4
- require 'rake'
5
-
6
- # ====================================================================
7
- class TestRequire < Test::Unit::TestCase
8
-
9
- def test_can_load_rake_library
10
- app = Rake::Application.new
11
- assert app.instance_eval {
12
- rake_require("test2", ['test/data/rakelib'], [])
13
- }
14
- end
15
-
16
- def test_wont_reload_rake_library
17
- app = Rake::Application.new
18
- assert ! app.instance_eval {
19
- rake_require("test2", ['test/data/rakelib'], ['test2'])
20
- }
21
- end
22
-
23
- def test_throws_error_if_library_not_found
24
- app = Rake::Application.new
25
- ex = assert_raise(LoadError) {
26
- assert app.instance_eval {
27
- rake_require("testx", ['test/data/rakelib'], [])
28
- }
29
- }
30
- assert_match(/x/, ex.message)
31
- end
32
- end
33
-
@@ -1,347 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- require 'test/unit'
4
- require 'fileutils'
5
- require 'rake'
6
- require 'test/filecreation'
7
-
8
- ######################################################################
9
- class TestRules < Test::Unit::TestCase
10
- include Rake
11
- include FileCreation
12
-
13
- SRCFILE = "testdata/abc.c"
14
- SRCFILE2 = "testdata/xyz.c"
15
- FTNFILE = "testdata/abc.f"
16
- OBJFILE = "testdata/abc.o"
17
- FOOFILE = "testdata/foo"
18
- DOTFOOFILE = "testdata/.foo"
19
-
20
- def setup
21
- Task.clear
22
- @runs = []
23
- end
24
-
25
- def teardown
26
- FileList['testdata/*'].each do |f| rm_r(f, :verbose=>false) end
27
- end
28
-
29
- def test_multiple_rules1
30
- create_file(FTNFILE)
31
- delete_file(SRCFILE)
32
- delete_file(OBJFILE)
33
- rule(/\.o$/ => ['.c']) do @runs << :C end
34
- rule(/\.o$/ => ['.f']) do @runs << :F end
35
- t = Task[OBJFILE]
36
- t.invoke
37
- Task[OBJFILE].invoke
38
- assert_equal [:F], @runs
39
- end
40
-
41
- def test_multiple_rules2
42
- create_file(FTNFILE)
43
- delete_file(SRCFILE)
44
- delete_file(OBJFILE)
45
- rule(/\.o$/ => ['.f']) do @runs << :F end
46
- rule(/\.o$/ => ['.c']) do @runs << :C end
47
- Task[OBJFILE].invoke
48
- assert_equal [:F], @runs
49
- end
50
-
51
- def test_create_with_source
52
- create_file(SRCFILE)
53
- rule(/\.o$/ => ['.c']) do |t|
54
- @runs << t.name
55
- assert_equal OBJFILE, t.name
56
- assert_equal SRCFILE, t.source
57
- end
58
- Task[OBJFILE].invoke
59
- assert_equal [OBJFILE], @runs
60
- end
61
-
62
- def test_single_dependent
63
- create_file(SRCFILE)
64
- rule(/\.o$/ => '.c') do |t|
65
- @runs << t.name
66
- end
67
- Task[OBJFILE].invoke
68
- assert_equal [OBJFILE], @runs
69
- end
70
-
71
- def test_rule_can_be_created_by_string
72
- create_file(SRCFILE)
73
- rule '.o' => ['.c'] do |t|
74
- @runs << t.name
75
- end
76
- Task[OBJFILE].invoke
77
- assert_equal [OBJFILE], @runs
78
- end
79
-
80
- def test_rule_prereqs_can_be_created_by_string
81
- create_file(SRCFILE)
82
- rule '.o' => '.c' do |t|
83
- @runs << t.name
84
- end
85
- Task[OBJFILE].invoke
86
- assert_equal [OBJFILE], @runs
87
- end
88
-
89
- def test_plain_strings_as_dependents_refer_to_files
90
- create_file(SRCFILE)
91
- rule '.o' => SRCFILE do |t|
92
- @runs << t.name
93
- end
94
- Task[OBJFILE].invoke
95
- assert_equal [OBJFILE], @runs
96
- end
97
-
98
- def test_file_names_beginning_with_dot_can_be_tricked_into_refering_to_file
99
- verbose(false) do
100
- chdir("testdata") do
101
- create_file('.foo')
102
- rule '.o' => "./.foo" do |t|
103
- @runs << t.name
104
- end
105
- Task[OBJFILE].invoke
106
- assert_equal [OBJFILE], @runs
107
- end
108
- end
109
- end
110
-
111
- def test_file_names_beginning_with_dot_can_be_wrapped_in_lambda
112
- verbose(false) do
113
- chdir("testdata") do
114
- create_file(".foo")
115
- rule '.o' => lambda{".foo"} do |t|
116
- @runs << "#{t.name} - #{t.source}"
117
- end
118
- Task[OBJFILE].invoke
119
- assert_equal ["#{OBJFILE} - .foo"], @runs
120
- end
121
- end
122
- end
123
-
124
- def test_file_names_containing_percent_can_be_wrapped_in_lambda
125
- verbose(false) do
126
- chdir("testdata") do
127
- create_file("foo%x")
128
- rule '.o' => lambda{"foo%x"} do |t|
129
- @runs << "#{t.name} - #{t.source}"
130
- end
131
- Task[OBJFILE].invoke
132
- assert_equal ["#{OBJFILE} - foo%x"], @runs
133
- end
134
- end
135
- end
136
-
137
- def test_non_extension_rule_name_refers_to_file
138
- verbose(false) do
139
- chdir("testdata") do
140
- create_file("abc.c")
141
- rule "abc" => '.c' do |t|
142
- @runs << t.name
143
- end
144
- Task["abc"].invoke
145
- assert_equal ["abc"], @runs
146
- end
147
- end
148
- end
149
-
150
- def test_pathmap_automatically_applies_to_name
151
- verbose(false) do
152
- chdir("testdata") do
153
- create_file("zzabc.c")
154
- rule ".o" => 'zz%{x,a}n.c' do |t|
155
- @runs << "#{t.name} - #{t.source}"
156
- end
157
- Task["xbc.o"].invoke
158
- assert_equal ["xbc.o - zzabc.c"], @runs
159
- end
160
- end
161
- end
162
-
163
- def test_plain_strings_are_just_filenames
164
- verbose(false) do
165
- chdir("testdata") do
166
- create_file("plainname")
167
- rule ".o" => 'plainname' do |t|
168
- @runs << "#{t.name} - #{t.source}"
169
- end
170
- Task["xbc.o"].invoke
171
- assert_equal ["xbc.o - plainname"], @runs
172
- end
173
- end
174
- end
175
-
176
- def test_rule_runs_when_explicit_task_has_no_actions
177
- create_file(SRCFILE)
178
- create_file(SRCFILE2)
179
- delete_file(OBJFILE)
180
- rule '.o' => '.c' do |t|
181
- @runs << t.source
182
- end
183
- file OBJFILE => [SRCFILE2]
184
- Task[OBJFILE].invoke
185
- assert_equal [SRCFILE], @runs
186
- end
187
-
188
- def test_close_matches_on_name_do_not_trigger_rule
189
- create_file("testdata/x.c")
190
- rule '.o' => ['.c'] do |t|
191
- @runs << t.name
192
- end
193
- assert_raises(RuntimeError) { Task['testdata/x.obj'].invoke }
194
- assert_raises(RuntimeError) { Task['testdata/x.xyo'].invoke }
195
- end
196
-
197
- def test_rule_rebuilds_obj_when_source_is_newer
198
- create_timed_files(OBJFILE, SRCFILE)
199
- rule(/\.o$/ => ['.c']) do
200
- @runs << :RULE
201
- end
202
- Task[OBJFILE].invoke
203
- assert_equal [:RULE], @runs
204
- end
205
-
206
- def test_rule_with_two_sources_runs_if_both_sources_are_present
207
- create_timed_files(OBJFILE, SRCFILE, SRCFILE2)
208
- rule OBJFILE => [lambda{SRCFILE}, lambda{SRCFILE2}] do
209
- @runs << :RULE
210
- end
211
- Task[OBJFILE].invoke
212
- assert_equal [:RULE], @runs
213
- end
214
-
215
- def test_rule_with_two_sources_but_one_missing_does_not_run
216
- create_timed_files(OBJFILE, SRCFILE)
217
- delete_file(SRCFILE2)
218
- rule OBJFILE => [lambda{SRCFILE}, lambda{SRCFILE2}] do
219
- @runs << :RULE
220
- end
221
- Task[OBJFILE].invoke
222
- assert_equal [], @runs
223
- end
224
-
225
- def test_rule_with_two_sources_builds_both_sources
226
- task 'x.aa'
227
- task 'x.bb'
228
- rule '.a' => '.aa' do
229
- @runs << "A"
230
- end
231
- rule '.b' => '.bb' do
232
- @runs << "B"
233
- end
234
- rule ".c" => ['.a', '.b'] do
235
- @runs << "C"
236
- end
237
- Task["x.c"].invoke
238
- assert_equal ["A", "B", "C"], @runs.sort
239
- end
240
-
241
- def test_second_rule_runs_when_first_rule_doesnt
242
- create_timed_files(OBJFILE, SRCFILE)
243
- delete_file(SRCFILE2)
244
- rule OBJFILE => [lambda{SRCFILE}, lambda{SRCFILE2}] do
245
- @runs << :RULE1
246
- end
247
- rule OBJFILE => [lambda{SRCFILE}] do
248
- @runs << :RULE2
249
- end
250
- Task[OBJFILE].invoke
251
- assert_equal [:RULE2], @runs
252
- end
253
-
254
- def test_second_rule_doest_run_if_first_triggers
255
- create_timed_files(OBJFILE, SRCFILE, SRCFILE2)
256
- rule OBJFILE => [lambda{SRCFILE}, lambda{SRCFILE2}] do
257
- @runs << :RULE1
258
- end
259
- rule OBJFILE => [lambda{SRCFILE}] do
260
- @runs << :RULE2
261
- end
262
- Task[OBJFILE].invoke
263
- assert_equal [:RULE1], @runs
264
- end
265
-
266
- def test_second_rule_doest_run_if_first_triggers_with_reversed_rules
267
- create_timed_files(OBJFILE, SRCFILE, SRCFILE2)
268
- rule OBJFILE => [lambda{SRCFILE}] do
269
- @runs << :RULE1
270
- end
271
- rule OBJFILE => [lambda{SRCFILE}, lambda{SRCFILE2}] do
272
- @runs << :RULE2
273
- end
274
- Task[OBJFILE].invoke
275
- assert_equal [:RULE1], @runs
276
- end
277
-
278
- def test_rule_with_proc_dependent_will_trigger
279
- ran = false
280
- mkdir_p("testdata/src/jw")
281
- create_file("testdata/src/jw/X.java")
282
- rule %r(classes/.*\.class) => [
283
- proc { |fn| fn.pathmap("%{classes,testdata/src}d/%n.java") }
284
- ] do |task|
285
- assert_equal task.name, 'classes/jw/X.class'
286
- assert_equal task.source, 'testdata/src/jw/X.java'
287
- @runs << :RULE
288
- end
289
- Task['classes/jw/X.class'].invoke
290
- assert_equal [:RULE], @runs
291
- ensure
292
- rm_r("testdata/src", :verbose=>false) rescue nil
293
- end
294
-
295
- def test_proc_returning_lists_are_flattened_into_prereqs
296
- ran = false
297
- mkdir_p("testdata/flatten")
298
- create_file("testdata/flatten/a.txt")
299
- task 'testdata/flatten/b.data' do |t|
300
- ran = true
301
- touch t.name, :verbose => false
302
- end
303
- rule '.html' =>
304
- proc { |fn|
305
- [
306
- fn.ext("txt"),
307
- "testdata/flatten/b.data"
308
- ]
309
- } do |task|
310
- end
311
- Task['testdata/flatten/a.html'].invoke
312
- assert ran, "Should have triggered flattened dependency"
313
- ensure
314
- rm_r("testdata/flatten", :verbose=>false) rescue nil
315
- end
316
-
317
- def test_recursive_rules_will_work_as_long_as_they_terminate
318
- actions = []
319
- create_file("testdata/abc.xml")
320
- rule '.y' => '.xml' do actions << 'y' end
321
- rule '.c' => '.y' do actions << 'c'end
322
- rule '.o' => '.c' do actions << 'o'end
323
- rule '.exe' => '.o' do actions << 'exe'end
324
- Task["testdata/abc.exe"].invoke
325
- assert_equal ['y', 'c', 'o', 'exe'], actions
326
- end
327
-
328
- def test_recursive_rules_that_dont_terminate_will_overflow
329
- create_file("testdata/a.a")
330
- prev = 'a'
331
- ('b'..'z').each do |letter|
332
- rule ".#{letter}" => ".#{prev}" do |t| puts "#{t.name}" end
333
- prev = letter
334
- end
335
- ex = assert_raises(Rake::RuleRecursionOverflowError) {
336
- Task["testdata/a.z"].invoke
337
- }
338
- assert_match(/a\.z => testdata\/a.y/, ex.message)
339
- end
340
-
341
- def test_rules_with_bad_dependents_will_fail
342
- rule "a" => [ 1 ] do |t| puts t.name end
343
- assert_raise(RuntimeError) do Task['a'].invoke end
344
- end
345
-
346
- end
347
-