tap 0.7.9 → 0.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (149) hide show
  1. data/History +28 -0
  2. data/MIT-LICENSE +1 -1
  3. data/README +71 -43
  4. data/Rakefile +81 -64
  5. data/Tutorial +235 -0
  6. data/bin/tap +80 -44
  7. data/lib/tap.rb +41 -12
  8. data/lib/tap/app.rb +243 -246
  9. data/lib/tap/file_task.rb +357 -118
  10. data/lib/tap/generator.rb +88 -29
  11. data/lib/tap/generator/generators/config/config_generator.rb +4 -2
  12. data/lib/tap/generator/generators/config/templates/config.erb +1 -2
  13. data/lib/tap/generator/generators/file_task/file_task_generator.rb +3 -18
  14. data/lib/tap/generator/generators/file_task/templates/task.erb +22 -15
  15. data/lib/tap/generator/generators/file_task/templates/test.erb +13 -2
  16. data/{test/test/inference_methods/test_assert_files_exist/input/input_1.txt → lib/tap/generator/generators/generator/USAGE} +0 -0
  17. data/lib/tap/generator/generators/generator/generator_generator.rb +21 -0
  18. data/lib/tap/generator/generators/generator/templates/generator.erb +23 -0
  19. data/lib/tap/generator/generators/generator/templates/usage.erb +1 -0
  20. data/{test/test/inference_methods/test_assert_files_exist/input/input_2.txt → lib/tap/generator/generators/package/USAGE} +0 -0
  21. data/lib/tap/generator/generators/package/package_generator.rb +38 -0
  22. data/lib/tap/generator/generators/package/templates/package.erb +186 -0
  23. data/lib/tap/generator/generators/root/root_generator.rb +14 -9
  24. data/lib/tap/generator/generators/root/templates/Rakefile +20 -14
  25. data/{test/test/inference_methods/test_infer_glob/expected/file.yml → lib/tap/generator/generators/root/templates/ReadMe.txt} +0 -0
  26. data/lib/tap/generator/generators/root/templates/tap.yml +82 -0
  27. data/lib/tap/generator/generators/root/templates/test/tap_test_helper.rb +0 -1
  28. data/lib/tap/generator/generators/root/templates/test/tap_test_suite.rb +2 -1
  29. data/{test/test/inference_methods/test_infer_glob/expected/file_1.txt → lib/tap/generator/generators/script/USAGE} +0 -0
  30. data/lib/tap/generator/generators/script/script_generator.rb +17 -0
  31. data/lib/tap/generator/generators/script/templates/script.erb +42 -0
  32. data/lib/tap/generator/generators/task/task_generator.rb +1 -1
  33. data/lib/tap/generator/generators/task/templates/task.erb +24 -16
  34. data/lib/tap/generator/generators/task/templates/test.erb +13 -17
  35. data/lib/tap/generator/generators/workflow/templates/task.erb +10 -10
  36. data/lib/tap/generator/generators/workflow/templates/test.erb +1 -1
  37. data/lib/tap/generator/generators/workflow/workflow_generator.rb +3 -18
  38. data/lib/tap/root.rb +108 -146
  39. data/lib/tap/script.rb +362 -0
  40. data/lib/tap/script/console.rb +28 -0
  41. data/lib/tap/script/destroy.rb +13 -1
  42. data/lib/tap/script/generate.rb +13 -1
  43. data/lib/tap/script/run.rb +100 -57
  44. data/lib/tap/support/batch_queue.rb +0 -3
  45. data/lib/tap/support/logger.rb +6 -3
  46. data/lib/tap/support/rake.rb +54 -0
  47. data/lib/tap/support/task_configuration.rb +169 -0
  48. data/lib/tap/support/tdoc.rb +198 -0
  49. data/lib/tap/support/tdoc/config_attr.rb +338 -0
  50. data/lib/tap/support/tdoc/tdoc_html_generator.rb +38 -0
  51. data/lib/tap/support/tdoc/tdoc_html_template.rb +42 -0
  52. data/lib/tap/support/versions.rb +33 -1
  53. data/lib/tap/task.rb +339 -227
  54. data/lib/tap/test.rb +86 -128
  55. data/lib/tap/test/env_vars.rb +16 -5
  56. data/lib/tap/test/file_methods.rb +373 -0
  57. data/lib/tap/test/subset_methods.rb +299 -180
  58. data/lib/tap/version.rb +2 -1
  59. data/lib/tap/workflow.rb +2 -0
  60. data/test/app/lib/app_test_task.rb +1 -0
  61. data/test/app_test.rb +327 -83
  62. data/test/check/binding_eval.rb +23 -0
  63. data/test/check/define_method_check.rb +22 -0
  64. data/test/check/dependencies_check.rb +175 -0
  65. data/test/check/inheritance_check.rb +22 -0
  66. data/test/file_task_test.rb +524 -291
  67. data/test/{test/inference_methods/test_infer_glob/expected/file_2.txt → root/glob/one.txt} +0 -0
  68. data/test/root/glob/two.txt +0 -0
  69. data/test/root_test.rb +330 -262
  70. data/test/script_test.rb +194 -0
  71. data/test/support/audit_test.rb +5 -2
  72. data/test/support/combinator_test.rb +10 -10
  73. data/test/support/rake_test.rb +35 -0
  74. data/test/support/task_configuration_test.rb +272 -0
  75. data/test/support/tdoc_test.rb +363 -0
  76. data/test/support/templater_test.rb +2 -2
  77. data/test/support/versions_test.rb +32 -0
  78. data/test/tap_test_helper.rb +39 -0
  79. data/test/task_base_test.rb +115 -0
  80. data/test/task_class_test.rb +56 -4
  81. data/test/task_execute_test.rb +29 -0
  82. data/test/task_test.rb +89 -70
  83. data/test/test/env_vars_test.rb +48 -0
  84. data/test/test/{inference_methods → file_methods}/test_assert_expected/expected/file.txt +0 -0
  85. data/test/test/{inference_methods → file_methods}/test_assert_expected/expected/folder/file.txt +0 -0
  86. data/test/test/{inference_methods → file_methods}/test_assert_expected/input/file.txt +0 -0
  87. data/test/test/{inference_methods → file_methods}/test_assert_expected/input/folder/file.txt +0 -0
  88. data/test/test/file_methods/test_assert_files_exist/input/input_1.txt +0 -0
  89. data/test/test/file_methods/test_assert_files_exist/input/input_2.txt +0 -0
  90. data/test/test/file_methods/test_assert_output_files_equal/expected/one.txt +1 -0
  91. data/test/test/file_methods/test_assert_output_files_equal/expected/two.txt +1 -0
  92. data/test/test/file_methods/test_assert_output_files_equal/input/one.txt +1 -0
  93. data/test/test/file_methods/test_assert_output_files_equal/input/two.txt +1 -0
  94. data/test/test/{inference_methods → file_methods}/test_file_compare/expected/output_1.txt +0 -0
  95. data/test/test/{inference_methods → file_methods}/test_file_compare/expected/output_2.txt +0 -0
  96. data/test/test/{inference_methods → file_methods}/test_file_compare/input/input_1.txt +0 -0
  97. data/test/test/{inference_methods → file_methods}/test_file_compare/input/input_2.txt +0 -0
  98. data/test/test/file_methods/test_infer_glob/expected/file.yml +0 -0
  99. data/test/test/file_methods/test_infer_glob/expected/file_1.txt +0 -0
  100. data/test/test/file_methods/test_infer_glob/expected/file_2.txt +0 -0
  101. data/test/test/file_methods/test_method_glob/expected/file.yml +0 -0
  102. data/test/test/file_methods/test_method_glob/expected/file_1.txt +0 -0
  103. data/test/test/file_methods/test_method_glob/expected/file_2.txt +0 -0
  104. data/test/test/{inference_methods → file_methods}/test_yml_compare/expected/output_1.yml +0 -0
  105. data/test/test/{inference_methods → file_methods}/test_yml_compare/expected/output_2.yml +0 -0
  106. data/test/test/{inference_methods → file_methods}/test_yml_compare/input/input_1.yml +0 -0
  107. data/test/test/{inference_methods → file_methods}/test_yml_compare/input/input_2.yml +0 -0
  108. data/test/test/file_methods_test.rb +204 -0
  109. data/test/test/subset_methods_test.rb +93 -33
  110. data/test/test/test_assert_expected_result_files/expected/task/name/a.txt +1 -0
  111. data/test/test/test_assert_expected_result_files/expected/task/name/b.txt +1 -0
  112. data/test/test/test_assert_expected_result_files/input/a.txt +1 -0
  113. data/test/test/test_assert_expected_result_files/input/b.txt +1 -0
  114. data/test/test/test_file_task_test/expected/one.txt +1 -0
  115. data/test/test/test_file_task_test/expected/two.txt +1 -0
  116. data/test/test/test_file_task_test/input/one.txt +1 -0
  117. data/test/test/test_file_task_test/input/two.txt +1 -0
  118. data/test/test_test.rb +143 -3
  119. data/test/workflow_test.rb +2 -0
  120. data/vendor/rails_generator.rb +56 -0
  121. data/vendor/rails_generator/base.rb +263 -0
  122. data/vendor/rails_generator/commands.rb +581 -0
  123. data/vendor/rails_generator/generated_attribute.rb +42 -0
  124. data/vendor/rails_generator/lookup.rb +209 -0
  125. data/vendor/rails_generator/manifest.rb +53 -0
  126. data/vendor/rails_generator/options.rb +143 -0
  127. data/vendor/rails_generator/scripts.rb +83 -0
  128. data/vendor/rails_generator/scripts/destroy.rb +7 -0
  129. data/vendor/rails_generator/scripts/generate.rb +7 -0
  130. data/vendor/rails_generator/scripts/update.rb +12 -0
  131. data/vendor/rails_generator/simple_logger.rb +46 -0
  132. data/vendor/rails_generator/spec.rb +44 -0
  133. metadata +180 -196
  134. data/lib/tap/generator/generators/root/templates/app.yml +0 -19
  135. data/lib/tap/generator/generators/root/templates/config/process_tap_request.yml +0 -4
  136. data/lib/tap/generator/generators/root/templates/lib/process_tap_request.rb +0 -26
  137. data/lib/tap/generator/generators/root/templates/public/images/nav.jpg +0 -0
  138. data/lib/tap/generator/generators/root/templates/public/stylesheets/color.css +0 -57
  139. data/lib/tap/generator/generators/root/templates/public/stylesheets/layout.css +0 -108
  140. data/lib/tap/generator/generators/root/templates/public/stylesheets/normalize.css +0 -40
  141. data/lib/tap/generator/generators/root/templates/public/stylesheets/typography.css +0 -21
  142. data/lib/tap/generator/generators/root/templates/server/config/environment.rb +0 -60
  143. data/lib/tap/generator/generators/root/templates/server/lib/tasks/clear_database_prerequisites.rake +0 -5
  144. data/lib/tap/generator/generators/root/templates/server/test/test_helper.rb +0 -53
  145. data/lib/tap/script/server.rb +0 -12
  146. data/lib/tap/support/rap.rb +0 -38
  147. data/lib/tap/test/inference_methods.rb +0 -298
  148. data/test/task/config/task_with_config.yml +0 -1
  149. data/test/test/inference_methods_test.rb +0 -311
