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

Windows file matcher does not match existing files #288

Closed
cheesesashimi opened this issue Dec 3, 2015 · 6 comments
Closed

Windows file matcher does not match existing files #288

cheesesashimi opened this issue Dec 3, 2015 · 6 comments
Assignees
Labels
Type: Bug Feature not working as expected
Milestone

Comments

@cheesesashimi
Copy link

This may not be the most appropriate place for this, so my apologies in advance :).

I think the Windows file matcher in inspec is not working as intended. For some reason, it cannot match any file paths I provide. It appears to make no difference whether the files were put in place by Chef or if the files were already present on the Windows system under test.

I was able to verify that other matchers such as user and os work correctly in Windows as evidenced in my inspec specification.

The output I get from kitchen and inspec is as follows:

-----> Verifying <default-win2012r2>...
....F.F.

Failures:

  1) File C:\Windows should exist
     Failure/Error: DEFAULT_FAILURE_NOTIFIER = lambda { |failure, _opts| raise failure }
       expected File C:\Windows to exist
     # ./test/integration/default/test_spec.rb:18:in `block (2 levels) in load'

  2) File C:\motd should exist
     Failure/Error: DEFAULT_FAILURE_NOTIFIER = lambda { |failure, _opts| raise failure }
       expected File C:\motd to exist
     # ./test/integration/default/test_spec.rb:23:in `block (2 levels) in load'

Finished in 24.73 seconds (files took 2 minutes 9.2 seconds to load)
8 examples, 2 failures

Failed examples:

rspec  # File C:\Windows should exist
rspec  # File C:\motd should exist

       Finished verifying <default-win2012r2> (0m25.76s).

I created a simple cookbook in an attempt to isolate this, so it is possible my .kitchen.yml and other setup of the cookbook is incorrect.

I'm happy to help debug this further, so please let me know if there is additional information I can provide that might be useful :).

@docwhat
Copy link

docwhat commented Dec 4, 2015

In your example, it looks like be_file and be_directory work, but exists is broken. Which is weird.

I'm having a hard time following where the actual file object is located to figure out how it is actually trying to resolve exist?... I see this bit of meta-programming... which actually looks suspicious, but I couldn't say why.

@docwhat
Copy link

docwhat commented Dec 4, 2015

Ah-hah... the real file object is in Train!

And here's the bug I think:

    def exist?
      nil
    end

@arlimus
Copy link
Contributor

arlimus commented Dec 4, 2015

@docwhat Oh doh, great catch, that's an awkward oversight 😬 ... Happy to take a PR

@cheesesashimi Thank you for finding and reporting this!!

@docwhat
Copy link

docwhat commented Dec 4, 2015

@arlimus You mean like that? 😀

@chris-rock chris-rock added the Type: Bug Feature not working as expected label Dec 6, 2015
@arlimus
Copy link
Contributor

arlimus commented Dec 7, 2015

@docwhat Spot on! 😄

@arlimus arlimus added this to the 0.9.6 milestone Dec 7, 2015
@chris-rock chris-rock self-assigned this Dec 7, 2015
@chris-rock
Copy link
Contributor

Will work with the next train and inspec release

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Bug Feature not working as expected
Projects
None yet
Development

No branches or pull requests

4 participants