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

rspec-puppet-augeas expects empty results from augparse #10

Open
mcallaway opened this issue Apr 23, 2014 · 1 comment
Open

rspec-puppet-augeas expects empty results from augparse #10

mcallaway opened this issue Apr 23, 2014 · 1 comment

Comments

@mcallaway
Copy link
Contributor

In rspec-puppet-augeas test_utils.rb, we have:

raise RSpec::Puppet::Augeas::Error, "augparse failed:\n#{output}" unless res == 0 && output.empty?

But the test that it performs produces output even if it's correct and exits 0.

> cat /tmp/rpa-augparse20140423-31379-vdz5tf/test_rspec_puppet_augeas.aug
module Test_Rspec_Puppet_Augeas =
  test Automaster.lns get Sys.read_file "/tmp/rpa-augparse20140423-31379-vdz5tf/input" =
    ?

> augparse --notypecheck /tmp/rpa-augparse20140423-31379-vdz5tf/test_rspec_puppet_augeas.aug
Test result: /tmp/rpa-augparse20140423-31379-vdz5tf/test_rspec_puppet_augeas.aug:2.2-3.5:
  { "#comment" = "This is a test empty auto.master file" }
  { "1" = "/gapp"
    { "map" = "/etc/auto.gapp" }
    { "opt" = "--timeout"
      { "value" = "300" }
    }
    { "opt" = "intr" }
    { "opt" = "tcp" }
  }

> echo $?
0

As you can see, the test passes, but not silently, and so the rspec test fails.

This is in:

augeas-tools 1.0.0-0ubuntu1raphink1lucid1

Failure exits 1, that should be enough.

@mcallaway mcallaway changed the title rspec-puppet-augeas expects empty results from augparse but are not so rspec-puppet-augeas expects empty results from augparse Apr 23, 2014
mcallaway pushed a commit to genome-vendor/rspec-puppet-augeas that referenced this issue Apr 23, 2014
@domcleal
Copy link
Owner

domcleal commented Dec 4, 2014

Sorry for the extremely late reply.

This is kind of by design, as the idea with the augparse() function is that you'd supply a result tree as a string in the first argument and the generated tree will be compared against the expected string. The default of '?' is a shortcut (IIRC) so the test will fail, but will output the expected tree, which you can copy and paste so it passes next time.

I could add an option in if you like to make the behaviour configurable? That way we could keep the above, and also allow just using '?' if you want to simply check the file parses, not that it matches a specific tree.

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

Successfully merging a pull request may close this issue.

2 participants