tap 0.8.0 → 0.9.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (185) hide show
  1. data/Basic Overview +151 -0
  2. data/Command Reference +99 -0
  3. data/History +24 -0
  4. data/MIT-LICENSE +1 -1
  5. data/README +29 -57
  6. data/Rakefile +30 -37
  7. data/Tutorial +243 -191
  8. data/bin/tap +66 -35
  9. data/lib/tap.rb +47 -29
  10. data/lib/tap/app.rb +700 -342
  11. data/lib/tap/{script → cmd}/console.rb +0 -0
  12. data/lib/tap/{script → cmd}/destroy.rb +0 -0
  13. data/lib/tap/{script → cmd}/generate.rb +0 -0
  14. data/lib/tap/cmd/run.rb +156 -0
  15. data/lib/tap/constants.rb +4 -0
  16. data/lib/tap/dump.rb +57 -0
  17. data/lib/tap/env.rb +316 -0
  18. data/lib/tap/file_task.rb +106 -109
  19. data/lib/tap/generator.rb +4 -1
  20. data/lib/tap/generator/generators/command/USAGE +6 -0
  21. data/lib/tap/generator/generators/command/command_generator.rb +17 -0
  22. data/lib/tap/generator/generators/{script/templates/script.erb → command/templates/command.erb} +10 -10
  23. data/lib/tap/generator/generators/config/USAGE +21 -0
  24. data/lib/tap/generator/generators/config/config_generator.rb +17 -7
  25. data/lib/tap/generator/generators/file_task/USAGE +3 -0
  26. data/lib/tap/generator/generators/file_task/file_task_generator.rb +16 -0
  27. data/lib/tap/generator/generators/file_task/templates/file.txt +2 -0
  28. data/lib/tap/generator/generators/file_task/templates/file.yml +3 -0
  29. data/lib/tap/generator/generators/file_task/templates/task.erb +26 -20
  30. data/lib/tap/generator/generators/file_task/templates/test.erb +20 -10
  31. data/lib/tap/generator/generators/generator/generator_generator.rb +1 -1
  32. data/lib/tap/generator/generators/generator/templates/generator.erb +21 -12
  33. data/lib/tap/generator/generators/root/templates/Rakefile +33 -24
  34. data/lib/tap/generator/generators/root/templates/tap.yml +28 -31
  35. data/lib/tap/generator/generators/root/templates/test/tap_test_helper.rb +1 -0
  36. data/lib/tap/generator/generators/task/USAGE +3 -0
  37. data/lib/tap/generator/generators/task/task_generator.rb +18 -5
  38. data/lib/tap/generator/generators/task/templates/task.erb +7 -12
  39. data/lib/tap/generator/generators/task/templates/test.erb +10 -11
  40. data/lib/tap/generator/generators/workflow/templates/task.erb +1 -1
  41. data/lib/tap/generator/generators/workflow/templates/test.erb +1 -1
  42. data/lib/tap/patches/rake/rake_test_loader.rb +8 -0
  43. data/lib/tap/patches/rake/testtask.rb +55 -0
  44. data/lib/tap/patches/ruby19/backtrace_filter.rb +51 -0
  45. data/lib/tap/patches/ruby19/parsedate.rb +16 -0
  46. data/lib/tap/root.rb +172 -67
  47. data/lib/tap/script.rb +70 -336
  48. data/lib/tap/support/aggregator.rb +55 -0
  49. data/lib/tap/support/audit.rb +281 -280
  50. data/lib/tap/support/batchable.rb +59 -0
  51. data/lib/tap/support/class_configuration.rb +279 -0
  52. data/lib/tap/support/configurable.rb +92 -0
  53. data/lib/tap/support/configurable_methods.rb +296 -0
  54. data/lib/tap/support/executable.rb +98 -0
  55. data/lib/tap/support/executable_queue.rb +82 -0
  56. data/lib/tap/support/logger.rb +9 -15
  57. data/lib/tap/support/rake.rb +43 -54
  58. data/lib/tap/support/run_error.rb +32 -13
  59. data/lib/tap/support/shell_utils.rb +47 -0
  60. data/lib/tap/support/tdoc.rb +9 -8
  61. data/lib/tap/support/tdoc/config_attr.rb +40 -16
  62. data/lib/tap/support/validation.rb +77 -0
  63. data/lib/tap/support/versions.rb +36 -36
  64. data/lib/tap/task.rb +276 -482
  65. data/lib/tap/test.rb +20 -261
  66. data/lib/tap/test/env_vars.rb +7 -5
  67. data/lib/tap/test/file_methods.rb +126 -121
  68. data/lib/tap/test/subset_methods.rb +86 -45
  69. data/lib/tap/test/tap_methods.rb +271 -0
  70. data/lib/tap/workflow.rb +174 -46
  71. data/test/app/config/another/task.yml +1 -0
  72. data/test/app/config/erb.yml +2 -1
  73. data/test/app/config/some/task.yml +1 -0
  74. data/test/app/config/template.yml +2 -6
  75. data/test/app_test.rb +1241 -1008
  76. data/test/env/test_configure/recurse_a.yml +2 -0
  77. data/test/env/test_configure/recurse_b.yml +2 -0
  78. data/test/env/test_configure/tap.yml +23 -0
  79. data/test/env/test_load_env_config/dir/tap.yml +3 -0
  80. data/test/env/test_load_env_config/recurse_a.yml +2 -0
  81. data/test/env/test_load_env_config/recurse_b.yml +2 -0
  82. data/test/env/test_load_env_config/tap.yml +3 -0
  83. data/test/env_test.rb +198 -0
  84. data/test/file_task_test.rb +70 -53
  85. data/{lib/tap/generator/generators/package/USAGE → test/root/file.txt} +0 -0
  86. data/test/root_test.rb +621 -454
  87. data/test/script_test.rb +38 -174
  88. data/test/support/aggregator_test.rb +99 -0
  89. data/test/support/audit_test.rb +409 -416
  90. data/test/support/batchable_test.rb +74 -0
  91. data/test/support/{task_configuration_test.rb → class_configuration_test.rb} +106 -47
  92. data/test/{task/config/overriding.yml → support/configurable/config/configured.yml} +0 -0
  93. data/test/support/configurable_test.rb +295 -0
  94. data/test/support/executable_queue_test.rb +103 -0
  95. data/test/support/executable_test.rb +38 -0
  96. data/test/support/logger_test.rb +17 -17
  97. data/test/support/rake_test.rb +4 -2
  98. data/test/support/shell_utils_test.rb +24 -0
  99. data/test/support/tdoc_test.rb +265 -258
  100. data/test/support/validation_test.rb +54 -0
  101. data/test/support/versions_test.rb +38 -38
  102. data/test/tap_test_helper.rb +19 -5
  103. data/test/tap_test_suite.rb +5 -2
  104. data/test/task_base_test.rb +13 -104
  105. data/test/task_syntax_test.rb +300 -0
  106. data/test/task_test.rb +258 -381
  107. data/test/test/env_vars_test.rb +40 -40
  108. data/test/test/file_methods/{test_assert_output_files_equal → test_assert_files}/expected/one.txt +0 -0
  109. data/test/test/file_methods/{test_assert_output_files_equal → test_assert_files}/expected/two.txt +0 -0
  110. data/test/test/file_methods/{test_assert_output_files_equal → test_assert_files}/input/one.txt +0 -0
  111. data/test/test/file_methods/{test_assert_output_files_equal → test_assert_files}/input/two.txt +0 -0
  112. data/test/test/{test_file_task_test → file_methods/test_assert_files_can_have_no_expected_files_if_specified}/input/one.txt +0 -0
  113. data/test/test/{test_file_task_test → file_methods/test_assert_files_can_have_no_expected_files_if_specified}/input/two.txt +0 -0
  114. data/test/test/file_methods/test_assert_files_fails_for_different_content/expected/one.txt +1 -0
  115. data/test/test/{test_file_task_test → file_methods/test_assert_files_fails_for_different_content}/expected/two.txt +0 -0
  116. data/test/test/file_methods/test_assert_files_fails_for_different_content/input/one.txt +1 -0
  117. data/test/test/file_methods/test_assert_files_fails_for_different_content/input/two.txt +1 -0
  118. data/test/test/{test_file_task_test → file_methods/test_assert_files_fails_for_missing_expected_file}/expected/one.txt +0 -0
  119. data/test/test/file_methods/test_assert_files_fails_for_missing_expected_file/input/one.txt +1 -0
  120. data/test/test/file_methods/test_assert_files_fails_for_missing_expected_file/input/two.txt +1 -0
  121. data/test/test/file_methods/test_assert_files_fails_for_missing_output_file/expected/one.txt +1 -0
  122. data/test/test/file_methods/test_assert_files_fails_for_missing_output_file/expected/two.txt +1 -0
  123. data/test/test/file_methods/test_assert_files_fails_for_missing_output_file/input/one.txt +1 -0
  124. data/test/test/file_methods/test_assert_files_fails_for_missing_output_file/input/two.txt +1 -0
  125. data/test/test/file_methods/test_assert_files_fails_for_no_expected_files/input/one.txt +1 -0
  126. data/test/test/file_methods/test_assert_files_fails_for_no_expected_files/input/two.txt +1 -0
  127. data/test/test/file_methods_doc/test_sub/expected/one.txt +1 -0
  128. data/test/test/file_methods_doc/test_sub/expected/two.txt +1 -0
  129. data/test/test/file_methods_doc/test_sub/input/one.txt +1 -0
  130. data/test/test/file_methods_doc/test_sub/input/two.txt +1 -0
  131. data/test/test/file_methods_doc_test.rb +29 -0
  132. data/test/test/file_methods_test.rb +214 -143
  133. data/test/test/subset_methods_test.rb +111 -115
  134. data/test/test/{test_assert_expected_result_files → tap_methods/test_assert_files}/expected/task/name/a.txt +0 -0
  135. data/test/test/{test_assert_expected_result_files → tap_methods/test_assert_files}/expected/task/name/b.txt +0 -0
  136. data/test/test/{test_assert_expected_result_files → tap_methods/test_assert_files}/input/a.txt +0 -0
  137. data/test/test/{test_assert_expected_result_files → tap_methods/test_assert_files}/input/b.txt +0 -0
  138. data/test/test/tap_methods_test.rb +399 -0
  139. data/test/workflow_test.rb +101 -91
  140. metadata +86 -70
  141. data/lib/tap/generator/generators/package/package_generator.rb +0 -38
  142. data/lib/tap/generator/generators/package/templates/package.erb +0 -186
  143. data/lib/tap/generator/generators/script/USAGE +0 -0
  144. data/lib/tap/generator/generators/script/script_generator.rb +0 -17
  145. data/lib/tap/script/run.rb +0 -154
  146. data/lib/tap/support/batch_queue.rb +0 -162
  147. data/lib/tap/support/combinator.rb +0 -114
  148. data/lib/tap/support/task_configuration.rb +0 -169
  149. data/lib/tap/support/template.rb +0 -81
  150. data/lib/tap/support/templater.rb +0 -155
  151. data/lib/tap/version.rb +0 -4
  152. data/test/app/config/addition_template.yml +0 -6
  153. data/test/app_class_test.rb +0 -33
  154. data/test/check/binding_eval.rb +0 -23
  155. data/test/check/define_method_check.rb +0 -22
  156. data/test/check/dependencies_check.rb +0 -175
  157. data/test/check/inheritance_check.rb +0 -22
  158. data/test/support/batch_queue_test.rb +0 -320
  159. data/test/support/combinator_test.rb +0 -249
  160. data/test/support/template_test.rb +0 -122
  161. data/test/support/templater/erb.txt +0 -2
  162. data/test/support/templater/erb.yml +0 -2
  163. data/test/support/templater/somefile.txt +0 -2
  164. data/test/support/templater_test.rb +0 -192
  165. data/test/task/config/template.yml +0 -4
  166. data/test/task_class_test.rb +0 -170
  167. data/test/task_execute_test.rb +0 -262
  168. data/test/test/file_methods/test_assert_expected/expected/file.txt +0 -1
  169. data/test/test/file_methods/test_assert_expected/expected/folder/file.txt +0 -1
  170. data/test/test/file_methods/test_assert_expected/input/file.txt +0 -1
  171. data/test/test/file_methods/test_assert_expected/input/folder/file.txt +0 -1
  172. data/test/test/file_methods/test_assert_files_exist/input/input_1.txt +0 -0
  173. data/test/test/file_methods/test_assert_files_exist/input/input_2.txt +0 -0
  174. data/test/test/file_methods/test_file_compare/expected/output_1.txt +0 -3
  175. data/test/test/file_methods/test_file_compare/expected/output_2.txt +0 -1
  176. data/test/test/file_methods/test_file_compare/input/input_1.txt +0 -3
  177. data/test/test/file_methods/test_file_compare/input/input_2.txt +0 -3
  178. data/test/test/file_methods/test_infer_glob/expected/file.yml +0 -0
  179. data/test/test/file_methods/test_infer_glob/expected/file_1.txt +0 -0
  180. data/test/test/file_methods/test_infer_glob/expected/file_2.txt +0 -0
  181. data/test/test/file_methods/test_yml_compare/expected/output_1.yml +0 -6
  182. data/test/test/file_methods/test_yml_compare/expected/output_2.yml +0 -6
  183. data/test/test/file_methods/test_yml_compare/input/input_1.yml +0 -4
  184. data/test/test/file_methods/test_yml_compare/input/input_2.yml +0 -4
  185. data/test/test_test.rb +0 -373