@@ -0,0 +1,23 @@
1
+ # this checks to see that you can unset and reset
2
+ # constants and retain the functionality of the
3
+ # constant.
4
+
5
+ module TestMod
6
+ CONST = 1
7
+
8
+ module_function
9
+
10
+ def function
11
+ puts "in function"
12
+ end
13
+ end
14
+
15
+ class Object
16
+ old_ruby_token = remove_const(:TestMod)
17
+ const_set(:NewName, old_ruby_token )
18
+ end
19
+
20
+ puts NewName::CONST
21
+ puts NewName.function
22
+
23
+ puts "done"
@@ -0,0 +1,22 @@
1
+ require 'test/unit'
2
+
3
+ class ClassConfigurationTest < Test::Unit::TestCase
4
+ class A
5
+ class << self
6
+ def define_class_defined_method
7
+ define_method('class_defined_method') do
8
+ self
9
+ end
10
+ end
11
+ end
12
+
13
+ define_class_defined_method
14
+ end
15
+
16
+ def test_self_in_define_method
17
+ a = A.new
18
+
19
+ assert a.respond_to?(:class_defined_method)
20
+ assert_equal a, a.class_defined_method
21
+ end
22
+ end
@@ -0,0 +1,175 @@
1
+ require 'active_support'
2
+ require 'fileutils'
3
+ require 'test/unit'
4
+
5
+ class DependenciesCheck < Test::Unit::TestCase
6
+
7
+ def teardown
8
+ FileUtils.rm_r(dep_dir)
9
+ end
10
+
11
+ def dep_dir
12
+ File.join( File.dirname(__FILE__), "dependencies" )
13
+ end
14
+
15
+ #
16
+ # make files
17
+ #
18
+
19
+ def filepath(class_name)
20
+ File.join(dep_dir, class_name.underscore + ".rb")
21
+ end
22
+
23
+ def make_file(class_name, content)
24
+ path = filepath(class_name)
25
+ FileUtils.mkdir(File.dirname(path)) unless File.exists?(File.dirname(path))
26
+ File.open(path, "w") do |file|
27
+ file << content
28
+ end
29
+ class_name.underscore
30
+ end
31
+
32
+ def make_module_file(class_name)
33
+ make_file class_name, %Q{
34
+ module #{class_name.camelize}
35
+ end}
36
+ end
37
+
38
+ def make_unloadable_file(class_name)
39
+ make_file class_name, %Q{
40
+ module #{class_name.camelize}
41
+ unloadable
42
+ end}
43
+ end
44
+
45
+ #
46
+ # dependencies check
47
+ #
48
+
49
+ def test_dependencies
50
+ pre_load = make_module_file "PreLoad"
51
+ pre_load_unloadable = make_unloadable_file "PreLoadUnloadable"
52
+ pre_loader = make_file("PreLoader", "require 'pre_load_required'\nrequire 'pre_load_required_unloadable'")
53
+ pre_load_required = make_module_file "PreLoadRequired"
54
+ pre_load_required_unloadable = make_unloadable_file "PreLoadRequiredUnloadable"
55
+ pre_load_consts = ["PreLoad", "PreLoadUnloadable", "PreLoadRequired", "PreLoadRequiredUnloadable"]
56
+
57
+ post_load = make_module_file "PostLoad"
58
+ post_load_unloadable = make_unloadable_file "PostLoadUnloadable"
59
+ post_loader = make_file("PostLoader", "require 'post_load_required'\nrequire 'post_load_required_unloadable'")
60
+ post_load_required = make_module_file "PostLoadRequired"
61
+ post_load_required_unloadable = make_unloadable_file "PostLoadRequiredUnloadable"
62
+ post_load_consts = ["PostLoad", "PostLoadUnloadable", "PostLoadRequired", "PostLoadRequiredUnloadable"]
63
+
64
+ assert_equal 10, Dir.glob( File.join( dep_dir, "*") ).length
65
+
66
+ # can't load if not on load path
67
+ assert_raise(MissingSourceFile) do
68
+ require pre_load
69
+ end
70
+
71
+ $:.unshift dep_dir
72
+ assert_nothing_raised do
73
+ require pre_load
74
+ require pre_load_unloadable
75
+ require pre_loader
76
+ end
77
+
78
+ pre_load_consts.each {|const| assert Object.const_defined?(const)}
79
+ post_load_consts.each {|const| assert !Object.const_defined?(const)}
80
+
81
+ # now set Dependencies to load from dep_dir
82
+ Dependencies.load_paths << dep_dir
83
+
84
+ # PostLoad constants will be autoloaded as missing constants by Dependencies
85
+ assert PostLoad
86
+ assert PostLoadUnloadable
87
+ assert PostLoadRequired
88
+ assert PostLoadRequiredUnloadable
89
+
90
+ pre_load_consts.each {|const| assert Object.const_defined?(const)}
91
+ post_load_consts.each {|const| assert Object.const_defined?(const)}
92
+
93
+ # post load modules are cleared, and pre-unloadable modules.
94
+ # other modules are not cleared
95
+ Dependencies.clear
96
+
97
+ ["PreLoad", "PreLoadRequired"].each {|const| assert Object.const_defined?(const)}
98
+ ["PreLoadUnloadable", "PreLoadRequiredUnloadable"].each {|const| assert !Object.const_defined?(const)}
99
+ post_load_consts.each {|const| assert !Object.const_defined?(const)}
100
+
101
+ # calling the missing modules reloads them
102
+ assert PreLoadUnloadable
103
+ assert PreLoadRequiredUnloadable
104
+
105
+ assert PostLoad
106
+ assert PostLoadUnloadable
107
+ assert PostLoadRequired
108
+ assert PostLoadRequiredUnloadable
109
+
110
+ pre_load_consts.each {|const| assert Object.const_defined?(const)}
111
+ post_load_consts.each {|const| assert Object.const_defined?(const)}
112
+
113
+ # As before, post load modules should be cleared, and pre-unloadable modules
114
+ Dependencies.clear
115
+
116
+ ["PreLoad", "PreLoadRequired"].each {|const| assert Object.const_defined?(const)}
117
+ ["PreLoadUnloadable", "PreLoadRequiredUnloadable"].each {|const| assert !Object.const_defined?(const)}
118
+ post_load_consts.each {|const| assert !Object.const_defined?(const)}
119
+
120
+ # requiring files will NOT restore pre-loads by themselves...
121
+ # but it will restore post load requires, because they haven't
122
+ # been required yet
123
+ assert_nothing_raised do
124
+ require pre_load
125
+ require pre_load_unloadable
126
+ require pre_loader
127
+
128
+ require post_load
129
+ require post_load_unloadable
130
+ require post_loader
131
+ end
132
+
133
+ ["PreLoad", "PreLoadRequired"].each {|const| assert Object.const_defined?(const)}
134
+ ["PreLoadUnloadable", "PreLoadRequiredUnloadable"].each {|const| assert !Object.const_defined?(const)}
135
+ post_load_consts.each {|const| assert Object.const_defined?(const)}
136
+
137
+ # Now, ONLY unloadable modules will be cleared -- the others were loaded
138
+ # using require, and NOT Dependencies autoloading
139
+ Dependencies.clear
140
+
141
+ ["PreLoad", "PreLoadRequired"].each {|const| assert Object.const_defined?(const)}
142
+ ["PreLoadUnloadable", "PreLoadRequiredUnloadable"].each {|const| assert !Object.const_defined?(const)}
143
+ ["PostLoad", "PostLoadRequired"].each {|const| assert Object.const_defined?(const)}
144
+ ["PostLoadUnloadable", "PostLoadRequiredUnloadable"].each {|const| assert !Object.const_defined?(const)}
145
+
146
+ # Now, requiring files will NOT restore any modules because
147
+ # the files have already been required
148
+ assert_nothing_raised do
149
+ require pre_load
150
+ require pre_load_unloadable
151
+ require pre_loader
152
+
153
+ require post_load
154
+ require post_load_unloadable
155
+ require post_loader
156
+ end
157
+
158
+ ["PreLoad", "PreLoadRequired"].each {|const| assert Object.const_defined?(const)}
159
+ ["PreLoadUnloadable", "PreLoadRequiredUnloadable"].each {|const| assert !Object.const_defined?(const)}
160
+ ["PostLoad", "PostLoadRequired"].each {|const| assert Object.const_defined?(const)}
161
+ ["PostLoadUnloadable", "PostLoadRequiredUnloadable"].each {|const| assert !Object.const_defined?(const)}
162
+
163
+ # but again... calling the missing modules reloads them, so even
164
+ # though the require doesn't work, you shold be good because you
165
+ # won't be accessing the module without calling it. (right?)
166
+ assert PreLoadUnloadable
167
+ assert PreLoadRequiredUnloadable
168
+ assert PostLoadUnloadable
169
+ assert PostLoadRequiredUnloadable
170
+
171
+ pre_load_consts.each {|const| assert Object.const_defined?(const)}
172
+ post_load_consts.each {|const| assert Object.const_defined?(const)}
173
+ end
174
+
175
+ end
@@ -0,0 +1,22 @@
1
+ require 'active_support'
2
+ require 'test/unit'
3
+
4
+ class ClassConfigurationTest < Test::Unit::TestCase
5
+ class A
6
+ write_inheritable_attribute(:hash, {})
7
+ class_inheritable_reader(:hash)
8
+
9
+ self.hash[:one] = 'one'
10
+ end
11
+
12
+ class B < A
13
+ self.hash[:one] = 1
14
+ end
15
+
16
+ def test_inheritance
17
+ assert_not_equal A.hash, B.hash
18
+
19
+ assert_equal 'one', A.hash[:one]
20
+ assert_equal 1, B.hash[:one]
21
+ end
22
+ end
@@ -21,20 +21,134 @@ class FileTaskTest < Test::Unit::TestCase
21
21
  end
