Skip to content

Commit 83ef457

Browse files
committed
(#307) Fix plan parsing in JSON spec tests
Previously, the parsing code activated task support in Puppet when it detected that it was parsing a file in a plans/ directory. This casued the JSON spec test for plans to fail because it parsed a string, which naturally had no file name to check. This turns on task support (and thus enables parsing plans) whenever the parser starts (assuming that task support is available). This helps avoid surprises to future users who need to parse plans from ruby code, such as in tests.
1 parent 2a990bb commit 83ef457

File tree

1 file changed

+4
-6
lines changed
  • lib/puppet-strings/yard/parsers/puppet

1 file changed

+4
-6
lines changed

Diff for: lib/puppet-strings/yard/parsers/puppet/parser.rb

+4-6
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,11 @@ def initialize(source, filename)
2222
# @return [void]
2323
def parse
2424
begin
25-
if @file.to_s.match(/^plans|\/plans\//)
26-
if Puppet::Util::Package.versioncmp(Puppet.version, "5.0.0") < 0
27-
log.warn "Skipping #{@file}: Puppet Plans require Puppet 5 or greater."
28-
return
29-
end
30-
Puppet[:tasks] = true if Puppet.settings.include?(:tasks)
25+
if @file.to_s.match(/^plans|\/plans\//) && Puppet::Util::Package.versioncmp(Puppet.version, "5.0.0") < 0
26+
log.warn "Skipping #{@file}: Puppet Plans require Puppet 5 or greater."
27+
return
3128
end
29+
Puppet[:tasks] = true if Puppet.settings.include?(:tasks)
3230
@statements ||= (@visitor.visit(::Puppet::Pops::Parser::Parser.new.parse_string(source)) || []).compact
3331
rescue ::Puppet::ParseError => e
3432
log.error "Failed to parse #{@file}: #{e.message}"

0 commit comments

Comments
 (0)