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

Skip packages resource for unsupported OS #1484

Merged
merged 1 commit into from
Feb 10, 2017
Merged

Conversation

alexpop
Copy link
Contributor

@alexpop alexpop commented Feb 10, 2017

raise "packages resource is not yet supported on #{os.name}" was being hit when inspec check was executed on a non debian OS.

The test will be skipped on unsupported OSes if written like this:

  describe packages(/bash/) do
    its("names") { should be_empty }
  end

But succeed when written like this, hence the warn in filtered_packages:

  describe packages(/bash/).names do
    it { should be_empty }
  end

More about this limitation here: #1205 (comment)

Signed-off-by: Alex Pop <apop@chef.io>
@alexpop alexpop self-assigned this Feb 10, 2017
Copy link
Contributor

@arlimus arlimus left a comment

Choose a reason for hiding this comment

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

Awesome bugfix Alex, just one more tiny addition ;)

if os.debian?
command = "dpkg-query -W -f='${db:Status-Abbrev} ${Package} ${Version}\\n'"
end
command
Copy link
Contributor

Choose a reason for hiding this comment

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

Could we please add skip_resource for all those operating systems where this is not supported?

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've done it in initialize:
return skip_resource "The packages resource is not yet supported on OS #{inspec.os.name}" unless @command

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah perfect, I missed that! Thank you 👍

@arlimus arlimus merged commit 514a255 into master Feb 10, 2017
@arlimus arlimus deleted the ap/fix-packages-check branch February 10, 2017 13:03
@arlimus
Copy link
Contributor

arlimus commented Feb 10, 2017

Kudos Alex!!

@alexpop
Copy link
Contributor Author

alexpop commented Feb 10, 2017

Code shipped in inspec 1.14.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants