tap 0.8.0 → 0.9.0
Sign up to get free protection for your applications and to get access to all the features.
- data/Basic Overview +151 -0
- data/Command Reference +99 -0
- data/History +24 -0
- data/MIT-LICENSE +1 -1
- data/README +29 -57
- data/Rakefile +30 -37
- data/Tutorial +243 -191
- data/bin/tap +66 -35
- data/lib/tap.rb +47 -29
- data/lib/tap/app.rb +700 -342
- data/lib/tap/{script → cmd}/console.rb +0 -0
- data/lib/tap/{script → cmd}/destroy.rb +0 -0
- data/lib/tap/{script → cmd}/generate.rb +0 -0
- data/lib/tap/cmd/run.rb +156 -0
- data/lib/tap/constants.rb +4 -0
- data/lib/tap/dump.rb +57 -0
- data/lib/tap/env.rb +316 -0
- data/lib/tap/file_task.rb +106 -109
- data/lib/tap/generator.rb +4 -1
- data/lib/tap/generator/generators/command/USAGE +6 -0
- data/lib/tap/generator/generators/command/command_generator.rb +17 -0
- data/lib/tap/generator/generators/{script/templates/script.erb → command/templates/command.erb} +10 -10
- data/lib/tap/generator/generators/config/USAGE +21 -0
- data/lib/tap/generator/generators/config/config_generator.rb +17 -7
- data/lib/tap/generator/generators/file_task/USAGE +3 -0
- data/lib/tap/generator/generators/file_task/file_task_generator.rb +16 -0
- data/lib/tap/generator/generators/file_task/templates/file.txt +2 -0
- data/lib/tap/generator/generators/file_task/templates/file.yml +3 -0
- data/lib/tap/generator/generators/file_task/templates/task.erb +26 -20
- data/lib/tap/generator/generators/file_task/templates/test.erb +20 -10
- data/lib/tap/generator/generators/generator/generator_generator.rb +1 -1
- data/lib/tap/generator/generators/generator/templates/generator.erb +21 -12
- data/lib/tap/generator/generators/root/templates/Rakefile +33 -24
- data/lib/tap/generator/generators/root/templates/tap.yml +28 -31
- data/lib/tap/generator/generators/root/templates/test/tap_test_helper.rb +1 -0
- data/lib/tap/generator/generators/task/USAGE +3 -0
- data/lib/tap/generator/generators/task/task_generator.rb +18 -5
- data/lib/tap/generator/generators/task/templates/task.erb +7 -12
- data/lib/tap/generator/generators/task/templates/test.erb +10 -11
- data/lib/tap/generator/generators/workflow/templates/task.erb +1 -1
- data/lib/tap/generator/generators/workflow/templates/test.erb +1 -1
- data/lib/tap/patches/rake/rake_test_loader.rb +8 -0
- data/lib/tap/patches/rake/testtask.rb +55 -0
- data/lib/tap/patches/ruby19/backtrace_filter.rb +51 -0
- data/lib/tap/patches/ruby19/parsedate.rb +16 -0
- data/lib/tap/root.rb +172 -67
- data/lib/tap/script.rb +70 -336
- data/lib/tap/support/aggregator.rb +55 -0
- data/lib/tap/support/audit.rb +281 -280
- data/lib/tap/support/batchable.rb +59 -0
- data/lib/tap/support/class_configuration.rb +279 -0
- data/lib/tap/support/configurable.rb +92 -0
- data/lib/tap/support/configurable_methods.rb +296 -0
- data/lib/tap/support/executable.rb +98 -0
- data/lib/tap/support/executable_queue.rb +82 -0
- data/lib/tap/support/logger.rb +9 -15
- data/lib/tap/support/rake.rb +43 -54
- data/lib/tap/support/run_error.rb +32 -13
- data/lib/tap/support/shell_utils.rb +47 -0
- data/lib/tap/support/tdoc.rb +9 -8
- data/lib/tap/support/tdoc/config_attr.rb +40 -16
- data/lib/tap/support/validation.rb +77 -0
- data/lib/tap/support/versions.rb +36 -36
- data/lib/tap/task.rb +276 -482
- data/lib/tap/test.rb +20 -261
- data/lib/tap/test/env_vars.rb +7 -5
- data/lib/tap/test/file_methods.rb +126 -121
- data/lib/tap/test/subset_methods.rb +86 -45
- data/lib/tap/test/tap_methods.rb +271 -0
- data/lib/tap/workflow.rb +174 -46
- data/test/app/config/another/task.yml +1 -0
- data/test/app/config/erb.yml +2 -1
- data/test/app/config/some/task.yml +1 -0
- data/test/app/config/template.yml +2 -6
- data/test/app_test.rb +1241 -1008
- data/test/env/test_configure/recurse_a.yml +2 -0
- data/test/env/test_configure/recurse_b.yml +2 -0
- data/test/env/test_configure/tap.yml +23 -0
- data/test/env/test_load_env_config/dir/tap.yml +3 -0
- data/test/env/test_load_env_config/recurse_a.yml +2 -0
- data/test/env/test_load_env_config/recurse_b.yml +2 -0
- data/test/env/test_load_env_config/tap.yml +3 -0
- data/test/env_test.rb +198 -0
- data/test/file_task_test.rb +70 -53
- data/{lib/tap/generator/generators/package/USAGE → test/root/file.txt} +0 -0
- data/test/root_test.rb +621 -454
- data/test/script_test.rb +38 -174
- data/test/support/aggregator_test.rb +99 -0
- data/test/support/audit_test.rb +409 -416
- data/test/support/batchable_test.rb +74 -0
- data/test/support/{task_configuration_test.rb → class_configuration_test.rb} +106 -47
- data/test/{task/config/overriding.yml → support/configurable/config/configured.yml} +0 -0
- data/test/support/configurable_test.rb +295 -0
- data/test/support/executable_queue_test.rb +103 -0
- data/test/support/executable_test.rb +38 -0
- data/test/support/logger_test.rb +17 -17
- data/test/support/rake_test.rb +4 -2
- data/test/support/shell_utils_test.rb +24 -0
- data/test/support/tdoc_test.rb +265 -258
- data/test/support/validation_test.rb +54 -0
- data/test/support/versions_test.rb +38 -38
- data/test/tap_test_helper.rb +19 -5
- data/test/tap_test_suite.rb +5 -2
- data/test/task_base_test.rb +13 -104
- data/test/task_syntax_test.rb +300 -0
- data/test/task_test.rb +258 -381
- data/test/test/env_vars_test.rb +40 -40
- data/test/test/file_methods/{test_assert_output_files_equal → test_assert_files}/expected/one.txt +0 -0
- data/test/test/file_methods/{test_assert_output_files_equal → test_assert_files}/expected/two.txt +0 -0
- data/test/test/file_methods/{test_assert_output_files_equal → test_assert_files}/input/one.txt +0 -0
- data/test/test/file_methods/{test_assert_output_files_equal → test_assert_files}/input/two.txt +0 -0
- data/test/test/{test_file_task_test → file_methods/test_assert_files_can_have_no_expected_files_if_specified}/input/one.txt +0 -0
- data/test/test/{test_file_task_test → file_methods/test_assert_files_can_have_no_expected_files_if_specified}/input/two.txt +0 -0
- data/test/test/file_methods/test_assert_files_fails_for_different_content/expected/one.txt +1 -0
- data/test/test/{test_file_task_test → file_methods/test_assert_files_fails_for_different_content}/expected/two.txt +0 -0
- data/test/test/file_methods/test_assert_files_fails_for_different_content/input/one.txt +1 -0
- data/test/test/file_methods/test_assert_files_fails_for_different_content/input/two.txt +1 -0
- data/test/test/{test_file_task_test → file_methods/test_assert_files_fails_for_missing_expected_file}/expected/one.txt +0 -0
- data/test/test/file_methods/test_assert_files_fails_for_missing_expected_file/input/one.txt +1 -0
- data/test/test/file_methods/test_assert_files_fails_for_missing_expected_file/input/two.txt +1 -0
- data/test/test/file_methods/test_assert_files_fails_for_missing_output_file/expected/one.txt +1 -0
- data/test/test/file_methods/test_assert_files_fails_for_missing_output_file/expected/two.txt +1 -0
- data/test/test/file_methods/test_assert_files_fails_for_missing_output_file/input/one.txt +1 -0
- data/test/test/file_methods/test_assert_files_fails_for_missing_output_file/input/two.txt +1 -0
- data/test/test/file_methods/test_assert_files_fails_for_no_expected_files/input/one.txt +1 -0
- data/test/test/file_methods/test_assert_files_fails_for_no_expected_files/input/two.txt +1 -0
- data/test/test/file_methods_doc/test_sub/expected/one.txt +1 -0
- data/test/test/file_methods_doc/test_sub/expected/two.txt +1 -0
- data/test/test/file_methods_doc/test_sub/input/one.txt +1 -0
- data/test/test/file_methods_doc/test_sub/input/two.txt +1 -0
- data/test/test/file_methods_doc_test.rb +29 -0
- data/test/test/file_methods_test.rb +214 -143
- data/test/test/subset_methods_test.rb +111 -115
- data/test/test/{test_assert_expected_result_files → tap_methods/test_assert_files}/expected/task/name/a.txt +0 -0
- data/test/test/{test_assert_expected_result_files → tap_methods/test_assert_files}/expected/task/name/b.txt +0 -0
- data/test/test/{test_assert_expected_result_files → tap_methods/test_assert_files}/input/a.txt +0 -0
- data/test/test/{test_assert_expected_result_files → tap_methods/test_assert_files}/input/b.txt +0 -0
- data/test/test/tap_methods_test.rb +399 -0
- data/test/workflow_test.rb +101 -91
- metadata +86 -70
- data/lib/tap/generator/generators/package/package_generator.rb +0 -38
- data/lib/tap/generator/generators/package/templates/package.erb +0 -186
- data/lib/tap/generator/generators/script/USAGE +0 -0
- data/lib/tap/generator/generators/script/script_generator.rb +0 -17
- data/lib/tap/script/run.rb +0 -154
- data/lib/tap/support/batch_queue.rb +0 -162
- data/lib/tap/support/combinator.rb +0 -114
- data/lib/tap/support/task_configuration.rb +0 -169
- data/lib/tap/support/template.rb +0 -81
- data/lib/tap/support/templater.rb +0 -155
- data/lib/tap/version.rb +0 -4
- data/test/app/config/addition_template.yml +0 -6
- data/test/app_class_test.rb +0 -33
- data/test/check/binding_eval.rb +0 -23
- data/test/check/define_method_check.rb +0 -22
- data/test/check/dependencies_check.rb +0 -175
- data/test/check/inheritance_check.rb +0 -22
- data/test/support/batch_queue_test.rb +0 -320
- data/test/support/combinator_test.rb +0 -249
- data/test/support/template_test.rb +0 -122
- data/test/support/templater/erb.txt +0 -2
- data/test/support/templater/erb.yml +0 -2
- data/test/support/templater/somefile.txt +0 -2
- data/test/support/templater_test.rb +0 -192
- data/test/task/config/template.yml +0 -4
- data/test/task_class_test.rb +0 -170
- data/test/task_execute_test.rb +0 -262
- data/test/test/file_methods/test_assert_expected/expected/file.txt +0 -1
- data/test/test/file_methods/test_assert_expected/expected/folder/file.txt +0 -1
- data/test/test/file_methods/test_assert_expected/input/file.txt +0 -1
- data/test/test/file_methods/test_assert_expected/input/folder/file.txt +0 -1
- data/test/test/file_methods/test_assert_files_exist/input/input_1.txt +0 -0
- data/test/test/file_methods/test_assert_files_exist/input/input_2.txt +0 -0
- data/test/test/file_methods/test_file_compare/expected/output_1.txt +0 -3
- data/test/test/file_methods/test_file_compare/expected/output_2.txt +0 -1
- data/test/test/file_methods/test_file_compare/input/input_1.txt +0 -3
- data/test/test/file_methods/test_file_compare/input/input_2.txt +0 -3
- data/test/test/file_methods/test_infer_glob/expected/file.yml +0 -0
- data/test/test/file_methods/test_infer_glob/expected/file_1.txt +0 -0
- data/test/test/file_methods/test_infer_glob/expected/file_2.txt +0 -0
- data/test/test/file_methods/test_yml_compare/expected/output_1.yml +0 -6
- data/test/test/file_methods/test_yml_compare/expected/output_2.yml +0 -6
- data/test/test/file_methods/test_yml_compare/input/input_1.yml +0 -4
- data/test/test/file_methods/test_yml_compare/input/input_2.yml +0 -4
- data/test/test_test.rb +0 -373
@@ -0,0 +1,103 @@
|
|
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
|
@@ -0,0 +1,38 @@
|
|
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
CHANGED
@@ -3,29 +3,29 @@ require 'tap/support/logger'
|
|
3
3
|
require 'stringio'
|
4
4
|
|
5
5
|
class LoggerTest < Test::Unit::TestCase
|
6
|
-
|
6
|
+
include Tap
|
7
7
|
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
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
20
|
|
21
21
|
def test_logdev_returns_the_log_device
|
22
|
-
|
23
|
-
|
22
|
+
[StringIO.new(''), STDOUT].each do |device|
|
23
|
+
logger = Logger.new(device)
|
24
24
|
assert !logger.respond_to?(:logdev)
|
25
25
|
|
26
26
|
logger.extend Support::Logger
|
27
27
|
assert_equal Logger::LogDevice, logger.logdev.class
|
28
|
-
|
28
|
+
assert_equal device, logger.logdev.dev
|
29
29
|
end
|
30
|
-
|
30
|
+
end
|
31
31
|
end
|
data/test/support/rake_test.rb
CHANGED
@@ -17,11 +17,13 @@ class RakeTest < Test::Unit::TestCase
|
|
17
17
|
end
|
18
18
|
|
19
19
|
assert_equal [], runlist
|
20
|
-
app.
|
20
|
+
app.task(:task).enq
|
21
|
+
app.run
|
21
22
|
assert_equal [:prerequisite, :task], runlist
|
22
23
|
|
23
24
|
# notice the tasks do not get re-run
|
24
|
-
app.
|
25
|
+
app.task(:task).enq
|
26
|
+
app.run
|
25
27
|
assert_equal [:prerequisite, :task], runlist
|
26
28
|
|
27
29
|
# check that Rake still works natively
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), '../tap_test_helper')
|
2
|
+
require 'tap/support/shell_utils'
|
3
|
+
|
4
|
+
class ShellUtilsTest < Test::Unit::TestCase
|
5
|
+
include Tap::Support::ShellUtils
|
6
|
+
|
7
|
+
#
|
8
|
+
# capture_sh test
|
9
|
+
#
|
10
|
+
|
11
|
+
def test_capture_sh
|
12
|
+
assert_equal "hello\n", capture_sh('echo hello')
|
13
|
+
end
|
14
|
+
|
15
|
+
def test_capture_sh_with_block
|
16
|
+
was_in_block = false
|
17
|
+
result = capture_sh('echo hello') do |ok, status|
|
18
|
+
assert ok
|
19
|
+
was_in_block = true
|
20
|
+
end
|
21
|
+
assert_equal "hello\n", result
|
22
|
+
assert was_in_block
|
23
|
+
end
|
24
|
+
end
|
data/test/support/tdoc_test.rb
CHANGED
@@ -9,6 +9,7 @@ require File.join(File.dirname(__FILE__), '../tap_test_helper')
|
|
9
9
|
class TaskDocumentation < Tap::Task
|
10
10
|
config :c_nodoc, 'value' # :nodoc:
|
11
11
|
config(:c_accessor, 'value') # c_accessor
|
12
|
+
config(:c_validation, 'value') {|value| } # c_validation
|
12
13
|
|
13
14
|
config_reader
|
14
15
|
|
@@ -25,11 +26,12 @@ class TaskDocumentation < Tap::Task
|
|
25
26
|
# c_multiline1
|
26
27
|
config(:c_multiline, 'value' ) # c_multiline2
|
27
28
|
|
28
|
-
config :c_with_attr, 'value', {:key => 'value'} # c_with_attr
|
29
|
-
|
30
29
|
config :alt_c, 'value' # alt_c
|
31
|
-
config :
|
30
|
+
config :alt_c_validation, 'value' do |value| # alt_c_validation
|
31
|
+
end
|
32
32
|
config :alt_c_without_value # alt_c_without_value
|
33
|
+
config :alt_c_validation_without_value do |value| # alt_c_validation_without_value
|
34
|
+
end
|
33
35
|
|
34
36
|
# declare_config
|
35
37
|
declare_config :declare_config
|
@@ -103,261 +105,266 @@ class TDocTest < Test::Unit::TestCase
|
|
103
105
|
include Tap::Support
|
104
106
|
|
105
107
|
TDoc.document(__FILE__)
|
106
|
-
|
107
|
-
#
|
108
|
-
# RDoc RubyLex and RubyToken redefinition test
|
109
|
-
#
|
110
|
-
|
111
|
-
def test_rubylex_and_rubytoken_redefinition
|
112
|
-
filepath = __FILE__
|
113
|
-
tl = RDoc::TopLevel.new(filepath)
|
114
|
-
stats = RDoc::Stats.new
|
115
|
-
options = Options.instance
|
116
|
-
parser = RDoc::RubyParser.new(tl, filepath, File.read(filepath), options, stats)
|
117
|
-
|
118
|
-
assert Tap::Support::TDoc::ConfigParser.included_modules.include?(RDoc::RubyToken)
|
119
|
-
assert RDoc::RubyParser.included_modules.include?(RDoc::RubyToken)
|
120
|
-
assert_equal RDoc::RubyLex, parser.instance_variable_get("@scanner").class
|
121
|
-
|
122
|
-
if satisfied?(:irb_variant)
|
123
|
-
assert_not_equal RubyToken, RDoc::RubyToken
|
124
|
-
assert_not_equal RubyLex, RDoc::RubyLex
|
125
|
-
assert RubyLex.included_modules.include?(RubyToken)
|
126
|
-
assert !RubyLex.included_modules.include?(RDoc::RubyLex)
|
127
|
-
else
|
128
|
-
flunk unless !Object.const_defined?(:RubyToken) || RubyToken == RDoc::RubyToken
|
129
|
-
flunk unless !Object.const_defined?(:RubyLex) || RubyLex == RDoc::RubyLex
|
130
|
-
end
|
131
|
-
end
|
132
|
-
|
133
|
-
#
|
134
|
-
# [] tests
|
135
|
-
#
|
136
108
|
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
109
|
+
#
|
110
|
+
# RDoc RubyLex and RubyToken redefinition test
|
111
|
+
#
|
112
|
+
|
113
|
+
def test_rubylex_and_rubytoken_redefinition
|
114
|
+
filepath = __FILE__
|
115
|
+
tl = RDoc::TopLevel.new(filepath)
|
116
|
+
stats = RDoc::Stats.new
|
117
|
+
options = Options.instance
|
118
|
+
parser = RDoc::RubyParser.new(tl, filepath, File.read(filepath), options, stats)
|
119
|
+
|
120
|
+
assert Tap::Support::TDoc::ConfigParser.included_modules.include?(RDoc::RubyToken)
|
121
|
+
assert RDoc::RubyParser.included_modules.include?(RDoc::RubyToken)
|
122
|
+
assert_equal RDoc::RubyLex, parser.instance_variable_get("@scanner").class
|
123
|
+
|
124
|
+
if satisfied?(:irb_variant)
|
125
|
+
assert_not_equal RubyToken, RDoc::RubyToken
|
126
|
+
assert_not_equal RubyLex, RDoc::RubyLex
|
127
|
+
assert RubyLex.included_modules.include?(RubyToken)
|
128
|
+
assert !RubyLex.included_modules.include?(RDoc::RubyLex)
|
129
|
+
else
|
130
|
+
flunk unless !Object.const_defined?(:RubyToken) || RubyToken == RDoc::RubyToken
|
131
|
+
flunk unless !Object.const_defined?(:RubyLex) || RubyLex == RDoc::RubyLex
|
132
|
+
end
|
133
|
+
end
|
160
134
|
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
|
306
|
-
|
307
|
-
|
308
|
-
|
309
|
-
|
310
|
-
|
311
|
-
|
312
|
-
|
313
|
-
|
314
|
-
|
315
|
-
|
316
|
-
|
317
|
-
|
318
|
-
|
319
|
-
|
320
|
-
|
321
|
-
|
322
|
-
|
323
|
-
|
324
|
-
|
325
|
-
|
326
|
-
|
327
|
-
|
328
|
-
|
329
|
-
|
330
|
-
|
331
|
-
|
332
|
-
|
333
|
-
|
334
|
-
|
335
|
-
|
336
|
-
|
337
|
-
|
338
|
-
|
339
|
-
|
340
|
-
|
341
|
-
|
342
|
-
|
343
|
-
|
344
|
-
|
345
|
-
|
346
|
-
|
347
|
-
|
348
|
-
|
349
|
-
|
350
|
-
|
351
|
-
|
352
|
-
|
353
|
-
|
354
|
-
|
355
|
-
|
356
|
-
|
357
|
-
|
358
|
-
|
359
|
-
|
360
|
-
|
361
|
-
|
362
|
-
|
135
|
+
#
|
136
|
+
# [] tests
|
137
|
+
#
|
138
|
+
|
139
|
+
def test_get_class_documentation
|
140
|
+
c = TDoc[TaskDocumentation]
|
141
|
+
assert_equal RDoc::NormalClass, c.class
|
142
|
+
assert_equal "# = Section One\n# section one\n#\n# == Section Two\n# section two\n# line two\n", c.comment
|
143
|
+
|
144
|
+
|
145
|
+
c = TDoc[Nested]
|
146
|
+
assert_equal RDoc::NormalModule, c.class
|
147
|
+
assert_equal "# nested doc\n", c.comment
|
148
|
+
|
149
|
+
c = TDoc[Nested::Klass]
|
150
|
+
assert_equal RDoc::NormalClass, c.class
|
151
|
+
assert_equal "# class doc\n", c.comment
|
152
|
+
|
153
|
+
c = TDoc[Nested::Mod]
|
154
|
+
assert_equal RDoc::NormalModule, c.class
|
155
|
+
assert_equal "# mod doc\n", c.comment
|
156
|
+
end
|
157
|
+
|
158
|
+
def test_get_documentation_works_for_strings_and_constants
|
159
|
+
assert_equal RDoc::NormalClass, TDoc[Nested::Klass].class
|
160
|
+
assert_equal TDoc["Nested::Klass"].object_id, TDoc[Nested::Klass].object_id
|
161
|
+
end
|
162
|
+
|
163
|
+
def test_configs_are_documented
|
164
|
+
c = TDoc[TaskDocumentation]
|
165
|
+
|
166
|
+
attributes = c.attributes.collect do |attribute|
|
167
|
+
case attribute
|
168
|
+
when TDoc::ConfigAttr
|
169
|
+
{:comment => attribute.original_comment,
|
170
|
+
:name => attribute.name,
|
171
|
+
:rw => attribute.rw,
|
172
|
+
:text => attribute.text}
|
173
|
+
else
|
174
|
+
{:comment => attribute.comment,
|
175
|
+
:name => attribute.name,
|
176
|
+
:rw => attribute.rw,
|
177
|
+
:text => attribute.text}
|
178
|
+
end
|
179
|
+
end
|
180
|
+
|
181
|
+
expected_attributes.each_with_index do |expected, i|
|
182
|
+
assert_equal expected, attributes[i], "unequal attribute (index=#{i})"
|
183
|
+
end
|
184
|
+
assert_equal expected_attributes.length, attributes.length
|
185
|
+
end
|
186
|
+
|
187
|
+
#
|
188
|
+
# accessor extensions
|
189
|
+
#
|
190
|
+
|
191
|
+
def test_comment_sections
|
192
|
+
c = TDoc[TaskDocumentation]
|
193
|
+
|
194
|
+
assert c.respond_to?(:comment_sections)
|
195
|
+
assert_equal({
|
196
|
+
"Section One" => "# section one\n#\n",
|
197
|
+
"Section Two" => "# section two\n# line two\n"},
|
198
|
+
c.comment_sections)
|
199
|
+
|
200
|
+
assert_equal({
|
201
|
+
"Section Two" => "# section two\n# line two\n"},
|
202
|
+
c.comment_sections(/two/i))
|
203
|
+
|
204
|
+
assert_equal({
|
205
|
+
"Section Two" => "section two\nline two"},
|
206
|
+
c.comment_sections(/two/i, true))
|
207
|
+
end
|
208
|
+
|
209
|
+
# def test_collect_configurations
|
210
|
+
# c = TDoc.document(TaskDocumentation, __FILE__)
|
211
|
+
# assert_equal expected_attributes[0..-5], TDoc.collect_configurations(c)
|
212
|
+
# end
|
213
|
+
#
|
214
|
+
# def test_collect_attributes
|
215
|
+
# c = TDoc.document(TaskDocumentation, __FILE__)
|
216
|
+
# assert_equal expected_attributes[-4..-1], TDoc.collect_attributes(c)
|
217
|
+
# end
|
218
|
+
|
219
|
+
def expected_attributes
|
220
|
+
@expected_attributes ||= [{
|
221
|
+
:comment=>nil,
|
222
|
+
:name=>"c_accessor",
|
223
|
+
:rw=>"RW",
|
224
|
+
:text=>"# c_accessor ('value')"},
|
225
|
+
{
|
226
|
+
:comment=>nil,
|
227
|
+
:name=>"c_validation",
|
228
|
+
:rw=>"RW",
|
229
|
+
:text=>"# c_validation ('value')"},
|
230
|
+
{
|
231
|
+
:comment=>nil,
|
232
|
+
:name=>"c_reader",
|
233
|
+
:rw=>"R",
|
234
|
+
:text=>"# c_reader ('value')"},
|
235
|
+
{
|
236
|
+
:comment=>nil,
|
237
|
+
:name=>"c",
|
238
|
+
:rw=>nil,
|
239
|
+
:text=>"# c ('value')"},
|
240
|
+
{
|
241
|
+
:comment=>"# c_conventional\n",
|
242
|
+
:name=>"c_conventional",
|
243
|
+
:rw=>nil,
|
244
|
+
:text=>" ('value')"},
|
245
|
+
{
|
246
|
+
:comment=>nil,
|
247
|
+
:name=>"c_without_doc",
|
248
|
+
:rw=>nil,
|
249
|
+
:text=>" ('value')"},
|
250
|
+
{
|
251
|
+
:comment=>"# c_multiline1\n",
|
252
|
+
:name=>"c_multiline",
|
253
|
+
:rw=>nil,
|
254
|
+
:text=>"# c_multiline2 ('value')"},
|
255
|
+
{
|
256
|
+
:comment=>nil,
|
257
|
+
:name=>"alt_c",
|
258
|
+
:rw=>nil,
|
259
|
+
:text=>"# alt_c ('value')"},
|
260
|
+
{
|
261
|
+
:comment=>nil,
|
262
|
+
:name=>"alt_c_validation",
|
263
|
+
:rw=>nil,
|
264
|
+
:text=>"# alt_c_validation ('value')"},
|
265
|
+
{
|
266
|
+
:comment=>nil,
|
267
|
+
:name=>"alt_c_without_value",
|
268
|
+
:rw=>nil,
|
269
|
+
:text=>"# alt_c_without_value"},
|
270
|
+
{
|
271
|
+
:comment=>nil,
|
272
|
+
:name=>"alt_c_validation_without_value",
|
273
|
+
:rw=>nil,
|
274
|
+
:text=>"# alt_c_validation_without_value"},
|
275
|
+
{
|
276
|
+
:comment=>"# declare_config\n",
|
277
|
+
:name=>"declare_config",
|
278
|
+
:rw=>nil,
|
279
|
+
:text=>""},
|
280
|
+
{
|
281
|
+
:comment=>"# confg_accessor\n",
|
282
|
+
:name=>"config_accessor",
|
283
|
+
:rw=>"RW",
|
284
|
+
:text=>""},
|
285
|
+
{
|
286
|
+
:comment=>"# config_reader\n",
|
287
|
+
:name=>"config_reader",
|
288
|
+
:rw=>"R",
|
289
|
+
:text=>""},
|
290
|
+
{
|
291
|
+
:comment=>"# config_writer\n",
|
292
|
+
:name=>"config_writer",
|
293
|
+
:rw=>"W",
|
294
|
+
:text=>""},
|
295
|
+
{
|
296
|
+
:comment=>"# multi_config_accessor\n",
|
297
|
+
:name=>"multi_config_accessor1",
|
298
|
+
:rw=>"RW",
|
299
|
+
:text=>""},
|
300
|
+
{
|
301
|
+
:comment=>"# multi_config_accessor\n",
|
302
|
+
:name=>"multi_config_accessor2",
|
303
|
+
:rw=>"RW",
|
304
|
+
:text=>""},
|
305
|
+
{
|
306
|
+
:comment=>"# attr_accessor\n",
|
307
|
+
:name=>"attr_accessor",
|
308
|
+
:rw=>"RW",
|
309
|
+
:text=>"# ignored"},
|
310
|
+
{
|
311
|
+
:comment=>nil,
|
312
|
+
:name=>"attr_accessor_without_doc",
|
313
|
+
:rw=>"RW",
|
314
|
+
:text=>""},
|
315
|
+
{
|
316
|
+
:comment=>"# multi_attr_accessor\n",
|
317
|
+
:name=>"multi_attr_accessor1",
|
318
|
+
:rw=>"RW",
|
319
|
+
:text=>""},
|
320
|
+
{
|
321
|
+
:comment=>"# multi_attr_accessor\n",
|
322
|
+
:name=>"multi_attr_accessor2",
|
323
|
+
:rw=>"RW",
|
324
|
+
:text=>""}]
|
325
|
+
end
|
326
|
+
|
327
|
+
#
|
328
|
+
# NotATask documentation
|
329
|
+
#
|
330
|
+
|
331
|
+
# def test_not_a_task_document
|
332
|
+
# c = TDoc.document(NotATask, __FILE__)
|
333
|
+
#
|
334
|
+
# assert_equal RDoc::NormalClass, c.class
|
335
|
+
# assert_equal "", c.comment
|
336
|
+
#
|
337
|
+
# attributes = c.attributes.collect do |attribute|
|
338
|
+
# case attribute
|
339
|
+
# when TDoc::ConfigAttr
|
340
|
+
# {:comment => attribute.original_comment,
|
341
|
+
# :name => attribute.name,
|
342
|
+
# :rw => attribute.rw,
|
343
|
+
# :text => attribute.text}
|
344
|
+
# else
|
345
|
+
# {:comment => attribute.comment,
|
346
|
+
# :name => attribute.name,
|
347
|
+
# :rw => attribute.rw,
|
348
|
+
# :text => attribute.text}
|
349
|
+
# end
|
350
|
+
# end
|
351
|
+
#
|
352
|
+
# not_a_task_expected_attributes.each_with_index do |expected, i|
|
353
|
+
# assert_equal expected, attributes[i], "unequal attribute (index=#{i})"
|
354
|
+
# end
|
355
|
+
# assert_equal not_a_task_expected_attributes.length, attributes.length
|
356
|
+
# end
|
357
|
+
|
358
|
+
def not_a_task_expected_attributes
|
359
|
+
@not_a_task_expected_attributes ||= [{
|
360
|
+
:comment=>nil,
|
361
|
+
:name=>"is",
|
362
|
+
:rw=>"RW",
|
363
|
+
:text=>""},
|
364
|
+
{
|
365
|
+
:comment=>nil,
|
366
|
+
:name=>"documented",
|
367
|
+
:rw=>"RW",
|
368
|
+
:text=>""}]
|
369
|
+
end
|
363
370
|
end
|