puppet-debugger 0.16.0 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.gitlab-ci.yml +10 -26
- data/.rubocop.yml +64 -232
- data/.rubocop_todo.yml +89 -147
- data/.ruby-version +1 -1
- data/.vscode/launch.json +15 -0
- data/CHANGELOG.md +34 -0
- data/Gemfile +7 -5
- data/README.md +29 -261
- data/Rakefile +11 -12
- data/bin/pdb +1 -1
- data/lib/awesome_print/ext/awesome_puppet.rb +10 -8
- data/lib/plugins/puppet-debugger/input_responders/benchmark.rb +5 -4
- data/lib/plugins/puppet-debugger/input_responders/classes.rb +14 -2
- data/lib/plugins/puppet-debugger/input_responders/classification.rb +4 -2
- data/lib/plugins/puppet-debugger/input_responders/commands.rb +18 -18
- data/lib/plugins/puppet-debugger/input_responders/datatypes.rb +22 -6
- data/lib/plugins/puppet-debugger/input_responders/environment.rb +4 -2
- data/lib/plugins/puppet-debugger/input_responders/exit.rb +5 -3
- data/lib/plugins/puppet-debugger/input_responders/facterdb_filter.rb +4 -2
- data/lib/plugins/puppet-debugger/input_responders/facts.rb +4 -2
- data/lib/plugins/puppet-debugger/input_responders/functions.rb +34 -32
- data/lib/plugins/puppet-debugger/input_responders/help.rb +4 -2
- data/lib/plugins/puppet-debugger/input_responders/krt.rb +4 -2
- data/lib/plugins/puppet-debugger/input_responders/play.rb +22 -24
- data/lib/plugins/puppet-debugger/input_responders/reset.rb +5 -3
- data/lib/plugins/puppet-debugger/input_responders/resources.rb +16 -7
- data/lib/plugins/puppet-debugger/input_responders/set.rb +34 -32
- data/lib/plugins/puppet-debugger/input_responders/stacktrace.rb +31 -0
- data/lib/plugins/puppet-debugger/input_responders/types.rb +6 -2
- data/lib/plugins/puppet-debugger/input_responders/vars.rb +8 -7
- data/lib/plugins/puppet-debugger/input_responders/whereami.rb +5 -3
- data/lib/puppet-debugger.rb +1 -45
- data/lib/puppet-debugger/cli.rb +130 -92
- data/lib/puppet-debugger/code/code_file.rb +13 -14
- data/lib/puppet-debugger/code/code_range.rb +5 -3
- data/lib/puppet-debugger/code/loc.rb +1 -1
- data/lib/puppet-debugger/debugger_code.rb +2 -0
- data/lib/puppet-debugger/hooks.rb +15 -16
- data/lib/puppet-debugger/input_responder_plugin.rb +54 -52
- data/lib/puppet-debugger/monkey_patches.rb +57 -0
- data/lib/puppet-debugger/plugin_test_helper.rb +9 -8
- data/lib/puppet-debugger/support.rb +27 -17
- data/lib/puppet-debugger/support/environment.rb +6 -5
- data/lib/puppet-debugger/support/errors.rb +25 -27
- data/lib/puppet-debugger/support/facts.rb +5 -5
- data/lib/puppet-debugger/support/node.rb +4 -7
- data/lib/puppet-debugger/support/scope.rb +29 -0
- data/lib/puppet-debugger/trollop.rb +38 -31
- data/lib/puppet-debugger/version.rb +1 -1
- data/lib/puppet/application/debugger.rb +151 -126
- data/output.json +1 -0
- data/puppet-debugger.gemspec +17 -15
- data/spec/awesome_print/ext/awesome_puppet_spec.rb +30 -30
- data/spec/fixtures/pe-xl-core-0.puppet.vm.json +1 -0
- data/spec/fixtures/sample_start_debugger.pp +3 -2
- data/spec/hooks_spec.rb +33 -35
- data/spec/input_responder_plugin_spec.rb +7 -6
- data/spec/input_responders/benchmark_spec.rb +3 -1
- data/spec/input_responders/classes_spec.rb +12 -13
- data/spec/input_responders/classification_spec.rb +4 -2
- data/spec/input_responders/commands_spec.rb +2 -0
- data/spec/input_responders/datatypes_spec.rb +8 -2
- data/spec/input_responders/environment_spec.rb +2 -0
- data/spec/input_responders/exit_spec.rb +9 -11
- data/spec/input_responders/facterdb_filter_spec.rb +2 -0
- data/spec/input_responders/facts_spec.rb +2 -0
- data/spec/input_responders/functions_spec.rb +30 -28
- data/spec/input_responders/help_spec.rb +5 -3
- data/spec/input_responders/krt_spec.rb +3 -1
- data/spec/input_responders/play_spec.rb +10 -20
- data/spec/input_responders/reset_spec.rb +2 -0
- data/spec/input_responders/resources_spec.rb +7 -1
- data/spec/input_responders/set_spec.rb +3 -1
- data/spec/input_responders/stacktrace_spec.rb +15 -0
- data/spec/input_responders/types_spec.rb +2 -0
- data/spec/input_responders/vars_spec.rb +4 -4
- data/spec/input_responders/whereami_spec.rb +2 -0
- data/spec/pdb_spec.rb +0 -9
- data/spec/puppet/application/debugger_spec.rb +35 -17
- data/spec/puppet_debugger_spec.rb +81 -83
- data/spec/remote_node_spec.rb +1 -5
- data/spec/spec_helper.rb +22 -18
- data/spec/support_spec.rb +3 -5
- data/test_matrix.rb +1 -1
- metadata +56 -22
| @@ -1,13 +1,11 @@ | |
| 1 | 
            +
            # frozen_string_literal: true
         | 