22
22
 
23
23
  def test_touch_file
24
- non_existant_file = infer_filepath(:output, "non_existant_file.txt")
24
+ non_existant_file = method_filepath(:output, "non_existant_file.txt")
25
25
  assert !File.exists?(non_existant_file)
26
26
  touch_file(non_existant_file)
27
27
  assert File.exists?(non_existant_file)
28
28
  assert File.file?(non_existant_file)
29
29
  assert_equal "", File.read(non_existant_file)
30
30
 
31
- non_existant_file = infer_filepath(:output, "non_existant_file2.txt")
31
+ non_existant_file = method_filepath(:output, "non_existant_file2.txt")
32
32
  assert !File.exists?(non_existant_file)
33
33
  touch_file(non_existant_file, "content")
34
34
  assert File.exists?(non_existant_file)
35
35
  assert File.file?(non_existant_file)
36
36
  assert_equal "content", File.read(non_existant_file)
37
37
  end
38
+
39
+ #
40
+ # doc tests
41
+ #
42
+
43
+ def test_documentation
44
+ file_one = method_filepath(:output, "file.txt")
45
+ file_two = method_filepath(:output, "path/to/file.txt")
46
+ dir = method_filepath(:output, "some/dir")
47
+ FileUtils.mkdir_p( method_filepath(:output) )
48
+
49
+ File.open(file_one, "w") {|f| f << "original content"}
50
+ t = Tap::FileTask.new do |task, inputs|
51
+ task.mkdir(dir)
52
+ task.prepare([file_one, file_two])
53
+
54
+ File.open(file_one, "w") {|f| f << "new content"}
55
+ FileUtils.touch(file_two)
56
+
57
+ raise "error!"
58
+ end
59
+
60
+ begin
61
+ assert !File.exists?(dir)
62
+ assert !File.exists?(file_two)
63
+ t.execute(nil)
64
+ flunk "no error raised"
65
+ rescue
66
+ assert_equal "error!", $!.message
67
+ assert !File.exists?(dir)
68
+ assert !File.exists?(file_two)
69
+ assert_equal "original content", File.read(file_one)
70
+ end
71
+ end
72
+
73
+ #
74
+ # open tests
75
+ #
76
+
77
+ def test_open_doc
78
+ FileUtils.mkdir_p(method_filepath(:output))
79
+ one_filepath = method_filepath(:output, "one.txt")
80
+ two_filepath = method_filepath(:output, "two.txt")
81
+
82
+ Tap::FileTask.open([one_filepath, two_filepath], "w") do |one, two|
83
+ one << "one"
84
+ two << "two"
85
+ end
86
+
87
+ assert_equal "one", File.read(one_filepath)
88
+ assert_equal "two", File.read(two_filepath)
89
+
90
+ #
91
+ filepath = method_filepath(:output, "file.txt")
92
+ Tap::FileTask.open(filepath, "w") do |array|
93
+ array.first << "content"
94
+ end
95
+
96
+ assert_equal "content", File.read(filepath)
97
+ end
98
+
99
+ def test_open_opens_each_file
100
+ FileUtils.mkdir_p(method_filepath(:output))
101
+
102
+ list = [0, 1].collect do |n|
103
+ path = method_filepath(:output, "#{n}.txt")
104
+ File.open(path, "w") {|f| f << n.to_s}
105
+ path
106
+ end
107
+
108
+ Tap::FileTask.open(list) do |files|
109
+ files.each_with_index do |file, n|
110
+ assert_equal File, file.class
111
+ assert_equal n.to_s, file.read
112
+ end
113
+ end
114
+ end
115
+
116
+ def test_open_opens_with_input_mode
117
+ FileUtils.mkdir_p(method_filepath(:output))
118
+
119
+ list = [0, 1].collect do |n|
120
+ path = method_filepath(:output, "#{n}.txt")
121
+ path
122
+ end
123
+
124
+ Tap::FileTask.open(list, "w") do |files|
125
+ files.each_with_index do |file, n|
126
+ assert_equal File, file.class
127
+ file << n.to_s
128
+ end
129
+ end
130
+
131
+ list.each_with_index do |file, n|
132
+ assert_equal n.to_s, File.read(file)
133
+ end
134
+ end
135
+
136
+ def test_open_returns_open_files_if_no_block_is_given
137
+ FileUtils.mkdir_p(method_filepath(:output))
138
+
139
+ list = [0, 1].collect do |n|
140
+ path = method_filepath(:output, "#{n}.txt")
141
+ File.open(path, "w") {|f| f << n.to_s}
142
+ path
143
+ end
144
+
145
+ open_files = Tap::FileTask.open(list)
146
+ open_files.each_with_index do |file, n|
147
+ assert_equal File, file.class
148
+ assert_equal n.to_s, file.read
149
+ file.close
150
+ end
151
+ end
38
152
 
39
153
  #
40
154
  # dirname tests
@@ -72,54 +186,64 @@ class FileTaskTest < Test::Unit::TestCase
72
186
  end
73
187
 
74
188
  #
75
- # infer_filepath tests
189
+ # filepath tests
76
190
  #
77
191
 
78
- def test_infer_filepath_passes_app_dir_dirname_and_path_to_block
192
+ def test_filepath_passes_app_dir_dirname_and_path_to_block
79
193
  t.inference do |root, dir, path|
80
194
  [root, dir, path]
81
195
  end
82
196
 
83
197
  assert_equal "tap/file_task", t.dirname
84
- assert_equal [app[:dir], "tap/file_task", "path"], t.infer_filepath(:dir, "path")
198
+ assert_equal [app[:dir], "tap/file_task", "path"], t.filepath(:dir, "path")
85
199
  end
86
200
 
87
- def test_infer_filepath_with_multiple_paths
201
+ def test_filepath_with_multiple_paths
88
202
  t.inference do |root, dir, *paths|
89
203
  [root, dir, paths]
90
204
  end
91
- assert_equal [app[:dir], "tap/file_task", ["path", "to", "file"]], t.infer_filepath(:dir, "path", "to", "file")
205
+ assert_equal [app[:dir], "tap/file_task", ["path", "to", "file"]], t.filepath(:dir, "path", "to", "file")
92
206
  end
93
207
 
94
- def test_infer_filepath_with_multiple_paths_but_single_path_given
208
+ def test_filepath_with_multiple_paths_but_single_path_given
95
209
  t.inference do |root, dir, *paths|
96
210
  [root, dir, paths]
97
211
  end
98
- assert_equal [app[:dir], "tap/file_task", ["path"]], t.infer_filepath(:dir, "path")
212
+ assert_equal [app[:dir], "tap/file_task", ["path"]], t.filepath(:dir, "path")
99
213
 
100
214
  t.inference(true) do |root, dir, path_a, path_b|
101
215
  [root, dir, path_a, path_b]
102
216
  end
103
- assert_equal [app[:dir], "tap/file_task", "path", nil], t.infer_filepath(:dir, "path")
217
+ assert_equal [app[:dir], "tap/file_task", "path", nil], t.filepath(:dir, "path")
104
218
  end
105
219
 
106
- def test_infer_filepath_with_single_path_but_multiple_paths_given
220
+ def test_filepath_with_single_path_but_multiple_paths_given
107
221
  t.inference do |root, dir, path|
108
222
  [root, dir, path]
109
223
  end
110
- assert_equal [app[:dir], "tap/file_task", "path"], t.infer_filepath(:dir, "path", "to", "file")
224
+ assert_equal [app[:dir], "tap/file_task", "path"], t.filepath(:dir, "path", "to", "file")
111
225
  end
112
226
 
113
- def test_infer_filepath_constructs_path_using_app_filepath_when_inference_block_is_not_set
227
+ def test_filepath_constructs_path_using_app_filepath_when_inference_block_is_not_set
114
228
  assert_nil t.inference_block
115
229
  assert_equal(
116
230
  app.filepath(:dir, "tap/file_task", "path", "to", "file"),
117
- t.infer_filepath(:dir, "path", "to", "file"))
231
+ t.filepath(:dir, "path", "to", "file"))
118
232
  end
119
233
 
120
234
  #
121
235
  # backup_filepath test
122
236
  #
