duck_test 0.1.4
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/bin/ducktest +29 -0
- data/lib/duck_test/autoload_config.rb +103 -0
- data/lib/duck_test/base.rb +41 -0
- data/lib/duck_test/commands.rb +208 -0
- data/lib/duck_test/config.rb +675 -0
- data/lib/duck_test/config_helper.rb +99 -0
- data/lib/duck_test/console.rb +18 -0
- data/lib/duck_test/default_config.rb +48 -0
- data/lib/duck_test/frame_work/base.rb +587 -0
- data/lib/duck_test/frame_work/file_manager.rb +511 -0
- data/lib/duck_test/frame_work/filter_set.rb +233 -0
- data/lib/duck_test/frame_work/map.rb +331 -0
- data/lib/duck_test/frame_work/queue.rb +221 -0
- data/lib/duck_test/frame_work/queue_event.rb +29 -0
- data/lib/duck_test/frame_work/rspec/base.rb +17 -0
- data/lib/duck_test/frame_work/rspec/frame_work.rb +30 -0
- data/lib/duck_test/frame_work/test_unit/base.rb +14 -0
- data/lib/duck_test/frame_work/test_unit/frame_work.rb +33 -0
- data/lib/duck_test/frame_work/watch_config.rb +69 -0
- data/lib/duck_test/gem/helper.rb +107 -0
- data/lib/duck_test/logger.rb +127 -0
- data/lib/duck_test/option_parser.rb +30 -0
- data/lib/duck_test/platforms/base.rb +18 -0
- data/lib/duck_test/platforms/dependencies.rb +18 -0
- data/lib/duck_test/platforms/generic/base.rb +15 -0
- data/lib/duck_test/platforms/generic/listener.rb +104 -0
- data/lib/duck_test/platforms/linux/base.rb +15 -0
- data/lib/duck_test/platforms/linux/listener.rb +76 -0
- data/lib/duck_test/platforms/listener.rb +303 -0
- data/lib/duck_test/platforms/mac/base.rb +15 -0
- data/lib/duck_test/platforms/mac/listener.rb +79 -0
- data/lib/duck_test/platforms/mac/listener.rb.orig +147 -0
- data/lib/duck_test/platforms/os_helper.rb +102 -0
- data/lib/duck_test/platforms/watch_event.rb +47 -0
- data/lib/duck_test/platforms/windows/base.rb +15 -0
- data/lib/duck_test/platforms/windows/listener.rb +123 -0
- data/lib/duck_test/railtie.rb +29 -0
- data/lib/duck_test/usage.rb +34 -0
- data/lib/duck_test/usage.yml +112 -0
- data/lib/duck_test/version.rb +3 -0
- data/lib/duck_test.rb +6 -0
- data/lib/notes.txt +215 -0
- data/lib/tasks/duck_tests.rake +35 -0
- data/lib/tasks/gem_tasks.rake +18 -0
- metadata +92 -0
data/lib/notes.txt
ADDED
@@ -0,0 +1,215 @@
|
|
1
|
+
random brainstorming notes when I first starting toying with the idea of building this gem.
|
2
|
+
|
3
|
+
Should be able to run the debugger from a test.
|
4
|
+
|
5
|
+
potential idea to unload files
|
6
|
+
http://www.ruby-forum.com/topic/121905
|
7
|
+
|
8
|
+
# # watch pattern: "**/*" do
|
9
|
+
# # map /^models/, /^bike/ do
|
10
|
+
# # target /^unit/, /^bike_spec.rb/
|
11
|
+
# # target /^functional/, /^bike_controller_spec.rb/
|
12
|
+
# # end
|
13
|
+
# # end
|
14
|
+
|
15
|
+
|
16
|
+
DuckTest.config do
|
17
|
+
|
18
|
+
# would set global includes / excludes within the default framework
|
19
|
+
included /.rb$/
|
20
|
+
included_dirs /^unit/
|
21
|
+
excluded /.rb$/
|
22
|
+
excluded_dirs /^functional/
|
23
|
+
|
24
|
+
framework :rspec do
|
25
|
+
|
26
|
+
# would set global includes / excludes within the framework being defined
|
27
|
+
included /.rb$/
|
28
|
+
included_dirs /^unit/
|
29
|
+
excluded /.rb$/
|
30
|
+
excluded_dirs /^functional/
|
31
|
+
|
32
|
+
watch "**/*", included: /book/ do
|
33
|
+
# would set includes / excludes within the watch list being defined
|
34
|
+
included /.rb$/
|
35
|
+
included_dirs /^unit/
|
36
|
+
excluded /.rb$/
|
37
|
+
excluded_dirs /^functional/
|
38
|
+
|
39
|
+
app_watch "**/*", included: /book/ do
|
40
|
+
resolver /asdjajd/
|
41
|
+
resolver /asdjajd/
|
42
|
+
end
|
43
|
+
|
44
|
+
end
|
45
|
+
|
46
|
+
end
|
47
|
+
|
48
|
+
end
|
49
|
+
|
50
|
+
|
51
|
+
|
52
|
+
NOTES:
|
53
|
+
- a rule is that there will be ONLY one runnable watchlist and allow multiple app watchlists.
|
54
|
+
- object containing criteria, settings, etc. is considered a config object
|
55
|
+
- directories are the source for config objects, however, directories and files in the common list will have a reference to the config object that created it.
|
56
|
+
- a watch list is created in config/environments/test.rb config file using the watch statement
|
57
|
+
watch "**/*", /book/
|
58
|
+
- non-runnable files that are watched are considered "app" files.
|
59
|
+
- a single statement creates a single watch list object.
|
60
|
+
|
61
|
+
CONSOLE SESSION NOTE:
|
62
|
+
- criteria for all watched directories / files is configured in config/environments/test.rb
|
63
|
+
- config data is loaded and kept in memory during the console session
|
64
|
+
- attempt to allow adding / removing criteria via the console and do a full reload including stopping all of the watched directories, etc. ??
|
65
|
+
|
66
|
+
use a pattern to get a list of files and directories.
|
67
|
+
|
68
|
+
- traverse the list
|
69
|
+
NOTE: directories and files have separate included / excluded regexp arrays.
|
70
|
+
- match the directory or file against the included / excluded regexp arrays.
|
71
|
+
- if directory / file should be watched
|
72
|
+
- the directory / file gets added to the actual watch notifier to receive messages about changes.
|
73
|
+
- the directory / file gets added to a common lookup list for easy lookup later with a reference back
|
74
|
+
to the object config object.
|
75
|
+
|
76
|
+
- else, directories / files that do not match get blacklisted right away
|
77
|
+
|
78
|
+
when a file is deleted:
|
79
|
+
- for now, do nothing.
|
80
|
+
|
81
|
+
when a file is created / moved into the directory:
|
82
|
+
- should be able to follow the same logic and call the same method as for changes, however,
|
83
|
+
DO NOT autorun the file. everything else.
|
84
|
+
|
85
|
+
when a file changes:
|
86
|
+
|
87
|
+
- if -> is it blacklisted?
|
88
|
+
yes
|
89
|
+
- ignore it
|
90
|
+
|
91
|
+
- elsif -> is it whitelisted and runnable?
|
92
|
+
yes
|
93
|
+
- run it
|
94
|
+
|
95
|
+
- elsif -> is it whitelisted and NON-runnable?
|
96
|
+
- can it be resolved to a runnable set of files?
|
97
|
+
yes
|
98
|
+
- run those files
|
99
|
+
|
100
|
+
no
|
101
|
+
- do nothing
|
102
|
+
|
103
|
+
- else
|
104
|
+
- if we have a file that has changed and was not previously on the whitelist, then,
|
105
|
+
the event must have been triggered due to some other action such as after being created or being moved to the containing directory.
|
106
|
+
|
107
|
+
- current file parent object exist and is the parent watchable?
|
108
|
+
yes
|
109
|
+
- whitelist the file with the config object attached
|
110
|
+
|
111
|
+
# parent object will always be a directory, therefore, NEVER runnable.
|
112
|
+
- can file_spec be resolved to a runnable set of files?
|
113
|
+
yes
|
114
|
+
- run those files
|
115
|
+
|
116
|
+
no
|
117
|
+
- blacklist the file due to no parent
|
118
|
+
|
119
|
+
- else
|
120
|
+
- blacklist the file
|
121
|
+
|
122
|
+
when a directory changes:
|
123
|
+
- could be a subdirectory is added, etc.
|
124
|
+
- lookup the criteria of the parent directory and match against the directory
|
125
|
+
- if match
|
126
|
+
- add to the common list as normal with a reference back to the object containing the criteria that allowed the directory to be included.
|
127
|
+
In this case, it should be the parent directory found during the lookup.
|
128
|
+
|
129
|
+
|
130
|
+
let's say this was the app file that changed.
|
131
|
+
how would i resolve the associated test?
|
132
|
+
rails does follow convention, however, that does mean all developers will follow it.
|
133
|
+
|
134
|
+
# /alldata/rails/gems/duck_test/spec/testdir/app/app01.rb
|
135
|
+
|
136
|
+
# this might get very complicated !!!!
|
137
|
+
resolving link between non-runnable and runnable files:
|
138
|
+
- a config object is needed for this process
|
139
|
+
- break the full file spec into pieces
|
140
|
+
|
141
|
+
/alldata/rails/gems/duck_test/spec/testdir/app/app01.rb
|
142
|
+
|
143
|
+
| root | watch directory | subdir | file name
|
144
|
+
/alldata/rails/gems/duck_test/spec/testdir / app / / app01.rb
|
145
|
+
|
146
|
+
# source file
|
147
|
+
/alldata/rails/gems/duck_test/spec/testdir / app /models / bike.rb
|
148
|
+
|
149
|
+
sub dir mappings
|
150
|
+
|
151
|
+
/alldata/rails/gems/duck_test/spec/testdir/models/bike.rb
|
152
|
+
|
153
|
+
/^models/ -> /^bike/ mapped to --> [
|
154
|
+
unit => /^bike_spec.rb/,
|
155
|
+
functional => /^bike_controller_spec.rb/
|
156
|
+
]
|
157
|
+
|
158
|
+
/^models/ -> /^(.+)/ mapped to --> [
|
159
|
+
unit => /^bike_spec.rb/,
|
160
|
+
functional => /^bike_controller_spec.rb/
|
161
|
+
]
|
162
|
+
|
163
|
+
|
164
|
+
models -> [unit => [/^bike_spec/, /^car/, /^truck/],
|
165
|
+
functional => [/^bike/, /^car/, /^truck/]
|
166
|
+
]
|
167
|
+
|
168
|
+
controllers -> [functional]
|
169
|
+
|
170
|
+
|
171
|
+
# mapped to
|
172
|
+
/alldata/rails/gems/duck_test/spec/testdir / spec / unit / bike_spec.rb
|
173
|
+
/alldata/rails/gems/duck_test/spec/testdir / spec / functional / bike_controller_spec.rb
|
174
|
+
|
175
|
+
- note: the runnable watch list is considered the target watchlist in this context.
|
176
|
+
|
177
|
+
- the first task would be find target director(ies)y within the target watchlist.
|
178
|
+
the goal is to build a list of target directories.
|
179
|
+
|
180
|
+
- if the changed file HAS a subdirectory
|
181
|
+
- extract the subdirectory
|
182
|
+
- build a list of translation directories
|
183
|
+
|
184
|
+
# this would be the default order of precedence
|
185
|
+
# i should make the order of precedence configurable
|
186
|
+
- first, add the sub-directory
|
187
|
+
- then, add translation directories attached to the config object
|
188
|
+
- then, add global translation directories
|
189
|
+
|
190
|
+
- the translations will be an array of Strings or regexp's
|
191
|
+
|
192
|
+
- search the target watch list for a subdirectory(ies) matching the translation directory(ies).
|
193
|
+
- there should be a switch that says match first or match all. this should facilitate the ability
|
194
|
+
to trigger multiple tests when a single file changes. for instance, when I change model I might
|
195
|
+
want it to run the unit tests and the functional tests as well.
|
196
|
+
|
197
|
+
- if there is no sub directory, then, the root of the runnable watch list is the target directory.
|
198
|
+
- add the watch directory root to the list of directories to search.
|
199
|
+
|
200
|
+
- at this point, we should have a list of target directories to search for matching files.
|
201
|
+
|
202
|
+
# i will not recursively search thru the subdirectories. this compares the file names ONLY.
|
203
|
+
- loop thru each of the directory(ies)
|
204
|
+
|
205
|
+
# this step requires IO with the disk which will create a little bit of a performance issue, but, worth it.
|
206
|
+
- grab a list of the files contained within the directory
|
207
|
+
|
208
|
+
# each file will have a set of filters used to resolve links between non-runnable and runnable files.
|
209
|
+
# basically, it is an array of regexp's PAIRS
|
210
|
+
- loop thru all of the regexp pairs and compare the first regexp against the source file (non-runnable file that changed)
|
211
|
+
- if the regexp matches
|
212
|
+
- loop thru the files contained in the directory
|
213
|
+
- compare the second regexp in the pair against the target file
|
214
|
+
- if regexp matches
|
215
|
+
- add to list of runnable files that should be executed.
|
@@ -0,0 +1,35 @@
|
|
1
|
+
namespace :test do
|
2
|
+
|
3
|
+
desc "Removes all of the test files using rake test:prepare"
|
4
|
+
task :clean do
|
5
|
+
$:.unshift File.expand_path("spec")
|
6
|
+
require "test_files"
|
7
|
+
TestFiles.clean
|
8
|
+
end
|
9
|
+
|
10
|
+
desc "Runs all of the necessary tasks prior to running the tests"
|
11
|
+
task :prepare do
|
12
|
+
$:.unshift File.expand_path("spec")
|
13
|
+
require "test_files"
|
14
|
+
TestFiles.prepare
|
15
|
+
end
|
16
|
+
|
17
|
+
desc "Runs all of the tests"
|
18
|
+
task :all do
|
19
|
+
$:.unshift File.expand_path("spec")
|
20
|
+
load "all_specs.rb"
|
21
|
+
end
|
22
|
+
|
23
|
+
desc "Tests I used to develop small pieces of code or ideas"
|
24
|
+
task :dev do
|
25
|
+
$:.unshift File.expand_path("spec")
|
26
|
+
load "dev_specs.rb"
|
27
|
+
end
|
28
|
+
|
29
|
+
desc "Run the file watch queue. Not designed to run with normal tests"
|
30
|
+
task :queue do
|
31
|
+
$:.unshift File.expand_path("spec")
|
32
|
+
load "run_queue.rb"
|
33
|
+
end
|
34
|
+
|
35
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
# once upon a time, I had a series of tasks and gemspecs to build different versions for different platforms.
|
2
|
+
# this file was huge. I made a decision to adandon all of those different gems and simply notify the developer
|
3
|
+
# to edit their Gemfile
|
4
|
+
require "duck_test/gem/helper"
|
5
|
+
|
6
|
+
namespace :local do
|
7
|
+
|
8
|
+
desc "Locally build and release the default gem without dependencies"
|
9
|
+
task :default do
|
10
|
+
DuckTest::Gem::Helper.new.local("duck_test", "duck_test")
|
11
|
+
end
|
12
|
+
|
13
|
+
desc "Locally build and release all of the gems"
|
14
|
+
task :all => [:default]
|
15
|
+
|
16
|
+
end
|
17
|
+
|
18
|
+
task :local => "local:default"
|
metadata
ADDED
@@ -0,0 +1,92 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: duck_test
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.4
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Jeff Duckett
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-02-22 00:00:00.000000000 Z
|
13
|
+
dependencies: []
|
14
|
+
description: DuckTest is a gem that facilitates automated running of TestUnit and
|
15
|
+
RSpec tests directly in the IRB console. Tests run within a second of being changed.
|
16
|
+
email:
|
17
|
+
- jeff.duckett@gmail.com
|
18
|
+
executables:
|
19
|
+
- ducktest
|
20
|
+
extensions: []
|
21
|
+
extra_rdoc_files: []
|
22
|
+
files:
|
23
|
+
- lib/tasks/gem_tasks.rake
|
24
|
+
- lib/tasks/duck_tests.rake
|
25
|
+
- lib/duck_test/config_helper.rb
|
26
|
+
- lib/duck_test/version.rb
|
27
|
+
- lib/duck_test/console.rb
|
28
|
+
- lib/duck_test/default_config.rb
|
29
|
+
- lib/duck_test/autoload_config.rb
|
30
|
+
- lib/duck_test/config.rb
|
31
|
+
- lib/duck_test/base.rb
|
32
|
+
- lib/duck_test/option_parser.rb
|
33
|
+
- lib/duck_test/usage.rb
|
34
|
+
- lib/duck_test/commands.rb
|
35
|
+
- lib/duck_test/platforms/dependencies.rb
|
36
|
+
- lib/duck_test/platforms/watch_event.rb
|
37
|
+
- lib/duck_test/platforms/listener.rb
|
38
|
+
- lib/duck_test/platforms/base.rb
|
39
|
+
- lib/duck_test/platforms/windows/listener.rb
|
40
|
+
- lib/duck_test/platforms/windows/base.rb
|
41
|
+
- lib/duck_test/platforms/generic/listener.rb
|
42
|
+
- lib/duck_test/platforms/generic/base.rb
|
43
|
+
- lib/duck_test/platforms/os_helper.rb
|
44
|
+
- lib/duck_test/platforms/mac/listener.rb
|
45
|
+
- lib/duck_test/platforms/mac/base.rb
|
46
|
+
- lib/duck_test/platforms/mac/listener.rb.orig
|
47
|
+
- lib/duck_test/platforms/linux/listener.rb
|
48
|
+
- lib/duck_test/platforms/linux/base.rb
|
49
|
+
- lib/duck_test/gem/helper.rb
|
50
|
+
- lib/duck_test/logger.rb
|
51
|
+
- lib/duck_test/railtie.rb
|
52
|
+
- lib/duck_test/usage.yml
|
53
|
+
- lib/duck_test/frame_work/file_manager.rb
|
54
|
+
- lib/duck_test/frame_work/base.rb
|
55
|
+
- lib/duck_test/frame_work/queue.rb
|
56
|
+
- lib/duck_test/frame_work/rspec/base.rb
|
57
|
+
- lib/duck_test/frame_work/rspec/frame_work.rb
|
58
|
+
- lib/duck_test/frame_work/watch_config.rb
|
59
|
+
- lib/duck_test/frame_work/filter_set.rb
|
60
|
+
- lib/duck_test/frame_work/map.rb
|
61
|
+
- lib/duck_test/frame_work/test_unit/base.rb
|
62
|
+
- lib/duck_test/frame_work/test_unit/frame_work.rb
|
63
|
+
- lib/duck_test/frame_work/queue_event.rb
|
64
|
+
- lib/duck_test.rb
|
65
|
+
- lib/notes.txt
|
66
|
+
- bin/ducktest
|
67
|
+
homepage: http://www.jeffduckett.com/
|
68
|
+
licenses: []
|
69
|
+
post_install_message:
|
70
|
+
rdoc_options: []
|
71
|
+
require_paths:
|
72
|
+
- lib
|
73
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
74
|
+
none: false
|
75
|
+
requirements:
|
76
|
+
- - ! '>='
|
77
|
+
- !ruby/object:Gem::Version
|
78
|
+
version: '0'
|
79
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
80
|
+
none: false
|
81
|
+
requirements:
|
82
|
+
- - ! '>='
|
83
|
+
- !ruby/object:Gem::Version
|
84
|
+
version: '0'
|
85
|
+
requirements: []
|
86
|
+
rubyforge_project:
|
87
|
+
rubygems_version: 1.8.11
|
88
|
+
signing_key:
|
89
|
+
specification_version: 3
|
90
|
+
summary: DuckTest runs TestUnit and RSpec tests directly in the IRB console.
|
91
|
+
test_files: []
|
92
|
+
has_rdoc:
|