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
Spec test that checks file with incorrect (non-passing) mode fails with ArgumentError #34
Comments
I realize I should probably show the backtrace, which doesn't appear to be all that useful. (I need to figure out how to enable better backtraces.)
|
Does the following work?
|
How about this?
|
Tested your suggestions, and I can confirm the same output, which does help validate that it's a bug somewhere. The problem is the trace isn't useful in helping us really determine what is calling the function incorrectly. Once I have a way to do that, then I suspect the bug fix itself will be trivial. |
Curious if anyone has thoughts on how I might track this down? Got stuck trying to figure out what part in the chain path might be causing the issue. Thought appreciated! |
Well I got chef hacked up and know what is being passed now. There are two arguments being passed to the diff function in the file.rb file. It only accepts 1 argument but it is getting 2. The values it is getting are the preferred and actual mode's of the file. I added a Chef::Log.info() to the file.rb and get this:
I will continue to track down what is causing the multiple values, or whether the diff function should accept 2 arguments when it only gets 1 right now. |
There appears to be a bug somewhere in either the usage of 'assert_equal' or perhaps a bug in the implementation of 'assert_equal' in the MiniTest::Assert library. When things match, I do not get the Chef::Log.info() message I added to the diff function in Chef proper. When they do not match, then I do get the message. This seems to lead me to believe the diff function in Chef proper should never really be getting triggered for these tests. Something is happening in an implementation that is causing it to be used when it probably shouldn't be. Here is the step through of the various lines and usage that is causing the error here. This is not related to just the 'mode' attribute, but pretty much anything to do with the 'with' resource. I get the same thing when using :owner etc.... Here is the trace through the related applications I've been testing with: https://github.com/seattlerb/minitest/blob/master/lib/minitest/unit.rb#L230 http://bfts.rubyforge.org/minitest/MiniTest/Assertions.html#method-i-assert_equal https://github.com/opscode/chef/blob/master/lib/chef/resource/file.rb#L85 |
Hi Leif, Thanks a lot for persevering and debugging this. In the backtrace you can see Chef::Resource::File#diff is being called from MiniTest's assert_equal method. This is because we mix the The fix should be to avoid including Cheers, Andrew. |
@acrmp thanks for the follow up! Now it all makes perfect sense. I'll give a shot at trying to enhance that section of code and determine what areas really need to be mixed into |
This is an important bug to fix. I have a lot of tests, as I test each and every cookbook / recipe, hence this is super annoying. I'd appreciate a fix :) |
Sorry, I should have chimed in earlier with some more detail for Leif. The suggested fix was to avoid including Within the #with method we would instead do something like: mt = Object.extend(MiniTest::Assertions)
mt.assert_equal values, actual_values,
"The #{resource_name} does not have the expected #{attribute}" @leifmadsen - Can you give this a try? If you can get it working would you mind putting together a pull request? I also wanted to write a spec to verify the methods exposed on Thanks again for your dogged persistence! Cheers, Andrew. |
@acrmp that's awesome thanks! I will check that out and see what I can come up with. I should probably be able to figure that out based on your info and then I'll create a pull request. A set of spec tests to check things would be a great idea. If you have some hints as to how you were going to approach that I can likely write the tests as well. Thanks very much for continuing to follow up on this! |
#40 is the pull request that resolves this issue. Thanks! |
Fixed. |
So I found this a little odd today. I created this spec test:
When the mode of the file is not equal to 644 (mode 600 in this case) then I get the following:
test_0003_ensures_ssh_config_file_exists_with_correct_permissions(recipe::voiceaxis::sshd::files):
ArgumentError: wrong number of arguments (2 for 1)
/usr/local/lib/ruby/gems/1.9.1/gems/chef-10.14.4/lib/chef/resource/file.rb:85:in `diff'
If you look at the chef/resources/file.rb file, then you can see the 'diff' function only requires a single argument.
When the mode check is correct, then the output shows as a valid test, so you wouldn't notice it not working.
I've looked through the code some, and I can't seem to see what exactly is causing a 2nd argument to be passed to the 'diff' function.
The text was updated successfully, but these errors were encountered: