Uploaded image for project: 'Puppet Development Kit'
  1. Puppet Development Kit
  2. PDK-926

when running {{pdk test unit}} from somewhere other than the module root, spec test failures cause Errno::ENOENT errors

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Normal
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: PDK 1.6.0
    • Component/s: None
    • Template:
    • Method Found:
      Needs Assessment
    • Release Notes:
      Bug Fix
    • Release Notes Summary:
      Hide
      Fixed an issue where `pdk test unit` would raise an unhandled exception when trying to display the context of a failing test to the user. When reading the spec files for context, PDK will now open the absolute path to the file (rather than the relative path), allowing `pdk test unit` to be run from any directory in the module.
      Show
      Fixed an issue where `pdk test unit` would raise an unhandled exception when trying to display the context of a failing test to the user. When reading the spec files for context, PDK will now open the absolute path to the file (rather than the relative path), allowing `pdk test unit` to be run from any directory in the module.
    • QA Risk Assessment:
      Needs Assessment

      Description

      pdk unit test, when run in a subdirectory of the module directory, produces Ruby errors when a spec test fails.

      Reproducer:

      $ pdk new module test-test --skip-interview
      $ cd test
      $ pdk new class test
      $ sed -i -e 's/to compile/not_to compile/' spec/classes/test_spec.rb
      $ pdk test unit
      $ cd spec
      $ pdk test unit
      

      The first pdk test unit fails and reports the failed test.

      The second pdk test unit (run inside the spec directory) fails and errors out:

      $ pdk test unit
      [✔] Preparing to run the unit tests.
      [✖] Running unit tests.
        Evaluated 4 tests in 0.312774696 seconds: 4 failures, 0 pending.
      [✔] Cleaning up after running unit tests.
      /opt/puppetlabs/pdk/private/ruby/2.1.9/lib/ruby/gems/2.1.0/gems/pdk-1.4.1/lib/pdk/report/event.rb:329:in `read': No such file or directory @ rb_sysopen - ./spec/classes/test_spec.rb (Errno::ENOENT)
              from /opt/puppetlabs/pdk/private/ruby/2.1.9/lib/ruby/gems/2.1.0/gems/pdk-1.4.1/lib/pdk/report/event.rb:329:in `context_lines'
              from /opt/puppetlabs/pdk/private/ruby/2.1.9/lib/ruby/gems/2.1.0/gems/pdk-1.4.1/lib/pdk/report/event.rb:102:in `to_text'
              from /opt/puppetlabs/pdk/private/ruby/2.1.9/lib/ruby/gems/2.1.0/gems/pdk-1.4.1/lib/pdk/report.rb:99:in `block (2 levels) in write_text'
              from /opt/puppetlabs/pdk/private/ruby/2.1.9/lib/ruby/gems/2.1.0/gems/pdk-1.4.1/lib/pdk/report.rb:98:in `each'
              from /opt/puppetlabs/pdk/private/ruby/2.1.9/lib/ruby/gems/2.1.0/gems/pdk-1.4.1/lib/pdk/report.rb:98:in `block in write_text'
              from /opt/puppetlabs/pdk/private/ruby/2.1.9/lib/ruby/gems/2.1.0/gems/pdk-1.4.1/lib/pdk/report.rb:97:in `each'
              from /opt/puppetlabs/pdk/private/ruby/2.1.9/lib/ruby/gems/2.1.0/gems/pdk-1.4.1/lib/pdk/report.rb:97:in `write_text'
              from /opt/puppetlabs/pdk/private/ruby/2.1.9/lib/ruby/gems/2.1.0/gems/pdk-1.4.1/lib/pdk/cli/test/unit.rb:63:in `block (3 levels) in <module:CLI>'
              from /opt/puppetlabs/pdk/private/ruby/2.1.9/lib/ruby/gems/2.1.0/gems/pdk-1.4.1/lib/pdk/cli/test/unit.rb:62:in `each'
              from /opt/puppetlabs/pdk/private/ruby/2.1.9/lib/ruby/gems/2.1.0/gems/pdk-1.4.1/lib/pdk/cli/test/unit.rb:62:in `block (2 levels) in <module:CLI>'
              from /opt/puppetlabs/pdk/private/ruby/2.1.9/lib/ruby/gems/2.1.0/gems/cri-2.9.1/lib/cri/command.rb:319:in `call'
              from /opt/puppetlabs/pdk/private/ruby/2.1.9/lib/ruby/gems/2.1.0/gems/cri-2.9.1/lib/cri/command.rb:319:in `run_this'
              from /opt/puppetlabs/pdk/private/ruby/2.1.9/lib/ruby/gems/2.1.0/gems/cri-2.9.1/lib/cri/command.rb:264:in `run'
              from /opt/puppetlabs/pdk/private/ruby/2.1.9/lib/ruby/gems/2.1.0/gems/cri-2.9.1/lib/cri/command.rb:282:in `run'
              from /opt/puppetlabs/pdk/private/ruby/2.1.9/lib/ruby/gems/2.1.0/gems/cri-2.9.1/lib/cri/command.rb:282:in `run'
              from /opt/puppetlabs/pdk/private/ruby/2.1.9/lib/ruby/gems/2.1.0/gems/pdk-1.4.1/lib/pdk/cli.rb:17:in `run'
              from /opt/puppetlabs/pdk/private/ruby/2.1.9/lib/ruby/gems/2.1.0/gems/pdk-1.4.1/exe/pdk:6:in `<top (required)>'
              from /opt/puppetlabs/pdk/private/ruby/2.1.9/bin/pdk:23:in `load'
              from /opt/puppetlabs/pdk/private/ruby/2.1.9/bin/pdk:23:in `<main>'
      

        Attachments

          Issue Links

            Activity

              jsd-sla-details-panel

                People

                • Assignee:
                  tim.sharpe Tim Sharpe
                  Reporter:
                  JohnsonEarls Johnson Earls
                • Votes:
                  0 Vote for this issue
                  Watchers:
                  1 Start watching this issue

                  Dates

                  • Created:
                    Updated:
                    Resolved: