tap 0.10.1 → 0.11.0
Sign up to get free protection for your applications and to get access to all the features.
- data/History +12 -0
- data/MIT-LICENSE +0 -2
- data/README +23 -32
- data/bin/rap +116 -0
- data/bin/tap +6 -9
- data/cgi/run.rb +67 -0
- data/cmd/console.rb +1 -1
- data/cmd/destroy.rb +4 -4
- data/cmd/generate.rb +4 -4
- data/cmd/manifest.rb +61 -53
- data/cmd/run.rb +8 -75
- data/doc/Class Reference +130 -121
- data/doc/Command Reference +76 -124
- data/doc/Syntax Reference +290 -0
- data/doc/Tutorial +305 -237
- data/lib/tap/app.rb +140 -467
- data/lib/tap/constants.rb +2 -2
- data/lib/tap/declarations.rb +211 -0
- data/lib/tap/env.rb +171 -193
- data/lib/tap/exe.rb +100 -21
- data/lib/tap/file_task.rb +3 -3
- data/lib/tap/generator/base.rb +1 -1
- data/lib/tap/generator/destroy.rb +10 -10
- data/lib/tap/generator/generate.rb +29 -18
- data/lib/tap/generator/generators/command/command_generator.rb +2 -2
- data/lib/tap/generator/generators/command/templates/command.erb +2 -2
- data/lib/tap/generator/generators/config/config_generator.rb +3 -3
- data/lib/tap/generator/generators/config/templates/doc.erb +1 -1
- data/lib/tap/generator/generators/file_task/file_task_generator.rb +1 -1
- data/lib/tap/generator/generators/file_task/templates/task.erb +1 -1
- data/lib/tap/generator/generators/file_task/templates/test.erb +1 -1
- data/lib/tap/generator/generators/generator/generator_generator.rb +27 -0
- data/lib/tap/generator/generators/generator/templates/task.erb +27 -0
- data/lib/tap/generator/generators/root/root_generator.rb +13 -13
- data/lib/tap/generator/generators/root/templates/README +0 -0
- data/lib/tap/generator/generators/root/templates/Rakefile +2 -2
- data/lib/tap/generator/generators/root/templates/gemspec +4 -5
- data/lib/tap/generator/generators/root/templates/tapfile +11 -8
- data/lib/tap/generator/generators/root/templates/test/tap_test_suite.rb +1 -1
- data/lib/tap/generator/generators/task/task_generator.rb +1 -3
- data/lib/tap/generator/generators/task/templates/test.erb +1 -3
- data/lib/tap/patches/optparse/summarize.rb +62 -0
- data/lib/tap/root.rb +41 -29
- data/lib/tap/support/aggregator.rb +16 -3
- data/lib/tap/support/assignments.rb +10 -9
- data/lib/tap/support/audit.rb +58 -64
- data/lib/tap/support/class_configuration.rb +33 -44
- data/lib/tap/support/combinator.rb +125 -0
- data/lib/tap/support/configurable.rb +13 -14
- data/lib/tap/support/configurable_class.rb +21 -43
- data/lib/tap/support/configuration.rb +55 -9
- data/lib/tap/support/constant.rb +87 -13
- data/lib/tap/support/constant_manifest.rb +116 -0
- data/lib/tap/support/dependencies.rb +54 -0
- data/lib/tap/support/dependency.rb +44 -0
- data/lib/tap/support/executable.rb +247 -32
- data/lib/tap/support/executable_queue.rb +1 -1
- data/lib/tap/support/gems/rake.rb +29 -8
- data/lib/tap/support/gems.rb +10 -30
- data/lib/tap/support/instance_configuration.rb +29 -3
- data/lib/tap/support/intern.rb +46 -0
- data/lib/tap/support/join.rb +143 -0
- data/lib/tap/support/joins/fork.rb +19 -0
- data/lib/tap/support/joins/merge.rb +22 -0
- data/lib/tap/support/joins/sequence.rb +21 -0
- data/lib/tap/support/joins/switch.rb +25 -0
- data/lib/tap/support/joins/sync_merge.rb +63 -0
- data/lib/tap/support/joins.rb +15 -0
- data/lib/tap/support/lazy_attributes.rb +17 -2
- data/lib/tap/support/lazydoc/comment.rb +503 -0
- data/lib/tap/support/lazydoc/config.rb +17 -0
- data/lib/tap/support/lazydoc/definition.rb +36 -0
- data/lib/tap/support/lazydoc/document.rb +152 -0
- data/lib/tap/support/lazydoc/method.rb +24 -0
- data/lib/tap/support/lazydoc.rb +269 -343
- data/lib/tap/support/manifest.rb +121 -103
- data/lib/tap/support/minimap.rb +90 -0
- data/lib/tap/support/node.rb +56 -0
- data/lib/tap/support/parser.rb +436 -0
- data/lib/tap/support/schema.rb +359 -0
- data/lib/tap/support/shell_utils.rb +3 -5
- data/lib/tap/support/string_ext.rb +60 -0
- data/lib/tap/support/tdoc.rb +7 -2
- data/lib/tap/support/templater.rb +30 -16
- data/lib/tap/support/validation.rb +77 -8
- data/lib/tap/task.rb +431 -143
- data/lib/tap/tasks/dump.rb +15 -10
- data/lib/tap/tasks/load.rb +112 -0
- data/lib/tap/tasks/rake.rb +4 -41
- data/lib/tap/test/assertions.rb +38 -0
- data/lib/tap/test/env_vars.rb +1 -1
- data/lib/tap/test/extensions.rb +79 -0
- data/lib/tap/test/file_test.rb +420 -0
- data/lib/tap/test/file_test_class.rb +12 -0
- data/lib/tap/test/regexp_escape.rb +87 -0
- data/lib/tap/test/script_test.rb +46 -0
- data/lib/tap/test/script_tester.rb +115 -0
- data/lib/tap/test/subset_test.rb +260 -0
- data/lib/tap/test/subset_test_class.rb +99 -0
- data/lib/tap/test/{tap_methods.rb → tap_test.rb} +45 -43
- data/lib/tap/test/utils.rb +231 -0
- data/lib/tap/test.rb +53 -26
- data/lib/tap.rb +3 -20
- metadata +50 -27
- data/lib/tap/generator/generators/root/templates/test/tapfile_test.rb +0 -15
- data/lib/tap/patches/rake/rake_test_loader.rb +0 -8
- data/lib/tap/patches/rake/testtask.rb +0 -57
- data/lib/tap/patches/ruby19/backtrace_filter.rb +0 -51
- data/lib/tap/patches/ruby19/parsedate.rb +0 -16
- data/lib/tap/support/batchable.rb +0 -47
- data/lib/tap/support/batchable_class.rb +0 -107
- data/lib/tap/support/command_line.rb +0 -98
- data/lib/tap/support/comment.rb +0 -270
- data/lib/tap/support/constant_utils.rb +0 -127
- data/lib/tap/support/declarations.rb +0 -111
- data/lib/tap/support/framework.rb +0 -83
- data/lib/tap/support/framework_class.rb +0 -180
- data/lib/tap/support/run_error.rb +0 -39
- data/lib/tap/support/summary.rb +0 -30
- data/lib/tap/test/file_methods.rb +0 -377
- data/lib/tap/test/script_methods/script_test.rb +0 -98
- data/lib/tap/test/script_methods.rb +0 -107
- data/lib/tap/test/subset_methods.rb +0 -420
- data/lib/tap/workflow.rb +0 -200
@@ -0,0 +1,112 @@
|
|
1
|
+
module Tap
|
2
|
+
module Tasks
|
3
|
+
# :startdoc::manifest the default load task
|
4
|
+
#
|
5
|
+
# Load YAML-formatted data, as may be produced using Tap::Dump,
|
6
|
+
# and makes this data available for other tasks. Load is often
|
7
|
+
# used as a gateway task to other tasks.
|
8
|
+
#
|
9
|
+
# % tap run -- load FILEPATH --: [task]
|
10
|
+
#
|
11
|
+
# Load can select items from Hash or Array objects using one or
|
12
|
+
# more keys when only a subset is desired. By default items are
|
13
|
+
# selected using []. For more flexible selection, use match.
|
14
|
+
#
|
15
|
+
# Match converts each of the keys to a Regexp. For hashes, all
|
16
|
+
# values with a matching key will be selected. For arrays, any
|
17
|
+
# item matching a regexp will be selected.
|
18
|
+
#
|
19
|
+
# Use the flags to flatten, compact, sort (etc) results before
|
20
|
+
# passing them on to the next task.
|
21
|
+
class Load < Tap::Task
|
22
|
+
|
23
|
+
config :match, false, :short => :m, &c.switch # match keys
|
24
|
+
config :flatten, false, :short => :f, &c.switch # flatten results
|
25
|
+
config :compact, false, :short => :c, &c.switch # compact results
|
26
|
+
config :unique, false, :short => :u, &c.switch # uniq results
|
27
|
+
config :sort, false, :short => :s, &c.switch # sort results
|
28
|
+
#config :preview, false, :short => :p, &c.switch # logs result
|
29
|
+
|
30
|
+
# Loads the input as YAML and selects objects using keys. Input may
|
31
|
+
# be an IO, StringIO, or a filepath. If keys are empty, the loaded
|
32
|
+
# object is returned directly.
|
33
|
+
#
|
34
|
+
# ==== Key Selection
|
35
|
+
# Keys select items from the loaded object using [] (ie obj[key]).
|
36
|
+
# If match==true, the behavior is different; each string key is
|
37
|
+
# converted into a Regexp and then arrays select items that match
|
38
|
+
# key:
|
39
|
+
#
|
40
|
+
# results = []
|
41
|
+
# array.each {|i| results << i if i =~ key}
|
42
|
+
#
|
43
|
+
# While hashes select values where the key matches key:
|
44
|
+
#
|
45
|
+
# results = []
|
46
|
+
# hash.each_pair {|k,v| results << v if k =~ key}
|
47
|
+
#
|
48
|
+
# Other objects raise an error when match is true.
|
49
|
+
#
|
50
|
+
# ==== Post Processing
|
51
|
+
# After loading/key selection, the results may be processed (in this
|
52
|
+
# order) using flatten, compact, unique, and sort, each performing as
|
53
|
+
# you would expect.
|
54
|
+
#
|
55
|
+
def process(input, *keys)
|
56
|
+
|
57
|
+
# load the input
|
58
|
+
obj = case input
|
59
|
+
when StringIO, IO
|
60
|
+
YAML.load(input.read)
|
61
|
+
else
|
62
|
+
log :load, input
|
63
|
+
YAML.load_file(input)
|
64
|
+
end
|
65
|
+
|
66
|
+
# select results by key
|
67
|
+
results = case
|
68
|
+
when keys.empty? then obj
|
69
|
+
when match
|
70
|
+
regexps = keys.collect {|key| Regexp.new(key.to_s) }
|
71
|
+
select_matching(obj, regexps)
|
72
|
+
else
|
73
|
+
keys.collect do |key|
|
74
|
+
index = key.kind_of?(String) ? YAML.load(key) : key
|
75
|
+
obj[index]
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
# post-process results
|
80
|
+
results = results.flatten if flatten
|
81
|
+
results = results.compact if compact
|
82
|
+
results = results.uniq if unique
|
83
|
+
results = results.sort if sort
|
84
|
+
|
85
|
+
#if preview
|
86
|
+
# should be a log or something
|
87
|
+
#puts results.inspect
|
88
|
+
#end
|
89
|
+
|
90
|
+
results
|
91
|
+
end
|
92
|
+
|
93
|
+
protected
|
94
|
+
|
95
|
+
# selects items from obj which match one of the regexps.
|
96
|
+
def select_matching(obj, regexps) # :nodoc:
|
97
|
+
case obj
|
98
|
+
when Array
|
99
|
+
obj.select {|item| regexps.any? {|r| item =~ r} }
|
100
|
+
when Hash
|
101
|
+
results = []
|
102
|
+
obj.each_pair do |key, value|
|
103
|
+
results << value if regexps.any? {|r| key =~ r}
|
104
|
+
end
|
105
|
+
results
|
106
|
+
else
|
107
|
+
raise ArgumentError, "cannot match keys from a #{obj.class}"
|
108
|
+
end
|
109
|
+
end
|
110
|
+
end
|
111
|
+
end
|
112
|
+
end
|
data/lib/tap/tasks/rake.rb
CHANGED
@@ -16,38 +16,11 @@ module Tap
|
|
16
16
|
# to access the rake help, and --help to access this help.
|
17
17
|
#
|
18
18
|
class Rake < Tap::Task
|
19
|
-
|
20
|
-
# Modifies Rake::Application by adding a hook to the standard_exception_handling
|
21
|
-
# method. This allows more fine-grained use of Rake::Applications by Tap.
|
22
|
-
module Application
|
23
|
-
def enq_top_level(app)
|
24
|
-
# takes the place of rake.top_level
|
25
|
-
if options.show_tasks
|
26
|
-
display_tasks_and_comments
|
27
|
-
exit
|
28
|
-
elsif options.show_prereqs
|
29
|
-
display_prerequisites
|
30
|
-
exit
|
31
|
-
else
|
32
|
-
top_level_tasks.each do |task_string|
|
33
|
-
name, args = parse_task_string(task_string)
|
34
|
-
task = self[name]
|
35
|
-
|
36
|
-
unless task.kind_of?(Tap::Support::Executable)
|
37
|
-
Tap::Support::Executable.initialize(task, :invoke)
|
38
|
-
end
|
39
|
-
|
40
|
-
app.enq(task, *args)
|
41
|
-
end
|
42
|
-
end
|
43
|
-
end
|
44
|
-
end
|
45
|
-
|
46
19
|
class << self
|
47
20
|
|
48
|
-
# Overrides Tap::Support::FrameworkClass#
|
21
|
+
# Overrides Tap::Support::FrameworkClass#parse! to do
|
49
22
|
# nothing so that all args get passed forward to rake.
|
50
|
-
def
|
23
|
+
def parse!(argv, app=Tap::App.instance) # => instance, argv
|
51
24
|
if argv.include?('--help')
|
52
25
|
puts help
|
53
26
|
exit
|
@@ -55,21 +28,10 @@ module Tap
|
|
55
28
|
[new({}, default_name, app), argv.collect {|arg| arg == '--rake-help' ? '--help' : arg}]
|
56
29
|
end
|
57
30
|
end
|
58
|
-
|
59
|
-
#--
|
60
|
-
# def on_complete(override=false, &block)
|
61
|
-
# @rake_tasks.each do |task|
|
62
|
-
# task.on_complete(override, &block)
|
63
|
-
# end
|
64
|
-
# end
|
65
|
-
#++
|
66
31
|
|
67
32
|
def enq(*argv)
|
68
33
|
rake = ::Rake.application
|
69
|
-
|
70
|
-
rake.extend Application
|
71
|
-
end
|
72
|
-
|
34
|
+
|
73
35
|
# run as if from command line using argv
|
74
36
|
current_argv = ARGV.dup
|
75
37
|
begin
|
@@ -89,6 +51,7 @@ module Tap
|
|
89
51
|
|
90
52
|
nil
|
91
53
|
end
|
54
|
+
|
92
55
|
end
|
93
56
|
end
|
94
57
|
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
require 'tap/test/utils'
|
2
|
+
|
3
|
+
module Tap
|
4
|
+
module Test
|
5
|
+
module Assertions
|
6
|
+
def assert_output_equal(a, b, msg=nil)
|
7
|
+
a = a[1..-1] if a[0] == ?\n
|
8
|
+
if a == b
|
9
|
+
assert true
|
10
|
+
else
|
11
|
+
flunk %Q{
|
12
|
+
#{msg}
|
13
|
+
==================== expected output ====================
|
14
|
+
#{Utils.whitespace_escape(a)}
|
15
|
+
======================== but was ========================
|
16
|
+
#{Utils.whitespace_escape(b)}
|
17
|
+
=========================================================
|
18
|
+
}
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
def assert_alike(a, b, msg=nil)
|
23
|
+
if b =~ a
|
24
|
+
assert true
|
25
|
+
else
|
26
|
+
flunk %Q{
|
27
|
+
#{msg}
|
28
|
+
================= expected output like ==================
|
29
|
+
#{Utils.whitespace_escape(a)}
|
30
|
+
======================== but was ========================
|
31
|
+
#{Utils.whitespace_escape(b)}
|
32
|
+
=========================================================
|
33
|
+
}
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
data/lib/tap/test/env_vars.rb
CHANGED
@@ -0,0 +1,79 @@
|
|
1
|
+
module Tap
|
2
|
+
|
3
|
+
# Modules facilitating testing. TapTest are specific to
|
4
|
+
# Tap, but SubsetTest and FileTest are more general in
|
5
|
+
# their utility.
|
6
|
+
module Test
|
7
|
+
autoload(:SubsetTest, 'tap/test/subset_test')
|
8
|
+
autoload(:FileTest, 'tap/test/file_test')
|
9
|
+
autoload(:TapTest, 'tap/test/tap_test')
|
10
|
+
autoload(:ScriptTest, 'tap/test/script_test')
|
11
|
+
autoload(:Utils, 'tap/test/utils')
|
12
|
+
|
13
|
+
module Extensions
|
14
|
+
def acts_as_subset_test
|
15
|
+
include Tap::Test::SubsetTest
|
16
|
+
end
|
17
|
+
|
18
|
+
# Causes a TestCase to act as a file test, by including FileTest and
|
19
|
+
# instantiating class_test_root (a Tap::Root). The root and directories
|
20
|
+
# used by class_test_root may be specified as options.
|
21
|
+
#
|
22
|
+
# Note: by default acts_as_file_test determines a root directory
|
23
|
+
# <em>based on the calling file</em>. Be sure to specify the root
|
24
|
+
# directory manually if you call acts_as_file_test from a file that
|
25
|
+
# isn't the test file.
|
26
|
+
def acts_as_file_test(options={})
|
27
|
+
include Tap::Test::FileTest
|
28
|
+
|
29
|
+
options = {
|
30
|
+
:root => test_root_dir,
|
31
|
+
:directories => {
|
32
|
+
:input => 'input',
|
33
|
+
:output => 'output',
|
34
|
+
:expected => 'expected'}
|
35
|
+
}.merge(options)
|
36
|
+
|
37
|
+
self.class_test_root = Tap::Root.new(options[:root], options[:directories])
|
38
|
+
end
|
39
|
+
|
40
|
+
# Causes a unit test to act as a tap test -- resulting in the following:
|
41
|
+
# - setup using acts_as_file_test
|
42
|
+
# - inclusion of Tap::Test::SubsetTest
|
43
|
+
# - inclusion of Tap::Test::InstanceMethods
|
44
|
+
#
|
45
|
+
# Note: by default acts_as_tap_test determines a root directory
|
46
|
+
# <em>based on the calling file</em>. Be sure to specify the root
|
47
|
+
# directory manually if you call acts_as_file_test from a file that
|
48
|
+
# isn't the test file.
|
49
|
+
def acts_as_tap_test(options={})
|
50
|
+
acts_as_subset_test
|
51
|
+
acts_as_file_test({:root => test_root_dir}.merge(options))
|
52
|
+
|
53
|
+
include Tap::Test::TapTest
|
54
|
+
end
|
55
|
+
|
56
|
+
def acts_as_script_test(options={})
|
57
|
+
acts_as_file_test({:root => test_root_dir}.merge(options))
|
58
|
+
|
59
|
+
include Tap::Test::ScriptTest
|
60
|
+
end
|
61
|
+
|
62
|
+
private
|
63
|
+
|
64
|
+
# Infers the test root directory from the calling file.
|
65
|
+
# 'some_class.rb' => 'some_class'
|
66
|
+
# 'some_class_test.rb' => 'some_class'
|
67
|
+
def test_root_dir # :nodoc:
|
68
|
+
# caller[1] is considered the calling file (which should be the test case)
|
69
|
+
# note that caller entries are like this:
|
70
|
+
# ./path/to/file.rb:10
|
71
|
+
# ./path/to/file.rb:10:in 'method'
|
72
|
+
|
73
|
+
calling_file = caller[1].gsub(/:\d+(:in .*)?$/, "")
|
74
|
+
calling_file.chomp(File.extname(calling_file)).chomp("_test")
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|