doubleshot 1.0-java → 1.0.1-java

Sign up to get free protection for your applications and to get access to all the features.
data/Doubleshot CHANGED
@@ -4,7 +4,7 @@ Doubleshot.new do |config|
4
4
 
5
5
  config.project = "doubleshot"
6
6
  config.group = "org.sam.doubleshot"
7
- config.version = "1.0"
7
+ config.version = "1.0.1"
8
8
 
9
9
  config.gem "minitest", ">= 3.0.1"
10
10
  config.gem "minitest-wscolor", ">= 0"
@@ -36,7 +36,7 @@ class Doubleshot::CLI::Commands::Test < Doubleshot::CLI
36
36
 
37
37
  @@pid_file = Pathname(".doubleshot_test.pid")
38
38
  if @@pid_file.exist? && !options.force_tests
39
-
39
+
40
40
  begin
41
41
  if Process.getpgid(@@pid_file.read.to_i)
42
42
  puts ".doubleshot_test.pid exists: Are you running tests elsewhere? (Use --force to override.)"
@@ -125,26 +125,65 @@ class Doubleshot::CLI::Commands::Test < Doubleshot::CLI
125
125
  private
126
126
  def listener
127
127
  require "listen"
128
-
128
+
129
+ monitored = [
130
+ @config.source.tests,
131
+ @config.source.ruby,
132
+ @config.source.java
133
+ ].select(&:exist?).map(&:to_s)
134
+
129
135
  # This creates a MultiListener
130
- Listen.to(@config.source.tests.to_s, @config.source.ruby.to_s, @config.source.java.to_s).change do |modified, added, removed|
136
+ Listen.to(*monitored).change do |modified, added, removed|
131
137
  modified.each do |location|
132
138
  path = Pathname(location)
133
139
 
134
140
  next unless path.extname == ".rb" or path.extname == ".java"
135
141
 
136
- test = if path.basename.to_s =~ /_(spec|test).rb/ && path.child_of?(@config.source.tests)
137
- path
142
+ test = nil
143
+
144
+ if path.child_of?(@config.source.tests)
145
+ if path.basename.to_s =~ /_(spec|test).rb/
146
+ test = path
147
+ else
148
+ next
149
+ end
138
150
  else
139
- relative_path = if path.extname == ".rb"
140
- path.relative_path_from(@config.source.ruby.expand_path)
141
- else
142
- path.relative_path_from(@config.source.java.expand_path)
143
- end
144
- matcher = relative_path.sub(/(\w+)\.(rb|java)/, "\\1_{spec,test}.rb")
145
- matchers = [ matcher, Pathname(matcher.to_s.split("/")[1..-1].join("/")) ]
146
-
147
- match = matchers.detect do |matcher|
151
+ case path.extname
152
+ when ".rb" then
153
+ if @config.source.ruby.exist?
154
+ test = path.relative_path_from(@config.source.ruby.expand_path)
155
+ else
156
+ next
157
+ end
158
+ when ".java" then
159
+ if @config.source.java.exist?
160
+ test = path.relative_path_from(@config.source.java.expand_path)
161
+ else
162
+ next
163
+ end
164
+ end
165
+
166
+ matcher = test.sub(/(\w+)\.(rb|java)/, "\\1_{spec,test}.rb")
167
+ matchers = [ matcher ]
168
+
169
+ # If this is a nested path, then create a lower priority matcher
170
+ # without the first portion of the path, so that a path like:
171
+ #
172
+ # "lib/doubleshot/configuration/source_locations.rb"
173
+ #
174
+ # would search for the following paths:
175
+ #
176
+ # test/doubleshot/configuration/source_locations_{spec,test}.rb
177
+ # test/configuration/source_locations_{spec,test}.rb
178
+ #
179
+ # So if you follow the exact lib structure convention in your test folder,
180
+ # those files will get precedence, but otherwise, you can drop the
181
+ # project-name so you don't have to nest ALL-THE-THINGS.
182
+ unless matcher.basename == matcher
183
+ matchers << Pathname(matcher.to_s.split("/")[1..-1].join("/"))
184
+ end
185
+
186
+ test = matchers.detect do |matcher|
148
187
  if match = Pathname::glob(@config.source.tests + matcher).first
149
188
  break match
150
189
  end
Binary file
metadata CHANGED
@@ -2,14 +2,14 @@
2
2
  name: doubleshot
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: '1.0'
5
+ version: 1.0.1
6
6
  platform: java
7
7
  authors:
8
8
  - Sam Smoot
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-11-27 00:00:00.000000000 Z
12
+ date: 2012-11-30 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: minitest