237
+
238
+ def btest_backup_filepath_documentation
239
+
240
+ t = FileTask.new("dir/name", :backup_dir => :backup, :backup_timestamp => "%Y%m%d")
241
+ t.app[:backup] # => "/backup"
242
+ Date.today.to_s # => "2007-08-08"
243
+
244
+ t.backup_filepath("path/to/folder/file.txt") # => "/backup/file_20070808.txt"
245
+ t.backup_filepath("dir/name/folder/file.txt") # => "/backup/folder/file_20070808.txt"
246
+ end
123
247
 
124
248
  def prepare_backup_filepath_with_output_and_timestamp
125
249
  timestamp_format = "%Y%m%d"
@@ -176,7 +300,8 @@ class FileTaskTest < Test::Unit::TestCase
176
300
  t.backup_filepath("path/to/file.txt"))
177
301
  end
178
302
 
179
- def test_backup_filepath_does_not_mistake_files_as_folders_when_checking_if_input_is_relative_to_dirname
303
+ # the SciTE text editor whines and fails for 'words' this long... hence the last part of the test name is commented out
304
+ def test_backup_filepath_does_not_mistake_files_as_folders#_when_checking_if_input_is_relative_to_dirname
180
305
  timestamp = prepare_backup_filepath_with_output_and_timestamp
181
306
 
182
307
  t.inference do |root, dir, path|
@@ -188,71 +313,13 @@ class FileTaskTest < Test::Unit::TestCase
188
313
  t.backup_filepath("folder/tap/file_task.txt"))
189
314
  end
190
315
 
191
- #
192
- # open tests
193
- #
194
-
195
- def test_open_opens_each_file
196
- FileUtils.mkdir_p(infer_filepath(:output))
197
-
198
- list = [0, 1].collect do |n|
199
- path = infer_filepath(:output, "#{n}.txt")
200
- File.open(path, "w") {|f| f << n.to_s}
201
- path
202
- end
203
-
204
- t.open(list) do |files|
205
- files.each_with_index do |file, n|
206
- assert_equal File, file.class
207
- assert_equal n.to_s, file.read
208
- end
209
- end
210
- end
211
-
212
- def test_open_opens_with_input_mode
213
- FileUtils.mkdir_p(infer_filepath(:output))
214
-
215
- list = [0, 1].collect do |n|
216
- path = infer_filepath(:output, "#{n}.txt")
217
- path
218
- end
219
-
220
- t.open(list, "w") do |files|
221
- files.each_with_index do |file, n|
222
- assert_equal File, file.class
223
- file << n.to_s
224
- end
225
- end
226
-
227
- list.each_with_index do |file, n|
228
- assert_equal n.to_s, File.read(file)
229
- end
230
- end
231
-
232
- def test_open_returns_open_files_if_no_block_is_given
233
- FileUtils.mkdir_p(infer_filepath(:output))
234
-
235
- list = [0, 1].collect do |n|
236
- path = infer_filepath(:output, "#{n}.txt")
237
- File.open(path, "w") {|f| f << n.to_s}
238
- path
239
- end
240
-
241
- open_files = t.open(list)
242
- open_files.each_with_index do |file, n|
243
- assert_equal File, file.class
244
- assert_equal n.to_s, file.read
245
- file.close
246
- end
247
- end
248
-
249
316
  #
250
317
  # uptodate tests
251
318
  #
252
319
 
253
320
  def uptodate_test_setup(output_str='')
254
- of1 = ifs.filepath(:root, 'old_file_one.txt')
255
- of2 = ifs.filepath(:root, 'old_file_two.txt')
321
+ of1 = trs.filepath(:root, 'old_file_one.txt')
322
+ of2 = trs.filepath(:root, 'old_file_two.txt')
256
323
 
257
324
  nf1 = tempfile('new_file_one.txt')
258
325
  File.open(nf1, "w") {|file| file << output_str}
@@ -277,7 +344,7 @@ class FileTaskTest < Test::Unit::TestCase
277
344
  def test_uptodate
278
345
  of1, of2, nf1, nf2 = uptodate_test_setup
279
346
 
280
- non = ifs.filepath(:output, "non_existant_file.txt")
347
+ non = trs.filepath(:output, "non_existant_file.txt")
281
348
  assert !File.exists?(non)
282
349
 
283
350
  assert t.uptodate?(nf1)
@@ -300,7 +367,7 @@ class FileTaskTest < Test::Unit::TestCase
300
367
 
301
368
  of1, of2, nf1, nf2 = uptodate_test_setup
302
369
 
303
- non = ifs.filepath(:output, "non_existant_file.txt")
370
+ non = trs.filepath(:output, "non_existant_file.txt")
304
371
  assert !File.exists?(non)
305
372
 
306
373
  assert t.uptodate?(nf1)
@@ -319,7 +386,7 @@ class FileTaskTest < Test::Unit::TestCase
319
386
  end
320
387
 
321
388
  def test_uptodate_with_out_of_date_config_file
322
- filepath = ifs.filepath(:config, "configured-0.1.yml")
389
+ filepath = trs.filepath(:config, "configured-0.1.yml")
323
390
  assert !File.exists?(filepath)
324
391
  begin
325
392
  of1, of2, nf1, nf2 = uptodate_test_setup
@@ -350,9 +417,32 @@ class FileTaskTest < Test::Unit::TestCase
350
417
  # backup tests
351
418
  #
352
419
 
420
+ def test_backup_restore_doc
421
+ FileUtils.mkdir_p(method_filepath(:output))
422
+ FileUtils.mkdir_p(method_filepath(:output))
423
+
424
+ file = method_filepath(:output, "file.txt")
425
+ File.open(file, "w") {|f| f << "file content"}
426
+
427
+ t = Tap::FileTask.new
428
+ t.app[:backup, true] = method_filepath(:backup)
429
+ backed_up_file = t.backup(file).first
430
+
431
+ assert !File.exists?(file)
432
+ assert File.exists?(backed_up_file)
433
+ assert_equal "file content", File.read(backed_up_file)
434
+
435
+ File.open(file, "w") {|f| f << "new content"}
436
+ t.restore(file)
437
+
438
+ assert File.exists?(file)
439
+ assert !File.exists?(backed_up_file)
440
+ assert_equal "file content", File.read(file)
441
+ end
442
+
353
443
  def backup_test_setup
354
- existing_file = infer_filepath(:output, "file.txt")
355
- backup_file = infer_filepath(:output, "backup.txt")
444
+ existing_file = method_filepath(:output, "file.txt")
445
+ backup_file = method_filepath(:output, "backup.txt")
356
446
 
357
447
  touch_file(existing_file, "existing content")
358
448
  # assure backup_filepath will return backup_file
@@ -371,34 +461,39 @@ class FileTaskTest < Test::Unit::TestCase
371
461
  assert_equal backup_file, t.backup_filepath(existing_file)
372
462
  end
373
463
 
374
- def test_backup_copies_filepath_to_backup_filepath
464
+ def test_backup_moves_filepath_to_backup_filepath
375
465
  existing_file, backup_file = backup_test_setup
376
466
 
377
467
  t.backup(existing_file)
378
468
 
379
- assert File.exists?(existing_file)
469
+ assert !File.exists?(existing_file)
380
470
  assert File.exists?(backup_file)
381
- assert FileUtils.compare_file(existing_file, backup_file)
471
+ assert_equal "existing content", File.read(backup_file)
382
472
  end
383
473
 
384
- def test_backup_moves_filepath_to_backup_filepath_unless_copy_is_true
474
+ def test_backup_copies_filepath_to_backup_filepath_if_backup_using_copy_is_true
385
475
  existing_file, backup_file = backup_test_setup
386
476
 
387
- t.backup(existing_file, false)
477
+ t.backup(existing_file, true)
388
478
 
389
- assert !File.exists?(existing_file)
479
+ assert File.exists?(existing_file)
390
480
  assert File.exists?(backup_file)
391
- assert_equal "existing content", File.read(backup_file)
481
+ assert FileUtils.compare_file(existing_file, backup_file)
392
482
  end
393
483
 
394
484
  def test_backup_registers_expanded_filepath_and_backup_filepath_in_backed_up_files
395
485
  existing_file, backup_file = backup_test_setup
396
486
 
397
- assert_not_equal existing_file, File.expand_path(existing_file)
487
+ relative_filepath = Tap::Root.relative_filepath(Dir.pwd, existing_file)
488
+ assert_not_equal existing_file, relative_filepath
489
+
490
+ assert_equal existing_file, File.expand_path(existing_file)
491
+ assert_equal existing_file, File.expand_path(relative_filepath)
492
+ assert_equal backup_file, File.expand_path(backup_file)
398
493
 
399
494
  assert_equal({}, t.backed_up_files)
400
- t.backup(existing_file)
401
- assert_equal({File.expand_path(existing_file) => File.expand_path(backup_file)}, t.backed_up_files)
495
+ t.backup(relative_filepath)
496
+ assert_equal({existing_file => backup_file}, t.backed_up_files)
402
497
  end
403
498
 
404
499
  def test_backup_does_nothing_if_filepath_does_not_exist
@@ -417,10 +512,10 @@ class FileTaskTest < Test::Unit::TestCase
417
512
  end
418
513
 
419
514
  def test_backup_acts_on_list_and_returns_backup_files
420
- existing_file0 = infer_filepath(:output, "file0.txt")
421
- existing_file1 = infer_filepath(:output, "file1.txt")
422
- backup_file0 = infer_filepath(:output, "backup0.txt")
423
- backup_file1 = infer_filepath(:output, "backup1.txt")
515
+ existing_file0 = method_filepath(:output, "file0.txt")
516
+ existing_file1 = method_filepath(:output, "file1.txt")
517
+ backup_file0 = method_filepath(:output, "backup0.txt")
518
+ backup_file1 = method_filepath(:output, "backup1.txt")
424
519
 
425
520
  touch_file(existing_file0)
426
521
  touch_file(existing_file1)
@@ -439,7 +534,7 @@ class FileTaskTest < Test::Unit::TestCase
439
534
 
