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,55 +0,0 @@
1
- require File.expand_path('../helper', __FILE__)
2
- require 'fileutils'
3
-
4
- class TestRakeDirectoryTask < Rake::TestCase
5
- include Rake
6
-
7
- def setup
8
- super
9
-
10
- Rake.rm_rf "testdata", :verbose=>false
11
- end
12
-
13
- def teardown
14
- Rake.rm_rf "testdata", :verbose=>false
15
-
16
- super
17
- end
18
-
19
- def test_directory
20
- desc "DESC"
21
- directory "testdata/a/b/c"
22
- assert_equal FileCreationTask, Task["testdata"].class
23
- assert_equal FileCreationTask, Task["testdata/a"].class
24
- assert_equal FileCreationTask, Task["testdata/a/b/c"].class
25
- assert_nil Task["testdata"].comment
26
- assert_equal "DESC", Task["testdata/a/b/c"].comment
27
- assert_nil Task["testdata/a/b"].comment
28
- verbose(false) {
29
- Task['testdata/a/b'].invoke
30
- }
31
- assert File.exist?("testdata/a/b")
32
- assert ! File.exist?("testdata/a/b/c")
33
- end
34
-
35
- if Rake::Win32.windows?
36
- def test_directory_win32
37
- desc "WIN32 DESC"
38
- FileUtils.mkdir_p("testdata")
39
- Dir.chdir("testdata") do
40
- directory 'c:/testdata/a/b/c'
41
- assert_equal FileCreationTask, Task['c:/testdata'].class
42
- assert_equal FileCreationTask, Task['c:/testdata/a'].class
43
- assert_equal FileCreationTask, Task['c:/testdata/a/b/c'].class
44
- assert_nil Task['c:/testdata'].comment
45
- assert_equal "WIN32 DESC", Task['c:/testdata/a/b/c'].comment
46
- assert_nil Task['c:/testdata/a/b'].comment
47
- verbose(false) {
48
- Task['c:/testdata/a/b'].invoke
49
- }
50
- assert File.exist?('c:/testdata/a/b')
51
- assert ! File.exist?('c:/testdata/a/b/c')
52
- end
53
- end
54
- end
55
- end
@@ -1,73 +0,0 @@
1
- require File.expand_path('../helper', __FILE__)
2
-
3
- class TestRakeDsl < Rake::TestCase
4
-
5
- def setup
6
- super
7
- Rake::Task.clear
8
- end
9
-
10
- def test_namespace_command
11
- namespace "n" do
12
- task "t"
13
- end
14
- refute_nil Rake::Task["n:t"]
15
- end
16
-
17
- def test_namespace_command_with_bad_name
18
- ex = assert_raises(ArgumentError) do
19
- namespace 1 do end
20
- end
21
- assert_match(/string/i, ex.message)
22
- assert_match(/symbol/i, ex.message)
23
- end
24
-
25
- def test_namespace_command_with_a_string_like_object
26
- name = Object.new
27
- def name.to_str
28
- "bob"
29
- end
30
- namespace name do
31
- task "t"
32
- end
33
- refute_nil Rake::Task["bob:t"]
34
- end
35
-
36
- class Foo
37
- def initialize
38
- task :foo_deprecated_a => "foo_deprecated_b" do
39
- print "a"
40
- end
41
- file "foo_deprecated_b" do
42
- print "b"
43
- end
44
- end
45
- end
46
-
47
- def test_deprecated_object_dsl
48
- out, err = capture_io do
49
- Foo.new
50
- Rake.application.invoke_task :foo_deprecated_a
51
- end
52
- assert_equal("ba", out)
53
- assert_match(/deprecated/, err)
54
- assert_match(/Foo\#task/, err)
55
- assert_match(/Foo\#file/, err)
56
- assert_match(/test_rake_dsl\.rb:\d+/, err)
57
- end
58
-
59
- def test_deprecated_object_dsl_with_suppressed_warnings
60
- Rake.application.options.ignore_deprecate = true
61
- out, err = capture_io do
62
- Foo.new
63
- Rake.application.invoke_task :foo_deprecated_a
64
- end
65
- assert_equal("ba", out)
66
- refute_match(/deprecated/, err)
67
- refute_match(/Foo\#task/, err)
68
- refute_match(/Foo\#file/, err)
69
- refute_match(/test_rake_dsl\.rb:\d+/, err)
70
- ensure
71
- Rake.application.options.ignore_deprecate = false
72
- end
73
- end
@@ -1,31 +0,0 @@
1
- require File.expand_path('../helper', __FILE__)
2
-
3
- class TestRakeEarlyTime < Rake::TestCase
4
- def test_create
5
- early = Rake::EarlyTime.instance
6
- assert early <= Time.now
7
- assert early < Time.now
8
- assert early != Time.now
9
- assert Time.now > early
10
- assert Time.now >= early
11
- assert Time.now != early
12
- end
13
-
14
- def test_equality
15
- early = Rake::EarlyTime.instance
16
- assert_equal early, early, "two early times should be equal"
17
- end
18
-
19
- def test_original_time_compare_is_not_messed_up
20
- t1 = Time.mktime(1970, 1, 1, 0, 0, 0)
21
- t2 = Time.now
22
- assert t1 < t2
23
- assert t2 > t1
24
- assert t1 == t1
25
- assert t2 == t2
26
- end
27
-
28
- def test_to_s
29
- assert_equal "<EARLY TIME>", Rake::EARLY.to_s
30
- end
31
- end
@@ -1,59 +0,0 @@
1
- require File.expand_path('../helper', __FILE__)
2
- require 'stringio'
3
-
4
- class TestRakeExtension < Rake::TestCase
5
-
6
- module Redirect
7
- def error_redirect
8
- old_err = $stderr
9
- result = StringIO.new
10
- $stderr = result
11
- yield
12
- result
13
- ensure
14
- $stderr = old_err
15
- end
16
- end
17
-
18
- class Sample
19
- extend Redirect
20
-
21
- def duplicate_method
22
- :original
23
- end
24
-
25
- OK_ERRS = error_redirect do
26
- rake_extension("a") do
27
- def ok_method
28
- end
29
- end
30
- end
31
-
32
-
33
- DUP_ERRS = error_redirect do
34
- rake_extension("duplicate_method") do
35
- def duplicate_method
36
- :override
37
- end
38
- end
39
- end
40
- end
41
-
42
- def test_methods_actually_exist
43
- sample = Sample.new
44
- sample.ok_method
45
- sample.duplicate_method
46
- end
47
-
48
- def test_no_warning_when_defining_ok_method
49
- assert_equal "", Sample::OK_ERRS.string
50
- end
51
-
52
- def test_extension_complains_when_a_method_that_is_present
53
- assert_match(/warning:/i, Sample::DUP_ERRS.string)
54
- assert_match(/already exists/i, Sample::DUP_ERRS.string)
55
- assert_match(/duplicate_method/i, Sample::DUP_ERRS.string)
56
- assert_equal :original, Sample.new.duplicate_method
57
- end
58
-
59
- end
@@ -1,62 +0,0 @@
1
- require File.expand_path('../helper', __FILE__)
2
- require 'fileutils'
3
-
4
- ######################################################################
5
- class TestRakeFileCreationTask < Rake::TestCase
6
- include Rake
7
- include Rake::DSL
8
-
9
- DUMMY_DIR = 'testdata/dummy_dir'
10
-
11
- def setup
12
- super
13
-
14
- Task.clear
15
- end
16
-
17
- def teardown
18
- FileUtils.rm_rf DUMMY_DIR
19
-
20
- super
21
- end
22
-
23
- def test_file_needed
24
- create_dir DUMMY_DIR
25
- fc_task = Task[DUMMY_DIR]
26
- assert_equal DUMMY_DIR, fc_task.name
27
- FileUtils.rm_rf fc_task.name
28
- assert fc_task.needed?, "file should be needed"
29
- FileUtils.mkdir fc_task.name
30
- assert_equal nil, fc_task.prerequisites.collect{|n| Task[n].timestamp}.max
31
- assert ! fc_task.needed?, "file should not be needed"
32
- end
33
-
34
- def test_directory
35
- directory DUMMY_DIR
36
- fc_task = Task[DUMMY_DIR]
37
- assert_equal DUMMY_DIR, fc_task.name
38
- assert FileCreationTask === fc_task
39
- end
40
-
41
- def test_no_retriggers_on_filecreate_task
42
- create_timed_files(OLDFILE, NEWFILE)
43
- t1 = Rake.application.intern(FileCreationTask, OLDFILE).enhance([NEWFILE])
44
- t2 = Rake.application.intern(FileCreationTask, NEWFILE)
45
- assert ! t2.needed?, "Should not need to build new file"
46
- assert ! t1.needed?, "Should not need to rebuild old file because of new"
47
- end
48
-
49
- def test_no_retriggers_on_file_task
50
- create_timed_files(OLDFILE, NEWFILE)
51
- t1 = Rake.application.intern(FileCreationTask, OLDFILE).enhance([NEWFILE])
52
- t2 = Rake.application.intern(FileCreationTask, NEWFILE)
53
- assert ! t2.needed?, "Should not need to build new file"
54
- assert ! t1.needed?, "Should not need to rebuild old file because of new"
55
- end
56
-
57
- def test_very_early_timestamp
58
- t1 = Rake.application.intern(FileCreationTask, OLDFILE)
59
- assert t1.timestamp < Time.now
60
- assert t1.timestamp < Time.now - 1000000
61
- end
62
- end
@@ -1,633 +0,0 @@
1
- require File.expand_path('../helper', __FILE__)
2
-
3
- class TestRakeFileList < Rake::TestCase
4
- FileList = Rake::FileList
5
-
6
- def setup
7
- super
8
-
9
- create_test_data
10
- end
11
-
12
- def teardown
13
- # FileList.select_default_ignore_patterns
14
- FileUtils.rm_rf("testdata")
15
-
16
- super
17
- end
18
-
19
- def test_delegating_methods_do_not_include_to_a_or_to_ary
20
- assert ! FileList::DELEGATING_METHODS.include?("to_a"), "should not include to_a"
21
- assert ! FileList::DELEGATING_METHODS.include?(:to_a), "should not include to_a"
22
- assert ! FileList::DELEGATING_METHODS.include?("to_ary"), "should not include to_ary"
23
- assert ! FileList::DELEGATING_METHODS.include?(:to_ary), "should not include to_ary"
24
- end
25
-
26
- def test_create
27
- fl = FileList.new
28
- assert_equal 0, fl.size
29
- end
30
-
31
- def test_create_with_args
32
- fl = FileList.new("testdata/*.c", "x")
33
- assert_equal ["testdata/abc.c", "testdata/x.c", "testdata/xyz.c", "x"].sort,
34
- fl.sort
35
- end
36
-
37
- def test_create_with_block
38
- fl = FileList.new { |f| f.include("x") }
39
- assert_equal ["x"], fl.resolve
40
- end
41
-
42
- def test_create_with_brackets
43
- fl = FileList["testdata/*.c", "x"]
44
- assert_equal ["testdata/abc.c", "testdata/x.c", "testdata/xyz.c", "x"].sort,
45
- fl.sort
46
- end
47
-
48
- def test_create_with_brackets_and_filelist
49
- fl = FileList[FileList["testdata/*.c", "x"]]
50
- assert_equal ["testdata/abc.c", "testdata/x.c", "testdata/xyz.c", "x"].sort,
51
- fl.sort
52
- end
53
-
54
- def test_include_with_another_array
55
- fl = FileList.new.include(["x", "y", "z"])
56
- assert_equal ["x", "y", "z"].sort, fl.sort
57
- end
58
-
59
- def test_include_with_another_filelist
60
- fl = FileList.new.include(FileList["testdata/*.c", "x"])
61
- assert_equal ["testdata/abc.c", "testdata/x.c", "testdata/xyz.c", "x"].sort,
62
- fl.sort
63
- end
64
-
65
- def test_append
66
- fl = FileList.new
67
- fl << "a.rb" << "b.rb"
68
- assert_equal ['a.rb', 'b.rb'], fl
69
- end
70
-
71
- def test_add_many
72
- fl = FileList.new
73
- fl.include %w(a d c)
74
- fl.include('x', 'y')
75
- assert_equal ['a', 'd', 'c', 'x', 'y'], fl
76
- assert_equal ['a', 'd', 'c', 'x', 'y'], fl.resolve
77
- end
78
-
79
- def test_add_return
80
- f = FileList.new
81
- g = f << "x"
82
- assert_equal f.object_id, g.object_id
83
- h = f.include("y")
84
- assert_equal f.object_id, h.object_id
85
- end
86
-
87
- def test_match
88
- fl = FileList.new
89
- fl.include('test/test_*.rb')
90
- assert fl.include?("test/test_rake_file_list.rb")
91
- assert fl.size > 3
92
- fl.each { |fn| assert_match(/\.rb$/, fn) }
93
- end
94
-
95
- def test_add_matching
96
- fl = FileList.new
97
- fl << "a.java"
98
- fl.include("test/*.rb")
99
- assert_equal "a.java", fl[0]
100
- assert fl.size > 2
101
- assert fl.include?("test/test_rake_file_list.rb")
102
- end
103
-
104
- def test_multiple_patterns
105
- create_test_data
106
- fl = FileList.new
107
- fl.include('*.c', '*xist*')
108
- assert_equal [], fl
109
- fl.include('testdata/*.c', 'testdata/*xist*')
110
- assert_equal [
111
- 'testdata/x.c', 'testdata/xyz.c', 'testdata/abc.c', 'testdata/existing'
112
- ].sort, fl.sort
113
- end
114
-
115
- def test_square_bracket_pattern
116
- fl = FileList.new
117
- fl.include("testdata/abc.[ch]")
118
- assert fl.size == 2
119
- assert fl.include?("testdata/abc.c")
120
- assert fl.include?("testdata/abc.h")
121
- end
122
-
123
- def test_curly_bracket_pattern
124
- fl = FileList.new
125
- fl.include("testdata/abc.{c,h}")
126
- assert fl.size == 2
127
- assert fl.include?("testdata/abc.c")
128
- assert fl.include?("testdata/abc.h")
129
- end
130
-
131
- def test_reject
132
- fl = FileList.new
133
- fl.include %w(testdata/x.c testdata/abc.c testdata/xyz.c testdata/existing)
134
- fl.reject! { |fn| fn =~ %r{/x} }
135
- assert_equal [
136
- 'testdata/abc.c', 'testdata/existing'
137
- ], fl
138
- end
139
-
140
- def test_exclude
141
- fl = FileList['testdata/x.c', 'testdata/abc.c', 'testdata/xyz.c', 'testdata/existing']
142
- fl.each { |fn| touch fn, :verbose => false }
143
- x = fl.exclude(%r{/x.+\.})
144
- assert_equal FileList, x.class
145
- assert_equal %w(testdata/x.c testdata/abc.c testdata/existing), fl
146
- assert_equal fl.object_id, x.object_id
147
- fl.exclude('testdata/*.c')
148
- assert_equal ['testdata/existing'], fl
149
- fl.exclude('testdata/existing')
150
- assert_equal [], fl
151
- end
152
-
153
- def test_excluding_via_block
154
- fl = FileList['testdata/a.c', 'testdata/b.c', 'testdata/xyz.c']
155
- fl.exclude { |fn| fn.pathmap('%n') == 'xyz' }
156
- assert fl.exclude?("xyz.c"), "Should exclude xyz.c"
157
- assert_equal ['testdata/a.c', 'testdata/b.c'], fl
158
- end
159
-
160
- def test_exclude_return_on_create
161
- fl = FileList['testdata/*'].exclude(/.*\.[hcx]$/)
162
- assert_equal ['testdata/existing', 'testdata/cfiles'].sort, fl.sort
163
- assert_equal FileList, fl.class
164
- end
165
-
166
- def test_exclude_with_string_return_on_create
167
- fl = FileList['testdata/*'].exclude('testdata/abc.c')
168
- assert_equal %w(testdata/existing testdata/cfiles testdata/x.c testdata/abc.h testdata/abc.x testdata/xyz.c).sort, fl.sort
169
- assert_equal FileList, fl.class
170
- end
171
-
172
- def test_default_exclude
173
- fl = FileList.new
174
- fl.clear_exclude
175
- fl.include("**/*~", "**/*.bak", "**/core")
176
- assert fl.member?("testdata/core"), "Should include core"
177
- assert fl.member?("testdata/x.bak"), "Should include .bak files"
178
- end
179
-
180
- def test_unique
181
- fl = FileList.new
182
- fl << "x.c" << "a.c" << "b.rb" << "a.c"
183
- assert_equal ['x.c', 'a.c', 'b.rb', 'a.c'], fl
184
- fl.uniq!
185
- assert_equal ['x.c', 'a.c', 'b.rb'], fl
186
- end
187
-
188
- def test_to_string
189
- fl = FileList.new
190
- fl << "a.java" << "b.java"
191
- assert_equal "a.java b.java", fl.to_s
192
- assert_equal "a.java b.java", "#{fl}"
193
- end
194
-
195
- def test_to_array
196
- fl = FileList['a.java', 'b.java']
197
- assert_equal ['a.java', 'b.java'], fl.to_a
198
- assert_equal Array, fl.to_a.class
199
- assert_equal ['a.java', 'b.java'], fl.to_ary
200
- assert_equal Array, fl.to_ary.class
201
- end
202
-
203
- def test_to_s_pending
204
- fl = FileList['testdata/abc.*']
205
- result = fl.to_s
206
- assert_match(%r{testdata/abc\.c}, result)
207
- assert_match(%r{testdata/abc\.h}, result)
208
- assert_match(%r{testdata/abc\.x}, result)
209
- assert_match(%r{(testdata/abc\..\b ?){2}}, result)
210
- end
211
-
212
- def test_inspect_pending
213
- fl = FileList['testdata/abc.*']
214
- result = fl.inspect
215
- assert_match(%r{"testdata/abc\.c"}, result)
216
- assert_match(%r{"testdata/abc\.h"}, result)
217
- assert_match(%r{"testdata/abc\.x"}, result)
218
- assert_match(%r|^\[("testdata/abc\..", ){2}"testdata/abc\.."\]$|, result)
219
- end
220
-
221
- def test_sub
222
- fl = FileList["testdata/*.c"]
223
- f2 = fl.sub(/\.c$/, ".o")
224
- assert_equal FileList, f2.class
225
- assert_equal ["testdata/abc.o", "testdata/x.o", "testdata/xyz.o"].sort,
226
- f2.sort
227
- f3 = fl.gsub(/\.c$/, ".o")
228
- assert_equal FileList, f3.class
229
- assert_equal ["testdata/abc.o", "testdata/x.o", "testdata/xyz.o"].sort,
230
- f3.sort
231
- end
232
-
233
- def test_claim_to_be_a_kind_of_array
234
- fl = FileList['testdata/*.c']
235
- assert fl.is_a?(Array)
236
- assert fl.kind_of?(Array)
237
- end
238
-
239
- def test_claim_to_be_a_kind_of_filelist
240
- fl = FileList['testdata/*.c']
241
- assert fl.is_a?(FileList)
242
- assert fl.kind_of?(FileList)
243
- end
244
-
245
- def test_claim_to_be_a_filelist_instance
246
- fl = FileList['testdata/*.c']
247
- assert fl.instance_of?(FileList)
248
- end
249
-
250
- def test_dont_claim_to_be_an_array_instance
251
- fl = FileList['testdata/*.c']
252
- assert ! fl.instance_of?(Array)
253
- end
254
-
255
- def test_sub!
256
- f = "x/a.c"
257
- fl = FileList[f, "x/b.c"]
258
- res = fl.sub!(/\.c$/, ".o")
259
- assert_equal ["x/a.o", "x/b.o"].sort, fl.sort
260
- assert_equal "x/a.c", f
261
- assert_equal fl.object_id, res.object_id
262
- end
263
-
264
- def test_sub_with_block
265
- fl = FileList["src/org/onestepback/a.java", "src/org/onestepback/b.java"]
266
- # The block version doesn't work the way I want it to ...
267
- # f2 = fl.sub(%r{^src/(.*)\.java$}) { |x| "classes/" + $1 + ".class" }
268
- f2 = fl.sub(%r{^src/(.*)\.java$}, "classes/\\1.class")
269
- assert_equal [
270
- "classes/org/onestepback/a.class",
271
- "classes/org/onestepback/b.class"
272
- ].sort,
273
- f2.sort
274
- end
275
-
276
- def test_string_ext
277
- assert_equal "one.net", "one.two".ext("net")
278
- assert_equal "one.net", "one.two".ext(".net")
279
- assert_equal "one.net", "one".ext("net")
280
- assert_equal "one.net", "one".ext(".net")
281
- assert_equal "one.two.net", "one.two.c".ext(".net")
282
- assert_equal "one/two.net", "one/two.c".ext(".net")
283
- assert_equal "one.x/two.net", "one.x/two.c".ext(".net")
284
- assert_equal "one.x/two.net", "one.x/two".ext(".net")
285
- assert_equal ".onerc.net", ".onerc.dot".ext("net")
286
- assert_equal ".onerc.net", ".onerc".ext("net")
287
- assert_equal ".a/.onerc.net", ".a/.onerc".ext("net")
288
- assert_equal "one", "one.two".ext('')
289
- assert_equal "one", "one.two".ext
290
- assert_equal ".one", ".one.two".ext
291
- assert_equal ".one", ".one".ext
292
- assert_equal ".", ".".ext("c")
293
- assert_equal "..", "..".ext("c")
294
- # These only need to work in windows
295
- if Rake::Win32.windows?
296
- assert_equal "one.x\\two.net", "one.x\\two.c".ext(".net")
297
- assert_equal "one.x\\two.net", "one.x\\two".ext(".net")
298
- end
299
- end
300
-
301
- def test_filelist_ext
302
- assert_equal FileList['one.c', '.one.c'],
303
- FileList['one.net', '.one'].ext('c')
304
- end
305
-
306
- def test_gsub
307
- create_test_data
308
- fl = FileList["testdata/*.c"]
309
- f2 = fl.gsub(/a/, "A")
310
- assert_equal ["testdAtA/Abc.c", "testdAtA/x.c", "testdAtA/xyz.c"].sort,
311
- f2.sort
312
- end
313
-
314
- def test_gsub!
315
- create_test_data
316
- f = FileList["testdata/*.c"]
317
- f.gsub!(/a/, "A")
318
- assert_equal ["testdAtA/Abc.c", "testdAtA/x.c", "testdAtA/xyz.c"].sort,
319
- f.sort
320
- end
321
-
322
- def test_egrep_returns_0_if_no_matches
323
- files = FileList['test/lib/*_test.rb'].exclude("test/lib/filelist_test.rb")
324
- assert_equal 0, files.egrep(/XYZZY/) { }
325
- end
326
-
327
- def test_egrep_with_output
328
- files = FileList['test/test_*.rb']
329
- the_line_number = __LINE__ + 1
330
- out, = capture_io do files.egrep(/PUGH/) end
331
- assert_match(/:#{the_line_number}:/, out)
332
- end
333
-
334
- def test_egrep_with_block
335
- files = FileList['test/test_*.rb']
336
- found = nil
337
- the_line_number = __LINE__ + 1
338
- files.egrep(/XYZZY/) do |fn, ln, line |
339
- found = [fn, ln, line]
340
- end
341
- assert_equal 'test/test_rake_file_list.rb', found[0]
342
- assert_equal the_line_number, found[1]
343
- assert_match(/files\.egrep/, found[2])
344
- end
345
-
346
- def test_egrep_with_error
347
- files = FileList['test/test_*.rb']
348
- _, err = capture_io do
349
- files.egrep(/ANYTHING/) do |fn, ln, line |
350
- fail "_EGREP_FAILURE_"
351
- end
352
- end
353
- assert_match(/_EGREP_FAILURE_/, err)
354
- end
355
-
356
- def test_existing
357
- fl = FileList['testdata/abc.c', 'testdata/notthere.c']
358
- assert_equal ["testdata/abc.c"], fl.existing
359
- assert fl.existing.is_a?(FileList)
360
- end
361
-
362
- def test_existing!
363
- fl = FileList['testdata/abc.c', 'testdata/notthere.c']
364
- result = fl.existing!
365
- assert_equal ["testdata/abc.c"], fl
366
- assert_equal fl.object_id, result.object_id
367
- end
368
-
369
- def test_ignore_special
370
- f = FileList['testdata/*']
371
- assert ! f.include?("testdata/CVS"), "Should not contain CVS"
372
- assert ! f.include?("testdata/.svn"), "Should not contain .svn"
373
- assert ! f.include?("testdata/.dummy"), "Should not contain dot files"
374
- assert ! f.include?("testdata/x.bak"), "Should not contain .bak files"
375
- assert ! f.include?("testdata/x~"), "Should not contain ~ files"
376
- assert ! f.include?("testdata/core"), "Should not contain core files"
377
- end
378
-
379
- def test_clear_ignore_patterns
380
- f = FileList['testdata/*', 'testdata/.svn']
381
- f.clear_exclude
382
- assert f.include?("testdata/abc.c")
383
- assert f.include?("testdata/xyz.c")
384
- assert f.include?("testdata/CVS")
385
- assert f.include?("testdata/.svn")
386
- assert f.include?("testdata/x.bak")
387
- assert f.include?("testdata/x~")
388
- end
389
-
390
- def test_exclude_with_alternate_file_seps
391
- fl = FileList.new
392
- assert fl.exclude?("x/CVS/y")
393
- assert fl.exclude?("x\\CVS\\y")
394
- assert fl.exclude?("x/.svn/y")
395
- assert fl.exclude?("x\\.svn\\y")
396
- assert fl.exclude?("x/core")
397
- assert fl.exclude?("x\\core")
398
- end
399
-
400
- def test_add_default_exclude_list
401
- fl = FileList.new
402
- fl.exclude(/~\d+$/)
403
- assert fl.exclude?("x/CVS/y")
404
- assert fl.exclude?("x\\CVS\\y")
405
- assert fl.exclude?("x/.svn/y")
406
- assert fl.exclude?("x\\.svn\\y")
407
- assert fl.exclude?("x/core")
408
- assert fl.exclude?("x\\core")
409
- assert fl.exclude?("x/abc~1")
410
- end
411
-
412
- def test_basic_array_functions
413
- f = FileList['b', 'c', 'a']
414
- assert_equal 'b', f.first
415
- assert_equal 'b', f[0]
416
- assert_equal 'a', f.last
417
- assert_equal 'a', f[2]
418
- assert_equal 'a', f[-1]
419
- assert_equal ['a', 'b', 'c'], f.sort
420
- f.sort!
421
- assert_equal ['a', 'b', 'c'], f
422
- end
423
-
424
- def test_flatten
425
- assert_equal ['a', 'testdata/x.c', 'testdata/xyz.c', 'testdata/abc.c'].sort,
426
- ['a', FileList['testdata/*.c']].flatten.sort
427
- end
428
-
429
- def test_clone_and_dup
430
- a = FileList['a', 'b', 'c']
431
- c = a.clone
432
- d = a.dup
433
- a << 'd'
434
- assert_equal ['a', 'b', 'c', 'd'], a
435
- assert_equal ['a', 'b', 'c'], c
436
- assert_equal ['a', 'b', 'c'], d
437
- end
438
-
439
- def test_dup_and_clone_replicate_taint
440
- a = FileList['a', 'b', 'c']
441
- a.taint
442
- c = a.clone
443
- d = a.dup
444
- assert c.tainted?, "Clone should be tainted"
445
- assert d.tainted?, "Dup should be tainted"
446
- end
447
-
448
- def test_duped_items_will_thaw
449
- a = FileList['a', 'b', 'c']
450
- a.freeze
451
- d = a.dup
452
- d << 'more'
453
- assert_equal ['a', 'b', 'c', 'more'], d
454
- end
455
-
456
- def test_cloned_items_stay_frozen
457
- a = FileList['a', 'b', 'c']
458
- a.freeze
459
- c = a.clone
460
- assert_raises(TypeError, RuntimeError) do
461
- c << 'more'
462
- end
463
- end
464
-
465
- def test_array_comparisons
466
- fl = FileList['b', 'b']
467
- a = ['b', 'a']
468
- b = ['b', 'b']
469
- c = ['b', 'c']
470
- assert_equal( 1, fl <=> a )
471
- assert_equal( 0, fl <=> b )
472
- assert_equal( -1, fl <=> c )
473
- assert_equal( -1, a <=> fl )
474
- assert_equal( 0, b <=> fl )
475
- assert_equal( 1, c <=> fl )
476
- end
477
-
478
- def test_array_equality
479
- a = FileList['a', 'b']
480
- b = ['a', 'b']
481
- assert a == b
482
- assert b == a
483
- # assert a.eql?(b)
484
- # assert b.eql?(a)
485
- assert ! a.equal?(b)
486
- assert ! b.equal?(a)
487
- end
488
-
489
- def test_enumeration_methods
490
- a = FileList['a', 'b']
491
- b = a.collect { |it| it.upcase }
492
- assert_equal ['A', 'B'], b
493
- assert_equal FileList, b.class
494
-
495
- b = a.map { |it| it.upcase }
496
- assert_equal ['A', 'B'], b
497
- assert_equal FileList, b.class
498
-
499
- b = a.sort
500
- assert_equal ['a', 'b'], b
501
- assert_equal FileList, b.class
502
-
503
- b = a.sort_by { |it| it }
504
- assert_equal ['a', 'b'], b
505
- assert_equal FileList, b.class
506
-
507
- b = a.find_all { |it| it == 'b'}
508
- assert_equal ['b'], b
509
- assert_equal FileList, b.class
510
-
511
- b = a.select { |it| it.size == 1 }
512
- assert_equal ['a', 'b'], b
513
- assert_equal FileList, b.class
514
-
515
- b = a.reject { |it| it == 'b' }
516
- assert_equal ['a'], b
517
- assert_equal FileList, b.class
518
-
519
- b = a.grep(/./)
520
- assert_equal ['a', 'b'], b
521
- assert_equal FileList, b.class
522
-
523
- b = a.partition { |it| it == 'b' }
524
- assert_equal [['b'], ['a']], b
525
- assert_equal Array, b.class
526
- assert_equal FileList, b[0].class
527
- assert_equal FileList, b[1].class
528
-
529
- b = a.zip(['x', 'y']).to_a
530
- assert_equal [['a', 'x'], ['b', 'y']], b
531
- assert_equal Array, b.class
532
- assert_equal Array, b[0].class
533
- assert_equal Array, b[1].class
534
- end
535
-
536
- def test_array_operators
537
- a = ['a', 'b']
538
- b = ['c', 'd']
539
- f = FileList['x', 'y']
540
- g = FileList['w', 'z']
541
-
542
- r = f + g
543
- assert_equal ['x', 'y', 'w', 'z'], r
544
- assert_equal FileList, r.class
545
-
546
- r = a + g
547
- assert_equal ['a', 'b', 'w', 'z'], r
548
- assert_equal Array, r.class
549
-
550
- r = f + b
551
- assert_equal ['x', 'y', 'c', 'd'], r
552
- assert_equal FileList, r.class
553
-
554
- r = FileList['w', 'x', 'y', 'z'] - f
555
- assert_equal ['w', 'z'], r
556
- assert_equal FileList, r.class
557
-
558
- r = FileList['w', 'x', 'y', 'z'] & f
559
- assert_equal ['x', 'y'], r
560
- assert_equal FileList, r.class
561
-
562
- r = f * 2
563
- assert_equal ['x', 'y', 'x', 'y'], r
564
- assert_equal FileList, r.class
565
-
566
- r = f * ','
567
- assert_equal 'x,y', r
568
- assert_equal String, r.class
569
-
570
- r = f | ['a', 'x']
571
- assert_equal ['a', 'x', 'y'].sort, r.sort
572
- assert_equal FileList, r.class
573
- end
574
-
575
- def test_other_array_returning_methods
576
- f = FileList['a', nil, 'b']
577
- r = f.compact
578
- assert_equal ['a', 'b'], r
579
- assert_equal FileList, r.class
580
-
581
- f = FileList['a', 'b']
582
- r = f.concat(['x', 'y'])
583
- assert_equal ['a', 'b', 'x', 'y'], r
584
- assert_equal FileList, r.class
585
-
586
- f = FileList['a', ['b', 'c'], FileList['d', 'e']]
587
- r = f.flatten
588
- assert_equal ['a', 'b', 'c', 'd', 'e'], r
589
- assert_equal FileList, r.class
590
-
591
- f = FileList['a', 'b', 'a']
592
- r = f.uniq
593
- assert_equal ['a', 'b'], r
594
- assert_equal FileList, r.class
595
-
596
- f = FileList['a', 'b', 'c', 'd']
597
- r = f.values_at(1,3)
598
- assert_equal ['b', 'd'], r
599
- assert_equal FileList, r.class
600
- end
601
-
602
- def test_file_utils_can_use_filelists
603
- cfiles = FileList['testdata/*.c']
604
-
605
- cp cfiles, @cdir, :verbose => false
606
-
607
- assert File.exist?(File.join(@cdir, 'abc.c'))
608
- assert File.exist?(File.join(@cdir, 'xyz.c'))
609
- assert File.exist?(File.join(@cdir, 'x.c'))
610
- end
611
-
612
- def create_test_data
613
- verbose(false) do
614
-
615
- mkdir "testdata" unless File.exist? "testdata"
616
- mkdir "testdata/CVS" rescue nil
617
- mkdir "testdata/.svn" rescue nil
618
- @cdir = "testdata/cfiles"
619
- mkdir @cdir rescue nil
620
- touch "testdata/.dummy"
621
- touch "testdata/x.bak"
622
- touch "testdata/x~"
623
- touch "testdata/core"
624
- touch "testdata/x.c"
625
- touch "testdata/xyz.c"
626
- touch "testdata/abc.c"
627
- touch "testdata/abc.h"
628
- touch "testdata/abc.x"
629
- touch "testdata/existing"
630
- end
631
- end
632
-
633
- end