tap 0.7.9

Sign up to get free protection for your applications and to get access to all the features.
Files changed (146) hide show
  1. data/MIT-LICENSE +21 -0
  2. data/README +71 -0
  3. data/Rakefile +117 -0
  4. data/bin/tap +63 -0
  5. data/lib/tap.rb +15 -0
  6. data/lib/tap/app.rb +739 -0
  7. data/lib/tap/file_task.rb +354 -0
  8. data/lib/tap/generator.rb +29 -0
  9. data/lib/tap/generator/generators/config/USAGE +0 -0
  10. data/lib/tap/generator/generators/config/config_generator.rb +23 -0
  11. data/lib/tap/generator/generators/config/templates/config.erb +2 -0
  12. data/lib/tap/generator/generators/file_task/USAGE +0 -0
  13. data/lib/tap/generator/generators/file_task/file_task_generator.rb +21 -0
  14. data/lib/tap/generator/generators/file_task/templates/task.erb +27 -0
  15. data/lib/tap/generator/generators/file_task/templates/test.erb +12 -0
  16. data/lib/tap/generator/generators/root/USAGE +0 -0
  17. data/lib/tap/generator/generators/root/root_generator.rb +36 -0
  18. data/lib/tap/generator/generators/root/templates/Rakefile +48 -0
  19. data/lib/tap/generator/generators/root/templates/app.yml +19 -0
  20. data/lib/tap/generator/generators/root/templates/config/process_tap_request.yml +4 -0
  21. data/lib/tap/generator/generators/root/templates/lib/process_tap_request.rb +26 -0
  22. data/lib/tap/generator/generators/root/templates/public/images/nav.jpg +0 -0
  23. data/lib/tap/generator/generators/root/templates/public/stylesheets/color.css +57 -0
  24. data/lib/tap/generator/generators/root/templates/public/stylesheets/layout.css +108 -0
  25. data/lib/tap/generator/generators/root/templates/public/stylesheets/normalize.css +40 -0
  26. data/lib/tap/generator/generators/root/templates/public/stylesheets/typography.css +21 -0
  27. data/lib/tap/generator/generators/root/templates/server/config/environment.rb +60 -0
  28. data/lib/tap/generator/generators/root/templates/server/lib/tasks/clear_database_prerequisites.rake +5 -0
  29. data/lib/tap/generator/generators/root/templates/server/test/test_helper.rb +53 -0
  30. data/lib/tap/generator/generators/root/templates/test/tap_test_helper.rb +3 -0
  31. data/lib/tap/generator/generators/root/templates/test/tap_test_suite.rb +4 -0
  32. data/lib/tap/generator/generators/task/USAGE +0 -0
  33. data/lib/tap/generator/generators/task/task_generator.rb +21 -0
  34. data/lib/tap/generator/generators/task/templates/task.erb +21 -0
  35. data/lib/tap/generator/generators/task/templates/test.erb +29 -0
  36. data/lib/tap/generator/generators/workflow/USAGE +0 -0
  37. data/lib/tap/generator/generators/workflow/templates/task.erb +16 -0
  38. data/lib/tap/generator/generators/workflow/templates/test.erb +7 -0
  39. data/lib/tap/generator/generators/workflow/workflow_generator.rb +21 -0
  40. data/lib/tap/generator/options.rb +26 -0
  41. data/lib/tap/generator/usage.rb +26 -0
  42. data/lib/tap/root.rb +275 -0
  43. data/lib/tap/script/console.rb +7 -0
  44. data/lib/tap/script/destroy.rb +8 -0
  45. data/lib/tap/script/generate.rb +8 -0
  46. data/lib/tap/script/run.rb +111 -0
  47. data/lib/tap/script/server.rb +12 -0
  48. data/lib/tap/support/audit.rb +415 -0
  49. data/lib/tap/support/batch_queue.rb +165 -0
  50. data/lib/tap/support/combinator.rb +114 -0
  51. data/lib/tap/support/logger.rb +91 -0
  52. data/lib/tap/support/rap.rb +38 -0
  53. data/lib/tap/support/run_error.rb +20 -0
  54. data/lib/tap/support/template.rb +81 -0
  55. data/lib/tap/support/templater.rb +155 -0
  56. data/lib/tap/support/versions.rb +63 -0
  57. data/lib/tap/task.rb +448 -0
  58. data/lib/tap/test.rb +320 -0
  59. data/lib/tap/test/env_vars.rb +16 -0
  60. data/lib/tap/test/inference_methods.rb +298 -0
  61. data/lib/tap/test/subset_methods.rb +260 -0
  62. data/lib/tap/version.rb +3 -0
  63. data/lib/tap/workflow.rb +73 -0
  64. data/test/app/config/addition_template.yml +6 -0
  65. data/test/app/config/batch.yml +2 -0
  66. data/test/app/config/empty.yml +0 -0
  67. data/test/app/config/erb.yml +1 -0
  68. data/test/app/config/template.yml +6 -0
  69. data/test/app/config/version-0.1.yml +1 -0
  70. data/test/app/config/version.yml +1 -0
  71. data/test/app/lib/app_test_task.rb +2 -0
  72. data/test/app_class_test.rb +33 -0
  73. data/test/app_test.rb +1372 -0
  74. data/test/file_task/config/batch.yml +2 -0
  75. data/test/file_task/config/configured.yml +1 -0
  76. data/test/file_task/old_file_one.txt +0 -0
  77. data/test/file_task/old_file_two.txt +0 -0
  78. data/test/file_task_test.rb +1041 -0
  79. data/test/root/alt_lib/alt_module.rb +4 -0
  80. data/test/root/lib/absolute_alt_filepath.rb +2 -0
  81. data/test/root/lib/alternative_filepath.rb +2 -0
  82. data/test/root/lib/another_module.rb +2 -0
  83. data/test/root/lib/nested/some_module.rb +4 -0
  84. data/test/root/lib/no_module_included.rb +0 -0
  85. data/test/root/lib/some/module.rb +4 -0
  86. data/test/root/lib/some_class.rb +2 -0
  87. data/test/root/lib/some_module.rb +3 -0
  88. data/test/root/load_path/load_path_module.rb +2 -0
  89. data/test/root/load_path/skip_module.rb +2 -0
  90. data/test/root/mtime/older.txt +0 -0
  91. data/test/root/unload/full_path.rb +2 -0
  92. data/test/root/unload/loaded_by_nested.rb +2 -0
  93. data/test/root/unload/nested/nested_load.rb +6 -0
  94. data/test/root/unload/nested/nested_with_ext.rb +4 -0
  95. data/test/root/unload/nested/relative_path.rb +4 -0
  96. data/test/root/unload/older.rb +2 -0
  97. data/test/root/unload/unload_base.rb +9 -0
  98. data/test/root/versions/another.yml +0 -0
  99. data/test/root/versions/file-0.1.2.yml +0 -0
  100. data/test/root/versions/file-0.1.yml +0 -0
  101. data/test/root/versions/file.yml +0 -0
  102. data/test/root_test.rb +483 -0
  103. data/test/support/audit_test.rb +449 -0
  104. data/test/support/batch_queue_test.rb +320 -0
  105. data/test/support/combinator_test.rb +249 -0
  106. data/test/support/logger_test.rb +31 -0
  107. data/test/support/template_test.rb +122 -0
  108. data/test/support/templater/erb.txt +2 -0
  109. data/test/support/templater/erb.yml +2 -0
  110. data/test/support/templater/somefile.txt +2 -0
  111. data/test/support/templater_test.rb +192 -0
  112. data/test/support/versions_test.rb +71 -0
  113. data/test/tap_test_helper.rb +4 -0
  114. data/test/tap_test_suite.rb +4 -0
  115. data/test/task/config/batch.yml +2 -0
  116. data/test/task/config/batched.yml +2 -0
  117. data/test/task/config/configured.yml +1 -0
  118. data/test/task/config/example.yml +1 -0
  119. data/test/task/config/overriding.yml +2 -0
  120. data/test/task/config/task_with_config.yml +1 -0
  121. data/test/task/config/template.yml +4 -0
  122. data/test/task_class_test.rb +118 -0
  123. data/test/task_execute_test.rb +233 -0
  124. data/test/task_test.rb +424 -0
  125. data/test/test/inference_methods/test_assert_expected/expected/file.txt +1 -0
  126. data/test/test/inference_methods/test_assert_expected/expected/folder/file.txt +1 -0
  127. data/test/test/inference_methods/test_assert_expected/input/file.txt +1 -0
  128. data/test/test/inference_methods/test_assert_expected/input/folder/file.txt +1 -0
  129. data/test/test/inference_methods/test_assert_files_exist/input/input_1.txt +0 -0
  130. data/test/test/inference_methods/test_assert_files_exist/input/input_2.txt +0 -0
  131. data/test/test/inference_methods/test_file_compare/expected/output_1.txt +3 -0
  132. data/test/test/inference_methods/test_file_compare/expected/output_2.txt +1 -0
  133. data/test/test/inference_methods/test_file_compare/input/input_1.txt +3 -0
  134. data/test/test/inference_methods/test_file_compare/input/input_2.txt +3 -0
  135. data/test/test/inference_methods/test_infer_glob/expected/file.yml +0 -0
  136. data/test/test/inference_methods/test_infer_glob/expected/file_1.txt +0 -0
  137. data/test/test/inference_methods/test_infer_glob/expected/file_2.txt +0 -0
  138. data/test/test/inference_methods/test_yml_compare/expected/output_1.yml +6 -0
  139. data/test/test/inference_methods/test_yml_compare/expected/output_2.yml +6 -0
  140. data/test/test/inference_methods/test_yml_compare/input/input_1.yml +4 -0
  141. data/test/test/inference_methods/test_yml_compare/input/input_2.yml +4 -0
  142. data/test/test/inference_methods_test.rb +311 -0
  143. data/test/test/subset_methods_test.rb +115 -0
  144. data/test/test_test.rb +233 -0
  145. data/test/workflow_test.rb +108 -0
  146. metadata +274 -0
