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
data/lib/tap/test.rb
CHANGED
|
@@ -25,9 +25,9 @@ end
|
|
|
25
25
|
|
|
26
26
|
module Tap
|
|
27
27
|
|
|
28
|
-
# Modules facilitating testing.
|
|
29
|
-
# Tap, but
|
|
30
|
-
#
|
|
28
|
+
# Modules facilitating testing. TapMethods are specific to
|
|
29
|
+
# Tap, but SubsetMethods and FileMethods are more general in
|
|
30
|
+
# their utility.
|
|
31
31
|
module Test
|
|
32
32
|
end
|
|
33
33
|
end
|
data/lib/tap/test/env_vars.rb
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
module Tap
|
|
2
2
|
module Test
|
|
3
3
|
|
|
4
|
-
# Provides
|
|
4
|
+
# Provides for case-insensitive access to the ENV variables
|
|
5
5
|
module EnvVars
|
|
6
6
|
|
|
7
7
|
# Access to the case-insensitive ENV variables. Raises an error
|
|
@@ -20,7 +20,7 @@ module Tap
|
|
|
20
20
|
end
|
|
21
21
|
end
|
|
22
22
|
|
|
23
|
-
# Returns true if the env_var(var) is set and matches /^true
|
|
23
|
+
# Returns true if the env_var(var) is set and matches /^true$/i
|
|
24
24
|
def env_true?(var)
|
|
25
25
|
env(var) && env(var) =~ /^true$/i
|
|
26
26
|
end
|
|
@@ -2,13 +2,15 @@ require 'tap/root'
|
|
|
2
2
|
require 'tap/test/env_vars'
|
|
3
3
|
require 'test/unit'
|
|
4
4
|
require 'fileutils'
|
|
5
|
-
require 'active_support/core_ext/class'
|
|
6
5
|
|
|
7
6
|
module Test # :nodoc:
|
|
8
7
|
module Unit # :nodoc:
|
|
9
8
|
class TestCase
|
|
10
9
|
class << self
|
|
11
10
|
|
|
11
|
+
# Access the test root structure (a Tap::Root)
|
|
12
|
+
attr_accessor :trs
|
|
13
|
+
|
|
12
14
|
# Causes a TestCase to act as a file test, by instantiating a class Tap::Root
|
|
13
15
|
# (trs), and including FileMethods. The root and directories used to
|
|
14
16
|
# instantiate trs can be specified as options. By default file_test_root
|
|
@@ -25,10 +27,7 @@ module Test # :nodoc:
|
|
|
25
27
|
}.merge(options)
|
|
26
28
|
|
|
27
29
|
directories = options[:directories]
|
|
28
|
-
trs = Tap::Root.new(options[:root], directories)
|
|
29
|
-
|
|
30
|
-
write_inheritable_attribute(:trs, trs)
|
|
31
|
-
class_inheritable_reader :trs
|
|
30
|
+
self.trs = Tap::Root.new(options[:root], directories)
|
|
32
31
|
|
|
33
32
|
include Tap::Test::FileMethods
|
|
34
33
|
end
|
|
@@ -57,8 +56,7 @@ end
|
|
|
57
56
|
module Tap
|
|
58
57
|
module Test
|
|
59
58
|
|
|
60
|
-
|
|
61
|
-
#
|
|
59
|
+
|
|
62
60
|
# FileMethods sets up a TestCase with methods for accessing and utilizing
|
|
63
61
|
# test-specific files and directories. Each class that acts_as_file_test
|
|
64
62
|
# is set up with a Tap::Root structure (trs) that mediates the creation of
|
|
@@ -137,6 +135,10 @@ module Tap
|
|
|
137
135
|
# % rake test keep_outputs=true
|
|
138
136
|
# % tap run test keep_failures=true
|
|
139
137
|
#
|
|
138
|
+
#
|
|
139
|
+
# === Class Methods
|
|
140
|
+
#
|
|
141
|
+
# See {Test::Unit::TestCase}[link:classes/Test/Unit/TestCase.html] for documentation of the class methods added by FileMethods.
|
|
140
142
|
module FileMethods
|
|
141
143
|
include Tap::Test::EnvVars
|
|
142
144
|
|
|
@@ -152,11 +154,14 @@ module Tap
|
|
|
152
154
|
end
|
|
153
155
|
end
|
|
154
156
|
|
|
157
|
+
attr_reader :method_tempfiles
|
|
158
|
+
|
|
155
159
|
# Setup deletes the the output directory if it exists, and tries to remove the
|
|
156
160
|
# method root directory so the directory structure is reset before running the
|
|
157
161
|
# test, even if outputs were left over from previous tests.
|
|
158
162
|
def setup
|
|
159
163
|
super
|
|
164
|
+
@method_tempfiles = []
|
|
160
165
|
clear_method_dir(:output)
|
|
161
166
|
try_remove_dir(method_root)
|
|
162
167
|
end
|
|
@@ -258,21 +263,20 @@ module Tap
|
|
|
258
263
|
# - If the directory for the filepath does not exist, the directory will be created
|
|
259
264
|
# - Like all files in the output directory, tempfiles will be deleted by the default
|
|
260
265
|
# +teardown+ method
|
|
261
|
-
def
|
|
262
|
-
n = 0
|
|
266
|
+
def method_tempfile(filename=method_name_str, &block)
|
|
263
267
|
ext = File.extname(filename)
|
|
264
268
|
basename = filename.chomp(ext)
|
|
265
|
-
filepath =
|
|
266
|
-
|
|
267
|
-
n += 1
|
|
268
|
-
filepath = make_tmpname(basename, n, ext)
|
|
269
|
-
end
|
|
269
|
+
filepath = method_filepath(:output, sprintf('%s%d.%d%s', basename, $$, method_tempfiles.length, ext))
|
|
270
|
+
method_tempfiles << filepath
|
|
270
271
|
|
|
271
272
|
dirname = File.dirname(filepath)
|
|
272
273
|
FileUtils.mkdir_p(dirname) unless File.exists?(dirname)
|
|
274
|
+
if block_given?
|
|
275
|
+
File.open(filepath, "w", &block)
|
|
276
|
+
end
|
|
273
277
|
filepath
|
|
274
278
|
end
|
|
275
|
-
|
|
279
|
+
|
|
276
280
|
# Yields to the input block for each pair of entries in the input
|
|
277
281
|
# arrays. An error is raised if the input arrays do not have equal
|
|
278
282
|
# numbers of entries.
|
|
@@ -368,11 +372,6 @@ module Tap
|
|
|
368
372
|
flunk "File compare failed:\n" + errors.join("\n") unless errors.empty?
|
|
369
373
|
end
|
|
370
374
|
|
|
371
|
-
private
|
|
372
|
-
|
|
373
|
-
def make_tmpname(basename, n, ext="") # :nodoc:
|
|
374
|
-
method_filepath(:output, sprintf('%s%d.%d%s', basename, $$, n, ext))
|
|
375
|
-
end
|
|
376
375
|
end
|
|
377
376
|
end
|
|
378
377
|
end
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
require 'test/unit'
|
|
2
|
+
require 'tap/test/file_methods'
|
|
3
|
+
require 'tap/test/subset_methods'
|
|
4
|
+
#require 'tap/support/shell_utils'
|
|
5
|
+
|
|
6
|
+
module Test # :nodoc:
|
|
7
|
+
module Unit # :nodoc:
|
|
8
|
+
class TestCase
|
|
9
|
+
class << self
|
|
10
|
+
|
|
11
|
+
def acts_as_script_test(options={})
|
|
12
|
+
options = options.inject({:root => file_test_root}) do |hash, (key, value)|
|
|
13
|
+
hash[key.to_sym || key] = value
|
|
14
|
+
hash
|
|
15
|
+
end
|
|
16
|
+
acts_as_file_test(options)
|
|
17
|
+
include Tap::Test::SubsetMethods
|
|
18
|
+
include Tap::Test::ScriptMethods
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
module Tap
|
|
27
|
+
module Test
|
|
28
|
+
|
|
29
|
+
module ScriptMethods
|
|
30
|
+
class CommandTest
|
|
31
|
+
attr_accessor :command_path
|
|
32
|
+
attr_reader :commands
|
|
33
|
+
|
|
34
|
+
def initialize
|
|
35
|
+
@command_path = nil
|
|
36
|
+
@commands = []
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
def check(argstr, msg=nil, expected=nil, &block)
|
|
40
|
+
commands << ["#{command_path}#{argstr}", msg, expected, block]
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
def check_cmd(cmd, msg=nil, expected=nil, &block)
|
|
44
|
+
commands << [cmd, msg, expected, block]
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
include Tap::Support::ShellUtils
|
|
49
|
+
|
|
50
|
+
def assert_output_equal(a, b, cmd, msg)
|
|
51
|
+
a = a[1..-1] if a[0] == ?\n
|
|
52
|
+
if a == b
|
|
53
|
+
assert true
|
|
54
|
+
else
|
|
55
|
+
flunk %Q{
|
|
56
|
+
#{msg}
|
|
57
|
+
% #{cmd}
|
|
58
|
+
==================== expected output ====================
|
|
59
|
+
#{a.gsub(/\t/, "\\t").gsub(/\r\n/, "\\r\\n\n").gsub(/\n/, "\\n\n")}
|
|
60
|
+
======================== but was ========================
|
|
61
|
+
#{b.gsub(/\t/, "\\t").gsub(/\r\n/, "\\r\\n\n").gsub(/\n/, "\\n\n")}
|
|
62
|
+
=========================================================
|
|
63
|
+
}
|
|
64
|
+
end
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
def assert_alike(a, b, cmd, msg)
|
|
68
|
+
if b =~ a
|
|
69
|
+
assert true
|
|
70
|
+
else
|
|
71
|
+
flunk %Q{
|
|
72
|
+
#{msg}
|
|
73
|
+
% #{cmd}
|
|
74
|
+
================= expected output like ==================
|
|
75
|
+
#{a}
|
|
76
|
+
======================== but was ========================
|
|
77
|
+
#{b.gsub(/\t/, "\\t").gsub(/\r\n/, "\\r\\n\n").gsub(/\n/, "\\n\n")}
|
|
78
|
+
=========================================================
|
|
79
|
+
}
|
|
80
|
+
end
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
def script_test(test_dir=method_dir(:output))
|
|
84
|
+
subset_test("SCRIPT", "s") do
|
|
85
|
+
test = CommandTest.new
|
|
86
|
+
yield(test)
|
|
87
|
+
|
|
88
|
+
current_dir = Dir.pwd
|
|
89
|
+
current_argv = ARGV.dup
|
|
90
|
+
begin
|
|
91
|
+
ARGV.clear
|
|
92
|
+
make_test_directories
|
|
93
|
+
Dir.chdir(test_dir)
|
|
94
|
+
|
|
95
|
+
puts "\n# == #{method_name}"
|
|
96
|
+
|
|
97
|
+
test.commands.each do |cmd, msg, expected, block|
|
|
98
|
+
start = Time.now
|
|
99
|
+
result = capture_sh(cmd) {|ok, status, tempfile_path| }
|
|
100
|
+
elapsed = Time.now - start
|
|
101
|
+
|
|
102
|
+
case expected
|
|
103
|
+
when String
|
|
104
|
+
assert_output_equal(expected, result, cmd, msg)
|
|
105
|
+
when Regexp
|
|
106
|
+
assert_alike(expected, result, cmd, msg)
|
|
107
|
+
end
|
|
108
|
+
|
|
109
|
+
if block
|
|
110
|
+
block.call(result)
|
|
111
|
+
end
|
|
112
|
+
|
|
113
|
+
if env('stepwise') || (expected == nil && block == nil)
|
|
114
|
+
print %Q{
|
|
115
|
+
------------------------------------
|
|
116
|
+
%s
|
|
117
|
+
> %s
|
|
118
|
+
%s
|
|
119
|
+
Time Elapsed: %.3fs} % [msg, cmd, result, elapsed]
|
|
120
|
+
|
|
121
|
+
if env('stepwise')
|
|
122
|
+
print "\nContinue? (y/n): "
|
|
123
|
+
break if gets.strip =~ /^no?$/i
|
|
124
|
+
end
|
|
125
|
+
else
|
|
126
|
+
puts "%.3fs : %s" % [elapsed, msg]
|
|
127
|
+
end
|
|
128
|
+
end
|
|
129
|
+
ensure
|
|
130
|
+
Dir.chdir(current_dir)
|
|
131
|
+
ARGV.clear
|
|
132
|
+
ARGV.concat(current_argv)
|
|
133
|
+
end
|
|
134
|
+
|
|
135
|
+
end
|
|
136
|
+
end
|
|
137
|
+
|
|
138
|
+
end
|
|
139
|
+
end
|
|
140
|
+
end
|
|
141
|
+
|
|
142
|
+
|
|
143
|
+
|
|
144
|
+
|
|
@@ -244,7 +244,7 @@ module Tap
|
|
|
244
244
|
#
|
|
245
245
|
# === Class Methods
|
|
246
246
|
#
|
|
247
|
-
# See Test::Unit::TestCase for documentation of the class methods added by SubsetMethods
|
|
247
|
+
# See {Test::Unit::TestCase}[link:classes/Test/Unit/TestCase.html] for documentation of the class methods added by SubsetMethods
|
|
248
248
|
module SubsetMethods
|
|
249
249
|
include Tap::Test::EnvVars
|
|
250
250
|
|
data/lib/tap/test/tap_methods.rb
CHANGED
|
@@ -15,7 +15,10 @@ module Test # :nodoc:
|
|
|
15
15
|
# based on the calling file. Be sure to specify the root directory explicitly
|
|
16
16
|
# if you call acts_as_file_test from a file that is NOT meant to be test file.
|
|
17
17
|
def acts_as_tap_test(options={})
|
|
18
|
-
options = {:root => file_test_root}
|
|
18
|
+
options = options.inject({:root => file_test_root}) do |hash, (key, value)|
|
|
19
|
+
hash[key.to_sym || key] = value
|
|
20
|
+
hash
|
|
21
|
+
end
|
|
19
22
|
acts_as_file_test(options)
|
|
20
23
|
|
|
21
24
|
include Tap::Test::SubsetMethods
|
|
@@ -59,6 +62,10 @@ module Tap
|
|
|
59
62
|
# Tap-specific testing methods to help with testing Tasks, such as the
|
|
60
63
|
# checking of audits and test-specific modification of application
|
|
61
64
|
# configuration.
|
|
65
|
+
#
|
|
66
|
+
# === Class Methods
|
|
67
|
+
#
|
|
68
|
+
# See {Test::Unit::TestCase}[link:classes/Test/Unit/TestCase.html] for documentation of the class methods added by TapMethods.
|
|
62
69
|
module TapMethods
|
|
63
70
|
|
|
64
71
|
# Returns the test-method-specific application.
|
|
@@ -71,10 +78,7 @@ module Tap
|
|
|
71
78
|
# Also makes sure Tap::App.instance returns the test method app.
|
|
72
79
|
def setup
|
|
73
80
|
super
|
|
74
|
-
@app = Tap::App.new(
|
|
75
|
-
:root => method_root,
|
|
76
|
-
:directories => trs.directories,
|
|
77
|
-
:absolute_paths => trs.absolute_paths)
|
|
81
|
+
@app = Tap::App.new(app_config)
|
|
78
82
|
Tap::App.instance = @app
|
|
79
83
|
end
|
|
80
84
|
|
|
@@ -191,74 +195,36 @@ module Tap
|
|
|
191
195
|
|
|
192
196
|
public
|
|
193
197
|
|
|
194
|
-
#
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
# the app options will be reconfigured to just the inputs.
|
|
202
|
-
#
|
|
203
|
-
# For convenience, with_options is setup such that options
|
|
204
|
-
# {:debug => true, :quiet => true} are implicitly specified.
|
|
205
|
-
# Overrides are respected.
|
|
206
|
-
#
|
|
207
|
-
# app = Tap::App.new(:options => {:one => 1, :two => 2})
|
|
208
|
-
#
|
|
209
|
-
# with_options({:one => 'one', :quiet => false}, app) do
|
|
210
|
-
# app.options.marshal_dump # => {:one => 'one', :two => 2, :debug => true, :quiet => false}
|
|
211
|
-
# end
|
|
212
|
-
#
|
|
213
|
-
# app.options.marshal_dump # => {:one => 1, :two => 2}
|
|
214
|
-
#
|
|
215
|
-
def with_options(options={}, app=self.app, merge_with_existing=true, &block)
|
|
216
|
-
app_config = {:options => options}
|
|
217
|
-
with_config(app_config, app, merge_with_existing, &block)
|
|
198
|
+
# The configurations used to initialize self.app
|
|
199
|
+
def app_config
|
|
200
|
+
{ :root => method_root,
|
|
201
|
+
:directories => trs.directories,
|
|
202
|
+
:absolute_paths => trs.absolute_paths,
|
|
203
|
+
:quiet => true,
|
|
204
|
+
:debug => true}
|
|
218
205
|
end
|
|
219
206
|
|
|
220
|
-
#
|
|
221
|
-
# duration of the block.
|
|
222
|
-
# the input configurations will be merged with the existing
|
|
223
|
-
# configurations; otherwise the app will be reconfigured to
|
|
224
|
-
# using the inputs as specified.
|
|
225
|
-
#
|
|
226
|
-
# For convenience, with_config is setup such that options
|
|
227
|
-
# {:debug => true, :quiet => true} are implicitly specified.
|
|
228
|
-
# Overrides are respected.
|
|
207
|
+
# Reconfigures app with the input configurations for the
|
|
208
|
+
# duration of the block.
|
|
229
209
|
#
|
|
230
|
-
# app = Tap::App.new(:
|
|
231
|
-
#
|
|
232
|
-
#
|
|
233
|
-
#
|
|
234
|
-
#
|
|
235
|
-
# with_config(tmp_config, app) do
|
|
236
|
-
# app.directories # => {:dir => 'dir', :alt => 'another', :new => 'new_dir'}
|
|
237
|
-
# app.options.marshal_dump # => {:one => 1, :debug => true, :quiet => false}
|
|
210
|
+
# app = Tap::App.new(:quiet => true, :debug => false)
|
|
211
|
+
# with_config({:quiet => false}, app) do
|
|
212
|
+
# app.quiet # => false
|
|
213
|
+
# app.debug # => false
|
|
238
214
|
# end
|
|
239
215
|
#
|
|
240
|
-
# app.
|
|
241
|
-
# app.
|
|
216
|
+
# app.quiet # => true
|
|
217
|
+
# app.debug # => false
|
|
242
218
|
#
|
|
243
|
-
def with_config(
|
|
219
|
+
def with_config(config={}, app=self.app, &block)
|
|
244
220
|
begin
|
|
245
|
-
hold = app.config
|
|
246
|
-
|
|
247
|
-
app_config[:options] = default_options.merge(app_config[:options] || {})
|
|
248
|
-
if merge_with_existing
|
|
249
|
-
hold.each_pair do |key, value|
|
|
250
|
-
next unless app_config.has_key?(key)
|
|
251
|
-
next unless value.kind_of?(Hash)
|
|
252
|
-
|
|
253
|
-
app_config[key] = value.merge(app_config[key])
|
|
254
|
-
end
|
|
255
|
-
end
|
|
221
|
+
hold = app.config.to_hash
|
|
256
222
|
|
|
257
|
-
app.reconfigure(
|
|
223
|
+
app.reconfigure(config)
|
|
258
224
|
|
|
259
225
|
yield block if block_given?
|
|
260
226
|
ensure
|
|
261
|
-
app.
|
|
227
|
+
app.send(:initialize_config, hold)
|
|
262
228
|
end
|
|
263
229
|
end
|
|
264
230
|
|
data/lib/tap/workflow.rb
CHANGED
|
@@ -1,11 +1,7 @@
|
|
|
1
1
|
module Tap
|
|
2
2
|
|
|
3
|
-
#
|
|
4
|
-
#
|
|
5
|
-
# App can build workflows directly, using methods like sequence, merge, and
|
|
6
|
-
# multithread, but these workflows are hard to abstract and resuse. Workflow
|
|
7
|
-
# is a specialized type of Task allows the encapsulation and reuse of workflow
|
|
8
|
-
# logic. See Tap::Task for the shared documentation.
|
|
3
|
+
# Workflow is a specialized type of Task allowing the encapsulation and reuse of
|
|
4
|
+
# workflow logic. Workflows are still under construction.
|
|
9
5
|
#
|
|
10
6
|
# === Workflow Definition
|
|
11
7
|
#
|
|
@@ -81,9 +77,8 @@ module Tap
|
|
|
81
77
|
# app.results(w1.exit_points, w2.exit_points)) # => [8, -8]
|
|
82
78
|
#
|
|
83
79
|
class Workflow
|
|
84
|
-
include Support::
|
|
85
|
-
|
|
86
|
-
|
|
80
|
+
include Support::Framework
|
|
81
|
+
|
|
87
82
|
# The entry point for self.
|
|
88
83
|
attr_accessor :entry_point
|
|
89
84
|
|
|
@@ -94,24 +89,18 @@ module Tap
|
|
|
94
89
|
attr_reader :task_block
|
|
95
90
|
|
|
96
91
|
# Creates a new Task with the specified attributes.
|
|
97
|
-
def initialize(
|
|
92
|
+
def initialize(config={}, name=nil, app=App.instance, &task_block)
|
|
93
|
+
super(config, name, app)
|
|
98
94
|
@task_block = (task_block == nil ? default_task_block : task_block)
|
|
99
|
-
|
|
95
|
+
initialize_workflow
|
|
100
96
|
end
|
|
101
97
|
|
|
102
98
|
# Initializes a new batch object, running workflow to set the
|
|
103
99
|
# instance-specific entry/exit points. Raises an error if
|
|
104
100
|
# no entry points are defined.
|
|
105
|
-
def
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
task.entry_point = {}
|
|
109
|
-
task.exit_point = {}
|
|
110
|
-
task.workflow
|
|
111
|
-
|
|
112
|
-
raise WorkflowError.new("No entry points defined") if task.entry_points.empty?
|
|
113
|
-
|
|
114
|
-
task
|
|
101
|
+
def initialize_copy(orig)
|
|
102
|
+
super
|
|
103
|
+
initialize_workflow
|
|
115
104
|
end
|
|
116
105
|
|
|
117
106
|
# Returns an array of entry points, determined from entry_point.
|
|
@@ -142,33 +131,24 @@ module Tap
|
|
|
142
131
|
# if the entry points have different input requirements, they
|
|
143
132
|
# have to be enqued separately.
|
|
144
133
|
def enq(*inputs)
|
|
145
|
-
batch.each {|t| t.unbatched_enq(*inputs) }
|
|
146
|
-
self
|
|
147
|
-
end
|
|
148
|
-
|
|
149
|
-
# Enques all entry points to app with the inputs.
|
|
150
|
-
def unbatched_enq(*inputs)
|
|
151
134
|
entry_points.each do |task|
|
|
152
135
|
app.enq(task, *inputs)
|
|
153
136
|
end
|
|
154
|
-
self
|
|
155
137
|
end
|
|
156
138
|
|
|
139
|
+
batch_function :enq
|
|
140
|
+
|
|
157
141
|
# Sets the on_complete_block for all exit points for self and
|
|
158
142
|
# self.batch. Use unbatched_on_complete to set the on_complete_block
|
|
159
143
|
# for just self.exit_points.
|
|
160
144
|
def on_complete(override=false, &block)
|
|
161
|
-
batch.each {|t| t.unbatched_on_complete(override, &block)}
|
|
162
|
-
self
|
|
163
|
-
end
|
|
164
|
-
|
|
165
|
-
# Sets the on_complete_block for all exit points for self.
|
|
166
|
-
def unbatched_on_complete(override=false, &block)
|
|
167
145
|
exit_points.each do |task|
|
|
168
146
|
task.on_complete(override, &block)
|
|
169
147
|
end
|
|
170
148
|
self
|
|
171
149
|
end
|
|
150
|
+
|
|
151
|
+
batch_function(:on_complete) {}
|
|
172
152
|
|
|
173
153
|
# The workflow definition method. By default workflow
|
|
174
154
|
# simply calls the task_block. In subclasses, workflow
|
|
@@ -189,13 +169,16 @@ module Tap
|
|
|
189
169
|
input == nil ? @name : File.join(@name, input)
|
|
190
170
|
end
|
|
191
171
|
|
|
192
|
-
# Returns name
|
|
193
|
-
def to_s
|
|
194
|
-
name
|
|
195
|
-
end
|
|
196
|
-
|
|
197
172
|
protected
|
|
198
173
|
|
|
174
|
+
def initialize_workflow
|
|
175
|
+
@entry_point = {}
|
|
176
|
+
@exit_point = {}
|
|
177
|
+
|
|
178
|
+
workflow
|
|
179
|
+
raise WorkflowError.new("No entry points defined") if entry_points.empty?
|
|
180
|
+
end
|
|
181
|
+
|
|
199
182
|
# Hook to set a default task block. By default, nil.
|
|
200
183
|
def default_task_block
|
|
201
184
|
nil
|