lib/pdk/validate/base_validator.rb in pdk-1.6.0 vs lib/pdk/validate/base_validator.rb in pdk-1.6.1
- old
+ new
@@ -34,18 +34,27 @@
[PDK::Util.module_root]
else
options[:targets]
end
+ fixtures_pattern = File.join('**', 'spec', 'fixtures', '**', '*')
targets.map! { |r| r.gsub(File::ALT_SEPARATOR, File::SEPARATOR) } if File::ALT_SEPARATOR
skipped = []
invalid = []
matched = targets.map { |target|
if respond_to?(:pattern)
if File.directory?(target)
- pattern_glob = Array(pattern).map { |p| Dir.glob(File.join(PDK::Util.module_root, p)) }
- target_list = pattern_glob.flatten.select { |file| File.fnmatch(File.join(File.expand_path(target), '*'), file) }
+ target_root = PDK::Util.module_root
+ pattern_glob = Array(pattern).map { |p| Dir.glob(File.join(target_root, p)) }
+ pattern_glob = pattern_glob.flatten.reject { |file| File.fnmatch(fixtures_pattern, file) }
+
+ target_list = pattern_glob.map do |file|
+ if File.fnmatch(File.join(File.expand_path(target), '*'), file)
+ Pathname.new(file).relative_path_from(Pathname.new(PDK::Util.module_root)).to_s
+ end
+ end
+
skipped << target if target_list.flatten.empty?
target_list
elsif File.file?(target)
if Array(pattern).include? target
target
@@ -124,11 +133,11 @@
end
exit_codes = []
targets.each do |invokation_targets|
- cmd_argv = parse_options(options, invokation_targets).unshift(cmd_path)
+ cmd_argv = parse_options(options, invokation_targets).unshift(cmd_path).compact
cmd_argv.unshift(File.join(PDK::Util::RubyVersion.bin_path, 'ruby.exe'), '-W0') if Gem.win_platform?
command = PDK::CLI::Exec::Command.new(*cmd_argv).tap do |c|
c.context = :module
unless options[:split_exec]
@@ -143,17 +152,26 @@
end
if options[:split_exec]
options[:split_exec].register do
result = command.execute!
- parse_output(report, result, invokation_targets)
+
+ begin
+ parse_output(report, result, invokation_targets.compact)
+ rescue PDK::Validate::ParseOutputError => e
+ $stderr.puts e.message
+ end
result[:exit_code]
end
else
result = command.execute!
exit_codes << result[:exit_code]
- parse_output(report, result, invokation_targets)
+ begin
+ parse_output(report, result, invokation_targets.compact)
+ rescue PDK::Validate::ParseOutputError => e
+ $stderr.puts e.message
+ end
end
end
options.key?(:split_exec) ? options[:split_exec].exit_code : exit_codes.max
end