440
535
  def test_backup_raises_error_if_backup_for_file_already_exists
441
536
  existing_file, backup_file = backup_test_setup
442
- t.backup(existing_file)
537
+ t.backup(existing_file, true)
443
538
 
444
539
  assert_raise(RuntimeError) { t.backup(existing_file) }
445
540
  end
@@ -449,8 +544,8 @@ class FileTaskTest < Test::Unit::TestCase
449
544
  #
450
545
 
451
546
  def test_restore_restores_backed_up_file_to_original_location_as_listed_in_backed_up_files
452
- original_file = File.expand_path(infer_filepath(:output, 'original/file.txt'))
453
- backup_file = File.expand_path(infer_filepath(:output, 'backup/file.txt'))
547
+ original_file = File.expand_path(method_filepath(:output, 'original/file.txt'))
548
+ backup_file = File.expand_path(method_filepath(:output, 'backup/file.txt'))
454
549
 
455
550
  FileUtils.mkdir_p( File.dirname(original_file) )
456
551
  touch_file(backup_file)
@@ -467,8 +562,8 @@ class FileTaskTest < Test::Unit::TestCase
467
562
  end
468
563
 
469
564
  def test_restore_creates_dirs_as_needed_to_restore_file
470
- original_file = File.expand_path(infer_filepath(:output, 'original/file.txt'))
471
- backup_file = File.expand_path(infer_filepath(:output, 'backup/file.txt'))
565
+ original_file = File.expand_path(method_filepath(:output, 'original/file.txt'))
566
+ backup_file = File.expand_path(method_filepath(:output, 'backup/file.txt'))
472
567
 
473
568
  touch_file(backup_file)
474
569
 
@@ -483,14 +578,16 @@ class FileTaskTest < Test::Unit::TestCase
483
578
  assert !File.exists?(backup_file)
484
579
  end
485
580
 
486
- def test_restore_raises_error_if_the_input_file_is_not_backed_up
581
+ def test_restore_does_nothing_if_the_input_file_is_not_backed_up
582
+ assert !File.exists?("original_file")
487
583
  assert t.backed_up_files.empty?
488
- assert_raise(RuntimeError) { t.restore("original_file") }
584
+ assert_equal [], t.restore("original_file")
585
+ assert !File.exists?("original_file")
489
586
  end
490
587
 
491
588
  def test_restore_removes_backup_dir_using_rmdir
492
- original_file = File.expand_path(infer_filepath(:output, 'original/file.txt'))
493
- backup_file = File.expand_path(infer_filepath(:output, 'backup/file.txt'))
589
+ original_file = File.expand_path(method_filepath(:output, 'original/file.txt'))
590
+ backup_file = File.expand_path(method_filepath(:output, 'backup/file.txt'))
494
591
  backup_dir = File.dirname(backup_file)
495
592
 
496
593
  t.mkdir(backup_file)
@@ -505,10 +602,10 @@ class FileTaskTest < Test::Unit::TestCase
505
602
  end
506
603
 
507
604
  def test_restore_acts_on_list_and_returns_restored_files
508
- existing_file0 = File.expand_path(infer_filepath(:output, "file0.txt"))
509
- existing_file1 = File.expand_path(infer_filepath(:output, "file1.txt"))
510
- backup_file0 = File.expand_path(infer_filepath(:output, "backup0.txt"))
511
- backup_file1 = File.expand_path(infer_filepath(:output, "backup1.txt"))
605
+ existing_file0 = File.expand_path(method_filepath(:output, "file0.txt"))
606
+ existing_file1 = File.expand_path(method_filepath(:output, "file1.txt"))
607
+ backup_file0 = File.expand_path(method_filepath(:output, "backup0.txt"))
608
+ backup_file1 = File.expand_path(method_filepath(:output, "backup1.txt"))
512
609
 
513
610
  touch_file(backup_file0)
514
611
  touch_file(backup_file1)
@@ -529,8 +626,34 @@ class FileTaskTest < Test::Unit::TestCase
529
626
  # mkdir tests
530
627
  #
531
628
 
629
+ def test_mkdir_documentation
630
+ dir_one = method_filepath(:output, "path/to/dir")
631
+ dir_two = method_filepath(:output, "path/to/another")
632
+
633
+ t = Tap::FileTask.new do |task, inputs|
634
+ assert !File.exists?(method_filepath(:output, "path"))
635
+
636
+ task.mkdir(dir_one)
637
+ assert File.exists?(dir_one)
638
+
639
+ FileUtils.mkdir(dir_two)
640
+ assert File.exists?(dir_two)
641
+
642
+ raise "error!"
643
+ end
644
+
645
+ begin
646
+ t.execute(nil)
647
+ flunk "no error raised"
648
+ rescue
649
+ assert_equal "error!", $!.message
650
+ assert !File.exists?(dir_one)
651
+ assert File.exists?(dir_two)
652
+ end
653
+ end
654
+
532
655
  def test_mkdir_creates_dir_if_it_does_not_exist
533
- dir = infer_filepath(:output, 'path/to/non_existant_folder')
656
+ dir = method_filepath(:output, 'path/to/non_existant_folder')
534
657
  FileUtils.mkdir_p(File.dirname(dir))
535
658
  assert !File.exists?(dir)
536
659
 
@@ -539,36 +662,37 @@ class FileTaskTest < Test::Unit::TestCase
539
662
  end
540
663
 
541
664
  def test_mkdir_creates_parent_dirs_if_they_do_not_exist
542
- dir = infer_filepath(:output, 'path/to/non_existant_folder')
543
- assert !File.exists?(infer_filepath(:output))
665
+ dir = method_filepath(:output, 'path/to/non_existant_folder')
666
+ assert !File.exists?(method_filepath(:output))
544
667
 
545
668
  t.mkdir(dir)
546
669
  assert File.exists?(dir)
547
670
  end
548
671
 
549
- def test_mkdir_registers_expanded_dir_and_all_non_existing_parent_dirs_in_made_files
550
- dir = infer_filepath(:output, 'path/to/non_existant_folder')
551
- assert_equal [], t.made_files
552
- assert_not_equal dir, File.expand_path(dir)
672
+ def test_mkdir_registers_expanded_dir_and_all_non_existing_parent_dirs_in_added_files
673
+ dir = method_filepath(:output, 'path/to/non_existant_folder')
674
+ assert_equal [], t.added_files
553
675
 
554
- t.mkdir(dir)
676
+ relative_dir = Tap::Root.relative_filepath(Dir.pwd, dir)
677
+ assert_not_equal dir, relative_dir
678
+ assert_equal dir, File.expand_path(relative_dir)
679
+
680
+ t.mkdir(relative_dir)
555
681
 
556
682
  expected = [
557
- infer_root,
558
- infer_filepath(:output),
559
- infer_filepath(:output, 'path'),
560
- infer_filepath(:output, 'path/to'),
561
- infer_filepath(:output, 'path/to/non_existant_folder')
562
- ].collect do |dir|
563
- File.expand_path(dir)
564
- end
683
+ method_root,
684
+ method_filepath(:output),
685
+ method_filepath(:output, 'path'),
686
+ method_filepath(:output, 'path/to'),
687
+ method_filepath(:output, 'path/to/non_existant_folder')
688
+ ]
565
689
 
566
- assert_equal expected, t.made_files
690
+ assert_equal expected, t.added_files
567
691
  end
568
692
 
569
693
  def test_mkdir_acts_on_and_returns_list
570
- dir = infer_filepath(:output, 'path')
571
- another = infer_filepath(:output, 'another')
694
+ dir = method_filepath(:output, 'path')
695
+ another = method_filepath(:output, 'another')
572
696
 
573
697
  assert !File.exists?(dir)
574
698
  assert !File.exists?(another)
@@ -583,9 +707,26 @@ class FileTaskTest < Test::Unit::TestCase
583
707
  # rmdir tests
584
708
  #
585
709
 
710
+ def test_rmdir_documentation
711
+ dir_one = method_filepath(:output, 'path')
712
+ dir_two = method_filepath(:output, 'path/to/dir')
713
+ FileUtils.mkdir_p( method_filepath(:output) )
714
+
715
+ t = Tap::FileTask.new
716
+ assert !File.exists?(dir_one)
717
+ FileUtils.mkdir(dir_one)
718
+
719
+ t.mkdir(dir_two)
720
+ assert File.exists?(dir_two)
721
+
722
+ t.rmdir(dir_two)
723
+ assert File.exists?(dir_one)
724
+ assert !File.exists?(method_filepath(:output, 'path/to'))
725
+ end
726
+
586
727
  def test_rmdir_removes_dir_if_made_by_the_task
587
- dir = infer_filepath(:output, 'path/to/non_existant_folder')
588
- existing_dir = infer_filepath(:output, 'path/to')
728
+ dir = method_filepath(:output, 'path/to/non_existant_folder')
729
+ existing_dir = method_filepath(:output, 'path/to')
589
730
 
590
731
  FileUtils.mkdir_p(existing_dir)
591
732
  assert File.exists?(existing_dir)
@@ -600,9 +741,9 @@ class FileTaskTest < Test::Unit::TestCase
600
741
  end
601
742
 
602
743
  def test_rmdir_removes_parent_dirs_if_made_by_the_task
603
- dir = infer_filepath(:output, 'path/to/non/existant/folder')
604
- root_parent_dir = infer_filepath(:output, 'path/to')
605
- existing_dir = infer_filepath(:output, 'path')
744
+ dir = method_filepath(:output, 'path/to/non/existant/folder')
745
+ root_parent_dir = method_filepath(:output, 'path/to')
746
+ existing_dir = method_filepath(:output, 'path')
606
747
 
607
748
  FileUtils.mkdir_p(existing_dir)
608
749
  assert File.exists?(existing_dir)
@@ -617,7 +758,7 @@ class FileTaskTest < Test::Unit::TestCase
617
758
  end
