Skip to content

Commit a737993

Browse files
committed
More useful flag combining for runner.
1 parent 17aac1b commit a737993

File tree

1 file changed

+13
-7
lines changed

1 file changed

+13
-7
lines changed

bin/xspec

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,19 +9,19 @@ require 'xspec'
99
$LOAD_PATH.unshift "spec"
1010
$LOAD_PATH.unshift "lib"
1111

12-
filter = //
12+
filter = nil
1313
short_ids = []
1414

1515
parser = OptionParser.new
1616
parser.banner = "Usage: xspec [options] [files]"
1717
parser.separator ""
18-
parser.on('-e FILTER', "Only run specs with full name including FILTER") do |f|
18+
parser.on('-e FILTER', "Run specs with full name including FILTER.") do |f|
1919
filter = Regexp.new(f)
2020
end
21-
parser.on('-f ID', "Run spec with short id ID. Overrides -e option.") do |f|
21+
parser.on('-f ID', "Run spec with short id ID. Use multiple times to specify more than one id.") do |f|
2222
short_ids << f
2323
end
24-
parser.on("-h", "--help", "Show this message") do
24+
parser.on("-h", "--help", "Show this message.") do
2525
$stderr.puts parser
2626
exit
2727
end
@@ -45,11 +45,17 @@ if respond_to?(:run!)
4545
config.update(scheduler: XSpec::Scheduler::Filter.new(
4646
scheduler: config.fetch(:scheduler),
4747
filter: -> uow {
48+
inc = true
49+
4850
if short_ids.any?
49-
short_ids.include?(config.fetch(:short_id).(uow))
50-
else
51-
uow.full_name =~ filter
51+
inc &&= short_ids.include?(config.fetch(:short_id).(uow))
52+
end
53+
54+
if filter
55+
inc &&= uow.full_name =~ filter
5256
end
57+
58+
inc
5359
}
5460
))
5561
}

0 commit comments

Comments
 (0)