@@ -1,4 +0,0 @@
1
- one: ONE
2
- variations!:
3
- - two: TWO
4
- - three: THREE
@@ -1,170 +0,0 @@
1
- require File.join(File.dirname(__FILE__), 'tap_test_helper')
2
- require 'tap/task'
3
-
4
- class TaskClassTest < Test::Unit::TestCase
5
-
6
- #
7
- # task config tests
8
- #
9
-
10
- class TaskWithDefaultConfig < Tap::Task
11
- declare_config
12
-
13
- config :one, 1
14
- config :two, 2
15
- config :three, 3
16
-
17
- config_accessor :one
18
- config_writer :two
19
- config_reader :three
20
- end
21
-
22
- class SomeTask < Tap::Task
23
- config :key, 'value' # a sample config
24
- end
25
-
26
- def test_class_configurations_doc
27
- t = SomeTask.new
28
- assert_equal 'value', t.key
29
- t.key = 'another'
30
- assert_equal({:key => 'another'}, t.config)
31
- end
32
-
33
- def test_task_class_configurations_and_default_config_set_by_class_configurations
34
- assert_equal(
35
- {TaskWithDefaultConfig => [0, :one, :two, :three]},
36
- TaskWithDefaultConfig.configurations.declarations)
37
- assert_equal({:one => 1, :two => 2, :three => 3}, TaskWithDefaultConfig.configurations.default)
38
- end
39
-
40
- def test_task_default_config_set_by_default_config
41
- t = TaskWithDefaultConfig.new
42
- assert_equal({:one => 1, :two => 2, :three => 3}, t.config)
43
-
44
- t = TaskWithDefaultConfig.new nil, :one => "one"
45
- assert_equal({:one => "one", :two => 2, :three => 3}, t.config)
46
- end
47
-
48
- def test_config_reader_and_writer_defined_by_config_accessor
49
- t = TaskWithDefaultConfig.new
50
- assert t.respond_to?(:one)
51
- assert t.respond_to?("one=")
52
-
53
- assert_equal 1, t.one
54
- assert_equal 1, t.config[:one]
55
-
56
- t.one = "one"
57
- assert_equal "one", t.one
58
- assert_equal "one", t.config[:one]
59
- end
60
-
61
- def test_config_reader_defined_by_config_reader
62
- t = TaskWithDefaultConfig.new
63
- assert t.respond_to?(:three)
64
- assert !t.respond_to?("three=")
65
-
66
- assert_equal 3, t.three
67
- assert_equal 3, t.config[:three]
68
- end
69
-
70
- def test_config_writer_defined_by_config_writer
71
- t = TaskWithDefaultConfig.new
72
- assert !t.respond_to?(:two)
73
- assert t.respond_to?("two=")
74
-
75
- assert_equal 2, t.config[:two]
76
- t.two = "two"
77
- assert_equal "two", t.config[:two]
78
- end
79
-
80
- # class ConfigFormats < Tap::Task
81
- # config :a, [:b, 'b']
82
- # config_accessor [:d, 'd'], :e
83
- # end
84
- #
85
- # def test_config_formats_create_configs_as_expected
86
- # assert_equal({:a => nil, :b => 'b', :d => 'd', :e => nil}, ConfigFormats.configurations.hash)
87
- #
88
- # t = ConfigFormats.new
89
- # assert !t.respond_to?(:a)
90
- # assert !t.respond_to?(:b)
91
- # assert t.respond_to?(:d)
92
- # assert t.respond_to?(:e)
93
- # assert_nil t.config[:a]
94
- # assert_equal 'b', t.config[:b]
95
- # assert_equal 'd', t.d
96
- # assert_nil t.e
97
- # end
98
-
99
- #
100
- # test subclass behavior
101
- #
102
-
103
- class SubclassedTask < TaskWithDefaultConfig
104
- config :one, "one"
105
- config :four, 4
106
- end
107
-
108
- def test_config_accessors_are_inherited
109
- t = SubclassedTask.new
110
-
111
- assert t.respond_to?(:one)
112
- assert t.respond_to?("one=")
113
- assert !t.respond_to?(:two)
114
- assert t.respond_to?("two=")
115
- assert t.respond_to?(:three)
116
- assert !t.respond_to?("three=")
117
-
118
- assert t.respond_to?(:four)
119
- assert t.respond_to?("four=")
120
- end
121
-
122
- def test_class_configurations_are_inherited_but_can_be_overridden
123
- assert_equal({
124
- TaskWithDefaultConfig => [0, :one, :two, :three],
125
- SubclassedTask => [1, :four]},
126
- SubclassedTask.configurations.declarations)
127
-
128
- assert_equal({:one => 1, :two => 2, :three => 3}, TaskWithDefaultConfig.configurations.default)
129
- end
130
-
131
- def test_default_configs_are_inherited_but_can_be_overridden
132
- s = SubclassedTask.new
133
- assert_equal({:one => "one", :two => 2, :three => 3, :four => 4}, s.config)
134
-
135
- # assure subclass configs do not affect superclass
136
- t = TaskWithDefaultConfig.new
137
- assert_equal({:one => 1, :two => 2, :three => 3}, t.config)
138
- end
139
-
140
- #
141
- # iterative tests
142
- #
143
-
144
- def test_iterative_is_by_default_true
145
- assert Tap::Task.iterative
146
- end
147
-
148
- class NonIterativeTask < Tap::Task
149
- do_not_iterate
150
- end
151
-
152
- def test_do_not_iterate_sets_iterative_to_false
153
- assert !NonIterativeTask.iterative
154
- end
155
-
156
- class AnotherNonIterativeTask < NonIterativeTask
157
- end
158
-
159
- def test_iterative_is_inherited
160
- assert !AnotherNonIterativeTask.iterative
161
- end
162
-
163
- class IterativeTask < NonIterativeTask
164
- iterate
165
- end
166
-
167
- def test_iterative_can_be_reset_with_iterate
168
- assert IterativeTask.iterative
169
- end
170
- end
@@ -1,262 +0,0 @@
1
- require File.join(File.dirname(__FILE__), 'tap_test_helper')
2
- require 'tap/task'
3
-
4
- class TaskExecuteTest < Test::Unit::TestCase
5
- include Tap
6
- include TapTestMethods
7
-
8
- acts_as_tap_test
9
-
10
- attr_accessor :t1, :t2, :t3, :t4
11
-
12
- def setup
13
- super
14
- 1.upto(4) do |index|
15
- var = "t#{index}".to_sym
16
- self.send("#{var}=", Task.new(&echo))
17
- end
18
- end
19
-
20
- #
21
- # check t1-t4 are iterative
22
- #
23
-
24
- def test_t1_to_t4_tasks_are_iterative
25
- assert t1.iterate?
26
- assert t2.iterate?
27
- assert t3.iterate?
28
- assert t4.iterate?
29
- end
30
-
31
- #
32
- # condition and on_complete tests
33
- #
34
-
35
- def test_execute_raises_error_unless_condtion_block_returns_true
36
- t = Task.new
37
- t.condition {false}
38
- assert_raise(RuntimeError) { t.execute }
39
- end
40
-
41
- def test_on_complete_executes_after_execute_and_recieves_results
42
- t = Task.new
43
-
44
- recieved = nil
45
- t.on_complete do |results|
46
- recieved = results
47
- end
48
-
49
- t.execute(1,2,3)
50
-
51
- assert_equal t.results, recieved
52
- end
53
-
54
- #
55
- # iterative execute tests
56
- #
57
-
58
- def test_execute_without_inputs_produces_empty_results
59
- t1.execute
60
-
61
- assert_equal [], runlist
62
- assert_equal [], t1.results
63
- end
64
-
65
- def test_execute_iteratively_processes_and_audits_each_input
66
- t1.execute([1,2], 3)
67
-
68
- assert_equal [[1,2], 3], runlist
69
- assert_inputs(t1 => [[1,2], 3])
70
- assert_outputs(t1 => [[1,2], 3])
71
- assert_audits(
72
- t1.results,
73
- 0 => [[nil, [1,2]], [t1, [1,2]]],
74
- 1 => [[nil, 3], [t1, 3]])
75
- end
76
-
77
- #
78
- # iterative audit tests
79
- #
80
-
81
- def test_each_result_is_an_audit
82
- t1.execute 1,2
83
-
84
- t1.results.each do |r|
85
- assert r.kind_of?(Support::Audit)
86
- end
87
- end
88
-
89
- def test_execute_passes_audit_trails
90
- t1.execute 1,2
91
- t2.execute(*t1.results)
92
- t3.execute(*t2.results)
93
-
94
- assert_outputs(
95
- t1 => [1,2],
96
- t2 => [1,2],
97
- t3 => [1,2])
98
- assert_audits(
99
- t3.results,
100
- 0 => [[nil, 1],[t1, 1],[t2, 1],[t3, 1]],
101
- 1 => [[nil, 2],[t1, 2],[t2, 2],[t3, 2]])
102
- end
103
-
104
- def test_execute_audits_additional_inputs
105
- t1.execute 1,2
106
- t2.execute(*(t1.results + [3]))
107
- t3.execute(*(t2.results + [4]))
108
-
109
- assert_outputs(
110
- t1 => [1,2],
111
- t2 => [1,2,3],
112
- t3 => [1,2,3,4])
113
- assert_audits(
114
- t3.results,
115
- 0 => [[nil, 1], [t1, 1],[t2, 1],[t3, 1]],
116
- 1 => [[nil, 2], [t1, 2],[t2, 2],[t3, 2]],
117
- 2 => [[nil, 3], [t2, 3],[t3, 3]],
118
- 3 => [[nil, 4], [t3, 4]])
119
-
120
- check_audit(t3.results[0]) do
121
- 1._from nil
122
- 1._from t1
123
- 1._from t2
124
- 1._from t3
125
- end
126
- end
127
-
128
- class NonIterativeTask < Task
129
- do_not_iterate
130
- end
131
-
132
- #
133
- # check NonIterativeTask is set to not iterate
134
- #
135
-
136
- def test_do_not_iterate
137
- assert !NonIterativeTask.iterative
138
- t = NonIterativeTask.new
139
- assert !t.iterate?
140
- end
141
-
142
- #
143
- # non iterative execute tests
144
- #
145
-
146
- def test_non_iterative_execute_processes_inputs_as_one_input
147
- t = NonIterativeTask.new(&echo)
148
- t.execute(1,2,3)
149
-
150
- assert_equal [[1,2,3]], runlist
151
- assert_inputs(t => [[1,2,3]])
152
- assert_outputs(t => [[1,2,3]])
153
- assert_audits(
154
- t.results,
155
- 0 => [ [[nil, nil, nil], [1,2,3]], [t, [1,2,3]] ])
156
- end
157
-
158
- def test_non_iterative_execute_respects_array_inputs
159
- t = NonIterativeTask.new(&echo)
160
- t.execute([1,2], 3)
161
-
162
- assert_equal [[[1,2], 3]], runlist
163
- assert_inputs(t => [[[1,2], 3]])
164
- assert_outputs(t => [[[1,2], 3]])
165
- assert_audits(
166
- t.results,
167
- 0 => [ [[nil, nil], [[1,2], 3]], [t, [[1,2], 3]] ])
168
- end
169
-
170
- def test_non_iterative_execute_without_inputs
171
- was_in_block = false
172
- t = NonIterativeTask.new do |task, input|
173
- assert_nil input
174
- was_in_block = true
175
- end
176
-
177
- t.execute
178
- assert was_in_block
179
-
180
- was_in_block = false
181
- t.app.run(t)
182
- assert was_in_block
183
-
184
- was_in_block = false
185
- t = NonIterativeTask.new do
186
- was_in_block = true
187
- end
188
-
189
- t.execute
190
- assert was_in_block
191
-
192
- was_in_block = false
193
- t.app.run(t)
194
- assert was_in_block
195
- end
196
-
197
-
198
- #
199
- # non iterative audit tests
200
- #
201
-
202
- def test_non_iterative_execute_audits_inputs_as_one_unit
203
- t = NonIterativeTask.new(&echo)
204
- t.execute 1,2
205
-
206
- assert_outputs(t => [[1,2]])
207
- assert_audits(
208
- t.results,
209
- 0 => [
210
- [[nil, nil], [1,2]], # original source
211
- [t, [1,2]]] # final value
212
- )
213
- end
214
-
215
- def test_non_iterative_execute_audits_additional_inputs_as_one_unit
216
- t1 = NonIterativeTask.new(&echo)
217
- t2 = NonIterativeTask.new(&echo)
218
-
219
- t1.execute 1,2
220
- assert_outputs(t1 => [[1,2]])
221
-
222
- t2.execute(t1.results.first, 3)
223
-
224
- assert_outputs(
225
- t2 => [ [[1,2],3] ])
226
- assert_audits(
227
- t2.results,
228
- 0 => [
229
- [[[[nil, nil], t1], nil], [[1, 2], 3]], # original source
230
- [t2, [[1, 2], 3]]] # final value source
231
- )
232
-
233
- check_audit(t2.results[0]) do
234
- [[1,2], 3]._from(t2) {
235
- [1,2]._from(t1) {
236
- 1._from nil
237
- 2._from nil }
238
- 3._from nil }
239
- end
240
- end
241
-
242
-
243
- #
244
- # synchronization tests
245
- #
246
-
247
- def test_execute_is_synchronized
248
- extended_test do
249
- count = 0
250
- counter = Task.new do
251
- count += 1
252
- end
253
-
254
- t1 = Thread.new { 10000.times { counter.execute(1) } }
255
- t2 = Thread.new { 10000.times { counter.execute(1) } }
256
- t1.join
257
- t2.join
258
-
259
- assert_equal 20000, count
260
- end
261
- end
262
- end