618
759
 
619
760
  def test_rmdir_does_not_remove_if_dir_was_not_made_by_task
620
- dir = infer_filepath(:output, 'path/to/non_existant_folder')
761
+ dir = method_filepath(:output, 'path/to/non_existant_folder')
621
762
 
622
763
  FileUtils.mkdir_p(dir)
623
764
  assert File.exists?(dir)
@@ -627,8 +768,8 @@ class FileTaskTest < Test::Unit::TestCase
627
768
  end
628
769
 
629
770
  def test_rmdir_does_not_remove_if_folder_is_not_empty
630
- dir = infer_filepath(:output, 'path/to/folder')
631
- not_empty_dir = infer_filepath(:output, 'path/to')
771
+ dir = method_filepath(:output, 'path/to/folder')
772
+ not_empty_dir = method_filepath(:output, 'path/to')
632
773
 
633
774
  t.mkdir(dir)
634
775
  assert File.exists?(dir)
@@ -641,8 +782,8 @@ class FileTaskTest < Test::Unit::TestCase
641
782
  end
642
783
 
643
784
  def test_rmdir_checks_for_hidden_files_as_well_as_regular_files
644
- dir = infer_filepath(:output, 'path/to/folder')
645
- not_empty_dir = infer_filepath(:output, 'path/to')
785
+ dir = method_filepath(:output, 'path/to/folder')
786
+ not_empty_dir = method_filepath(:output, 'path/to')
646
787
 
647
788
  t.mkdir(dir)
648
789
  assert File.exists?(dir)
@@ -654,73 +795,93 @@ class FileTaskTest < Test::Unit::TestCase
654
795
  assert !File.exists?(dir)
655
796
  end
656
797
 
657
- def test_rmdir_clears_made_files_of_removed_dirs
658
- dir = infer_filepath(:output, 'path/to/folder')
798
+ def test_rmdir_clears_added_files_of_removed_dirs
799
+ dir = method_filepath(:output, 'path/to/folder')
659
800
 
660
- FileUtils.mkdir_p(infer_filepath(:output))
661
- assert_equal [], t.made_files
801
+ FileUtils.mkdir_p(method_filepath(:output))
802
+ assert_equal [], t.added_files
662
803
 
663
804
  t.mkdir(dir)
664
805
  assert_equal [
665
- File.expand_path(infer_filepath(:output, 'path')),
666
- File.expand_path(infer_filepath(:output, 'path/to')),
667
- File.expand_path(infer_filepath(:output, 'path/to/folder'))], t.made_files
806
+ File.expand_path(method_filepath(:output, 'path')),
807
+ File.expand_path(method_filepath(:output, 'path/to')),
808
+ File.expand_path(method_filepath(:output, 'path/to/folder'))], t.added_files
668
809
 
669
810
  # touch a file so the 'path' folder isn't removed
670
- touch_file infer_filepath(:output, 'path/file.txt')
811
+ touch_file method_filepath(:output, 'path/file.txt')
671
812
 
672
813
  t.rmdir(dir)
673
814
  assert_equal [
674
- File.expand_path(infer_filepath(:output, 'path'))], t.made_files
815
+ File.expand_path(method_filepath(:output, 'path'))], t.added_files
675
816
  end
676
817
 
677
818
  def test_rmdir_acts_on_and_returns_expanded_list_of_removed_dirs
678
- dir = infer_filepath(:output, 'path')
679
- another = infer_filepath(:output, 'another')
680
- not_removed = infer_filepath(:output, 'not')
681
- removed = infer_filepath(:output, 'not/removed')
819
+ dir = method_filepath(:output, 'path')
820
+ another = method_filepath(:output, 'another')
821
+ not_removed = method_filepath(:output, 'not')
822
+ removed = method_filepath(:output, 'not/removed')
682
823
 
683
824
  t.mkdir([dir, another, not_removed, removed])
684
825
  # touch a file so the not_removed folder isn't removed
685
- touch_file infer_filepath(:output, 'not/file.txt')
826
+ touch_file method_filepath(:output, 'not/file.txt')
686
827
 
687
828
  expected = [dir, another, removed].collect {|d| File.expand_path(d)}
688
829
  assert_equal expected, t.rmdir([dir, another, not_removed, removed])
689
830
  end
690
831
 
691
832
  #
692
- # make tests
833
+ # prepare tests
693
834
  #
694
835
 
695
- def test_make_acts_on_and_returns_list
696
- filepath = "file.txt"
697
- another = "another.txt"
698
- assert_equal [filepath, another], t.make([filepath, another])
699
- end
836
+ def test_prepare_documentation
837
+ file_one = method_filepath(:output, "file.txt")
838
+ file_two = method_filepath(:output, "path/to/file.txt")
839
+ FileUtils.mkdir_p( method_filepath(:output) )
840
+
841
+ File.open(file_one, "w") {|f| f << "original content"}
842
+ t = Tap::FileTask.new do |task, inputs|
843
+ assert !File.exists?(method_filepath(:output, "path"))
700
844
 
701
- def test_make_yields_list_if_block_given
702
- was_in_make = false
703
- t.make("file.txt") do |list|
704
- was_in_make = true
705
- assert_equal ["file.txt"], list
845
+ # backup... prepare parent dirs... prepare for restore
846
+ task.prepare([file_one, file_two])
847
+
848
+ File.open(file_one, "w") {|f| f << "new content"}
849
+ FileUtils.touch(file_two)
850
+
851
+ raise "error!"
706
852
  end
707
- assert was_in_make
853
+
854
+ begin
855
+ t.execute(nil)
856
+ flunk "no error raised"
857
+ rescue
858
+ assert_equal "error!", $!.message
859
+ assert File.exists?(file_one)
860
+ assert_equal "original content", File.read(file_one)
861
+ assert !File.exists?(method_filepath(:output, "path"))
862
+ end
863
+ end
864
+
865
+ def test_prepare_acts_on_and_returns_list
866
+ filepath = "file.txt"
867
+ another = "another.txt"
868
+ assert_equal [filepath, another], t.prepare([filepath, another])
708
869
  end
709
870
 
710
- def test_make_backs_up_existing_files_and_creates_non_existant_dirs
711
- existing_file = infer_filepath(:output, "path/to/existing/file.txt")
712
- non_existant_file = infer_filepath(:output, "path/to/non/existant/file.txt")
871
+ def test_prepare_backs_up_existing_files_and_creates_non_existant_dirs
872
+ existing_file = method_filepath(:output, "path/to/existing/file.txt")
873
+ non_existant_file = method_filepath(:output, "path/to/non/existant/file.txt")
713
874
  touch_file(existing_file, "existing content")
714
875
 
715
876
  # be sure inference leads files to an output dir, for cleanup
716
- removal_path = infer_filepath(:output, 'removal')
877
+ removal_path = method_filepath(:output, 'removal')
717
878
  t.inference {|root, dir, path| removal_path}
718
879
 
719
880
  assert File.exists?(existing_file)
720
881
  assert !File.exists?(non_existant_file)
721
882
 
722
883
  files = [existing_file, non_existant_file]
723
- t.make(files)
884
+ t.prepare(files)
724
885
 
725
886
  # check neither of the files exist at this point
726
887
  # and the parent dirs all exist
@@ -734,50 +895,68 @@ class FileTaskTest < Test::Unit::TestCase
734
895
  assert_equal "existing content", File.read(removal_path)
735
896
  end
736
897
 
737
- def test_make_adds_list_to_made_files
738
- existing_file = infer_filepath(:output, "path/to/existing/file.txt")
739
- non_existant_file = infer_filepath(:output, "path/to/non/existant/file.txt")
898
+ def test_prepare_adds_list_to_added_files
899
+ existing_file = method_filepath(:output, "path/to/existing/file.txt")
900
+ non_existant_file = method_filepath(:output, "path/to/non/existant/file.txt")
740
901
  touch_file(existing_file)
741
902
 
742
903
  # be sure inference leads files to an output dir, for cleanup
743
- removal_path = infer_filepath(:output, 'removal')
904
+ removal_path = method_filepath(:output, 'removal')
744
905
  t.inference {|root, dir, path| File.join(removal_path, path) }
745
906
 
746
- assert_equal([], t.made_files)
907
+ assert_equal([], t.added_files)
747
908
  assert File.exists?(existing_file)
748
909
  assert !File.exists?(non_existant_file)
749
910
  assert !File.exists?(removal_path)
750
911
 
751
912
  files = [existing_file, non_existant_file]
752
- t.make(files)
913
+ t.prepare(files)
753
914
 
754
915
  expected = [
755
916
  removal_path, # added by backup of existing_file
756
- existing_file, # added by make
757
- infer_filepath(:output, 'path/to/non'), # added by mkdir
758
- infer_filepath(:output, 'path/to/non/existant'), # added by mkdir
759
- non_existant_file # added by make
917
+ method_filepath(:output, 'path/to/non'), # added by mkdir
918
+ method_filepath(:output, 'path/to/non/existant'), # added by mkdir
919
+ existing_file, # added by prepare
920
+ non_existant_file # added by prepare
760
921
  ].collect do |dir|
761
922
  File.expand_path(dir)
762
923
  end
763
924
 
764
- assert_equal expected, t.made_files
925
+ assert_equal expected, t.added_files
765
926
  end
766
927
 
767
928
  #
768
929
  # rm tests
769
930
  #
770
931
 
932
+ def test_rm_documentation
933
+ dir = method_filepath(:output, 'path')
934
+ file = method_filepath(:output, 'path/to/file.txt')
935
+ FileUtils.mkdir_p( method_filepath(:output) )
936
+
937
+ t = Tap::FileTask.new
938
+ assert !File.exists?(dir)
939
+ FileUtils.mkdir(dir)
940
+
941
+ t.prepare(file)
942
+ FileUtils.touch(file)
943
+ assert File.exists?(file)
944
+
945
+ t.rm(file)
946
+ assert File.exists?(dir)
947
+ assert !File.exists?(method_filepath(:output, 'path/to'))
948
+ end
949
+
771
950
  def test_rm_removes_file_and_parent_dirs_if_made_by_the_task