| 2 | 
            +
             | 
| 1 3 | 
             
            require 'spec_helper'
         | 
| 2 4 | 
             
            require 'puppet-debugger'
         | 
| 3 5 |  | 
| 4 6 | 
             
            describe :exit do
         | 
| 5 7 | 
             
              let(:args) { [] }
         | 
| 6 8 |  | 
| 7 | 
            -
              xit 'exits' do
         | 
| 8 | 
            -
                expect{plugin.run(args)}.to eq('')
         | 
| 9 | 
            -
              end
         | 
| 10 | 
            -
             | 
| 11 9 | 
             
              let(:plugin) do
         | 
| 12 10 | 
             
                instance = PuppetDebugger::InputResponders::Commands.plugin_from_command(subject.to_s).instance
         | 
| 13 11 | 
             
                instance.debugger = debugger
         | 
| @@ -26,21 +24,21 @@ describe :exit do | |
| 26 24 | 
             
                {}
         | 
| 27 25 | 
             
              end
         | 
| 28 26 |  | 
| 29 | 
            -
              it  | 
| 27 | 
            +
              it 'commands contant is an array' do
         | 
| 30 28 | 
             
                expect(plugin.class::COMMAND_WORDS).to be_a(Array)
         | 
| 31 29 | 
             
              end
         | 
| 32 30 |  | 
| 33 | 
            -
              it  | 
| 34 | 
            -
                expect(plugin.class::COMMAND_WORDS.count).to | 
| 31 | 
            +
              it 'commands must contain at least one word' do
         | 
| 32 | 
            +
                expect(plugin.class::COMMAND_WORDS.count).to be > 0
         | 
| 35 33 | 
             
              end
         | 
| 36 34 |  | 
| 37 | 
            -
              it  | 
| 35 | 
            +
              it 'summary must be a string' do
         | 
| 38 36 | 
             
                expect(plugin.class::SUMMARY).to be_a(String)
         | 
| 39 37 | 
             
              end
         | 
| 40 38 |  | 
| 41 | 
            -
              it 'implements run' do
         | 
| 42 | 
            -
             | 
| 43 | 
            -
              end
         | 
| 39 | 
            +
              # it 'implements run' do
         | 
| 40 | 
            +
              #   expect { plugin.run([]) }.not_to raise(SystemExit)
         | 
| 41 | 
            +
              # end
         | 
| 44 42 |  | 
| 45 43 | 
             
              it 'be looked up via any command words' do
         | 
| 46 44 | 
             
                plugin.class::COMMAND_WORDS.each do |word|
         | 