@@ -0,0 +1,71 @@
1
+ require File.join(File.dirname(__FILE__), '../tap_test_helper')
2
+ require 'tap/support/versions'
3
+
4
+ class VersionTest < Test::Unit::TestCase
5
+ include Tap::Support::Versions
6
+
7
+ def test_documentation
8
+ assert_equal "path/to/file-1.0.txt", version("path/to/file.txt", 1.0)
9
+ assert_equal "path/to/file-1.0.1.txt", increment("path/to/file-1.0.txt", "0.0.1")
10
+ assert_equal "path/to/file-1.0.txt", increment("path/to/file.txt", 1.0)
11
+ assert_equal ["path/to/file.txt", "1.0"], deversion("path/to/file-1.0.txt")
12
+ assert_equal ["path/to/file.txt", nil], deversion("path/to/file.txt")
13
+ end
14
+
15
+ #
16
+ # version tests
17
+ #
18
+
19
+ def test_version_accepts_string_or_numeric_versions
20
+ assert_equal "path/to/file-1.1.txt", version("path/to/file.txt", "1.1")
21
+ assert_equal "path/to/file-1.1.txt", version("path/to/file.txt", 1.1)
22
+
23
+ assert_equal "path/to/file-1.1", version("path/to/file", "1.1")
24
+ end
25
+
26
+ def test_version_defaults_to_filepath_when_no_version_is_specified
27
+ assert_equal "path/to/file.txt", version("path/to/file.txt", "")
28
+ assert_equal "path/to/file.txt", version("path/to/file.txt", " ")
29
+ assert_equal "path/to/file.txt", version("path/to/file.txt", nil)
30
+
31
+ assert_equal "path/to/file", version("path/to/file", "")
32
+ end
33
+
34
+ #
35
+ # deversion tests
36
+ #
37
+
38
+ def test_deversion_returns_filepath_and_version
39
+ assert_equal ["path/to/file.txt", "1.1"], deversion("path/to/file-1.1.txt")
40
+ assert_equal ["path/to/file", "1.1"], deversion("path/to/file-1.1")
41
+ end
42
+
43
+ def test_deversion_returns_nil_for_version_when_no_version_is_specified
44
+ assert_equal ["path/to/file.txt", nil], deversion("path/to/file.txt")
45
+ assert_equal ["path/to/file", nil], deversion("path/to/file")
46
+ end
47
+
48
+ #
49
+ # increment tests
50
+ #
51
+
52
+ def test_increment_adds_increment_to_current_version
53
+ assert_equal "path/to/file-1.0.1.txt", increment("path/to/file-1.0.txt", "0.0.1")
54
+ assert_equal "path/to/file-2.1.txt", increment("path/to/file-1.0.txt", 1.1)
55
+ assert_equal "path/to/file-2.0.txt", increment("path/to/file-1.0.txt", 1)
56
+ assert_equal "path/to/file-1.1.txt", increment("path/to/file.txt", 1.1)
57
+
58
+ assert_equal "path/to/file-1.0.1", increment("path/to/file-1.0", "0.0.1")
59
+ assert_equal "path/to/file-2.1", increment("path/to/file-1.0", 1.1)
60
+ assert_equal "path/to/file-2.0", increment("path/to/file-1.0", 1)
61
+ assert_equal "path/to/file-1.1", increment("path/to/file", 1.1)
62
+ end
63
+
64
+ def test_increment_adds_zero_if_increment_is_nil
65
+ assert_equal "path/to/file-1.0.txt", increment("path/to/file-1.0.txt", nil)
66
+ assert_equal "path/to/file.txt", increment("path/to/file.txt", nil)
67
+
68
+ assert_equal "path/to/file-1.0", increment("path/to/file-1.0", nil)
69
+ assert_equal "path/to/file", increment("path/to/file", nil)
70
+ end
71
+ end
@@ -0,0 +1,4 @@
1
+ require 'rubygems'
2
+
3
+ require File.dirname(__FILE__) + '/../lib/tap'
4
+ require 'tap/test'
@@ -0,0 +1,4 @@
1
+ $:.unshift File.join(File.dirname(__FILE__), '../lib')
2
+
3
+ ENV["ALL"] = 'true'
4
+ Dir.glob("./**/*_test.rb").each {|test| require test}
@@ -0,0 +1,2 @@
1
+ - one: ONE
2
+ - one: ANOTHER ONE
@@ -0,0 +1,2 @@
1
+ - key: first
2
+ - key: second
@@ -0,0 +1 @@
1
+ key: value
@@ -0,0 +1 @@
1
+ one: ONE
@@ -0,0 +1,2 @@
1
+ two: TWO
2
+ three: THREE
@@ -0,0 +1 @@
1
+ config: value
@@ -0,0 +1,4 @@
1
+ one: ONE
2
+ variations!:
3
+ - two: TWO
4
+ - three: THREE
@@ -0,0 +1,118 @@
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
+ set_default_config :one => 1, :two => 2, :three => 3
12
+ config_accessor :one
13
+ config_writer :two
14
+ config_reader :three
15
+ end
16
+
17
+ def test_task_default_config_set_by_default_config
18
+ t = TaskWithDefaultConfig.new
19
+ assert_equal({:one => 1, :two => 2, :three => 3}, t.config)
20
+
21
+ t = TaskWithDefaultConfig.new nil, :one => "one"
22
+ assert_equal({:one => "one", :two => 2, :three => 3}, t.config)
23
+ end
24
+
25
+ def test_config_reader_and_writer_defined_by_config_accessor
26
+ t = TaskWithDefaultConfig.new
27
+ assert t.respond_to?(:one)
28
+ assert t.respond_to?("one=")
29
+
30
+ assert_equal 1, t.one
31
+ assert_equal 1, t.config[:one]
32
+
33
+ t.one = "one"
34
+ assert_equal "one", t.one
35
+ assert_equal "one", t.config[:one]
36
+ end
37
+
38
+ def test_config_reader_defined_by_config_reader
39
+ t = TaskWithDefaultConfig.new
40
+ assert t.respond_to?(:three)
41
+ assert !t.respond_to?("three=")
42
+
43
+ assert_equal 3, t.three
44
+ assert_equal 3, t.config[:three]
45
+ end
46
+
47
+ def test_config_writer_defined_by_config_writer
48
+ t = TaskWithDefaultConfig.new
49
+ assert !t.respond_to?(:two)
50
+ assert t.respond_to?("two=")
51
+
52
+ assert_equal 2, t.config[:two]
53
+ t.two = "two"
54
+ assert_equal "two", t.config[:two]
55
+ end
56
+
57
+ #
58
+ # test subclass behavior
59
+ #
60
+
61
+ class SubclassedTask < TaskWithDefaultConfig
62
+ set_default_config :one => "one", :four => 4
63
+ end
64
+
65
+ def test_config_accessors_are_inherited
66
+ t = SubclassedTask.new
67
+
68
+ assert t.respond_to?(:one)
69
+ assert t.respond_to?("one=")
70
+ assert !t.respond_to?(:two)
71
+ assert t.respond_to?("two=")
72
+ assert t.respond_to?(:three)
73
+ assert !t.respond_to?("three=")
74
+
75
+ assert !t.respond_to?(:four)
76
+ assert !t.respond_to?("four=")
77
+ end
78
+
79
+ def test_default_configs_are_inherited_but_can_be_overridden
80
+ s = SubclassedTask.new
81
+ assert_equal({:one => "one", :two => 2, :three => 3, :four => 4}, s.config)
82
+
83
+ # assure subclass configs do not affect superclass
84
+ t = TaskWithDefaultConfig.new
85
+ assert_equal({:one => 1, :two => 2, :three => 3}, t.config)
86
+ end
87
+
88
+ #
89
+ # iterative tests
90
+ #
91
+
92
+ def test_iterative_is_by_default_true
93
+ assert Tap::Task.iterative
94
+ end
95
+
96
+ class NonIterativeTask < Tap::Task
97
+ do_not_iterate
98
+ end
99
+
100
+ def test_do_not_iterate_sets_iterative_to_false
101
+ assert !NonIterativeTask.iterative
102
+ end
103
+
104
+ class AnotherNonIterativeTask < NonIterativeTask
105
+ end
106
+
107
+ def test_iterative_is_inherited
108
+ assert !AnotherNonIterativeTask.iterative
109
+ end
110
+
111
+ class IterativeTask < NonIterativeTask
112
+ iterate
113
+ end
114
+
115
+ def test_iterative_can_be_reset_with_iterate
116
+ assert IterativeTask.iterative
117
+ end
118
+ end
@@ -0,0 +1,233 @@
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
+
7
+ acts_as_tap_test
8
+
9
+ attr_accessor :t1, :t2, :t3, :t4
10
+
11
+ def setup
12
+ super
13
+ 1.upto(4) do |index|
14
+ var = "t#{index}".to_sym
15
+ self.send("#{var}=", Task.new(&echo))
16
+ end
17
+ end
18
+
19
+ #
20
+ # check t1-t4 are iterative
21
+ #
22
+
23
+ def test_t1_to_t4_tasks_are_iterative
24
+ assert t1.iterate?
25
+ assert t2.iterate?
26
+ assert t3.iterate?
27
+ assert t4.iterate?
28
+ end
29
+
30
+ #
31
+ # condition and on_complete tests
32
+ #
33
+
34
+ def test_execute_raises_error_unless_condtion_block_returns_true
35
+ t = Task.new
36
+ t.condition {false}
37
+ assert_raise(RuntimeError) { t.execute }
38
+ end
39
+
40
+ def test_on_complete_executes_after_execute_and_recieves_results
41
+ t = Task.new
42
+
43
+ recieved = nil
44
+ t.on_complete do |results|
45
+ recieved = results
46
+ end
47
+
48
+ t.execute(1,2,3)
49
+
50
+ assert_equal t.results, recieved
51
+ end
52
+
53
+ #
54
+ # iterative execute tests
55
+ #
56
+
57
+ def test_execute_without_inputs_produces_empty_results
58
+ t1.execute
59
+
60
+ assert_equal [], runlist
61
+ assert_equal [], t1.results
62
+ end
63
+
64
+ def test_execute_iteratively_processes_and_audits_each_input
65
+ t1.execute([1,2], 3)
66
+
67
+ assert_equal [[1,2], 3], runlist
68
+ assert_inputs(t1 => [[1,2], 3])
69
+ assert_outputs(t1 => [[1,2], 3])
70
+ assert_audits(
71
+ t1.results,
72
+ 0 => [[nil, [1,2]], [t1, [1,2]]],
73
+ 1 => [[nil, 3], [t1, 3]])
74
+ end
75
+
76
+ #
77
+ # iterative audit tests
78
+ #
79
+
80
+ def test_each_result_is_an_audit
81
+ t1.execute 1,2
82
+
83
+ t1.results.each do |r|
84
+ assert r.kind_of?(Support::Audit)
85
+ end
86
+ end
87
+
88
+ def test_execute_passes_audit_trails
89
+ t1.execute 1,2
90
+ t2.execute(*t1.results)
91
+ t3.execute(*t2.results)
92
+
93
+ assert_outputs(
94
+ t1 => [1,2],
95
+ t2 => [1,2],
96
+ t3 => [1,2])
97
+ assert_audits(
98
+ t3.results,
99
+ 0 => [[nil, 1],[t1, 1],[t2, 1],[t3, 1]],
100
+ 1 => [[nil, 2],[t1, 2],[t2, 2],[t3, 2]])
101
+ end
102
+
103
+ def test_execute_audits_additional_inputs
104
+ t1.execute 1,2
105
+ t2.execute(*(t1.results + [3]))
106
+ t3.execute(*(t2.results + [4]))
107
+
108
+ assert_outputs(
109
+ t1 => [1,2],
110
+ t2 => [1,2,3],
111
+ t3 => [1,2,3,4])
112
+ assert_audits(
113
+ t3.results,
114
+ 0 => [[nil, 1], [t1, 1],[t2, 1],[t3, 1]],
115
+ 1 => [[nil, 2], [t1, 2],[t2, 2],[t3, 2]],
116
+ 2 => [[nil, 3], [t2, 3],[t3, 3]],
117
+ 3 => [[nil, 4], [t3, 4]])
118
+
119
+ check_audit(t3.results[0]) do
120
+ 1._from nil
121
+ 1._from t1
122
+ 1._from t2
123
+ 1._from t3
124
+ end
125
+ end
126
+
127
+ class NonIterativeTask < Task
128
+ do_not_iterate
129
+ end
130
+
131
+ #
132
+ # check NonIterativeTask is set to not iterate
133
+ #
134
+
135
+ def test_do_not_iterate
136
+ assert !NonIterativeTask.iterative
137
+ t = NonIterativeTask.new
138
+ assert !t.iterate?
139
+ end
140
+
141
+ #
142
+ # non iterative execute tests
143
+ #
144
+
145
+ def test_non_iterative_execute_processes_inputs_as_one_input
146
+ t = NonIterativeTask.new(&echo)
147
+ t.execute(1,2,3)
148
+
149
+ assert_equal [[1,2,3]], runlist
150
+ assert_inputs(t => [[1,2,3]])
151
+ assert_outputs(t => [[1,2,3]])
152
+ assert_audits(
153
+ t.results,
154
+ 0 => [ [[nil, nil, nil], [1,2,3]], [t, [1,2,3]] ])
155
+ end
156
+
157
+ def test_non_iterative_execute_respects_array_inputs
158
+ t = NonIterativeTask.new(&echo)
159
+ t.execute([1,2], 3)
160
+
161
+ assert_equal [[[1,2], 3]], runlist
162
+ assert_inputs(t => [[[1,2], 3]])
163
+ assert_outputs(t => [[[1,2], 3]])
164
+ assert_audits(
165
+ t.results,
166
+ 0 => [ [[nil, nil], [[1,2], 3]], [t, [[1,2], 3]] ])
167
+ end
168
+
169
+ #
170
+ # non iterative audit tests
171
+ #
172
+
173
+ def test_non_iterative_execute_audits_inputs_as_one_unit
174
+ t = NonIterativeTask.new(&echo)
175
+ t.execute 1,2
176
+
177
+ assert_outputs(t => [[1,2]])
178
+ assert_audits(
179
+ t.results,
180
+ 0 => [
181
+ [[nil, nil], [1,2]], # original source
182
+ [t, [1,2]]] # final value
183
+ )
184
+ end
185
+
186
+ def test_non_iterative_execute_audits_additional_inputs_as_one_unit
187
+ t1 = NonIterativeTask.new(&echo)
188
+ t2 = NonIterativeTask.new(&echo)
189
+
190
+ t1.execute 1,2
191
+ assert_outputs(t1 => [[1,2]])
192
+
193
+ t2.execute(t1.results.first, 3)
194
+
195
+ assert_outputs(
196
+ t2 => [ [[1,2],3] ])
197
+ assert_audits(
198
+ t2.results,
199
+ 0 => [
200
+ [[[[nil, nil], t1], nil], [[1, 2], 3]], # original source
201
+ [t2, [[1, 2], 3]]] # final value source
202
+ )
203
+
204
+ check_audit(t2.results[0]) do
205
+ [[1,2], 3]._from(t2) {
206
+ [1,2]._from(t1) {
207
+ 1._from nil
208
+ 2._from nil }
209
+ 3._from nil }
210
+ end
211
+ end
212
+
213
+
214
+ #
215
+ # synchronization tests
216
+ #
217
+
218
+ def test_execute_is_synchronized
219
+ extended_test do
220
+ count = 0
221
+ counter = Task.new do
222
+ count += 1
223
+ end
224
+
225
+ t1 = Thread.new { 10000.times { counter.execute(1) } }
226
+ t2 = Thread.new { 10000.times { counter.execute(1) } }
227
+ t1.join
228
+ t2.join
229
+
230
+ assert_equal 20000, count
231
+ end
232
+ end
233
+ end