772
- file = infer_filepath(:output, 'path/to/file.txt')
773
- parent_dir = infer_filepath(:output, 'path/to')
774
- existing_dir = infer_filepath(:output, 'path')
951
+ file = method_filepath(:output, 'path/to/file.txt')
952
+ parent_dir = method_filepath(:output, 'path/to')
953
+ existing_dir = method_filepath(:output, 'path')
775
954
  FileUtils.mkdir_p existing_dir
776
955
 
777
956
  assert File.exists?(existing_dir)
778
957
  assert !File.exists?(file)
779
958
 
780
- t.make file
959
+ t.prepare file
781
960
  touch_file(file)
782
961
  assert File.exists?(file)
783
962
 
@@ -788,15 +967,15 @@ class FileTaskTest < Test::Unit::TestCase
788
967
  end
789
968
 
790
969
  def test_rm_removes_parent_dirs_even_if_file_does_not_exist
791
- file = infer_filepath(:output, 'path/to/file.txt')
792
- parent_dir = infer_filepath(:output, 'path/to')
793
- existing_dir = infer_filepath(:output, 'path')
970
+ file = method_filepath(:output, 'path/to/file.txt')
971
+ parent_dir = method_filepath(:output, 'path/to')
972
+ existing_dir = method_filepath(:output, 'path')
794
973
  FileUtils.mkdir_p existing_dir
795
974
 
796
975
  assert File.exists?(existing_dir)
797
976
  assert !File.exists?(file)
798
977
 
799
- t.make file
978
+ t.prepare file
800
979
  assert !File.exists?(file)
801
980
 
802
981
  t.rm(file)
@@ -805,7 +984,7 @@ class FileTaskTest < Test::Unit::TestCase
805
984
  end
806
985
 
807
986
  def test_rm_does_not_remove_file_if_not_made_by_the_task
808
- file = infer_filepath(:output, 'path/to/file.txt')
987
+ file = method_filepath(:output, 'path/to/file.txt')
809
988
 
810
989
  touch_file(file)
811
990
  assert File.exists?(file)
@@ -814,50 +993,50 @@ class FileTaskTest < Test::Unit::TestCase
814
993
  assert File.exists?(file)
815
994
  end
816
995
 
817
- def test_rm_clears_made_files_of_removed_files
818
- file0 = infer_filepath(:output, 'file0.txt')
819
- file1 = infer_filepath(:output, 'file1.txt')
996
+ def test_rm_clears_added_files_of_removed_files
997
+ file0 = method_filepath(:output, 'file0.txt')
998
+ file1 = method_filepath(:output, 'file1.txt')
820
999
 
821
- FileUtils.mkdir_p(infer_filepath(:output))
822
- assert_equal [], t.made_files
1000
+ FileUtils.mkdir_p(method_filepath(:output))
1001
+ assert_equal [], t.added_files
823
1002
 
824
- t.make([file0,file1])
1003
+ t.prepare([file0,file1])
825
1004
  assert_equal [
826
- File.expand_path(infer_filepath(:output, 'file0.txt')),
827
- File.expand_path(infer_filepath(:output, 'file1.txt'))], t.made_files
1005
+ File.expand_path(method_filepath(:output, 'file0.txt')),
1006
+ File.expand_path(method_filepath(:output, 'file1.txt'))], t.added_files
828
1007
 
829
1008
  t.rm(file0)
830
1009
  assert_equal [
831
- File.expand_path(infer_filepath(:output, 'file1.txt'))], t.made_files
1010
+ File.expand_path(method_filepath(:output, 'file1.txt'))], t.added_files
832
1011
  end
833
1012
 
834
1013
  def test_rm_acts_on_and_returns_expanded_list_of_removed_files_and_dirs
835
- file = infer_filepath(:output, 'file.txt')
836
- another = infer_filepath(:output, 'another.txt')
837
- not_removed = infer_filepath(:output, 'not')
838
- removed = infer_filepath(:output, 'not/removed.txt')
1014
+ file = method_filepath(:output, 'file.txt')
1015
+ another = method_filepath(:output, 'another.txt')
1016
+ not_removed = method_filepath(:output, 'not')
1017
+ removed = method_filepath(:output, 'not/removed.txt')
839
1018
 
840
- t.make([file, another, removed])
1019
+ t.prepare([file, another, removed])
841
1020
  # touch a file so the not_removed folder isn't removed
842
- touch_file infer_filepath(:output, 'not/file.txt')
1021
+ touch_file method_filepath(:output, 'not/file.txt')
843
1022
 
844
1023
  expected = [file, another, removed].collect {|f| File.expand_path(f)}
845
1024
  assert_equal expected, t.rm([file, another, removed])
846
1025
  end
847
1026
 
848
1027
  #
849
- # process tests
1028
+ # execute tests
850
1029
  #
851
1030
 
852
- def setup_process_test(&block)
853
- existing_file = infer_filepath(:output, "path/to/existing/file.txt")
854
- non_existant_dir = infer_filepath(:output, "path/to/non/existing")
1031
+ def setup_execute_test(&block)
1032
+ existing_file = method_filepath(:output, "path/to/existing/file.txt")
1033
+ non_existant_dir = method_filepath(:output, "path/to/non/existing")
855
1034
  non_existant_file = File.join(non_existant_dir, "file.txt")
856
- backup_file = infer_filepath(:output, "backup/file.txt")
1035
+ backup_file = method_filepath(:output, "backup/file.txt")
857
1036
 
858
1037
  touch_file(existing_file, "original content")
859
1038
  @t = Tap::FileTask.new do |task, input|
860
- task.make([existing_file, non_existant_file])
1039
+ task.prepare([existing_file, non_existant_file])
861
1040
 
862
1041
  block.call if block_given?
863
1042
  end
@@ -869,8 +1048,8 @@ class FileTaskTest < Test::Unit::TestCase
869
1048
  [existing_file, backup_file, non_existant_dir, non_existant_file]
870
1049
  end
871
1050
 
872
- def test_setup_process_test
873
- existing_file, backup_file, non_existant_dir, non_existant_file = setup_process_test do
1051
+ def test_setup_execute_test
1052
+ existing_file, backup_file, non_existant_dir, non_existant_file = setup_execute_test do
874
1053
  assert !File.exists?(non_existant_file)
875
1054
  assert File.exists?(non_existant_dir)
876
1055
  assert File.exists?(backup_file)
@@ -879,109 +1058,163 @@ class FileTaskTest < Test::Unit::TestCase
879
1058
  t.execute(nil)
880
1059
  end
881
1060
 
882
- def test_process_restores_backups_and_removes_made_files_on_error
883
- was_in_process = false
884
- existing_file, backup_file, non_existant_dir, non_existant_file = setup_process_test do
885
- was_in_process = true
1061
+ def test_execute_restores_backups_and_removes_added_files_on_error
1062
+ was_in_execute = false
1063
+ existing_file, backup_file, non_existant_dir, non_existant_file = setup_execute_test do
1064
+ was_in_execute = true
886
1065
  raise "error"
887
1066
  end
888
1067
 
889
1068
  assert_raise(RuntimeError) { t.execute(nil) }
890
1069
 
891
1070
  # check the existing file was restored
892
- assert was_in_process
1071
+ assert was_in_execute
893
1072
  assert File.exists?(existing_file)
894
1073
  assert !File.exists?(non_existant_dir)
895
1074
  assert !File.exists?(backup_file)
896
1075
  assert_equal "original content", File.read(existing_file)
1076
+ assert t.added_files.empty?
1077
+ assert t.backed_up_files.empty?
897
1078
  end
898
1079
 
899
- def test_process_does_not_restores_backups_if_restore_on_error_is_false
900
- was_in_process = false
901
- existing_file, backup_file, non_existant_dir, non_existant_file = setup_process_test do
902
- was_in_process = true
1080
+ def test_execute_does_not_restore_backups_if_rollback_on_error_is_false
1081
+ was_in_execute = false
1082
+ existing_file, backup_file, non_existant_dir, non_existant_file = setup_execute_test do
1083
+ was_in_execute = true
903
1084
  raise "error"
904
1085
  end
905
1086
 
906
- t.restore_on_error = false
1087
+ t.rollback_on_error = false
907
1088
  assert_raise(RuntimeError) { t.execute(nil) }
908
1089
 
909
1090
  # check the existing file was NOT restored
910
- assert was_in_process
1091
+ assert was_in_execute
911
1092
  assert !File.exists?(existing_file)
912
1093
  assert File.exists?(non_existant_dir)
913
1094
  assert File.exists?(backup_file)
914
1095
  assert_equal "original content", File.read(backup_file)
1096
+ assert !t.added_files.empty?
1097
+ assert !t.backed_up_files.empty?
915
1098
  end
916
1099
 
