elliottcable-echoe 3.1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (114) hide show
  1. data/CHANGELOG +69 -0
  2. data/LICENSE +184 -0
  3. data/MIT-LICENSE +21 -0
  4. data/Manifest +113 -0
  5. data/README +114 -0
  6. data/Rakefile +15 -0
  7. data/TODO +4 -0
  8. data/echoe.gemspec +37 -0
  9. data/lib/echoe/client.rb +25 -0
  10. data/lib/echoe/extensions.rb +57 -0
  11. data/lib/echoe/platform.rb +36 -0
  12. data/lib/echoe/rubygems.rb +41 -0
  13. data/lib/echoe.rb +717 -0
  14. data/vendor/rake/CHANGES +400 -0
  15. data/vendor/rake/MIT-LICENSE +21 -0
  16. data/vendor/rake/README +285 -0
  17. data/vendor/rake/Rakefile +418 -0
  18. data/vendor/rake/TODO +20 -0
  19. data/vendor/rake/bin/rake +31 -0
  20. data/vendor/rake/doc/example/Rakefile1 +38 -0
  21. data/vendor/rake/doc/example/Rakefile2 +35 -0
  22. data/vendor/rake/doc/example/a.c +6 -0
  23. data/vendor/rake/doc/example/b.c +6 -0
  24. data/vendor/rake/doc/example/main.c +11 -0
  25. data/vendor/rake/doc/glossary.rdoc +51 -0
  26. data/vendor/rake/doc/jamis.rb +591 -0
  27. data/vendor/rake/doc/proto_rake.rdoc +127 -0
  28. data/vendor/rake/doc/rake.1.gz +0 -0
  29. data/vendor/rake/doc/rakefile.rdoc +534 -0
  30. data/vendor/rake/doc/rational.rdoc +151 -0
  31. data/vendor/rake/doc/release_notes/rake-0.4.14.rdoc +23 -0
  32. data/vendor/rake/doc/release_notes/rake-0.4.15.rdoc +35 -0
  33. data/vendor/rake/doc/release_notes/rake-0.5.0.rdoc +53 -0
  34. data/vendor/rake/doc/release_notes/rake-0.5.3.rdoc +78 -0
  35. data/vendor/rake/doc/release_notes/rake-0.5.4.rdoc +46 -0
  36. data/vendor/rake/doc/release_notes/rake-0.6.0.rdoc +141 -0
  37. data/vendor/rake/doc/release_notes/rake-0.7.0.rdoc +119 -0
  38. data/vendor/rake/doc/release_notes/rake-0.7.1.rdoc +59 -0
  39. data/vendor/rake/doc/release_notes/rake-0.7.2.rdoc +121 -0
  40. data/vendor/rake/doc/release_notes/rake-0.7.3.rdoc +47 -0
  41. data/vendor/rake/doc/release_notes/rake-0.8.0.rdoc +114 -0
  42. data/vendor/rake/doc/release_notes/rake-0.8.2.rdoc +165 -0
  43. data/vendor/rake/doc/release_notes/rake-0.8.3.rdoc +112 -0
  44. data/vendor/rake/install.rb +88 -0
  45. data/vendor/rake/lib/rake/classic_namespace.rb +8 -0
  46. data/vendor/rake/lib/rake/clean.rb +33 -0
  47. data/vendor/rake/lib/rake/contrib/compositepublisher.rb +24 -0
  48. data/vendor/rake/lib/rake/contrib/ftptools.rb +153 -0
  49. data/vendor/rake/lib/rake/contrib/publisher.rb +75 -0
  50. data/vendor/rake/lib/rake/contrib/rubyforgepublisher.rb +18 -0
  51. data/vendor/rake/lib/rake/contrib/sshpublisher.rb +47 -0
  52. data/vendor/rake/lib/rake/contrib/sys.rb +209 -0
  53. data/vendor/rake/lib/rake/gempackagetask.rb +103 -0
  54. data/vendor/rake/lib/rake/loaders/makefile.rb +35 -0
  55. data/vendor/rake/lib/rake/packagetask.rb +185 -0
  56. data/vendor/rake/lib/rake/rake_test_loader.rb +5 -0
  57. data/vendor/rake/lib/rake/rdoctask.rb +147 -0
  58. data/vendor/rake/lib/rake/ruby182_test_unit_fix.rb +23 -0
  59. data/vendor/rake/lib/rake/runtest.rb +23 -0
  60. data/vendor/rake/lib/rake/tasklib.rb +23 -0
  61. data/vendor/rake/lib/rake/testtask.rb +161 -0
  62. data/vendor/rake/lib/rake/win32.rb +54 -0
  63. data/vendor/rake/lib/rake.rb +2468 -0
  64. data/vendor/rake/test/capture_stdout.rb +26 -0
  65. data/vendor/rake/test/check_expansion.rb +5 -0
  66. data/vendor/rake/test/contrib/test_sys.rb +47 -0
  67. data/vendor/rake/test/data/chains/Rakefile +15 -0
  68. data/vendor/rake/test/data/default/Rakefile +19 -0
  69. data/vendor/rake/test/data/dryrun/Rakefile +22 -0
  70. data/vendor/rake/test/data/file_creation_task/Rakefile +33 -0
  71. data/vendor/rake/test/data/imports/Rakefile +19 -0
  72. data/vendor/rake/test/data/imports/deps.mf +1 -0
  73. data/vendor/rake/test/data/multidesc/Rakefile +17 -0
  74. data/vendor/rake/test/data/namespace/Rakefile +57 -0
  75. data/vendor/rake/test/data/rakelib/test1.rb +3 -0
  76. data/vendor/rake/test/data/rbext/rakefile.rb +3 -0
  77. data/vendor/rake/test/data/sample.mf +12 -0
  78. data/vendor/rake/test/data/statusreturn/Rakefile +8 -0
  79. data/vendor/rake/test/data/unittest/Rakefile +1 -0
  80. data/vendor/rake/test/filecreation.rb +32 -0
  81. data/vendor/rake/test/functional.rb +15 -0
  82. data/vendor/rake/test/in_environment.rb +30 -0
  83. data/vendor/rake/test/rake_test_setup.rb +10 -0
  84. data/vendor/rake/test/reqfile.rb +3 -0
  85. data/vendor/rake/test/reqfile2.rb +3 -0
  86. data/vendor/rake/test/session_functional.rb +337 -0
  87. data/vendor/rake/test/shellcommand.rb +3 -0
  88. data/vendor/rake/test/test_application.rb +694 -0
  89. data/vendor/rake/test/test_clean.rb +14 -0
  90. data/vendor/rake/test/test_definitions.rb +82 -0
  91. data/vendor/rake/test/test_earlytime.rb +35 -0
  92. data/vendor/rake/test/test_extension.rb +63 -0
  93. data/vendor/rake/test/test_file_creation_task.rb +62 -0
  94. data/vendor/rake/test/test_file_task.rb +139 -0
  95. data/vendor/rake/test/test_filelist.rb +618 -0
  96. data/vendor/rake/test/test_fileutils.rb +250 -0
  97. data/vendor/rake/test/test_ftp.rb +59 -0
  98. data/vendor/rake/test/test_invocation_chain.rb +75 -0
  99. data/vendor/rake/test/test_makefile_loader.rb +25 -0
  100. data/vendor/rake/test/test_multitask.rb +45 -0
  101. data/vendor/rake/test/test_namespace.rb +36 -0
  102. data/vendor/rake/test/test_package_task.rb +116 -0
  103. data/vendor/rake/test/test_pathmap.rb +209 -0
  104. data/vendor/rake/test/test_rake.rb +41 -0
  105. data/vendor/rake/test/test_require.rb +33 -0
  106. data/vendor/rake/test/test_rules.rb +347 -0
  107. data/vendor/rake/test/test_task_arguments.rb +89 -0
  108. data/vendor/rake/test/test_task_manager.rb +170 -0
  109. data/vendor/rake/test/test_tasklib.rb +12 -0
  110. data/vendor/rake/test/test_tasks.rb +371 -0
  111. data/vendor/rake/test/test_test_task.rb +75 -0
  112. data/vendor/rake/test/test_top_level_functions.rb +84 -0
  113. data/vendor/rake/test/test_win32.rb +57 -0
  114. metadata +195 -0
@@ -0,0 +1,209 @@
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
@@ -0,0 +1,41 @@
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
@@ -0,0 +1,33 @@
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
+
@@ -0,0 +1,347 @@
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
+