rake 0.9.2 → 13.0.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (170) hide show
  1. checksums.yaml +7 -0
  2. data/CONTRIBUTING.rdoc +43 -0
  3. data/Gemfile +10 -0
  4. data/History.rdoc +2386 -0
  5. data/MIT-LICENSE +1 -1
  6. data/README.rdoc +64 -109
  7. data/Rakefile +22 -386
  8. data/bin/bundle +105 -0
  9. data/bin/console +7 -0
  10. data/bin/rake +20 -23
  11. data/bin/rdoc +29 -0
  12. data/bin/rubocop +29 -0
  13. data/bin/setup +6 -0
  14. data/doc/command_line_usage.rdoc +65 -21
  15. data/doc/glossary.rdoc +40 -49
  16. data/doc/jamis.rb +1 -0
  17. data/doc/rake.1 +156 -0
  18. data/doc/rakefile.rdoc +127 -62
  19. data/exe/rake +27 -0
  20. data/lib/rake.rb +37 -31
  21. data/lib/rake/application.rb +507 -272
  22. data/lib/rake/backtrace.rb +24 -0
  23. data/lib/rake/clean.rb +55 -8
  24. data/lib/rake/cloneable.rb +11 -19
  25. data/lib/rake/cpu_counter.rb +107 -0
  26. data/lib/rake/default_loader.rb +5 -0
  27. data/lib/rake/dsl_definition.rb +74 -46
  28. data/lib/rake/early_time.rb +5 -1
  29. data/lib/rake/ext/core.rb +5 -6
  30. data/lib/rake/ext/string.rb +61 -52
  31. data/lib/rake/file_creation_task.rb +4 -3
  32. data/lib/rake/file_list.rb +81 -49
  33. data/lib/rake/file_task.rb +15 -8
  34. data/lib/rake/file_utils.rb +69 -47
  35. data/lib/rake/file_utils_ext.rb +18 -26
  36. data/lib/rake/invocation_chain.rb +25 -19
  37. data/lib/rake/invocation_exception_mixin.rb +1 -0
  38. data/lib/rake/late_time.rb +18 -0
  39. data/lib/rake/linked_list.rb +112 -0
  40. data/lib/rake/loaders/makefile.rb +23 -9
  41. data/lib/rake/multi_task.rb +4 -6
  42. data/lib/rake/name_space.rb +36 -23
  43. data/lib/rake/packagetask.rb +71 -34
  44. data/lib/rake/phony.rb +16 -0
  45. data/lib/rake/private_reader.rb +21 -0
  46. data/lib/rake/promise.rb +100 -0
  47. data/lib/rake/pseudo_status.rb +8 -2
  48. data/lib/rake/rake_module.rb +41 -3
  49. data/lib/rake/rake_test_loader.rb +21 -7
  50. data/lib/rake/rule_recursion_overflow_error.rb +2 -2
  51. data/lib/rake/scope.rb +43 -0
  52. data/lib/rake/task.rb +186 -79
  53. data/lib/rake/task_argument_error.rb +1 -0
  54. data/lib/rake/task_arguments.rb +50 -15
  55. data/lib/rake/task_manager.rb +89 -65
  56. data/lib/rake/tasklib.rb +2 -12
  57. data/lib/rake/testtask.rb +61 -63
  58. data/lib/rake/thread_history_display.rb +49 -0
  59. data/lib/rake/thread_pool.rb +163 -0
  60. data/lib/rake/trace_output.rb +23 -0
  61. data/lib/rake/version.rb +7 -7
  62. data/lib/rake/win32.rb +14 -18
  63. data/rake.gemspec +43 -0
  64. metadata +82 -221
  65. data/.gemtest +0 -0
  66. data/CHANGES +0 -509
  67. data/RRR +0 -9
  68. data/TODO +0 -20
  69. data/doc/rake.1.gz +0 -0
  70. data/doc/release_notes/rake-0.4.14.rdoc +0 -23
  71. data/doc/release_notes/rake-0.4.15.rdoc +0 -35
  72. data/doc/release_notes/rake-0.5.0.rdoc +0 -53
  73. data/doc/release_notes/rake-0.5.3.rdoc +0 -78
  74. data/doc/release_notes/rake-0.5.4.rdoc +0 -46
  75. data/doc/release_notes/rake-0.6.0.rdoc +0 -141
  76. data/doc/release_notes/rake-0.7.0.rdoc +0 -119
  77. data/doc/release_notes/rake-0.7.1.rdoc +0 -59
  78. data/doc/release_notes/rake-0.7.2.rdoc +0 -121
  79. data/doc/release_notes/rake-0.7.3.rdoc +0 -47
  80. data/doc/release_notes/rake-0.8.0.rdoc +0 -114
  81. data/doc/release_notes/rake-0.8.2.rdoc +0 -165
  82. data/doc/release_notes/rake-0.8.3.rdoc +0 -112
  83. data/doc/release_notes/rake-0.8.4.rdoc +0 -147
  84. data/doc/release_notes/rake-0.8.5.rdoc +0 -53
  85. data/doc/release_notes/rake-0.8.6.rdoc +0 -55
  86. data/doc/release_notes/rake-0.8.7.rdoc +0 -55
  87. data/doc/release_notes/rake-0.9.0.rdoc +0 -112
  88. data/doc/release_notes/rake-0.9.1.rdoc +0 -52
  89. data/doc/release_notes/rake-0.9.2.rdoc +0 -49
  90. data/install.rb +0 -90
  91. data/lib/rake/alt_system.rb +0 -109
  92. data/lib/rake/classic_namespace.rb +0 -9
  93. data/lib/rake/contrib/compositepublisher.rb +0 -21
  94. data/lib/rake/contrib/ftptools.rb +0 -150
  95. data/lib/rake/contrib/publisher.rb +0 -69
  96. data/lib/rake/contrib/rubyforgepublisher.rb +0 -16
  97. data/lib/rake/contrib/sshpublisher.rb +0 -45
  98. data/lib/rake/contrib/sys.rb +0 -191
  99. data/lib/rake/ext/module.rb +0 -39
  100. data/lib/rake/ext/time.rb +0 -14
  101. data/lib/rake/gempackagetask.rb +0 -13
  102. data/lib/rake/pathmap.rb +0 -1
  103. data/lib/rake/rdoctask.rb +0 -230
  104. data/lib/rake/ruby182_test_unit_fix.rb +0 -25
  105. data/lib/rake/runtest.rb +0 -21
  106. data/test/check_expansion.rb +0 -5
  107. data/test/check_no_expansion.rb +0 -5
  108. data/test/data/access/Rakefile +0 -35
  109. data/test/data/chains/Rakefile +0 -15
  110. data/test/data/comments/Rakefile +0 -18
  111. data/test/data/default/Rakefile +0 -17
  112. data/test/data/deprecated_import/Rakefile +0 -1
  113. data/test/data/dryrun/Rakefile +0 -22
  114. data/test/data/extra/Rakefile +0 -1
  115. data/test/data/file_creation_task/Rakefile +0 -31
  116. data/test/data/imports/Rakefile +0 -19
  117. data/test/data/imports/deps.mf +0 -1
  118. data/test/data/multidesc/Rakefile +0 -15
  119. data/test/data/namespace/Rakefile +0 -64
  120. data/test/data/rakelib/test1.rb +0 -4
  121. data/test/data/rbext/rakefile.rb +0 -3
  122. data/test/data/sample.mf +0 -14
  123. data/test/data/statusreturn/Rakefile +0 -6
  124. data/test/data/unittest/Rakefile +0 -1
  125. data/test/data/verbose/Rakefile +0 -34
  126. data/test/file_creation.rb +0 -34
  127. data/test/helper.rb +0 -44
  128. data/test/in_environment.rb +0 -35
  129. data/test/reqfile.rb +0 -3
  130. data/test/reqfile2.rb +0 -3
  131. data/test/shellcommand.rb +0 -3
  132. data/test/test_rake.rb +0 -38
  133. data/test/test_rake_application.rb +0 -364
  134. data/test/test_rake_application_options.rb +0 -382
  135. data/test/test_rake_clean.rb +0 -12
  136. data/test/test_rake_definitions.rb +0 -80
  137. data/test/test_rake_directory_task.rb +0 -55
  138. data/test/test_rake_dsl.rb +0 -73
  139. data/test/test_rake_early_time.rb +0 -31
  140. data/test/test_rake_extension.rb +0 -59
  141. data/test/test_rake_file_creation_task.rb +0 -62
  142. data/test/test_rake_file_list.rb +0 -633
  143. data/test/test_rake_file_list_path_map.rb +0 -8
  144. data/test/test_rake_file_task.rb +0 -104
  145. data/test/test_rake_file_utils.rb +0 -252
  146. data/test/test_rake_ftp_file.rb +0 -59
  147. data/test/test_rake_functional.rb +0 -468
  148. data/test/test_rake_invocation_chain.rb +0 -52
  149. data/test/test_rake_makefile_loader.rb +0 -23
  150. data/test/test_rake_multi_task.rb +0 -51
  151. data/test/test_rake_name_space.rb +0 -43
  152. data/test/test_rake_package_task.rb +0 -78
  153. data/test/test_rake_path_map.rb +0 -157
  154. data/test/test_rake_path_map_explode.rb +0 -31
  155. data/test/test_rake_path_map_partial.rb +0 -18
  156. data/test/test_rake_pseudo_status.rb +0 -20
  157. data/test/test_rake_rdoc_task.rb +0 -81
  158. data/test/test_rake_require.rb +0 -35
  159. data/test/test_rake_rules.rb +0 -346
  160. data/test/test_rake_task.rb +0 -271
  161. data/test/test_rake_task_argument_parsing.rb +0 -116
  162. data/test/test_rake_task_arguments.rb +0 -86
  163. data/test/test_rake_task_lib.rb +0 -9
  164. data/test/test_rake_task_manager.rb +0 -145
  165. data/test/test_rake_task_manager_argument_resolution.rb +0 -36
  166. data/test/test_rake_task_with_arguments.rb +0 -162
  167. data/test/test_rake_test_task.rb +0 -122
  168. data/test/test_rake_top_level_functions.rb +0 -76
  169. data/test/test_rake_win32.rb +0 -83
  170. data/test/test_sys.rb +0 -20
