This provides the user with messages if `json(command: 'command_that_errors')`
exits non-zero and/or has STDERR.
Without this the resource will report "No output from command" when really the
output is contained in STDERR.
Signed-off-by: Jerry Aldrich <jerryaldrichiii@gmail.com>
Backticks means you can't selectively run one of these tests w/o
subshelling out to `brew`, or having to edit first.
Signed-off-by: Ryan Davis <zenspider@chef.io>
Removes pre-loading and registration of resources by adding
method_missing to a couple key areas.
This still drops the ball in some areas, but it is a start.
Pass the first argument of the opts array instead of the whole array which
confuses the SimpleConfig parser. Also added a test which verifies this fixes
the issue.
In addition, change the base_name to something that matches other resource base
names.
Signed-off-by: Lance Albertson <lance@osuosl.org>
I think this is probably in contention with my other PR on resource
initialization. We definitely need to change that, so this might fall
to the side. Or maybe just the test needs to be redone. We'll discuss
and see.
Signed-off-by: Ryan Davis <zenspider@chef.io>
This is a first pass at fixing the failure found by @scottvidmar where
file resource was raising undefined_method on nil. The problem was
that the initialize method for file was not being called at all
because Resource#initialize was returning early without reporting
anything.
This fix causes a failure in test/functional/inspec_exec_test.rb where
it is testing a similar scenario but for some reason the unsupported
resources get reported. We need to figure that part out, but in the
meantime this will at least report an error at the root cause rather
than down the road.
Fixes#4208
Signed-off-by: Ryan Davis <zenspider@chef.io>
I noticed that my profile targeting group "staff" on OSX wasn't
returning *me*. I'm awesome! So that seemed wrong. And it turns out it
is wrong. We were not collecting any users whose primary group was
that group. (almost all regular users are in group staff and they're
all missing).
Signed-off-by: Ryan Davis <zenspider@chef.io>
BK currently runs our tests on ruby:X.Y-stretch docker images, which
use root. This puts license files it /etc/chef instead of the current
user's home and broke our tests.
This adds cleanup to /etc/chef AND checks both locations, so it should
continue to work even if we switch to docker images with non-root users.
Signed-off-by: Ryan Davis <zenspider@chef.io>
These were put in place because they pass locally and fail on
buildkite. We didn't care at the time, but now we should investigate.
Signed-off-by: Ryan Davis <zenspider@chef.io>
I've got this under debug in docker but this is a problem on the
license_acceptance gem on BK, not with inspec. And it is blocking a
release, so I'm bumping this out 2 weeks.
Signed-off-by: Ryan Davis <zenspider@chef.io>
This adds support for specifying a path to a profile in a Git repo.
For example, you could have a Git repo containing multiple profiles and
you want to specify a single one like below:
```yaml
depends:
- name: profile-1
git: https://github.com/myorg/all-my-profiles.git
profile_path: profiles/my-specific-profile-1
- name: profile-2
git: https://github.com/myorg/all-my-profiles.git
profile_path: profiles/my-specific-profile-2
```
Signed-off-by: Jerry Aldrich <jerryaldrichiii@gmail.com>
There is no reason why our tests should be failing because we deploy a
new version. That test shouldn't even be hitting the network for real.
Besides, the functionality has no place in our codebase. It's
functionality provided via `gem outdated` so why did we re-implement
it? And we expect most people to be running via omnibus, so they're
pinned to a specific version in the first place. Even if they updated,
they still couldn't run it and that would be more confusing.
Signed-off-by: Ryan Davis <zenspider@chef.io>
Not sure why these failures come up in a unified run (versus my
running all test files separately). Might be test infection. Might be
environmental.
Signed-off-by: Ryan Davis <zenspider@chef.io>
This activates a BUNCH of tests but keeps us green.
Whether these tests are valid or not is not being addressed here.
Signed-off-by: Ryan Davis <zenspider@chef.io>
This should get windows tests running again? Hopefully? They're
running SO slowly on my vagrant box that I'm just pushing for now.
They're clean on the mac side.
Signed-off-by: Ryan Davis <zenspider@chef.io>
When using `schtasks` a list is returned if the task has multiple
triggers. This merges that list with the last item taking precedence.
This is how `Get-ScheduledTask` behaves.
Initially, I was going to rewrite this resource to use
`Get-ScheduledTask` but the original author purposely did not do this
so that PowerShell v3 would be supported. We only support PowerShell
v5, but I don't want to break any current users and this change didn't
seem to controversial to me.
If it gives us trouble, I recommend rewriting it to use
`Get-ScheduledTask`.
Signed-off-by: Jerry Aldrich <jerryaldrichiii@gmail.com>
This should resolve#1011 which provides an ip6tables resource to test IPv6
iptables rules. This is essentially a copy of the iptables resource with a few
renames.
In addition, I've pulled in the integration tests for iptables into ip6tables
and enabled it on docker so that it properly gets tested regularly. The test
cookbook recipe has been updated to support all of the current platforms that
are being tested.
Signed-off-by: Lance Albertson <lance@osuosl.org>
This fixes `nginx_conf.params` when:
- Given an empty file
- Given a file with only comments
- Given a file that has an include for a file that:
- Is empty
- Has all lines commented out
This also fixes a test where a missing file is actually empty
Signed-off-by: Jerry Aldrich <jerryaldrichiii@gmail.com>
This was the next most expensive require in the analysis.
Also rearranged the way that ui handled tables to be lazy.
```
% SLOW=1 time rake test:functional
before: Finished in 681.514579s, 0.5136 runs/s, 2.9919 assertions/s.
after : Finished in 642.655918s, 0.5446 runs/s, 3.1728 assertions/s.
```
Signed-off-by: Ryan Davis <zenspider@chef.io>
Sometime during the 2.x's, `at_exit` changed its ordering. As a result,
a lot of things that were stacking `at_exit`'s broke. This is one of
those since both simplecov and minitest do their thing via `at_exit`.
This switches to simplecov w/ no defaults on, then replicates their
simplecov/defaults.rb with our own.
I'm going to try to get that entire file back upstream but it can live
here for now.
Signed-off-by: Ryan Davis <zenspider@chef.io>
Skip most everything.
After some digging, in those tests that didn't have 100% failures, of
the ~10+% passing, those tests weren't checking enough. So I skip them
too in the hopes that we improve testing across the board.
At this point, we need appveyor to be green more than we need these
tests to be fixed. If that means we skip them, so be it.
These tests will time-bomb at the end of July.
Signed-off-by: Ryan Davis <zenspider@chef.io>
Added InspecTest (which we should use across the board) and
ParallelTest (which we should use selectively and with metrics) to
helper.
Signed-off-by: Ryan Davis <zenspider@chef.io>
Essentially, the way rspec does stuff is pretty rude. By injecting
singleton methods into main (instead of Kernel, where all top-level
methods go) and "cleaning" them up using undef_method instead of
remove_method makes it pretty hard for anything else in the testing
arena to operate. I've already fixed the case where rspec would
overwrite minitest's `describe` in a way that made it very hard to put
back, but my fix didn't prevent rspec from doing it _AGAIN_.
This fixes the case where after some rspec interactions, mocha's
`any_instance` method would just disappear. I never did figure out
where or why this was happening, but I did address the how.
Signed-off-by: Ryan Davis <zenspider@chef.io>
Turns out we don't even use CMD in any units... so why make it?
Lots of other stuff got ripped out. Tests basically shouldn't need to
require anything but 1 implementation file and a test framework.
Anything more than that is a smell.
Signed-off-by: Ryan Davis <zenspider@chef.io>
This speeds up parallel unit test runs from a very consistent 2:49 to
a very consistent 1:53, or a 33% reduction.
Signed-off-by: Ryan Davis <zenspider@chef.io>
+ Add CHEF_LICENSE env variable.
+ Switch to using powershell to invoke inspec.
I still think we should look into using `spawn`, but this is a good
start.
This probably doesn't fix the rest of the tests, but they're SO slow
locally that I'm gonna start this PR.
Signed-off-by: Ryan Davis <zenspider@chef.io>
Not sure how it was supposed to work in the first place. The plugin in
question depends on ordinal_array and that wasn't in that fixture dir.
Switching to 2 is all it apparently needed.
This does cause yet another double-load warning (VERSION already
defined). I don't know how we're supposed to get around that with the
way we've set up these tests.
Signed-off-by: Ryan Davis <zenspider@chef.io>
Helps testing and lots of other things if we only use $stdout/$stderr.
STDOUT/STDERR should only be used to restore the globals.
Signed-off-by: Ryan Davis <zenspider@chef.io>
Trying to fix file_test failure that only happens on travis.
The "mock" file in question is supposed to have a stat of 644, but
actually has 664 but only on travis-ci.
Signed-off-by: Ryan Davis <zenspider@chef.io>
This time between:
+ PluginManagerCliDefinitionTests#(?:test_plugin_registered
+ PluginLoaderTests#test_load_mock_plugin_by_gem
Signed-off-by: Ryan Davis <zenspider@chef.io>
Specifically, if these were run in this order:
+ PluginLoaderTests#test_load_mock_plugin_by_gem
+ PluginInstallerInstallationTests#test_install_a_gem_from_local_file
the latter would fail.
The failure was in test setup. The solution was partially to crib off
of and normalize with LoaderTest setup/teardown and partially to set extra things.
Specifically:
+ HOME wasn't being set so it was finding my ~/.inspec/plugins.json
+ ENV wasn't being reset for Gem.paths
+ Installer wasn't being reset correctly, so plugins were known across tests.
Signed-off-by: Ryan Davis <zenspider@chef.io>
+ Added SLOW=1 to appveyor (I hope?) and travis.
+ Off by default.
Speeds up installer tests from ~5.5 seconds to ~0.5 seconds.
Once this is established, we can push this up to the main helper and
generalize if it works out for us.
Signed-off-by: Ryan Davis <zenspider@chef.io>
+ Do extra cleanup of loaded_specs for the dependencies.
+ Ensure rake is actually activated.
Fixes#4030.
Fixes#4026.
Signed-off-by: Ryan Davis <zenspider@chef.io>
As commented, I'm happy to push this to our tests, but it does seem
odd that we'd install rdoc/ri for plugins.
Signed-off-by: Ryan Davis <zenspider@chef.io>
+ float? comparison can raise a TypeError
+ octal? comparison was allowing non-octal values (which cast to 0)
+ symbol comparison was casting to a string, but then doing an == check instead of casecmp.
The latter seems optional, but consistent with the intent of cmp.
Signed-off-by: Ryan Davis <zenspider@chef.io>
Moved exec_inspec to inspec_path.
Added new exec_inspec that invokes ruby w/ -Ilib (expanded).
Decouples from bundler and/or needing inspec-bin to be installed.
Signed-off-by: Ryan Davis <zenspider@chef.io>
Can also try to use the bundler version first and then fall back to
VERSION... but VERSION is absolutely free.
Happy to push an edit to this to remove the comment or fold it in.
Signed-off-by: Ryan Davis <zenspider@chef.io>
This was testing serverspec compatibility, but those days are long past us and this is a deprecated resource now. This will quiet our tests up a bit.
Signed-off-by: Tim Smith <tsmith@chef.io>
RSpec is used internally. Minitest is used for our tests. They don't
really like each other. This fixes that and gets our tests
consistently running the correct number of tests (they were load-order
dependent before and each platform had its own different number of
tests it would run).
Signed-off-by: Ryan Davis <zenspider@chef.io>
These tests both involve dynamic un-rooted classes. As such, they have
no name and thus print like #<Class:0xXXXXXXXX:...>. I switched one to
a describe instead of Class.new(Minitest::Test) and the other I
stringified the anonymous class.
Signed-off-by: Ryan Davis <zenspider@chef.io>
The #disable_telemetry method now toggles @telemetry_toggle_off.
The @telemetry_toggle_off is defaulted to false
The #telemetry_enabled? method now checks @telemetry_toggle_off
and we generally check the configuration. We do not flip
@telemetry_toggle_off based on the content of the configuration.
Signed-off-by: Miah Johnson <miah@chia-pet.org>
Because of the way the test system loads I cannot guarantee that
`Inspec::Config.cached` won't be nil. I have to always pass in a mock
config object with our setting.
Signed-off-by: Miah Johnson <miah@chia-pet.org>