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,74 +0,0 @@
|
|
|
1
|
-
require File.join(File.dirname(__FILE__), '../tap_test_helper')
|
|
2
|
-
require 'tap/support/batchable'
|
|
3
|
-
|
|
4
|
-
class BatchableTest < Test::Unit::TestCase
|
|
5
|
-
|
|
6
|
-
class BatchableClass
|
|
7
|
-
include Tap::Support::Batchable
|
|
8
|
-
def initialize
|
|
9
|
-
@batch = []
|
|
10
|
-
initialize_batch_obj
|
|
11
|
-
end
|
|
12
|
-
end
|
|
13
|
-
|
|
14
|
-
attr_accessor :t
|
|
15
|
-
|
|
16
|
-
def setup
|
|
17
|
-
@t = BatchableClass.new
|
|
18
|
-
end
|
|
19
|
-
|
|
20
|
-
#
|
|
21
|
-
# batch test
|
|
22
|
-
#
|
|
23
|
-
|
|
24
|
-
def test_batch_documentation
|
|
25
|
-
t1 = Tap::Task.new
|
|
26
|
-
t2 = Tap::Task.new
|
|
27
|
-
t3 = t2.initialize_batch_obj
|
|
28
|
-
|
|
29
|
-
Tap::Support::Batchable.batch(t1, t2)
|
|
30
|
-
assert_equal [t1,t2,t3], t3.batch
|
|
31
|
-
end
|
|
32
|
-
|
|
33
|
-
#
|
|
34
|
-
# batched? test
|
|
35
|
-
#
|
|
36
|
-
|
|
37
|
-
def test_batched_returns_true_if_batch_size_is_greater_than_one
|
|
38
|
-
assert !t.batched?
|
|
39
|
-
assert_equal 1, t.batch.size
|
|
40
|
-
|
|
41
|
-
t1 = t.initialize_batch_obj
|
|
42
|
-
|
|
43
|
-
assert t.batched?
|
|
44
|
-
assert t1.batched?
|
|
45
|
-
end
|
|
46
|
-
|
|
47
|
-
#
|
|
48
|
-
# batch_index test
|
|
49
|
-
#
|
|
50
|
-
|
|
51
|
-
def test_batch_index_returns_the_index_of_the_task_in_batch
|
|
52
|
-
t1 = t.initialize_batch_obj
|
|
53
|
-
|
|
54
|
-
assert_equal [t, t1], t.batch
|
|
55
|
-
assert_equal 0, t.batch_index
|
|
56
|
-
assert_equal 1, t1.batch_index
|
|
57
|
-
end
|
|
58
|
-
|
|
59
|
-
#
|
|
60
|
-
# initialize_batch_obj test
|
|
61
|
-
#
|
|
62
|
-
|
|
63
|
-
def test_created_batch_tasks_are_added_to_and_share_the_same_execute_batch
|
|
64
|
-
assert_equal [t], t.batch
|
|
65
|
-
|
|
66
|
-
t1 = t.initialize_batch_obj
|
|
67
|
-
t2 = t1.initialize_batch_obj
|
|
68
|
-
|
|
69
|
-
assert_equal [t, t1, t2], t.batch
|
|
70
|
-
assert_equal t.batch.object_id, t1.batch.object_id
|
|
71
|
-
assert_equal t.batch.object_id, t2.batch.object_id
|
|
72
|
-
end
|
|
73
|
-
|
|
74
|
-
end
|
|
@@ -1,331 +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
|
-
class MergeTask < BaseTask
|
|
18
|
-
config :three, 'three'
|
|
19
|
-
config_merge SubTask
|
|
20
|
-
end
|
|
21
|
-
class ValidationTask < Tap::Task
|
|
22
|
-
config :one, 'one', &c.check(String)
|
|
23
|
-
config :two, 'two', &c.yaml(/two/, Integer)
|
|
24
|
-
config :three, 'three' do |v|
|
|
25
|
-
v =~ /three/ ? v.upcase : raise("not three")
|
|
26
|
-
end
|
|
27
|
-
end
|
|
28
|
-
|
|
29
|
-
class ClassConfigurationTest < Test::Unit::TestCase
|
|
30
|
-
include Tap::Support
|
|
31
|
-
|
|
32
|
-
def test_config_merge
|
|
33
|
-
t = MergeTask.new
|
|
34
|
-
assert_equal({:one => 'one', :two => 'two', :three => 'three'}, t.config)
|
|
35
|
-
assert t.respond_to?(:two)
|
|
36
|
-
yaml = MergeTask.configurations.format_yaml
|
|
37
|
-
expected = %Q{
|
|
38
|
-
# BaseTask configuration
|
|
39
|
-
one: one
|
|
40
|
-
|
|
41
|
-
# MergeTask configuration
|
|
42
|
-
three: three
|
|
43
|
-
|
|
44
|
-
# SubTask configuration
|
|
45
|
-
two: two
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
assert_equal expected[1..-1], yaml
|
|
49
|
-
assert_equal({'one' => 'one', 'two' => 'two', 'three' => 'three'}, YAML.load(yaml))
|
|
50
|
-
end
|
|
51
|
-
|
|
52
|
-
def test_config_validations
|
|
53
|
-
t = ValidationTask.new
|
|
54
|
-
assert_equal({:one => 'one', :two => 'two', :three => 'THREE'}, t.config)
|
|
55
|
-
|
|
56
|
-
t.one = 'two'
|
|
57
|
-
assert_equal 'two', t.one
|
|
58
|
-
assert_raise(Validation::ValidationError) { t.one = 1 }
|
|
59
|
-
|
|
60
|
-
t.two = "two"
|
|
61
|
-
assert_equal 'two', t.two
|
|
62
|
-
t.two = 2
|
|
63
|
-
assert_equal 2, t.two
|
|
64
|
-
t.two = "2"
|
|
65
|
-
assert_equal 2, t.two
|
|
66
|
-
assert_raise(Validation::ValidationError) { t.two = 'three' }
|
|
67
|
-
assert_raise(Validation::ValidationError) { t.two = 2.2 }
|
|
68
|
-
|
|
69
|
-
t.three = "three"
|
|
70
|
-
assert_equal 'THREE', t.three
|
|
71
|
-
assert_raise(RuntimeError) { t.three = 'THREE' }
|
|
72
|
-
end
|
|
73
|
-
|
|
74
|
-
def test_initialization
|
|
75
|
-
c = ClassConfiguration.new ClassConfigurationTest
|
|
76
|
-
|
|
77
|
-
assert_equal ClassConfigurationTest, c.receiver
|
|
78
|
-
assert_equal [], c.declarations
|
|
79
|
-
assert_equal [[c.receiver, []]], c.declarations_array
|
|
80
|
-
assert_equal({}, c.default)
|
|
81
|
-
assert_equal({}, c.unprocessed_default)
|
|
82
|
-
assert_equal({}, c.process_blocks)
|
|
83
|
-
end
|
|
84
|
-
|
|
85
|
-
#
|
|
86
|
-
# format_yaml tests
|
|
87
|
-
#
|
|
88
|
-
|
|
89
|
-
def test_format_yaml_with_single_class
|
|
90
|
-
cc = ClassConfiguration.new ClassConfigurationTest
|
|
91
|
-
cc.add('one', 1)
|
|
92
|
-
|
|
93
|
-
yaml = cc.format_yaml
|
|
94
|
-
expected = %Q{
|
|
95
|
-
# ClassConfigurationTest configuration
|
|
96
|
-
one: 1
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
assert_equal expected[1..-1], yaml
|
|
100
|
-
assert_equal({'one' => 1}, YAML.load(yaml))
|
|
101
|
-
end
|
|
102
|
-
|
|
103
|
-
def test_format_stringifies_keys
|
|
104
|
-
cc = ClassConfiguration.new ClassConfigurationTest
|
|
105
|
-
cc.add(:one, 1)
|
|
106
|
-
|
|
107
|
-
yaml = cc.format_yaml
|
|
108
|
-
expected = %Q{
|
|
109
|
-
# ClassConfigurationTest configuration
|
|
110
|
-
one: 1
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
assert_equal expected[1..-1], yaml
|
|
114
|
-
assert_equal({'one' => 1}, YAML.load(yaml))
|
|
115
|
-
end
|
|
116
|
-
end
|
|
117
|
-
class Hold
|
|
118
|
-
def test_format_yaml_with_desc
|
|
119
|
-
cc = ClassConfiguration.new
|
|
120
|
-
cc.declare('one', ClassConfigurationTest)
|
|
121
|
-
cc.set('one', 1, :desc => "comment")
|
|
122
|
-
|
|
123
|
-
yaml = cc.format_yaml
|
|
124
|
-
expected = %Q{
|
|
125
|
-
# ClassConfigurationTest configuration
|
|
126
|
-
one: 1 # comment
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
assert_equal expected[1..-1], yaml
|
|
130
|
-
assert_equal({'one' => 1}, YAML.load(yaml))
|
|
131
|
-
end
|
|
132
|
-
|
|
133
|
-
def test_format_yaml_with_long_desc
|
|
134
|
-
cc = ClassConfiguration.new
|
|
135
|
-
cc.declare('one', ClassConfigurationTest)
|
|
136
|
-
cc.set('one', 1, :desc => 'comment longer than some twenty chars')
|
|
137
|
-
|
|
138
|
-
yaml = cc.format_yaml
|
|
139
|
-
expected = %Q{
|
|
140
|
-
# ClassConfigurationTest configuration
|
|
141
|
-
# comment longer than some twenty chars
|
|
142
|
-
one: 1
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
assert_equal expected[1..-1], yaml
|
|
146
|
-
assert_equal({'one' => 1}, YAML.load(yaml))
|
|
147
|
-
end
|
|
148
|
-
|
|
149
|
-
def test_format_yaml_with_long_value
|
|
150
|
-
cc = ClassConfiguration.new(['one', 'value longer than some twenty chars', 'comment', ClassConfigurationTest])
|
|
151
|
-
yaml = cc.format_yaml
|
|
152
|
-
expected = %Q{
|
|
153
|
-
# ClassConfigurationTest configuration
|
|
154
|
-
# comment
|
|
155
|
-
one: value longer than some twenty chars
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
assert_equal expected[1..-1], yaml
|
|
159
|
-
assert_equal({'one' => 'value longer than some twenty chars'}, YAML.load(yaml))
|
|
160
|
-
end
|
|
161
|
-
|
|
162
|
-
# def test_format_yaml_with_nil_value
|
|
163
|
-
# cc = ClassConfiguration.new(['one', nil, 'comment', ClassConfigurationTest])
|
|
164
|
-
# yaml = cc.format_yaml
|
|
165
|
-
# expected = %Q{
|
|
166
|
-
# # ClassConfigurationTest configuration
|
|
167
|
-
# #one: # comment
|
|
168
|
-
# }
|
|
169
|
-
#
|
|
170
|
-
# assert_equal expected[1..-1], yaml
|
|
171
|
-
# assert_equal(false, YAML.load(yaml))
|
|
172
|
-
# end
|
|
173
|
-
|
|
174
|
-
def test_format_yaml_with_multiline_comment
|
|
175
|
-
cc = ClassConfiguration.new(['one', 1, "multiline\ncomment", ClassConfigurationTest])
|
|
176
|
-
yaml = cc.format_yaml
|
|
177
|
-
expected = %Q{
|
|
178
|
-
# ClassConfigurationTest configuration
|
|
179
|
-
# multiline
|
|
180
|
-
# comment
|
|
181
|
-
one: 1
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
assert_equal expected[1..-1], yaml
|
|
185
|
-
assert_equal({'one' => 1}, YAML.load(yaml))
|
|
186
|
-
end
|
|
187
|
-
|
|
188
|
-
def test_format_yaml_with_multiline_value
|
|
189
|
-
cc = ClassConfiguration.new(['one', [1,2,3], "comment", ClassConfigurationTest])
|
|
190
|
-
yaml = cc.format_yaml
|
|
191
|
-
expected = %Q{
|
|
192
|
-
# ClassConfigurationTest configuration
|
|
193
|
-
# comment
|
|
194
|
-
one:
|
|
195
|
-
- 1
|
|
196
|
-
- 2
|
|
197
|
-
- 3
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
assert_equal expected[1..-1], yaml
|
|
201
|
-
assert_equal({'one' => [1,2,3]}, YAML.load(yaml))
|
|
202
|
-
end
|
|
203
|
-
|
|
204
|
-
def test_format_yaml_with_multiple_classes
|
|
205
|
-
cc = ClassConfiguration.new(
|
|
206
|
-
['one', 1, '', ClassConfigurationTest],
|
|
207
|
-
['one', 'one', 'integer', AnotherClass],
|
|
208
|
-
['two', {'key' => 'value'}, 'hash', AnotherClass],
|
|
209
|
-
['three', [1,2,3], "multiline\narray", AnotherClass])
|
|
210
|
-
yaml = cc.format_yaml
|
|
211
|
-
expected = %Q{
|
|
212
|
-
# ClassConfigurationTest configuration
|
|
213
|
-
one: one # integer
|
|
214
|
-
|
|
215
|
-
# ClassConfigurationTest::AnotherClass configurations
|
|
216
|
-
# hash
|
|
217
|
-
two:
|
|
218
|
-
key: value
|
|
219
|
-
# multiline
|
|
220
|
-
# array
|
|
221
|
-
three:
|
|
222
|
-
- 1
|
|
223
|
-
- 2
|
|
224
|
-
- 3
|
|
225
|
-
}
|
|
226
|
-
|
|
227
|
-
assert_equal expected[1..-1], yaml
|
|
228
|
-
assert_equal({'one' => 'one', 'two' => {'key' => 'value'}, 'three' => [1,2,3]}, YAML.load(yaml))
|
|
229
|
-
end
|
|
230
|
-
end
|
|
231
|
-
|
|
232
|
-
class Hold
|
|
233
|
-
|
|
234
|
-
# def test_documentation
|
|
235
|
-
# assert_equal({:one => 1}, BaseTask.configurations.hash)
|
|
236
|
-
# assert_equal({:one => 'one', :two => 'two'}, SubTask.configurations.hash)
|
|
237
|
-
#
|
|
238
|
-
# assert_equal "# BaseTask configuration\none: 1\n", BaseTask.configurations.format_yaml
|
|
239
|
-
#
|
|
240
|
-
# expected = %Q{
|
|
241
|
-
# # BaseTask configuration
|
|
242
|
-
# one: one # the first configuration
|
|
243
|
-
#
|
|
244
|
-
# # SubTask configuration
|
|
245
|
-
# two: two # the second configuration
|
|
246
|
-
# }
|
|
247
|
-
# assert_equal expected[1..-1], SubTask.configurations.format_yaml
|
|
248
|
-
# end
|
|
249
|
-
|
|
250
|
-
#
|
|
251
|
-
# add configurations
|
|
252
|
-
#
|
|
253
|
-
|
|
254
|
-
class AnotherClass
|
|
255
|
-
end
|
|
256
|
-
|
|
257
|
-
def test_add
|
|
258
|
-
cc = ClassConfiguration.new
|
|
259
|
-
cc.add(:key, 'value', ClassConfigurationTest)
|
|
260
|
-
|
|
261
|
-
assert_equal [[:key, 'value', ClassConfigurationTest]], cc.declarations
|
|
262
|
-
assert_equal({:key => 'value'}, cc.hash)
|
|
263
|
-
|
|
264
|
-
cc.add(:key, 'new value', AnotherClass)
|
|
265
|
-
assert_equal [
|
|
266
|
-
[:key, 'value', ClassConfigurationTest],
|
|
267
|
-
[:key, 'new value', AnotherClass]
|
|
268
|
-
], cc.declarations
|
|
269
|
-
assert_equal({:key => 'new value'}, cc.hash)
|
|
270
|
-
end
|
|
271
|
-
|
|
272
|
-
def test_add_symbolizes_keys
|
|
273
|
-
cc = ClassConfiguration.new
|
|
274
|
-
cc.add('key', 'value', ClassConfigurationTest)
|
|
275
|
-
|
|
276
|
-
assert_equal [[:key, 'value', ClassConfigurationTest]], cc.declarations
|
|
277
|
-
assert_equal({:key => 'value'}, cc.hash)
|
|
278
|
-
end
|
|
279
|
-
|
|
280
|
-
# def test_add_raises_error_if_declarations_are_not_correct
|
|
281
|
-
# cc = ClassConfiguration.new
|
|
282
|
-
# assert_raise(ArgumentError) { cc.add(:key, 'value')}
|
|
283
|
-
# assert_raise(ArgumentError) { cc.add([:key, 'value'])}
|
|
284
|
-
# end
|
|
285
|
-
|
|
286
|
-
#
|
|
287
|
-
# remove configurations
|
|
288
|
-
#
|
|
289
|
-
|
|
290
|
-
def test_remove
|
|
291
|
-
cc = ClassConfiguration.new(
|
|
292
|
-
[:one, 1, ClassConfigurationTest],
|
|
293
|
-
[:one, 'one', AnotherClass],
|
|
294
|
-
[:two, 'two', AnotherClass],
|
|
295
|
-
[:three, 'three', AnotherClass])
|
|
296
|
-
|
|
297
|
-
assert_equal 4, cc.declarations.length
|
|
298
|
-
assert_equal({:one => 'one', :two => 'two', :three => 'three'}, cc.hash)
|
|
299
|
-
|
|
300
|
-
cc.remove(:one, :three)
|
|
301
|
-
assert_equal [[:two, 'two', AnotherClass]], cc.declarations
|
|
302
|
-
assert_equal({:two => 'two'}, cc.hash)
|
|
303
|
-
end
|
|
304
|
-
|
|
305
|
-
def test_remove_symbolizes_inputs
|
|
306
|
-
cc = ClassConfiguration.new([:key, 'value', ClassConfigurationTest])
|
|
307
|
-
cc.remove('key')
|
|
308
|
-
assert_equal [], cc.declarations
|
|
309
|
-
end
|
|
310
|
-
|
|
311
|
-
#
|
|
312
|
-
# merge test
|
|
313
|
-
#
|
|
314
|
-
|
|
315
|
-
# def test_merge
|
|
316
|
-
# c1 = ClassConfiguration.new([:one, 1, '', ClassConfigurationTest])
|
|
317
|
-
# c2 = c1.merge([
|
|
318
|
-
# [:one, 'one', '', AnotherClass],
|
|
319
|
-
# [:two, 'two', '', AnotherClass]])
|
|
320
|
-
#
|
|
321
|
-
# assert_not_equal c1.object_id, c2.object_id
|
|
322
|
-
#
|
|
323
|
-
# assert_equal [[:one, 1, '', ClassConfigurationTest]], c1.declarations
|
|
324
|
-
# assert_equal [
|
|
325
|
-
# [:one, 1, '', ClassConfigurationTest],
|
|
326
|
-
# [:one, 'one', '', AnotherClass],
|
|
327
|
-
# [:two, 'two', '', AnotherClass]], c2.declarations
|
|
328
|
-
# end
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
end
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
require File.join(File.dirname(__FILE__), '../tap_test_helper')
|
|
2
|
-
require 'tap/support/command_line'
|
|
3
|
-
|
|
4
|
-
class CommandLineTest < Test::Unit::TestCase
|
|
5
|
-
include Tap::Support::CommandLine
|
|
6
|
-
|
|
7
|
-
#
|
|
8
|
-
# split_argv test
|
|
9
|
-
#
|
|
10
|
-
|
|
11
|
-
def test_split_argv
|
|
12
|
-
argv = ["a", "-b", "--c", "--", "d", "-e", "--f"]
|
|
13
|
-
assert_equal([
|
|
14
|
-
[["a", "-b", "--c"], ["d", "-e", "--f"]]
|
|
15
|
-
], split_argv(argv))
|
|
16
|
-
|
|
17
|
-
argv.unshift("--")
|
|
18
|
-
argv.push("--")
|
|
19
|
-
assert_equal([
|
|
20
|
-
[["a", "-b", "--c"], ["d", "-e", "--f"]]
|
|
21
|
-
], split_argv(argv))
|
|
22
|
-
|
|
23
|
-
argv.concat ["--++", "x", "-y", "--z"]
|
|
24
|
-
assert_equal([
|
|
25
|
-
[["a", "-b", "--c"], ["d", "-e", "--f"]],
|
|
26
|
-
[["x", "-y", "--z"]]
|
|
27
|
-
], split_argv(argv))
|
|
28
|
-
|
|
29
|
-
argv.concat ["--+", "m", "-n", "--o"]
|
|
30
|
-
assert_equal([
|
|
31
|
-
[["a", "-b", "--c"], ["d", "-e", "--f"]],
|
|
32
|
-
[["m", "-n", "--o"]],
|
|
33
|
-
[["x", "-y", "--z"]]
|
|
34
|
-
], split_argv(argv))
|
|
35
|
-
end
|
|
36
|
-
|
|
37
|
-
#
|
|
38
|
-
# parse_yaml tests
|
|
39
|
-
#
|
|
40
|
-
|
|
41
|
-
def test_parse_yaml_documentation
|
|
42
|
-
str = {'key' => 'value'}.to_yaml
|
|
43
|
-
assert_equal "--- \nkey: value\n", str
|
|
44
|
-
assert_equal({'key' => 'value'}, parse_yaml(str))
|
|
45
|
-
assert_equal "str", parse_yaml("str")
|
|
46
|
-
end
|
|
47
|
-
|
|
48
|
-
def test_parse_yaml_loads_arg_if_arg_matches_yaml_document_string
|
|
49
|
-
string = "---\nkey: value"
|
|
50
|
-
assert_equal({"key" => "value"}, parse_yaml(string))
|
|
51
|
-
end
|
|
52
|
-
|
|
53
|
-
def test_parse_yaml_returns_arg_unless_matches_yaml_document_string
|
|
54
|
-
string = "key: value"
|
|
55
|
-
assert_equal("key: value", parse_yaml(string))
|
|
56
|
-
end
|
|
57
|
-
|
|
58
|
-
end
|