| @@ -1,73 +1,75 @@ | |
| 1 | 
            -
             | 
| 2 | 
            -
             | 
| 3 | 
            -
            require  | 
| 1 | 
            +
            # frozen_string_literal: true
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            require 'spec_helper'
         | 
| 4 | 
            +
            require 'puppet-debugger'
         | 
| 5 | 
            +
            require 'puppet-debugger/plugin_test_helper'
         | 
| 4 6 |  | 
| 5 7 | 
             
            describe :functions do
         | 
| 6 | 
            -
              include_examples  | 
| 8 | 
            +
              include_examples 'plugin_tests'
         | 
| 7 9 |  | 
| 8 10 | 
             
              let(:input) do
         | 
| 9 11 | 
             
                "md5('hello')"
         | 
| 10 12 | 
             
              end
         | 
| 11 13 |  | 
| 12 14 | 
             
              let(:mod_dir) do
         | 
| 13 | 
            -
                File.join(fixtures_dir,  | 
| 15 | 
            +
                File.join(fixtures_dir, 'modules', 'extlib')
         | 
| 14 16 | 
             
              end
         | 
| 15 17 |  | 
| 16 | 
            -
              it  | 
| 18 | 
            +
              it 'runs' do
         | 
| 17 19 | 
             
                expect(plugin.run).to be_a String
         | 
| 18 20 | 
             
              end
         | 
| 19 21 |  | 
| 20 | 
            -
              it  | 
| 22 | 
            +
              it 'returns functions' do
         | 
| 21 23 | 
             
                expect(plugin.function_map).to be_a Hash
         | 
| 22 24 | 
             
              end
         | 
| 23 25 |  | 
| 24 | 
            -
              it  | 
| 26 | 
            +
              it 'sorted_list' do
         | 
| 25 27 | 
             
                expect(plugin.sorted_list).to be_a Array
         | 
| 26 28 | 
             
                expect(plugin.sorted_list.first).to be_a Hash
         | 
| 27 29 | 
             
              end
         | 
| 28 30 |  | 
| 29 | 
            -
              it  | 
| 31 | 
            +
              it 'returns function names' do
         | 
| 30 32 | 
             
                expect(plugin.func_list).to be_a Array
         | 
| 31 | 
            -
                expect(plugin.func_list.find { |m| m =~ /md5/ }).to eq( | 
| 33 | 
            +
                expect(plugin.func_list.find { |m| m =~ /md5/ }).to eq('md5()')
         | 
| 32 34 | 
             
              end
         | 
| 33 35 |  | 
| 34 | 
            -
              it  | 
| 36 | 
            +
              it 'execute md5' do
         | 
| 35 37 | 
             
                debugger_output = /5d41402abc4b2a76b9719d911017c592/
         | 
| 36 38 | 
             
                debugger.handle_input("md5('hello')")
         | 
| 37 39 | 
             
                expect(output.string).to match(debugger_output)
         | 
| 38 40 | 
             
              end
         | 
| 39 41 |  | 
| 40 | 
            -
              it  | 
| 42 | 
            +
              it 'execute swapcase' do
         | 
| 41 43 | 
             
                debugger_output = /HELLO/
         | 
| 42 44 | 
             
                debugger.handle_input("swapcase('hello')")
         | 
| 43 45 | 
             
                expect(output.string).to match(debugger_output)
         | 
| 44 46 | 
             
              end
         | 
| 45 47 |  | 
| 46 | 
            -
              it  | 
| 47 | 
            -
                expect(plugin.function_obj(File.join(mod_dir,  | 
| 48 | 
            -
                   | 
| 49 | 
            -
             | 
| 50 | 
            -
             | 
| 48 | 
            +
              it '#function_obj with native function' do
         | 
| 49 | 
            +
                expect(plugin.function_obj(File.join(mod_dir, 'functions', 'dir_split.pp'))).to eq(
         | 
| 50 | 
            +
                  file: File.join(mod_dir, 'functions', 'dir_split.pp'), mod_name: 'extlib',
         | 
| 51 | 
            +
                  full_name: 'extlib::dir_split', name: 'extlib::dir_split', namespace: 'extlib',
         | 
| 52 | 
            +
                  summary: 'Splits the given directory or directories into individual paths.'
         | 
| 51 53 | 
             
                )
         | 
| 52 54 | 
             
              end
         | 
| 53 55 |  | 
| 54 | 
            -
              it  | 
| 55 | 
            -
                expect(plugin.function_obj(File.join(mod_dir,  | 
| 56 | 
            -
             | 
| 56 | 
            +
              it '#function_obj ruby v4 without namespace' do
         | 
| 57 | 
            +
                expect(plugin.function_obj(File.join(mod_dir, 'lib', 'puppet', 'functions', 'echo.rb'))).to eq(file: File.join(mod_dir, 'lib', 'puppet', 'functions', 'echo.rb'), mod_name: 'extlib',
         | 
| 58 | 
            +
                                                                                                               full_name: 'echo', name: 'echo', namespace: '', summary: 'DEPRECATED.  Use the namespaced function [`extlib::echo`](#extlibecho) instead.')
         | 
| 57 59 | 
             
              end
         | 
| 58 60 |  | 
| 59 | 
            -
              it  | 
| 60 | 
            -
                expect(plugin.function_obj(File.join(mod_dir,  | 
| 61 | 
            -
             | 
| 61 | 
            +
              it '#function_obj ruby v4 and namespace' do
         | 
| 62 | 
            +
                expect(plugin.function_obj(File.join(mod_dir, 'lib', 'puppet', 'functions', 'extlib', 'echo.rb'))).to eq(file: File.join(mod_dir, 'lib', 'puppet', 'functions', 'extlib', 'echo.rb'), mod_name: 'extlib',
         | 
| 63 | 
            +
                                                                                                                         full_name: 'extlib::echo', name: 'extlib::echo', namespace: 'extlib', summary: nil)
         | 
| 62 64 | 
             
              end
         | 
| 63 65 |  | 
| 64 | 
            -
              it  | 
| 65 | 
            -
                file,  | 
| 66 | 
            +
              it '#function_obj has puppet namespace' do
         | 
| 67 | 
            +
                file, = Puppet::Functions.method(:create_function).source_location
         | 
| 66 68 | 
             
                dir = File.dirname(file)
         | 
| 67 | 
            -
                f_obj = plugin.function_obj(File.join(dir,  | 
| 69 | 
            +
                f_obj = plugin.function_obj(File.join(dir, 'functions', 'include.rb'))
         | 
| 68 70 | 
             
                expect(f_obj[:mod_name]).to match(/puppet-.*/)
         | 
| 69 | 
            -
                expect(f_obj[:name]).to eq( | 
| 70 | 
            -
                expect(f_obj[:full_name]).to eq( | 
| 71 | 
            +
                expect(f_obj[:name]).to eq('include')
         | 
| 72 | 
            +
                expect(f_obj[:full_name]).to eq('include')
         | 
| 71 73 | 
             
                expect(f_obj[:summary]).to be_nil
         | 
| 72 74 | 
             
              end
         | 
| 73 75 | 
             
            end
         | 
| @@ -1,8 +1,10 @@ | |
| 1 | 
            +
            # frozen_string_literal: true
         | 
| 2 | 
            +
             | 
| 1 3 | 
             
            require 'spec_helper'
         | 
| 2 4 | 
             
            require 'puppet-debugger/plugin_test_helper'
         | 
| 3 5 |  | 
| 4 6 | 
             
            describe :help do
         | 
| 5 | 
            -
              include_examples  | 
| 7 | 
            +
              include_examples 'plugin_tests'
         | 
| 6 8 | 
             
              let(:args) { [] }
         | 
| 7 9 |  | 
| 8 10 | 
             
              let(:help_output) do
         | 
| @@ -23,10 +25,10 @@ describe :help do | |
| 23 25 | 
             
              end
         | 
| 24 26 |  | 
| 25 27 | 
             
              it 'show debugger version' do
         | 
| 26 | 
            -
                expect(help_output).to match(/Puppet Debugger Version: \d.\d\d?.\d | 
| 28 | 
            +
                expect(help_output).to match(/Puppet Debugger Version: \d.\d\d?.\d.*+\n/)
         | 
| 27 29 | 
             
              end
         | 
| 28 30 |  | 
| 29 31 | 
             
              it 'show created by' do
         | 
| 30 32 | 
             
                expect(help_output).to match(/Created by: NWOps <corey@nwops.io>\n/)
         | 
| 31 33 | 
             
              end
         | 
| 32 | 
            -
            end
         | 
| 34 | 
            +
            end
         | 
| @@ -1,7 +1,9 @@ | |
| 1 | 
            +
            # frozen_string_literal: true
         | 
| 2 | 
            +
             | 
| 1 3 | 
             
            require 'spec_helper'
         | 
| 2 4 | 
             
            require 'puppet-debugger/plugin_test_helper'
         | 
| 3 5 | 
             
            describe :play do
         | 
| 4 | 
            -
              include_examples  | 
| 6 | 
            +
              include_examples 'plugin_tests'
         | 
| 5 7 |  | 
| 6 8 | 
             
              describe 'convert  url' do
         | 
| 7 9 | 
             
                describe 'unsupported' do
         | 
| @@ -96,7 +98,6 @@ describe :play do | |
| 96 98 |  | 
| 97 99 | 
             
              describe 'multiple lines of input' do
         | 
| 98 100 | 
             
                before(:each) do
         | 
| 99 | 
            -
             | 
| 100 101 | 
             
                end
         | 
| 101 102 | 
             
                describe '3 lines' do
         | 
| 102 103 | 
             
                  let(:input) do
         | 
| @@ -133,16 +134,12 @@ describe :play do | |
| 133 134 | 
             
                end
         | 
| 134 135 | 
             
                describe 'multiple lines puppet code' do
         | 
| 135 136 | 
             
                  let(:input) do
         | 
| 136 | 
            -
                     | 
| 137 | 
            -
            if $osfamily {
         | 
| 138 | 
            -
             | 
| 139 | 
            -
            }
         | 
| 140 | 
            -
            $var
         | 
| 141 | 
            -
                     | 
| 142 | 
            -
                  end
         | 
| 143 | 
            -
                  xit do
         | 
| 144 | 
            -
                    plugin.play_back_string(input)
         | 
| 145 | 
            -
                    expect(output.string).to include('"3"')
         | 
| 137 | 
            +
                    <<~OUT
         | 
| 138 | 
            +
                      if $osfamily {
         | 
| 139 | 
            +
                        $var = '3'
         | 
| 140 | 
            +
                      }
         | 
| 141 | 
            +
                      $var
         | 
| 142 | 
            +
                    OUT
         | 
| 146 143 | 
             
                  end
         | 
| 147 144 | 
             
                end
         | 
| 148 145 | 
             
              end
         | 
| @@ -158,17 +155,10 @@ $var | |
| 158 155 | 
             
                let(:input) do
         | 
| 159 156 | 
             
                  "play #{file_url}"
         | 
| 160 157 | 
             
                end
         | 
| 161 | 
            -
                # requires internet and stops testing
         | 
| 162 | 
            -
                xit 'url' do
         | 
| 163 | 
            -
                  allow(debugger).to receive(:fetch_url_data).with(file_url + '.txt').and_return(File.read(fixtures_file))
         | 
| 164 | 
            -
                  debugger.handle_input(input)
         | 
| 165 | 
            -
                  expect(output.string).to match(/test/)
         | 
| 166 | 
            -
                  expect(output.string).to match(/Puppet::Type::File/)
         | 
| 167 | 
            -
                end
         | 
| 168 158 |  | 
| 169 159 | 
             
                it 'file' do
         | 
| 170 160 | 
             
                  debugger.handle_input("play #{fixtures_file}")
         | 
| 171 161 | 
             
                  expect(output.string).to match(/Puppet::Type::File/)
         | 
| 172 162 | 
             
                end
         | 
| 173 163 | 
             
              end
         | 
| 174 | 
            -
            end
         | 
| 164 | 
            +
            end
         | 
| @@ -1,13 +1,19 @@ | |
| 1 | 
            +
            # frozen_string_literal: true
         | 
| 2 | 
            +
             | 
| 1 3 | 
             
            require 'spec_helper'
         | 
| 2 4 | 
             
            require 'puppet-debugger'
         | 
| 3 5 | 
             
            require 'puppet-debugger/plugin_test_helper'
         | 
| 4 6 |  | 
| 5 7 | 
             
            describe :resources do
         | 
| 6 8 | 
             
              include_examples 'plugin_tests'
         | 
| 7 | 
            -
              let(:args) { | 
| 9 | 
            +
              let(:args) {}
         | 
| 8 10 |  | 
| 9 11 | 
             
              it 'should be able to print resources' do
         | 
| 10 12 | 
             
                debugger_output = /main/
         | 
| 11 13 | 
             
                expect(plugin.run(args)).to match(debugger_output)
         | 
| 12 14 | 
             
              end
         | 
| 15 | 
            +
             | 
| 16 | 
            +
              it 'filter resources' do
         | 
| 17 | 
            +
                expect(plugin.run(['settings'])).to match(/Settings/)
         | 
| 18 | 
            +
              end
         | 
| 13 19 | 
             
            end
         | 
| @@ -1,3 +1,5 @@ | |
| 1 | 
            +
            # frozen_string_literal: true
         | 
| 2 | 
            +
             | 
| 1 3 | 
             
            require 'spec_helper'
         | 
| 2 4 | 
             
            require 'puppet-debugger'
         | 
| 3 5 | 
             
            require 'puppet-debugger/plugin_test_helper'
         | 
| @@ -7,7 +9,7 @@ describe 'set' do | |
| 7 9 | 
             
              let(:input) do
         | 
| 8 10 | 
             
                ':set loglevel debug'
         | 
| 9 11 | 
             
              end
         | 
| 10 | 
            -
             | 
| 12 | 
            +
             | 
| 11 13 | 
             
              it 'should set the loglevel' do
         | 
| 12 14 | 
             
                debugger_output = /loglevel debug is set/
         | 
| 13 15 | 
             
                debugger.handle_input(input)
         | 
| @@ -0,0 +1,15 @@ | |
| 1 | 
            +
            # frozen_string_literal: true
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            require 'spec_helper'
         | 
| 4 | 
            +
            require 'puppet-debugger'
         | 
| 5 | 
            +
            require 'puppet-debugger/plugin_test_helper'
         | 
| 6 | 
            +
             | 
| 7 | 
            +
            describe :stacktrace do
         | 
| 8 | 
            +
              include_examples 'plugin_tests'
         | 
| 9 | 
            +
              let(:args) {}
         | 
| 10 | 
            +
             | 
| 11 | 
            +
              it 'should be able to print stacktrace' do
         | 
| 12 | 
            +
                debugger_output = /stacktrace\snot\savailable/
         | 
| 13 | 
            +
                expect(plugin.run(args)).to match(debugger_output)
         | 
| 14 | 
            +
              end
         | 
| 15 | 
            +
            end
         | 
| @@ -1,3 +1,5 @@ | |
| 1 | 
            +
            # frozen_string_literal: true
         | 
| 2 | 
            +
             | 
| 1 3 | 
             
            require 'spec_helper'
         | 
| 2 4 | 
             
            require 'puppet-debugger'
         | 
| 3 5 | 
             
            require 'puppet-debugger/plugin_test_helper'
         | 
| @@ -38,10 +40,10 @@ describe :vars do | |
| 38 40 |  | 
| 39 41 | 
             
              describe 'list variables' do
         | 
| 40 42 | 
             
                let(:input) do
         | 
| 41 | 
            -
                  <<- | 
| 43 | 
            +
                  <<-OUT
         | 
| 42 44 | 
             
                  class test( $param1 = "files", $param2 = $param1 ) {}
         | 
| 43 45 | 
             
                  include test
         | 
| 44 | 
            -
                   | 
| 46 | 
            +
                  OUT
         | 
| 45 47 | 
             
                end
         | 
| 46 48 | 
             
                it 'ls test' do
         | 
| 47 49 | 
             
                  debugger.handle_input(input)
         | 
| @@ -49,7 +51,5 @@ describe :vars do | |
| 49 51 | 
             
                  expect(out).to include('"param1"')
         | 
| 50 52 | 
             
                  expect(out).to include('"param2"')
         | 
| 51 53 | 
             
                end
         | 
| 52 | 
            -
               
         | 
| 53 | 
            -
             | 
| 54 54 | 
             
              end
         | 
| 55 55 | 
             
            end
         | 
    
        data/spec/pdb_spec.rb
    CHANGED
    
    | @@ -28,11 +28,6 @@ describe 'pdb' do | |
| 28 28 | 
             
                expect(`bundle exec bin/pdb --play #{fixtures_file} --run-once`)
         | 
| 29 29 | 
             
                  .to match(/Puppet::Type::File/)
         | 
| 30 30 | 
             
              end
         | 
| 31 | 
            -
              # xit do
         | 
| 32 | 
            -
              #   # this test does not work without internet, and I am at 30K feet right now
         | 
| 33 | 
            -
              #   expect(`bundle exec bin/pdb --play #{file_url} --run-once`)
         | 
| 34 | 
            -
              #     .to match(/Puppet::Type::File/)
         | 
| 35 | 
            -
              # end
         | 
| 36 31 |  | 
| 37 32 | 
             
              describe 'remote_node' do
         | 
| 38 33 | 
             
                let(:node_obj) do
         | 
| @@ -44,9 +39,5 @@ describe 'pdb' do | |
| 44 39 | 
             
                before :each do
         | 
| 45 40 | 
             
                  allow(PuppetDebugger).to receive(:get_remote_node).with(node_name).and_return(node_obj)
         | 
| 46 41 | 
             
                end
         | 
| 47 | 
            -
                # xit do
         | 
| 48 | 
            -
                #   expect(`echo 'vars'| bundle exec bin/pdb -n #{node_name}`)
         | 
| 49 | 
            -
                #     .to match(/server_facts/)
         | 
| 50 | 
            -
                # end
         | 
| 51 42 | 
             
              end
         | 
| 52 43 | 
             
            end
         | 
| @@ -8,12 +8,15 @@ describe Puppet::Application::Debugger do | |
| 8 8 | 
             
                Puppet::Application::Debugger.new(command_line)
         | 
| 9 9 | 
             
              end
         | 
| 10 10 |  | 
| 11 | 
            +
              # ideally, we should only be providing args in stead of mocking the options
         | 
| 12 | 
            +
              # however during a text, the options in the puppet application are not merged from
         | 
| 13 | 
            +
              # the command line opts so the args never get passed through to options
         | 
| 11 14 | 
             
              let(:args) do
         | 
| 12 15 | 
             
                []
         | 
| 13 16 | 
             
              end
         | 
| 14 17 |  | 
| 15 18 | 
             
              let(:command_line) do
         | 
| 16 | 
            -
                Puppet::Util::CommandLine.new('debugger', args)
         | 
| 19 | 
            +
                Puppet::Util::CommandLine.new('puppet', ['debugger', args].flatten)
         | 
| 17 20 | 
             
              end
         | 
| 18 21 |  | 
| 19 22 | 
             
              let(:environment) do
         | 
| @@ -53,6 +56,7 @@ describe Puppet::Application::Debugger do | |
| 53 56 | 
             
              it 'shows describtion' do
         | 
| 54 57 | 
             
                expect(debugger.help).to match(/^puppet-debugger\([^\)]+\) -- (.*)$/)
         | 
| 55 58 | 
             
              end
         | 
| 59 | 
            +
             | 
| 56 60 | 
             
              describe 'with facterdb' do
         | 
| 57 61 | 
             
                before(:each) do
         | 
| 58 62 | 
             
                end
         | 
| @@ -68,13 +72,13 @@ describe Puppet::Application::Debugger do | |
| 68 72 |  | 
| 69 73 | 
             
                describe 'can reset correctly' do
         | 
| 70 74 | 
             
                  let(:input) do
         | 
| 71 | 
            -
                     | 
| 72 | 
            -
            $var1 = 'dsfasd'
         | 
| 73 | 
            -
            $var1
         | 
| 74 | 
            -
            reset
         | 
| 75 | 
            -
            $var1 = '111111'
         | 
| 76 | 
            -
            $var1
         | 
| 77 | 
            -
                     | 
| 75 | 
            +
                    <<~OUT
         | 
| 76 | 
            +
                      $var1 = 'dsfasd'
         | 
| 77 | 
            +
                      $var1
         | 
| 78 | 
            +
                      reset
         | 
| 79 | 
            +
                      $var1 = '111111'
         | 
| 80 | 
            +
                      $var1
         | 
| 81 | 
            +
                    OUT
         | 
| 78 82 | 
             
                  end
         | 
| 79 83 |  | 
| 80 84 | 
             
                  it 'assign variable' do
         | 
| @@ -85,26 +89,40 @@ $var1 | |
| 85 89 | 
             
              end
         | 
| 86 90 |  | 
| 87 91 | 
             
              describe 'without facterdb' do
         | 
| 88 | 
            -
                before(:each) do
         | 
| 89 | 
            -
                end
         | 
| 90 92 | 
             
                it 'run md5 function' do
         | 
| 91 93 | 
             
                  allow(debugger).to receive(:options).and_return(code: "md5('sdafsd')", quiet: true, run_once: true, use_facterdb: false)
         | 
| 92 94 | 
             
                  expect { debugger.run_command }.to output(/569ebc3d91672e7d3dce25de1684d0c9/).to_stdout
         | 
| 93 95 | 
             
                end
         | 
| 96 | 
            +
             | 
| 94 97 | 
             
                it 'assign variable' do
         | 
| 95 98 | 
             
                  allow(debugger).to receive(:options).and_return(code: "$var1 = 'blah'", quiet: true, run_once: true, use_facterdb: false)
         | 
| 96 99 | 
             
                  expect { debugger.run_command }.to output(/"blah"/).to_stdout
         | 
| 97 100 | 
             
                end
         | 
| 98 101 |  | 
| 102 | 
            +
                describe 'import a catalog' do
         | 
| 103 | 
            +
                  let(:args) do
         | 
| 104 | 
            +
                    [
         | 
| 105 | 
            +
                      '--quiet', '--run_once', "--code='resources'",
         | 
| 106 | 
            +
                      "--catalog=#{File.expand_path(File.join(fixtures_dir, 'pe-xl-core-0.puppet.vm.json'))}"
         | 
| 107 | 
            +
                    ]
         | 
| 108 | 
            +
                  end
         | 
| 109 | 
            +
                  it 'list resources in catalog' do
         | 
| 110 | 
            +
                    allow(debugger).to receive(:options).and_return(code: 'resources',
         | 
| 111 | 
            +
                                                                    quiet: true, run_once: true, use_facterdb: true,
         | 
| 112 | 
            +
                                                                    catalog: File.expand_path(File.join(fixtures_dir, 'pe-xl-core-0.puppet.vm.json')))
         | 
| 113 | 
            +
                    expect { debugger.run_command }.to output(/Puppet_enterprise/).to_stdout
         | 
| 114 | 
            +
                  end
         | 
| 115 | 
            +
                end
         | 
| 116 | 
            +
             | 
| 99 117 | 
             
                describe 'can reset correctly' do
         | 
| 100 118 | 
             
                  let(:input) do
         | 
| 101 | 
            -
                     | 
| 102 | 
            -
            $var1 = 'dsfasd'
         | 
| 103 | 
            -
            $var1
         | 
| 104 | 
            -
            reset
         | 
| 105 | 
            -
            $var1 = '111111'
         | 
| 106 | 
            -
            $var1
         | 
| 107 | 
            -
                     | 
| 119 | 
            +
                    <<~OUT
         | 
| 120 | 
            +
                      $var1 = 'dsfasd'
         | 
| 121 | 
            +
                      $var1
         | 
| 122 | 
            +
                      reset
         | 
| 123 | 
            +
                      $var1 = '111111'
         | 
| 124 | 
            +
                      $var1
         | 
| 125 | 
            +
                    OUT
         | 
| 108 126 | 
             
                  end
         | 
| 109 127 |  | 
| 110 128 | 
             
                  it 'assign variable' do
         |