tap 0.9.1 → 0.10.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.
- data/History +37 -30
- data/MIT-LICENSE +1 -1
- data/README +92 -44
- data/bin/tap +62 -75
- data/cmd/console.rb +42 -0
- data/cmd/destroy.rb +16 -0
- data/cmd/generate.rb +16 -0
- data/cmd/run.rb +126 -0
- data/doc/Class Reference +362 -0
- data/doc/Command Reference +153 -0
- data/doc/Tutorial +237 -0
- data/lib/tap.rb +6 -45
- data/lib/tap/app.rb +126 -500
- data/lib/tap/constants.rb +2 -29
- data/lib/tap/env.rb +555 -250
- data/lib/tap/file_task.rb +60 -103
- data/lib/tap/generator/base.rb +109 -0
- data/lib/tap/generator/destroy.rb +37 -0
- data/lib/tap/generator/generate.rb +61 -0
- data/lib/tap/generator/generators/command/command_generator.rb +16 -12
- data/lib/tap/generator/generators/command/templates/command.erb +13 -19
- data/lib/tap/generator/generators/config/config_generator.rb +18 -27
- data/lib/tap/generator/generators/config/templates/doc.erb +12 -0
- data/lib/tap/generator/generators/config/templates/nodoc.erb +8 -0
- data/lib/tap/generator/generators/file_task/file_task_generator.rb +16 -11
- data/lib/tap/generator/generators/file_task/templates/file.txt +11 -2
- data/lib/tap/generator/generators/file_task/templates/result.yml +6 -0
- data/lib/tap/generator/generators/file_task/templates/task.erb +24 -31
- data/lib/tap/generator/generators/file_task/templates/test.erb +18 -22
- data/lib/tap/generator/generators/root/root_generator.rb +45 -31
- data/lib/tap/generator/generators/root/templates/Rakefile +64 -41
- data/lib/tap/generator/generators/root/templates/gemspec +27 -0
- data/lib/tap/generator/generators/root/templates/tapfile +8 -0
- data/lib/tap/generator/generators/root/templates/test/tap_test_helper.rb +0 -0
- data/lib/tap/generator/generators/root/templates/test/tap_test_suite.rb +1 -1
- data/lib/tap/generator/generators/root/templates/test/tapfile_test.rb +15 -0
- data/lib/tap/generator/generators/task/task_generator.rb +21 -28
- data/lib/tap/generator/generators/task/templates/task.erb +13 -23
- data/lib/tap/generator/generators/task/templates/test.erb +15 -18
- data/lib/tap/generator/manifest.rb +14 -0
- data/lib/tap/patches/rake/rake_test_loader.rb +0 -0
- data/lib/tap/patches/rake/testtask.rb +0 -0
- data/lib/tap/patches/ruby19/backtrace_filter.rb +0 -0
- data/lib/tap/patches/ruby19/parsedate.rb +0 -0
- data/lib/tap/root.rb +260 -21
- data/lib/tap/support/aggregator.rb +11 -11
- data/lib/tap/support/assignments.rb +172 -0
- data/lib/tap/support/audit.rb +20 -18
- data/lib/tap/support/batchable.rb +21 -10
- data/lib/tap/support/batchable_class.rb +107 -0
- data/lib/tap/support/class_configuration.rb +154 -239
- data/lib/tap/support/command_line.rb +97 -102
- data/lib/tap/support/comment.rb +270 -0
- data/lib/tap/support/configurable.rb +86 -65
- data/lib/tap/support/configurable_class.rb +296 -0
- data/lib/tap/support/configuration.rb +122 -0
- data/lib/tap/support/constant.rb +70 -0
- data/lib/tap/support/constant_utils.rb +127 -0
- data/lib/tap/support/declarations.rb +111 -0
- data/lib/tap/support/executable.rb +30 -17
- data/lib/tap/support/executable_queue.rb +0 -0
- data/lib/tap/support/framework.rb +71 -0
- data/lib/tap/support/framework_class.rb +199 -0
- data/lib/tap/support/instance_configuration.rb +147 -0
- data/lib/tap/support/lazydoc.rb +428 -0
- data/lib/tap/support/manifest.rb +89 -0
- data/lib/tap/support/run_error.rb +0 -0
- data/lib/tap/support/shell_utils.rb +33 -9
- data/lib/tap/support/summary.rb +30 -0
- data/lib/tap/support/tdoc.rb +339 -134
- data/lib/tap/support/tdoc/tdoc_html_generator.rb +0 -0
- data/lib/tap/support/tdoc/tdoc_html_template.rb +0 -0
- data/lib/tap/support/templater.rb +180 -0
- data/lib/tap/support/validation.rb +409 -76
- data/lib/tap/support/versions.rb +5 -3
- data/lib/tap/task.rb +78 -174
- data/lib/tap/tasks/dump.rb +56 -0
- data/lib/tap/tasks/rake.rb +93 -0
- data/lib/tap/test.rb +3 -3
- data/lib/tap/test/env_vars.rb +2 -2
- data/lib/tap/test/file_methods.rb +19 -20
- data/lib/tap/test/script_methods.rb +144 -0
- data/lib/tap/test/subset_methods.rb +1 -1
- data/lib/tap/test/tap_methods.rb +28 -62
- data/lib/tap/workflow.rb +22 -39
- metadata +48 -179
- data/Basic Overview +0 -151
- data/Command Reference +0 -99
- data/Rakefile +0 -127
- data/Tutorial +0 -287
- data/lib/tap/cmd/console.rb +0 -31
- data/lib/tap/cmd/destroy.rb +0 -20
- data/lib/tap/cmd/generate.rb +0 -20
- data/lib/tap/cmd/run.rb +0 -151
- data/lib/tap/dump.rb +0 -57
- data/lib/tap/generator.rb +0 -91
- data/lib/tap/generator/generators/command/USAGE +0 -6
- data/lib/tap/generator/generators/config/USAGE +0 -21
- data/lib/tap/generator/generators/config/templates/config.erb +0 -1
- data/lib/tap/generator/generators/file_task/USAGE +0 -3
- data/lib/tap/generator/generators/file_task/templates/file.yml +0 -3
- data/lib/tap/generator/generators/generator/USAGE +0 -0
- data/lib/tap/generator/generators/generator/generator_generator.rb +0 -21
- data/lib/tap/generator/generators/generator/templates/generator.erb +0 -32
- data/lib/tap/generator/generators/generator/templates/usage.erb +0 -1
- data/lib/tap/generator/generators/root/USAGE +0 -0
- data/lib/tap/generator/generators/root/templates/ReadMe.txt +0 -0
- data/lib/tap/generator/generators/root/templates/tap.yml +0 -80
- data/lib/tap/generator/generators/task/USAGE +0 -3
- data/lib/tap/generator/generators/workflow/USAGE +0 -0
- data/lib/tap/generator/generators/workflow/templates/task.erb +0 -16
- data/lib/tap/generator/generators/workflow/templates/test.erb +0 -7
- data/lib/tap/generator/generators/workflow/workflow_generator.rb +0 -6
- data/lib/tap/generator/options.rb +0 -26
- data/lib/tap/generator/usage.rb +0 -26
- data/lib/tap/support/batchable_methods.rb +0 -34
- data/lib/tap/support/command_line_methods.rb +0 -76
- data/lib/tap/support/configurable_methods.rb +0 -224
- data/lib/tap/support/logger.rb +0 -88
- data/lib/tap/support/rake.rb +0 -43
- data/lib/tap/support/tdoc/config_attr.rb +0 -362
- data/test/app/config/another/task.yml +0 -1
- data/test/app/config/batch.yml +0 -2
- data/test/app/config/empty.yml +0 -0
- data/test/app/config/erb.yml +0 -2
- data/test/app/config/some/task.yml +0 -1
- data/test/app/config/template.yml +0 -2
- data/test/app/config/version-0.1.yml +0 -1
- data/test/app/config/version.yml +0 -1
- data/test/app/lib/app_test_task.rb +0 -3
- data/test/app_test.rb +0 -1849
- data/test/env/test_configure/recurse_a.yml +0 -2
- data/test/env/test_configure/recurse_b.yml +0 -2
- data/test/env/test_configure/tap.yml +0 -23
- data/test/env/test_load_env_config/dir/tap.yml +0 -3
- data/test/env/test_load_env_config/recurse_a.yml +0 -2
- data/test/env/test_load_env_config/recurse_b.yml +0 -2
- data/test/env/test_load_env_config/tap.yml +0 -3
- data/test/env_test.rb +0 -198
- data/test/file_task/config/batch.yml +0 -2
- data/test/file_task/config/configured.yml +0 -1
- data/test/file_task/old_file_one.txt +0 -0
- data/test/file_task/old_file_two.txt +0 -0
- data/test/file_task_test.rb +0 -1291
- data/test/root/alt_lib/alt_module.rb +0 -4
- data/test/root/file.txt +0 -0
- data/test/root/glob/one.txt +0 -0
- data/test/root/glob/two.txt +0 -0
- data/test/root/lib/absolute_alt_filepath.rb +0 -2
- data/test/root/lib/alternative_filepath.rb +0 -2
- data/test/root/lib/another_module.rb +0 -2
- data/test/root/lib/nested/some_module.rb +0 -4
- data/test/root/lib/no_module_included.rb +0 -0
- data/test/root/lib/some/module.rb +0 -4
- data/test/root/lib/some_class.rb +0 -2
- data/test/root/lib/some_module.rb +0 -3
- data/test/root/load_path/load_path_module.rb +0 -2
- data/test/root/load_path/skip_module.rb +0 -2
- data/test/root/mtime/older.txt +0 -0
- data/test/root/unload/full_path.rb +0 -2
- data/test/root/unload/loaded_by_nested.rb +0 -2
- data/test/root/unload/nested/nested_load.rb +0 -6
- data/test/root/unload/nested/nested_with_ext.rb +0 -4
- data/test/root/unload/nested/relative_path.rb +0 -4
- data/test/root/unload/older.rb +0 -2
- data/test/root/unload/unload_base.rb +0 -9
- data/test/root/versions/another.yml +0 -0
- data/test/root/versions/file-0.1.2.yml +0 -0
- data/test/root/versions/file-0.1.yml +0 -0
- data/test/root/versions/file.yml +0 -0
- data/test/root_test.rb +0 -718
- data/test/support/aggregator_test.rb +0 -99
- data/test/support/audit_test.rb +0 -445
- data/test/support/batchable_test.rb +0 -74
- data/test/support/class_configuration_test.rb +0 -331
- data/test/support/command_line_test.rb +0 -58
- data/test/support/configurable/config/configured.yml +0 -2
- data/test/support/configurable_test.rb +0 -295
- data/test/support/executable_queue_test.rb +0 -103
- data/test/support/executable_test.rb +0 -38
- data/test/support/logger_test.rb +0 -31
- data/test/support/rake_test.rb +0 -37
- data/test/support/shell_utils_test.rb +0 -24
- data/test/support/tdoc_test.rb +0 -370
- data/test/support/validation_test.rb +0 -54
- data/test/support/versions_test.rb +0 -103
- data/test/tap_test_helper.rb +0 -57
- data/test/tap_test_suite.rb +0 -7
- data/test/task/config/batch.yml +0 -2
- data/test/task/config/batched.yml +0 -2
- data/test/task/config/configured.yml +0 -1
- data/test/task/config/example.yml +0 -1
- data/test/task_base_test.rb +0 -24
- data/test/task_syntax_test.rb +0 -300
- data/test/task_test.rb +0 -320
- data/test/test/env_vars_test.rb +0 -48
- data/test/test/file_methods/test_assert_files/expected/one.txt +0 -1
- data/test/test/file_methods/test_assert_files/expected/two.txt +0 -1
- data/test/test/file_methods/test_assert_files/input/one.txt +0 -1
- data/test/test/file_methods/test_assert_files/input/two.txt +0 -1
- data/test/test/file_methods/test_assert_files_can_have_no_expected_files_if_specified/input/one.txt +0 -1
- data/test/test/file_methods/test_assert_files_can_have_no_expected_files_if_specified/input/two.txt +0 -1
- data/test/test/file_methods/test_assert_files_fails_for_different_content/expected/one.txt +0 -1
- data/test/test/file_methods/test_assert_files_fails_for_different_content/expected/two.txt +0 -1
- data/test/test/file_methods/test_assert_files_fails_for_different_content/input/one.txt +0 -1
- data/test/test/file_methods/test_assert_files_fails_for_different_content/input/two.txt +0 -1
- data/test/test/file_methods/test_assert_files_fails_for_missing_expected_file/expected/one.txt +0 -1
- data/test/test/file_methods/test_assert_files_fails_for_missing_expected_file/input/one.txt +0 -1
- data/test/test/file_methods/test_assert_files_fails_for_missing_expected_file/input/two.txt +0 -1
- data/test/test/file_methods/test_assert_files_fails_for_missing_output_file/expected/one.txt +0 -1
- data/test/test/file_methods/test_assert_files_fails_for_missing_output_file/expected/two.txt +0 -1
- data/test/test/file_methods/test_assert_files_fails_for_missing_output_file/input/one.txt +0 -1
- data/test/test/file_methods/test_assert_files_fails_for_missing_output_file/input/two.txt +0 -1
- data/test/test/file_methods/test_assert_files_fails_for_no_expected_files/input/one.txt +0 -1
- data/test/test/file_methods/test_assert_files_fails_for_no_expected_files/input/two.txt +0 -1
- data/test/test/file_methods/test_method_glob/expected/file.yml +0 -0
- data/test/test/file_methods/test_method_glob/expected/file_1.txt +0 -0
- data/test/test/file_methods/test_method_glob/expected/file_2.txt +0 -0
- data/test/test/file_methods_doc/test_sub/expected/one.txt +0 -1
- data/test/test/file_methods_doc/test_sub/expected/two.txt +0 -1
- data/test/test/file_methods_doc/test_sub/input/one.txt +0 -1
- data/test/test/file_methods_doc/test_sub/input/two.txt +0 -1
- data/test/test/file_methods_doc_test.rb +0 -29
- data/test/test/file_methods_test.rb +0 -275
- data/test/test/subset_methods_test.rb +0 -171
- data/test/test/tap_methods/test_assert_files/expected/task/name/a.txt +0 -1
- data/test/test/tap_methods/test_assert_files/expected/task/name/b.txt +0 -1
- data/test/test/tap_methods/test_assert_files/input/a.txt +0 -1
- data/test/test/tap_methods/test_assert_files/input/b.txt +0 -1
- data/test/test/tap_methods_test.rb +0 -399
- data/test/workflow_test.rb +0 -120
- data/vendor/rails_generator.rb +0 -56
- data/vendor/rails_generator/base.rb +0 -263
- data/vendor/rails_generator/commands.rb +0 -581
- data/vendor/rails_generator/generated_attribute.rb +0 -42
- data/vendor/rails_generator/lookup.rb +0 -209
- data/vendor/rails_generator/manifest.rb +0 -53
- data/vendor/rails_generator/options.rb +0 -143
- data/vendor/rails_generator/scripts.rb +0 -83
- data/vendor/rails_generator/scripts/destroy.rb +0 -7
- data/vendor/rails_generator/scripts/generate.rb +0 -7
- data/vendor/rails_generator/scripts/update.rb +0 -12
- data/vendor/rails_generator/simple_logger.rb +0 -46
- data/vendor/rails_generator/spec.rb +0 -44
|
@@ -1,295 +0,0 @@
|
|
|
1
|
-
require File.join(File.dirname(__FILE__), '../tap_test_helper')
|
|
2
|
-
require 'tap/support/class_configuration'
|
|
3
|
-
require 'tap/support/validation'
|
|
4
|
-
require 'tap/support/configurable_methods'
|
|
5
|
-
require 'tap/support/tdoc'
|
|
6
|
-
require 'tap/support/configurable'
|
|
7
|
-
|
|
8
|
-
# for documentation test
|
|
9
|
-
# class BaseTask
|
|
10
|
-
# include Tap::Support::Configurable
|
|
11
|
-
# config :one, 1
|
|
12
|
-
# end
|
|
13
|
-
# class SubTask < BaseTask
|
|
14
|
-
# config :one, 'one'
|
|
15
|
-
# config :two, 'two'
|
|
16
|
-
# end
|
|
17
|
-
#
|
|
18
|
-
|
|
19
|
-
class ConfigurableTest < Test::Unit::TestCase
|
|
20
|
-
acts_as_tap_test
|
|
21
|
-
|
|
22
|
-
class ConfigurableClassWithNoConfigs
|
|
23
|
-
include Tap::Support::Configurable
|
|
24
|
-
end
|
|
25
|
-
|
|
26
|
-
class ConfigurableClass
|
|
27
|
-
include Tap::Support::Configurable
|
|
28
|
-
|
|
29
|
-
config :one, 'one'
|
|
30
|
-
config :two, 'two'
|
|
31
|
-
config :three, 'three'
|
|
32
|
-
end
|
|
33
|
-
|
|
34
|
-
def setup
|
|
35
|
-
super
|
|
36
|
-
app.root = trs.root
|
|
37
|
-
end
|
|
38
|
-
|
|
39
|
-
def test_configurable_doc
|
|
40
|
-
t = ConfigurableClass.new
|
|
41
|
-
assert_equal({:one => 'one', :two => 'two', :three => 'three'}, t.config)
|
|
42
|
-
end
|
|
43
|
-
|
|
44
|
-
#
|
|
45
|
-
# include test
|
|
46
|
-
#
|
|
47
|
-
|
|
48
|
-
def test_include_extends_class_with_ConfigurableMethods
|
|
49
|
-
assert ConfigurableClassWithNoConfigs.kind_of?(Tap::Support::ConfigurableMethods)
|
|
50
|
-
end
|
|
51
|
-
|
|
52
|
-
#
|
|
53
|
-
# default_name test
|
|
54
|
-
#
|
|
55
|
-
|
|
56
|
-
def test_default_name
|
|
57
|
-
assert_equal "configurable_test/configurable_class", ConfigurableClass.default_name
|
|
58
|
-
end
|
|
59
|
-
|
|
60
|
-
#
|
|
61
|
-
# name test
|
|
62
|
-
#
|
|
63
|
-
|
|
64
|
-
def test_name_is_initialized_to_class_default_name_unless_specified
|
|
65
|
-
assert_equal ConfigurableClass.default_name, ConfigurableClass.new.name
|
|
66
|
-
assert_equal "alt", ConfigurableClass.new("alt").name
|
|
67
|
-
end
|
|
68
|
-
|
|
69
|
-
# config_file test
|
|
70
|
-
#
|
|
71
|
-
|
|
72
|
-
def test_config_file_is_app_config_filepath_when_config_file_exist
|
|
73
|
-
t = ConfigurableClass.new "configured"
|
|
74
|
-
app_config_filepath = app.config_filepath("configured")
|
|
75
|
-
|
|
76
|
-
assert_equal File.join(t.app['config'], "configured.yml"),app_config_filepath
|
|
77
|
-
assert File.exists?(app_config_filepath)
|
|
78
|
-
assert_equal app.config_filepath("configured"), t.config_file
|
|
79
|
-
end
|
|
80
|
-
|
|
81
|
-
def test_config_file_is_nil_for_nil_input_names
|
|
82
|
-
t = ConfigurableClass.new
|
|
83
|
-
assert_equal nil, t.config_file
|
|
84
|
-
|
|
85
|
-
t = ConfigurableClass.new nil
|
|
86
|
-
assert_equal nil, t.config_file
|
|
87
|
-
end
|
|
88
|
-
|
|
89
|
-
#
|
|
90
|
-
# config tests
|
|
91
|
-
#
|
|
92
|
-
|
|
93
|
-
class SampleClass
|
|
94
|
-
include Tap::Support::Configurable
|
|
95
|
-
|
|
96
|
-
config :key, 'value'
|
|
97
|
-
config_reader
|
|
98
|
-
config :reader_only
|
|
99
|
-
end
|
|
100
|
-
|
|
101
|
-
class ValidatingClass
|
|
102
|
-
include Tap::Support::Configurable
|
|
103
|
-
|
|
104
|
-
config :one, 'one', &c.check(String)
|
|
105
|
-
config :two, 'two' do |v|
|
|
106
|
-
v.upcase
|
|
107
|
-
end
|
|
108
|
-
end
|
|
109
|
-
|
|
110
|
-
def test_config_doc
|
|
111
|
-
t = SampleClass.new
|
|
112
|
-
assert t.respond_to?(:reader_only)
|
|
113
|
-
assert !t.respond_to?(:reader_only=)
|
|
114
|
-
|
|
115
|
-
assert_equal({:key => 'value', :reader_only => nil}, t.config)
|
|
116
|
-
assert_equal 'value', t.key
|
|
117
|
-
t.key = 'another'
|
|
118
|
-
assert_equal({:key => 'another', :reader_only => nil}, t.config)
|
|
119
|
-
|
|
120
|
-
t = ValidatingClass.new
|
|
121
|
-
assert_equal({:one => 'one', :two => 'TWO'}, t.config)
|
|
122
|
-
assert_raise(Tap::Support::Validation::ValidationError) { t.one = 1 }
|
|
123
|
-
assert_raise(Tap::Support::Validation::ValidationError) { t.config = {:one => 1} }
|
|
124
|
-
|
|
125
|
-
t.config = {:one => 'str', :two => 'str'}
|
|
126
|
-
assert_equal({:one => 'str', :two => 'STR'}, t.config)
|
|
127
|
-
end
|
|
128
|
-
|
|
129
|
-
def test_config_sets_config
|
|
130
|
-
t = ConfigurableClassWithNoConfigs.new
|
|
131
|
-
assert_equal({}, t.config)
|
|
132
|
-
t.config = {:key => 'value'}
|
|
133
|
-
assert_equal({:key => 'value'}, t.config)
|
|
134
|
-
end
|
|
135
|
-
|
|
136
|
-
def test_config_merges_default_config_and_overrides
|
|
137
|
-
t = ConfigurableClass.new "configured"
|
|
138
|
-
assert_equal({:one => 'one', :two => 'two', :three => 'three'}, t.class.configurations.default)
|
|
139
|
-
assert_equal({:one => 'one', :two => 'TWO', :three => 'THREE'}, t.config)
|
|
140
|
-
|
|
141
|
-
t.config = {:three => 3}
|
|
142
|
-
assert_equal({:one => 'one', :two => 'two', :three => 3}, t.config)
|
|
143
|
-
end
|
|
144
|
-
|
|
145
|
-
class ConfigurableClassWithManyConfigs
|
|
146
|
-
include Tap::Support::Configurable
|
|
147
|
-
|
|
148
|
-
config :one, 'one'
|
|
149
|
-
|
|
150
|
-
declare_config
|
|
151
|
-
config :two, 'two'
|
|
152
|
-
|
|
153
|
-
config_reader
|
|
154
|
-
config :three, 'three'
|
|
155
|
-
|
|
156
|
-
config_writer
|
|
157
|
-
config :four, 'four'
|
|
158
|
-
|
|
159
|
-
config_accessor
|
|
160
|
-
config :five, 'five'
|
|
161
|
-
|
|
162
|
-
declare_config :six
|
|
163
|
-
config_reader :seven
|
|
164
|
-
config_writer :eight
|
|
165
|
-
config_accessor :nine
|
|
166
|
-
end
|
|
167
|
-
|
|
168
|
-
def test_config_with_many_configs
|
|
169
|
-
t = ConfigurableClassWithManyConfigs.new
|
|
170
|
-
|
|
171
|
-
assert_equal({
|
|
172
|
-
:one => 'one', :six => nil,
|
|
173
|
-
:two => 'two', :seven => nil,
|
|
174
|
-
:three => 'three', :eight => nil,
|
|
175
|
-
:four => 'four', :nine => nil,
|
|
176
|
-
:five => 'five'},
|
|
177
|
-
t.config)
|
|
178
|
-
|
|
179
|
-
# readers only
|
|
180
|
-
[:three, :seven].each do |config|
|
|
181
|
-
assert t.respond_to?(config)
|
|
182
|
-
assert !t.respond_to?("#{config}=")
|
|
183
|
-
end
|
|
184
|
-
|
|
185
|
-
# writers only
|
|
186
|
-
[:four, :eight].each do |config|
|
|
187
|
-
assert !t.respond_to?(config)
|
|
188
|
-
assert t.respond_to?("#{config}=")
|
|
189
|
-
end
|
|
190
|
-
|
|
191
|
-
# both
|
|
192
|
-
[:one, :five, :nine].each do |config|
|
|
193
|
-
assert t.respond_to?(config)
|
|
194
|
-
assert t.respond_to?("#{config}=")
|
|
195
|
-
end
|
|
196
|
-
|
|
197
|
-
# neither
|
|
198
|
-
[:two, :six].each do |config|
|
|
199
|
-
assert !t.respond_to?(config)
|
|
200
|
-
assert !t.respond_to?("#{config}=")
|
|
201
|
-
end
|
|
202
|
-
end
|
|
203
|
-
|
|
204
|
-
#
|
|
205
|
-
# test subclass behavior
|
|
206
|
-
#
|
|
207
|
-
|
|
208
|
-
class DeclarationClass
|
|
209
|
-
include Tap::Support::Configurable
|
|
210
|
-
|
|
211
|
-
declare_config
|
|
212
|
-
|
|
213
|
-
config :one, 1
|
|
214
|
-
config :two, 2
|
|
215
|
-
config :three, 3
|
|
216
|
-
|
|
217
|
-
config_accessor :one
|
|
218
|
-
config_writer :two
|
|
219
|
-
config_reader :three
|
|
220
|
-
end
|
|
221
|
-
|
|
222
|
-
class DeclarationSubClass < DeclarationClass
|
|
223
|
-
config :one, "one"
|
|
224
|
-
config :four, 4
|
|
225
|
-
end
|
|
226
|
-
|
|
227
|
-
def test_config_accessors_are_inherited
|
|
228
|
-
t = DeclarationSubClass.new
|
|
229
|
-
|
|
230
|
-
assert t.respond_to?(:one)
|
|
231
|
-
assert t.respond_to?("one=")
|
|
232
|
-
assert !t.respond_to?(:two)
|
|
233
|
-
assert t.respond_to?("two=")
|
|
234
|
-
assert t.respond_to?(:three)
|
|
235
|
-
assert !t.respond_to?("three=")
|
|
236
|
-
|
|
237
|
-
assert t.respond_to?(:four)
|
|
238
|
-
assert t.respond_to?("four=")
|
|
239
|
-
end
|
|
240
|
-
|
|
241
|
-
def test_class_configurations_are_inherited_but_can_be_overridden
|
|
242
|
-
assert_equal([
|
|
243
|
-
[DeclarationClass, [:one, :two, :three]],
|
|
244
|
-
[DeclarationSubClass, [:four]]
|
|
245
|
-
], DeclarationSubClass.configurations.declarations_array)
|
|
246
|
-
|
|
247
|
-
assert_equal({:one => 1, :two => 2, :three => 3}, DeclarationClass.configurations.default)
|
|
248
|
-
assert_equal({:one => 'one', :two => 2, :three => 3, :four => 4}, DeclarationSubClass.configurations.default)
|
|
249
|
-
|
|
250
|
-
t = DeclarationSubClass.new
|
|
251
|
-
assert_equal({:one => 'one', :two => 2, :three => 3, :four => 4}, t.config)
|
|
252
|
-
end
|
|
253
|
-
|
|
254
|
-
#
|
|
255
|
-
# initialize_batch_obj test
|
|
256
|
-
#
|
|
257
|
-
|
|
258
|
-
def test_initialize_batch_obj_merges_default_config_and_overrides
|
|
259
|
-
t = ConfigurableClass.new "configured", :three => 3
|
|
260
|
-
assert_equal({:one => 'one', :two => 'two', :three => 'three'}, t.class.configurations.default)
|
|
261
|
-
assert_equal({:one => 'one', :two => 'TWO', :three => 3}, t.config)
|
|
262
|
-
|
|
263
|
-
t1 = t.initialize_batch_obj
|
|
264
|
-
assert_equal({:one => 'one', :two => 'two', :three => 'three'}, t1.config)
|
|
265
|
-
|
|
266
|
-
t2 = t.initialize_batch_obj(nil, {:three => 3})
|
|
267
|
-
assert_equal({:one => 'one', :two => 'two', :three => 3}, t2.config)
|
|
268
|
-
end
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
# include Tap::Support
|
|
272
|
-
#
|
|
273
|
-
# def test_config_validations
|
|
274
|
-
# t = ValidationTask.new
|
|
275
|
-
# assert_equal({:one => 'one', :two => 'two', :three => 'THREE'}, t.config)
|
|
276
|
-
#
|
|
277
|
-
# t.one = 'two'
|
|
278
|
-
# assert_equal 'two', t.one
|
|
279
|
-
# assert_raise(Validation::ValidationError) { t.one = 1 }
|
|
280
|
-
#
|
|
281
|
-
# t.two = "two"
|
|
282
|
-
# assert_equal 'two', t.two
|
|
283
|
-
# t.two = 2
|
|
284
|
-
# assert_equal 2, t.two
|
|
285
|
-
# t.two = "2"
|
|
286
|
-
# assert_equal 2, t.two
|
|
287
|
-
# assert_raise(Validation::ValidationError) { t.two = 'three' }
|
|
288
|
-
# assert_raise(Validation::ValidationError) { t.two = 2.2 }
|
|
289
|
-
#
|
|
290
|
-
# t.three = "three"
|
|
291
|
-
# assert_equal 'THREE', t.three
|
|
292
|
-
# assert_raise(RuntimeError) { t.three = 'THREE' }
|
|
293
|
-
# end
|
|
294
|
-
|
|
295
|
-
end
|
|
@@ -1,103 +0,0 @@
|
|
|
1
|
-
require File.join(File.dirname(__FILE__), '../tap_test_helper')
|
|
2
|
-
require 'tap/support/executable_queue'
|
|
3
|
-
|
|
4
|
-
class ExecutableQueueTest < Test::Unit::TestCase
|
|
5
|
-
include Tap::Support
|
|
6
|
-
|
|
7
|
-
attr_accessor :m, :queue
|
|
8
|
-
|
|
9
|
-
def setup
|
|
10
|
-
@m = Object.new.extend Executable
|
|
11
|
-
@queue = ExecutableQueue.new
|
|
12
|
-
end
|
|
13
|
-
|
|
14
|
-
#
|
|
15
|
-
# initialization tests
|
|
16
|
-
#
|
|
17
|
-
|
|
18
|
-
def test_initialize
|
|
19
|
-
q = ExecutableQueue.new
|
|
20
|
-
assert q.empty?
|
|
21
|
-
end
|
|
22
|
-
|
|
23
|
-
#
|
|
24
|
-
# size, clear, empty? tests
|
|
25
|
-
#
|
|
26
|
-
|
|
27
|
-
def test_size_return_number_of_tasks
|
|
28
|
-
assert_equal 0, queue.size
|
|
29
|
-
queue.enq m, []
|
|
30
|
-
assert_equal 1, queue.size
|
|
31
|
-
end
|
|
32
|
-
|
|
33
|
-
def test_empty_is_true_if_tasks_is_empty
|
|
34
|
-
assert queue.empty?
|
|
35
|
-
queue.enq m, []
|
|
36
|
-
assert !queue.empty?
|
|
37
|
-
end
|
|
38
|
-
|
|
39
|
-
def test_clear_resets_tasks_and_task_inputs
|
|
40
|
-
assert_equal([], queue.to_a)
|
|
41
|
-
|
|
42
|
-
queue.enq m, []
|
|
43
|
-
queue.clear
|
|
44
|
-
|
|
45
|
-
assert_equal([], queue.to_a)
|
|
46
|
-
end
|
|
47
|
-
|
|
48
|
-
def test_clear_returns_existing_queue_as_an_array
|
|
49
|
-
assert_equal([], queue.to_a)
|
|
50
|
-
|
|
51
|
-
queue.enq m, []
|
|
52
|
-
assert_equal [[m, []]], queue.clear
|
|
53
|
-
end
|
|
54
|
-
|
|
55
|
-
#
|
|
56
|
-
# queue test
|
|
57
|
-
#
|
|
58
|
-
|
|
59
|
-
def test_enq_pushes_task_and_inputs_onto_queue
|
|
60
|
-
assert_equal [], queue.to_a
|
|
61
|
-
|
|
62
|
-
queue.enq(m, [1])
|
|
63
|
-
assert_equal [[m,[1]]], queue.to_a
|
|
64
|
-
|
|
65
|
-
queue.enq(m, [2])
|
|
66
|
-
assert_equal [[m,[1]], [m,[2]]], queue.to_a
|
|
67
|
-
end
|
|
68
|
-
|
|
69
|
-
def test_enq_raises_error_for_non_task_methods
|
|
70
|
-
assert_raise(RuntimeError) { queue.enq(method(:setup), [1]) }
|
|
71
|
-
end
|
|
72
|
-
|
|
73
|
-
#
|
|
74
|
-
# unshift test
|
|
75
|
-
#
|
|
76
|
-
|
|
77
|
-
def test_unshift
|
|
78
|
-
assert_equal [], queue.to_a
|
|
79
|
-
|
|
80
|
-
queue.unshift(m, [1])
|
|
81
|
-
assert_equal [[m,[1]]], queue.to_a
|
|
82
|
-
|
|
83
|
-
queue.unshift(m, [2])
|
|
84
|
-
assert_equal [[m,[2]], [m,[1]]], queue.to_a
|
|
85
|
-
end
|
|
86
|
-
|
|
87
|
-
def test_unshift_raises_error_for_non_task_methods
|
|
88
|
-
assert_raise(RuntimeError) { queue.unshift(method(:setup), [1]) }
|
|
89
|
-
end
|
|
90
|
-
|
|
91
|
-
#
|
|
92
|
-
# deq test
|
|
93
|
-
#
|
|
94
|
-
|
|
95
|
-
def test_deq
|
|
96
|
-
queue.enq(m, [1])
|
|
97
|
-
queue.enq(m, [2])
|
|
98
|
-
|
|
99
|
-
assert_equal [m, [1]], queue.deq
|
|
100
|
-
assert_equal [m, [2]], queue.deq
|
|
101
|
-
end
|
|
102
|
-
|
|
103
|
-
end
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
require File.join(File.dirname(__FILE__), '../tap_test_helper')
|
|
2
|
-
require 'tap/support/executable'
|
|
3
|
-
|
|
4
|
-
class ExecutableTest < Test::Unit::TestCase
|
|
5
|
-
include Tap
|
|
6
|
-
|
|
7
|
-
attr_accessor :m
|
|
8
|
-
|
|
9
|
-
def setup
|
|
10
|
-
@m = Tap::Support::Executable.initialize(Object.new, :object_id)
|
|
11
|
-
end
|
|
12
|
-
|
|
13
|
-
#
|
|
14
|
-
# initialization tests
|
|
15
|
-
#
|
|
16
|
-
|
|
17
|
-
def test_initialization
|
|
18
|
-
assert !m.multithread
|
|
19
|
-
assert_nil m.on_complete_block
|
|
20
|
-
end
|
|
21
|
-
|
|
22
|
-
#
|
|
23
|
-
# on_complete block test
|
|
24
|
-
#
|
|
25
|
-
|
|
26
|
-
def test_on_complete_sets_on_complete_block
|
|
27
|
-
block = lambda {}
|
|
28
|
-
m.on_complete(&block)
|
|
29
|
-
assert_equal block, m.on_complete_block
|
|
30
|
-
end
|
|
31
|
-
|
|
32
|
-
def test_on_complete_can_only_be_set_once
|
|
33
|
-
m.on_complete {}
|
|
34
|
-
assert_raise(RuntimeError) { m.on_complete {} }
|
|
35
|
-
assert_raise(RuntimeError) { m.on_complete }
|
|
36
|
-
end
|
|
37
|
-
|
|
38
|
-
end
|
data/test/support/logger_test.rb
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
require File.join(File.dirname(__FILE__), '../tap_test_helper')
|
|
2
|
-
require 'tap/support/logger'
|
|
3
|
-
require 'stringio'
|
|
4
|
-
|
|
5
|
-
class LoggerTest < Test::Unit::TestCase
|
|
6
|
-
include Tap
|
|
7
|
-
|
|
8
|
-
#
|
|
9
|
-
# logger tests
|
|
10
|
-
#
|
|
11
|
-
|
|
12
|
-
def test_logger
|
|
13
|
-
output = StringIO.new('')
|
|
14
|
-
logger = Logger.new(output).extend Support::Logger
|
|
15
|
-
logger.datetime_format = '%H:%M:%S'
|
|
16
|
-
logger.subject 'message'
|
|
17
|
-
|
|
18
|
-
assert output.string =~ /^\s+I\[\d\d:\d\d:\d\d\]\s+subject\s+message/, output.string
|
|
19
|
-
end
|
|
20
|
-
|
|
21
|
-
def test_logdev_returns_the_log_device
|
|
22
|
-
[StringIO.new(''), STDOUT].each do |device|
|
|
23
|
-
logger = Logger.new(device)
|
|
24
|
-
assert !logger.respond_to?(:logdev)
|
|
25
|
-
|
|
26
|
-
logger.extend Support::Logger
|
|
27
|
-
assert_equal Logger::LogDevice, logger.logdev.class
|
|
28
|
-
assert_equal device, logger.logdev.dev
|
|
29
|
-
end
|
|
30
|
-
end
|
|
31
|
-
end
|