917
- def test_process_removes_backed_up_files_if_remove_backed_up_files_is_true
918
- was_in_process = false
919
- existing_file, backup_file, non_existant_dir, non_existant_file = setup_process_test do
920
- was_in_process = true
921
- touch_file(existing_file, "new content")
922
- end
923
-
924
- t.remove_backed_up_files = true
925
- t.execute(nil)
926
-
927
- # check the backup file was removed and that
928
- # there was no restore (no error was raised)
929
- assert was_in_process
930
- assert File.exists?(existing_file)
931
- assert_equal "new content", File.read(existing_file)
932
- assert !File.exists?(backup_file)
933
- assert !File.exists?(File.dirname(backup_file))
934
- end
1100
+ # def test_execute_removes_backed_up_files_if_cleanup_after_execute_is_true
1101
+ # was_in_execute = false
1102
+ # existing_file, backup_file, non_existant_dir, non_existant_file = setup_execute_test do
1103
+ # was_in_execute = true
1104
+ # touch_file(existing_file, "new content")
1105
+ # end
1106
+ #
1107
+ # t.cleanup_after_execute = true
1108
+ # t.execute(nil)
1109
+ #
1110
+ # # check the backup file was removed and that
1111
+ # # there was no restore (no error was raised)
1112
+ # assert was_in_execute
1113
+ # assert File.exists?(existing_file)
1114
+ # assert_equal "new content", File.read(existing_file)
1115
+ # assert !File.exists?(backup_file)
1116
+ # assert !File.exists?(File.dirname(backup_file))
1117
+ # assert !t.added_files.empty?
1118
+ # assert !t.added_files.include?(backup_file)
1119
+ # assert t.backed_up_files.empty?
1120
+ # end
935
1121
 
936
- def test_process_restores_backups_on_error_even_if_remove_backed_up_files_is_true
937
- was_in_process = false
938
- existing_file, backup_file, non_existant_dir, non_existant_file = setup_process_test do
939
- was_in_process = true
940
- touch_file(existing_file, "new content")
941
- raise "error"
942
- end
1122
+ # def test_execute_restores_backups_on_error_even_if_cleanup_after_execute_is_true
1123
+ # was_in_execute = false
1124
+ # existing_file, backup_file, non_existant_dir, non_existant_file = setup_execute_test do
1125
+ # was_in_execute = true
1126
+ # touch_file(existing_file, "new content")
1127
+ # raise "error"
1128
+ # end
1129
+ #
1130
+ # t.cleanup_after_execute = true
1131
+ # assert_raise(RuntimeError) { t.execute(nil) }
1132
+ #
1133
+ # # check the existing file was restored and
1134
+ # # backup file was removed
1135
+ # assert was_in_execute
1136
+ # assert File.exists?(existing_file)
1137
+ # assert_equal "original content", File.read(existing_file)
1138
+ # assert !File.exists?(backup_file)
1139
+ # assert !File.exists?(File.dirname(backup_file))
1140
+ # assert t.added_files.empty?
1141
+ # assert t.backed_up_files.empty?
1142
+ # end
943
1143
 
944
- t.remove_backed_up_files = true
945
- assert_raise(RuntimeError) { t.execute(nil) }
1144
+ def test_execute_does_not_rollback_results_from_prior_successful_executions
1145
+ existing_file = method_filepath(:output, "path/to/existing/file.txt")
1146
+ non_existant_dir = method_filepath(:output, "path/to/non/existing")
1147
+ non_existant_file = File.join(non_existant_dir, "file.txt")
1148
+ backup_file = method_filepath(:output, "backup/file.txt")
1149
+
1150
+ touch_file(existing_file, "original content")
1151
+ count = 0
1152
+ @t = Tap::FileTask.new do |task, input|
1153
+ if count > 0
1154
+ count = 2
1155
+ raise "error"
1156
+ else
1157
+ count = 1
1158
+ task.prepare([existing_file, non_existant_file])
1159
+ touch_file(existing_file, "new content")
1160
+ end
1161
+ end
1162
+
1163
+ # inference leads to the backup_file
1164
+ @t.inference do |root, dir, path|
1165
+ backup_file
1166
+ end
1167
+
1168
+ # assert !t.cleanup_after_execute
1169
+
1170
+ assert_nothing_raised { t.execute(nil) }
1171
+ assert_equal 1, count
1172
+ assert File.exists?(existing_file)
1173
+ assert_equal "new content", File.read(existing_file)
1174
+ assert File.exists?(non_existant_dir)
1175
+ assert File.exists?(backup_file)
1176
+ assert_equal "original content", File.read(backup_file)
1177
+
1178
+ assert_raise(RuntimeError) { t.execute(nil) }
946
1179
 
947
- # check the existing file was restored and
948
- # backup file was removed
949
- assert was_in_process
1180
+ # check the existing file was NOT restored
1181
+ assert_equal 2, count
950
1182
  assert File.exists?(existing_file)
951
- assert_equal "original content", File.read(existing_file)
952
- assert !File.exists?(backup_file)
953
- assert !File.exists?(File.dirname(backup_file))
1183
+ assert_equal "new content", File.read(existing_file)
1184
+ assert File.exists?(non_existant_dir)
1185
+ assert File.exists?(backup_file)
1186
+ assert_equal "original content", File.read(backup_file)
954
1187
  end
955
1188
 
956
1189
  #
957
- # test process with multiple files
1190
+ # test execute with multiple files
958
1191
  #
959
1192
 
960
- def setup_multiple_file_process_test(&block)
1193
+ def setup_multiple_file_execute_test(&block)
961
1194
  existing_files = [0,1].collect do |n|
962
- path = infer_filepath(:output, "path/to/existing/file#{n}.txt")
1195
+ path = method_filepath(:output, "path/to/existing/file#{n}.txt")
963
1196
  touch_file path, n.to_s
964
1197
  path
965
1198
  end
966
1199
 
967
1200
  non_existant_files = [0,1].collect do |n|
968
- infer_filepath(:output, "path/to/non/existing/file#{n}.txt")
1201
+ method_filepath(:output, "path/to/non/existing/file#{n}.txt")
969
1202
  end
970
1203
 
971
1204
  @t = Tap::FileTask.new do |task, input|
972
- task.make(existing_files + non_existant_files)
1205
+ task.prepare(existing_files + non_existant_files)
973
1206
  block.call if block_given?
974
1207
  end
975
1208
  # inference leads to an output_dir
976
1209
  @t.inference do |root, dir, path|
977
- infer_filepath(:output, 'backup', path)
1210
+ method_filepath(:output, 'backup', path)
978
1211
  end
979
1212
 
980
1213
  [existing_files, non_existant_files]
981
1214
  end
982
1215
 
983
- def test_setup_multiple_file_process_test
984
- existing_files, non_existant_files = setup_multiple_file_process_test do
1216
+ def test_setup_multiple_file_execute_test
1217
+ existing_files, non_existant_files = setup_multiple_file_execute_test do
985
1218
  (existing_files + existing_files).each do |file|
986
1219
  assert !File.exists?(file)
987
1220
  assert File.exists?(File.dirname(file))
@@ -990,21 +1223,21 @@ class FileTaskTest < Test::Unit::TestCase
990
1223
  t.execute(nil)
991
1224
  end
992
1225
 
993
- def test_process_restore_and_removal_with_multiple_files
994
- was_in_process = false
995
- existing_files, non_existant_files = setup_multiple_file_process_test do
996
- was_in_process = true
1226
+ def test_execute_restore_and_removal_with_multiple_files
1227
+ was_in_execute = false
1228
+ existing_files, non_existant_files = setup_multiple_file_execute_test do
1229
+ was_in_execute = true
997
1230
  (existing_files + non_existant_files) .each do |file|
998
1231
  touch_file file, "new content"
999
1232
  end
1000
1233
  raise "error"
1001
1234
  end
1002
1235
 
1003
- assert !File.exists?(infer_filepath(:output, 'backup'))
1236
+ assert !File.exists?(method_filepath(:output, 'backup'))
1004
1237
  assert_raise(RuntimeError) { t.execute(nil) }
1005
1238
 
1006
1239
  # check existing files were restored, made files and backups removed.
1007
- assert was_in_process
1240
+ assert was_in_execute
1008
1241
  existing_files.each_with_index do |existing_file, n|
1009
1242
  assert File.exists?(existing_file)
1010
1243
  assert_equal n.to_s, File.read(existing_file)
@@ -1012,30 +1245,30 @@ class FileTaskTest < Test::Unit::TestCase
1012
1245
  non_existant_files.each do |non_existing_file|
1013
1246
  assert !File.exists?(non_existing_file)
1014
1247
  end
1015
- assert !File.exists?(infer_filepath(:output, 'backup'))
1248
+ assert !File.exists?(method_filepath(:output, 'backup'))
1016
1249
  end
1017
1250
 
1018
- def test_process_remove_backed_up_files_with_multiple_files
1019
- was_in_process = false
1020
- existing_files, non_existant_files = setup_multiple_file_process_test do
1021
- was_in_process = true
1022
- (existing_files + non_existant_files) .each do |file|
1023
- touch_file file, "new content"
1024
- end
1025
- end
1026
-
1027
- assert !File.exists?(infer_filepath(:output, 'backup'))
1028
-
1029
- t.remove_backed_up_files = true
1030
- t.execute(nil)
1031
-
1032
- # check existing files were restored, made files and backups removed.
1033
- assert was_in_process
1034
- (existing_files + non_existant_files).each do |file|
1035
- assert File.exists?(file)
1036
- assert_equal "new content", File.read(file)
1037
- end
1038
- assert !File.exists?(infer_filepath(:output, 'backup'))
1039
- end
1251
+ # def test_execute_cleanup_after_execute_with_multiple_files
1252
+ # was_in_execute = false
1253
+ # existing_files, non_existant_files = setup_multiple_file_execute_test do
1254
+ # was_in_execute = true
1255
+ # (existing_files + non_existant_files) .each do |file|
1256
+ # touch_file file, "new content"
1257
+ # end
1258
+ # end
1259
+ #
1260
+ # assert !File.exists?(method_filepath(:output, 'backup'))
1261
+ #
1262
+ # t.cleanup_after_execute = true
1263
+ # t.execute(nil)
1264
+ #
1265
+ # # check existing files were restored, made files and backups removed.
1266
+ # assert was_in_execute
1267
+ # (existing_files + non_existant_files).each do |file|
1268
+ # assert File.exists?(file)
1269
+ # assert_equal "new content", File.read(file)
1270
+ # end
1271
+ # assert !File.exists?(method_filepath(:output, 'backup'))
1272
+ # end
1040
1273
 
1041
1274
  end