@@ -1,52 +0,0 @@
1
- require File.expand_path('../helper', __FILE__)
2
-
3
- class TestRakeInvocationChain < Rake::TestCase
4
-
5
- def setup
6
- super
7
-
8
- @empty = Rake::InvocationChain::EMPTY
9
-
10
- @first_member = "A"
11
- @second_member = "B"
12
- @one = @empty.append(@first_member)
13
- @two = @one.append(@second_member)
14
- end
15
-
16
- def test_append
17
- chain = @empty.append("A")
18
-
19
- assert_equal 'TOP => A', chain.to_s # HACK
20
- end
21
-
22
- def test_append_one_circular
23
- ex = assert_raises RuntimeError do
24
- @one.append(@first_member)
25
- end
26
- assert_match(/circular +dependency/i, ex.message)
27
- assert_match(/A.*=>.*A/, ex.message)
28
- end
29
-
30
- def test_append_two_circular
31
- ex = assert_raises RuntimeError do
32
- @two.append(@first_member)
33
- end
34
- assert_match(/A.*=>.*B.*=>.*A/, ex.message)
35
- end
36
-
37
- def test_member_eh_one
38
- assert @one.member?(@first_member)
39
- end
40
-
41
- def test_member_eh_two
42
- assert @two.member?(@first_member)
43
- assert @two.member?(@second_member)
44
- end
45
-
46
- def test_to_s_empty
47
- assert_equal "TOP", @empty.to_s
48
- assert_equal "TOP => A", @one.to_s
49
- end
50
-
51
- end
52
-
@@ -1,23 +0,0 @@
1
- require File.expand_path('../helper', __FILE__)
2
- require 'rake/loaders/makefile'
3
-
4
- class TestRakeMakefileLoader < Rake::TestCase
5
- include Rake
6
-
7
- def test_parse
8
- Task.clear
9
- loader = Rake::MakefileLoader.new
10
- loader.load("test/data/sample.mf")
11
- %w(a b c d).each do |t|
12
- assert Task.task_defined?(t), "#{t} should be a defined task"
13
- end
14
- assert_equal %w(a1 a2 a3 a4 a5 a6 a7).sort, Task['a'].prerequisites.sort
15
- assert_equal %w(b1 b2 b3 b4 b5 b6 b7).sort, Task['b'].prerequisites.sort
16
- assert_equal %w(c1).sort, Task['c'].prerequisites.sort
17
- assert_equal %w(d1 d2).sort, Task['d'].prerequisites.sort
18
- assert_equal %w(e1 f1).sort, Task['e'].prerequisites.sort
19
- assert_equal %w(e1 f1).sort, Task['f'].prerequisites.sort
20
- assert_equal ["g1", "g 2", "g 3", "g4"].sort, Task['g 0'].prerequisites.sort
21
- assert_equal 7, Task.tasks.size
22
- end
23
- end
@@ -1,51 +0,0 @@
1
- require File.expand_path('../helper', __FILE__)
2
- require 'thread'
3
-
4
- class TestRakeMultiTask < Rake::TestCase
5
- include Rake
6
- include Rake::DSL
7
-
8
- def setup
9
- super
10
-
11
- Task.clear
12
- @runs = Array.new
13
- @mutex = Mutex.new
14
- end
15
-
16
- def add_run(obj)
17
- @mutex.synchronize do
18
- @runs << obj
19
- end
20
- end
21
-
22
- def test_running_multitasks
23
- task :a do 3.times do |i| add_run("A#{i}"); sleep 0.01; end end
24
- task :b do 3.times do |i| add_run("B#{i}"); sleep 0.01; end end
25
- multitask :both => [:a, :b]
26
- Task[:both].invoke
27
- assert_equal 6, @runs.size
28
- assert @runs.index("A0") < @runs.index("A1")
29
- assert @runs.index("A1") < @runs.index("A2")
30
- assert @runs.index("B0") < @runs.index("B1")
31
- assert @runs.index("B1") < @runs.index("B2")
32
- end
33
-
34
- def test_all_multitasks_wait_on_slow_prerequisites
35
- task :slow do 3.times do |i| add_run("S#{i}"); sleep 0.05 end end
36
- task :a => [:slow] do 3.times do |i| add_run("A#{i}"); sleep 0.01 end end
37
- task :b => [:slow] do 3.times do |i| add_run("B#{i}"); sleep 0.01 end end
38
- multitask :both => [:a, :b]
39
- Task[:both].invoke
40
- assert_equal 9, @runs.size
41
- assert @runs.index("S0") < @runs.index("S1")
42
- assert @runs.index("S1") < @runs.index("S2")
43
- assert @runs.index("S2") < @runs.index("A0")
44
- assert @runs.index("S2") < @runs.index("B0")
45
- assert @runs.index("A0") < @runs.index("A1")
46
- assert @runs.index("A1") < @runs.index("A2")
47
- assert @runs.index("B0") < @runs.index("B1")
48
- assert @runs.index("B1") < @runs.index("B2")
49
- end
50
- end
51
-
@@ -1,43 +0,0 @@
1
- require File.expand_path('../helper', __FILE__)
2
-
3
- class TestRakeNameSpace < Rake::TestCase
4
-
5
- class TM
6
- include Rake::TaskManager
7
- end
8
-
9
- def test_namespace_creation
10
- mgr = TM.new
11
- ns = Rake::NameSpace.new(mgr, [])
12
- refute_nil ns
13
- end
14
-
15
- def test_namespace_lookup
16
- mgr = TM.new
17
- ns = mgr.in_namespace("n") do
18
- mgr.define_task(Rake::Task, "t")
19
- end
20
-
21
- refute_nil ns["t"]
22
- assert_equal mgr["n:t"], ns["t"]
23
- end
24
-
25
- def test_namespace_reports_tasks_it_owns
26
- mgr = TM.new
27
- nns = nil
28
- ns = mgr.in_namespace("n") do
29
- mgr.define_task(Rake::Task, :x)
30
- mgr.define_task(Rake::Task, :y)
31
- nns = mgr.in_namespace("nn") do
32
- mgr.define_task(Rake::Task, :z)
33
- end
34
- end
35
- mgr.in_namespace("m") do
36
- mgr.define_task(Rake::Task, :x)
37
- end
38
-
39
- assert_equal ["n:nn:z", "n:x", "n:y"],
40
- ns.tasks.map { |tsk| tsk.name }
41
- assert_equal ["n:nn:z"], nns.tasks.map {|t| t.name}
42
- end
43
- end
@@ -1,78 +0,0 @@
1
- require File.expand_path('../helper', __FILE__)
2
- require 'rake/packagetask'
3
-
4
- class TestRakePackageTask < Rake::TestCase
5
-
6
- def test_initialize
7
- pkg = Rake::PackageTask.new("pkgr", "1.2.3") { |p|
8
- p.package_files << "install.rb"
9
- p.package_files.include(
10
- '[A-Z]*',
11
- 'bin/**/*',
12
- 'lib/**/*.rb',
13
- 'test/**/*.rb',
14
- 'doc/**/*',
15
- 'build/rubyapp.rb',
16
- '*.blurb')
17
- p.package_files.exclude(/\bCVS\b/)
18
- p.package_files.exclude(/~$/)
19
- p.package_dir = 'pkg'
20
- p.need_tar = true
21
- p.need_tar_gz = true
22
- p.need_tar_bz2 = true
23
- p.need_zip = true
24
- }
25
-
26
- assert_equal "pkg", pkg.package_dir
27
- assert pkg.package_files.include?("bin/rake")
28
- assert_equal 'pkgr', pkg.name
29
- assert_equal '1.2.3', pkg.version
30
- assert Rake::Task[:package]
31
- assert Rake::Task['pkg/pkgr-1.2.3.tgz']
32
- assert Rake::Task['pkg/pkgr-1.2.3.tar.gz']
33
- assert Rake::Task['pkg/pkgr-1.2.3.tar.bz2']
34
- assert Rake::Task['pkg/pkgr-1.2.3.zip']
35
- assert Rake::Task['pkg/pkgr-1.2.3']
36
- assert Rake::Task[:clobber_package]
37
- assert Rake::Task[:repackage]
38
- end
39
-
40
- def test_initialize_no_version
41
- e = assert_raises RuntimeError do
42
- Rake::PackageTask.new 'pkgr'
43
- end
44
-
45
- assert_equal 'Version required (or :noversion)', e.message
46
- end
47
-
48
- def test_initialize_noversion
49
- pkg = Rake::PackageTask.new 'pkgr', :noversion
50
-
51
- assert_equal 'pkg', pkg.package_dir
52
- assert_equal 'pkgr', pkg.name
53
- assert_equal nil, pkg.version
54
- end
55
-
56
- def test_clone
57
- pkg = Rake::PackageTask.new("x", :noversion)
58
- p2 = pkg.clone
59
- pkg.package_files << "y"
60
- p2.package_files << "x"
61
- assert_equal ["y"], pkg.package_files
62
- assert_equal ["x"], p2.package_files
63
- end
64
-
65
- def test_package_name
66
- pkg = Rake::PackageTask.new 'a', '1'
67
-
68
- assert_equal 'a-1', pkg.package_name
69
- end
70
-
71
- def test_package_name_noversion
72
- pkg = Rake::PackageTask.new 'a', :noversion
73
-
74
- assert_equal 'a', pkg.package_name
75
- end
76
-
77
- end
78
-
@@ -1,157 +0,0 @@
1
- require File.expand_path('../helper', __FILE__)
2
-
3
- class TestRakePathMap < Rake::TestCase
4
-
5
- def test_returns_self_with_no_args
6
- assert_equal "abc.rb", "abc.rb".pathmap
7
- end
8
-
9
- def test_s_returns_file_separator
10
- sep = File::ALT_SEPARATOR || File::SEPARATOR
11
- assert_equal sep, "abc.rb".pathmap("%s")
12
- assert_equal sep, "".pathmap("%s")
13
- assert_equal "a#{sep}b", "a/b".pathmap("%d%s%f")
14
- end
15
-
16
- def test_f_returns_basename
17
- assert_equal "abc.rb", "abc.rb".pathmap("%f")
18
- assert_equal "abc.rb", "this/is/a/dir/abc.rb".pathmap("%f")
19
- assert_equal "abc.rb", "/this/is/a/dir/abc.rb".pathmap("%f")
20
- end
21
-
22
- def test_n_returns_basename_without_extension
23
- assert_equal "abc", "abc.rb".pathmap("%n")
24
- assert_equal "abc", "abc".pathmap("%n")
25
- assert_equal "abc", "this/is/a/dir/abc.rb".pathmap("%n")
26
- assert_equal "abc", "/this/is/a/dir/abc.rb".pathmap("%n")
27
- assert_equal "abc", "/this/is/a/dir/abc".pathmap("%n")
28
- end
29
-
30
- def test_d_returns_dirname
31
- assert_equal ".", "abc.rb".pathmap("%d")
32
- assert_equal "/", "/abc".pathmap("%d")
33
- assert_equal "this/is/a/dir", "this/is/a/dir/abc.rb".pathmap("%d")
34
- assert_equal "/this/is/a/dir", "/this/is/a/dir/abc.rb".pathmap("%d")
35
- end
36
-
37
- def test_9d_returns_partial_dirname
38
- assert_equal "this/is", "this/is/a/dir/abc.rb".pathmap("%2d")
39
- assert_equal "this", "this/is/a/dir/abc.rb".pathmap("%1d")
40
- assert_equal ".", "this/is/a/dir/abc.rb".pathmap("%0d")
41
- assert_equal "dir", "this/is/a/dir/abc.rb".pathmap("%-1d")
42
- assert_equal "a/dir", "this/is/a/dir/abc.rb".pathmap("%-2d")
43
- assert_equal "this/is/a/dir", "this/is/a/dir/abc.rb".pathmap("%100d")
44
- assert_equal "this/is/a/dir", "this/is/a/dir/abc.rb".pathmap("%-100d")
45
- end
46
-
47
- def test_x_returns_extension
48
- assert_equal "", "abc".pathmap("%x")
49
- assert_equal ".rb", "abc.rb".pathmap("%x")
50
- assert_equal ".rb", "abc.xyz.rb".pathmap("%x")
51
- assert_equal "", ".depends".pathmap("%x")
52
- assert_equal "", "dir/.depends".pathmap("%x")
53
- end
54
-
55
- def test_X_returns_everything_but_extension
56
- assert_equal "abc", "abc".pathmap("%X")
57
- assert_equal "abc", "abc.rb".pathmap("%X")
58
- assert_equal "abc.xyz", "abc.xyz.rb".pathmap("%X")
59
- assert_equal "ab.xyz", "ab.xyz.rb".pathmap("%X")
60
- assert_equal "a.xyz", "a.xyz.rb".pathmap("%X")
61
- assert_equal "abc", "abc.rb".pathmap("%X")
62
- assert_equal "ab", "ab.rb".pathmap("%X")
63
- assert_equal "a", "a.rb".pathmap("%X")
64
- assert_equal ".depends", ".depends".pathmap("%X")
65
- assert_equal "a/dir/.depends", "a/dir/.depends".pathmap("%X")
66
- assert_equal "/.depends", "/.depends".pathmap("%X")
67
- end
68
-
69
- def test_p_returns_entire_pathname
70
- assert_equal "abc.rb", "abc.rb".pathmap("%p")
71
- assert_equal "this/is/a/dir/abc.rb", "this/is/a/dir/abc.rb".pathmap("%p")
72
- assert_equal "/this/is/a/dir/abc.rb", "/this/is/a/dir/abc.rb".pathmap("%p")
73
- end
74
-
75
- def test_dash_returns_empty_string
76
- assert_equal "", "abc.rb".pathmap("%-")
77
- assert_equal "abc.rb", "abc.rb".pathmap("%X%-%x")
78
- end
79
-
80
- def test_percent_percent_returns_percent
81
- assert_equal "a%b", "".pathmap("a%%b")
82
- end
83
-
84
- def test_undefined_percent_causes_error
85
- assert_raises(ArgumentError) {
86
- "dir/abc.rb".pathmap("%z")
87
- }
88
- end
89
-
90
- def test_pattern_returns_substitutions
91
- assert_equal "bin/org/osb",
92
- "src/org/osb/Xyz.java".pathmap("%{src,bin}d")
93
- end
94
-
95
- def test_pattern_can_use_backreferences
96
- assert_equal "dir/hi/is", "dir/this/is".pathmap("%{t(hi)s,\\1}p")
97
- end
98
-
99
- def test_pattern_with_star_replacement_string_uses_block
100
- assert_equal "src/ORG/osb",
101
- "src/org/osb/Xyz.java".pathmap("%{/org,*}d") { |d| d.upcase }
102
- assert_equal "Xyz.java",
103
- "src/org/osb/Xyz.java".pathmap("%{.*,*}f") { |f| f.capitalize }
104
- end
105
-
106
- def test_pattern_with_no_replacement_nor_block_substitutes_empty_string
107
- assert_equal "bc.rb", "abc.rb".pathmap("%{a}f")
108
- end
109
-
110
- def test_pattern_works_with_certain_valid_operators
111
- assert_equal "dir/xbc.rb", "dir/abc.rb".pathmap("%{a,x}p")
112
- assert_equal "d1r", "dir/abc.rb".pathmap("%{i,1}d")
113
- assert_equal "xbc.rb", "dir/abc.rb".pathmap("%{a,x}f")
114
- assert_equal ".Rb", "dir/abc.rb".pathmap("%{r,R}x")
115
- assert_equal "xbc", "dir/abc.rb".pathmap("%{a,x}n")
116
- end
117
-
118
- def test_multiple_patterns
119
- assert_equal "this/is/b/directory/abc.rb",
120
- "this/is/a/dir/abc.rb".pathmap("%{a,b;dir,\\0ectory}p")
121
- end
122
-
123
- def test_partial_directory_selection_works_with_patterns
124
- assert_equal "this/is/a/long",
125
- "this/is/a/really/long/path/ok.rb".pathmap("%{/really/,/}5d")
126
- end
127
-
128
- def test_pattern_with_invalid_operator
129
- ex = assert_raises(ArgumentError) do
130
- "abc.xyz".pathmap("%{src,bin}z")
131
- end
132
- assert_match(/unknown.*pathmap.*spec.*z/i, ex.message)
133
- end
134
-
135
- def test_works_with_windows_separators
136
- if File::ALT_SEPARATOR
137
- assert_equal "abc", 'dir\abc.rb'.pathmap("%n")
138
- assert_equal 'this\is\a\dir',
139
- 'this\is\a\dir\abc.rb'.pathmap("%d")
140
- end
141
- end
142
-
143
- def test_complex_patterns
144
- sep = "".pathmap("%s")
145
- assert_equal "dir/abc.rb", "dir/abc.rb".pathmap("%d/%n%x")
146
- assert_equal "./abc.rb", "abc.rb".pathmap("%d/%n%x")
147
- assert_equal "Your file extension is '.rb'",
148
- "dir/abc.rb".pathmap("Your file extension is '%x'")
149
- assert_equal "bin/org/onstepback/proj/A.class",
150
- "src/org/onstepback/proj/A.java".pathmap("%{src,bin}d/%n.class")
151
- assert_equal "src_work/bin/org/onstepback/proj/A.class",
152
- "src_work/src/org/onstepback/proj/A.java".pathmap('%{\bsrc\b,bin}X.class')
153
- assert_equal ".depends.bak", ".depends".pathmap("%X.bak")
154
- assert_equal "d#{sep}a/b/c#{sep}file.txt", "a/b/c/d/file.txt".pathmap("%-1d%s%3d%s%f")
155
- end
156
- end
157
-
@@ -1,31 +0,0 @@
1
- require File.expand_path('../helper', __FILE__)
2
-
3
- class TestRakePathMapExplode < Rake::TestCase
4
- def setup
5
- super
6
-
7
- String.class_eval { public :pathmap_explode }
8
- end
9
-
10
- def teardown
11
- String.class_eval { protected :pathmap_explode }
12
- end
13
-
14
- def test_explode
15
- assert_equal ['a'], 'a'.pathmap_explode
16
- assert_equal ['a', 'b'], 'a/b'.pathmap_explode
17
- assert_equal ['a', 'b', 'c'], 'a/b/c'.pathmap_explode
18
- assert_equal ['/', 'a'], '/a'.pathmap_explode
19
- assert_equal ['/', 'a', 'b'], '/a/b'.pathmap_explode
20
- assert_equal ['/', 'a', 'b', 'c'], '/a/b/c'.pathmap_explode
21
- if File::ALT_SEPARATOR
22
- assert_equal ['c:.', 'a'], 'c:a'.pathmap_explode
23
- assert_equal ['c:.', 'a', 'b'], 'c:a/b'.pathmap_explode
24
- assert_equal ['c:.', 'a', 'b', 'c'], 'c:a/b/c'.pathmap_explode
25
- assert_equal ['c:/', 'a'], 'c:/a'.pathmap_explode
26
- assert_equal ['c:/', 'a', 'b'], 'c:/a/b'.pathmap_explode
27
- assert_equal ['c:/', 'a', 'b', 'c'], 'c:/a/b/c'.pathmap_explode
28
- end
29
- end
30
- end
31
-
@@ -1,18 +0,0 @@
1
- require File.expand_path('../helper', __FILE__)
2
-
3
- class TestRakePathMapPartial < Rake::TestCase
4
- def test_pathmap_partial
5
- @path = "1/2/file"
6
- def @path.call(n)
7
- pathmap_partial(n)
8
- end
9
- assert_equal("1", @path.call(1))
10
- assert_equal("1/2", @path.call(2))
11
- assert_equal("1/2", @path.call(3))
12
- assert_equal(".", @path.call(0))
13
- assert_equal("2", @path.call(-1))
14
- assert_equal("1/2", @path.call(-2))
15
- assert_equal("1/2", @path.call(-3))
16
- end
17
- end
18
-