Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(SDK-137) Add puppet syntax validation #105

Merged
merged 10 commits into from
Jun 28, 2017

Conversation

bmjen
Copy link
Contributor

@bmjen bmjen commented Jun 23, 2017

This feature requires this fix voxpupuli/puppet-syntax#83 to be published.

Copy link
Contributor

@DavidS DavidS left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Needs acceptance tests.

@@ -85,6 +85,9 @@ def to_junit(target = self.class.default_target)
# @param target [#write] an IO object that the report will be written to.
# Defaults to PDK::Report.default_target.
def to_text(target = self.class.default_target)
# Extra defaulting here, b/c the Class.send method will pass in nil
target ||= self.class.default_target
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This method looks like its primary concern should be formatting, not outputting. You can get rid of this dance here, and make the method more flexible, by just returning the final string, and leave IO to the caller.

Alternatively rename it to write_text_to, to capture its intent. Compare with to_hash returning a Hash, not IO.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea. And the formatting happens in the to_text method of the Event class.

end

def self.sanitize_console_output(line)
line.gsub!(%r{\e\[([;\d]+)?m}, '')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can this be avoided by setting Puppet[:color] = false in https://github.com/voxpupuli/puppet-syntax/blob/master/lib/puppet-syntax/manifests.rb#L19 , or a similar place ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wouldn't want to change the default behavior of puppet-syntax itself and strip the colors, since users of this tool outside of PDK may still want the distinct console colors. I could add a Rakefile option to disable the colors in puppet-syntax and toggle it on or off based on that.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good enough for now.

@DavidS DavidS changed the title Puppet Syntax Validation & misc cleanups (SDK-137) Add puppet syntax validation Jun 26, 2017
@DavidS DavidS added the feature label Jun 26, 2017
@DavidS
Copy link
Contributor

DavidS commented Jun 27, 2017

Still needs a rebase :-/

@bmjen
Copy link
Contributor Author

bmjen commented Jun 27, 2017

I'll rebase after I get these acceptance tests done. Conflicts came in after #99 and #109 were merged.

@DavidS
Copy link
Contributor

DavidS commented Jun 27, 2017

👍

@rodjek rodjek force-pushed the validation-cleanup branch 4 times, most recently from 5a7c1c2 to 96bcd77 Compare June 28, 2017 04:51
@rodjek
Copy link
Contributor

rodjek commented Jun 28, 2017

Made a couple of changes to fix up the acceptance tests on Windows:

  • Changed how the location information is parsed in the puppet-syntax validator to handle file path that have colons in them
  • Changed how we spawn ruby processes on windows to disable warnings generated by Kernel.warn. I don't like this change but unfortunately readline on Ruby 2.1 on Windows includes a deprecated library and Puppet requires readline. We patch our vendored build of Ruby 2.1 to remove the deprecation warning (see PUP-3060) but as we're dealing with system ruby here... Yeah.

@rodjek
Copy link
Contributor

rodjek commented Jun 28, 2017

An alternative to disabling warnings would be to remove matching known problematic deprecation warnings and removing them from the output before parsing, but that seems like a brittle solution. Group consensus on the least awful solution? :)

@DavidS
Copy link
Contributor

DavidS commented Jun 28, 2017

Filtering the known warnings for test purposes would be preferable, as it would allow us to detect new warnings on incoming code before it hits master.

No reason to block this PR for it though.

@DavidS DavidS merged commit d861740 into puppetlabs:master Jun 28, 2017
@bmjen bmjen deleted the validation-cleanup branch November 14, 2017 21:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants