Skip to content

Commit 1abe2ba

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 96c9e1c commit 1abe2ba

File tree

1 file changed

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

1 file changed

+4
-6
lines changed

lib/puppet-strings/yard/parsers/puppet/parser.rb

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,11 @@ def initialize(source, filename) # rubocop:disable Lint/MissingSuper
2424
# @return [void]
2525
def parse
2626
begin
27-
if @file.to_s.match?(%r{^plans|/plans/})
28-
if Puppet::Util::Package.versioncmp(Puppet.version, '5.0.0') < 0
29-
log.warn "Skipping #{@file}: Puppet Plans require Puppet 5 or greater."
30-
return
31-
end
32-
Puppet[:tasks] = true if Puppet.settings.include?(:tasks)
27+
if @file.to_s.match?(%r{^plans|/plans/}) && Puppet::Util::Package.versioncmp(Puppet.version, '5.0.0') < 0
28+
log.warn "Skipping #{@file}: Puppet Plans require Puppet 5 or greater."
29+
return
3330
end
31+
Puppet[:tasks] = true if Puppet.settings.include?(:tasks)
3432
@statements ||= (@visitor.visit(::Puppet::Pops::Parser::Parser.new.parse_string(source)) || []).compact
3533
rescue ::Puppet::ParseError => e
3634
log.error "Failed to parse #{@file}: #{e.message}"

0 commit comments

Comments
 (0)