puppet-debugger 0.19.0 → 1.0.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 -27
- data/.rubocop.yml +64 -232
- data/.rubocop_todo.yml +89 -147
- data/CHANGELOG.md +12 -1
- data/Gemfile +7 -5
- data/README.md +4 -5
- 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 +4 -1
- 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 +11 -5
- data/lib/plugins/puppet-debugger/input_responders/environment.rb +4 -2
- data/lib/plugins/puppet-debugger/input_responders/exit.rb +4 -2
- 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 +5 -2
- data/lib/plugins/puppet-debugger/input_responders/set.rb +34 -32
- data/lib/plugins/puppet-debugger/input_responders/stacktrace.rb +23 -0
- data/lib/plugins/puppet-debugger/input_responders/types.rb +6 -2
- data/lib/plugins/puppet-debugger/input_responders/vars.rb +6 -5
- data/lib/plugins/puppet-debugger/input_responders/whereami.rb +5 -3
- data/lib/puppet-debugger/cli.rb +118 -91
- 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 +4 -1
- 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 +4 -4
- 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 -5
- data/lib/puppet-debugger/support/scope.rb +19 -17
- data/lib/puppet-debugger/trollop.rb +38 -31
- data/lib/puppet-debugger/version.rb +1 -1
- data/lib/puppet/application/debugger.rb +141 -135
- data/output.json +1 -0
- data/puppet-debugger.gemspec +17 -16
- data/spec/awesome_print/ext/awesome_puppet_spec.rb +30 -30
- 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 -10
- 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 +4 -3
- 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 +4 -2
- 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 +3 -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 +18 -19
- data/spec/puppet_debugger_spec.rb +81 -84
- 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 +48 -31
@@ -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
|
@@ -29,4 +31,4 @@ describe :help do
|
|
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,10 +1,12 @@
|
|
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/
|
@@ -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
|
@@ -9,7 +9,7 @@ describe Puppet::Application::Debugger do
|
|
9
9
|
end
|
10
10
|
|
11
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
|
12
|
+
# however during a text, the options in the puppet application are not merged from
|
13
13
|
# the command line opts so the args never get passed through to options
|
14
14
|
let(:args) do
|
15
15
|
[]
|
@@ -72,13 +72,13 @@ describe Puppet::Application::Debugger do
|
|
72
72
|
|
73
73
|
describe 'can reset correctly' do
|
74
74
|
let(:input) do
|
75
|
-
|
76
|
-
$var1 = 'dsfasd'
|
77
|
-
$var1
|
78
|
-
reset
|
79
|
-
$var1 = '111111'
|
80
|
-
$var1
|
81
|
-
|
75
|
+
<<~OUT
|
76
|
+
$var1 = 'dsfasd'
|
77
|
+
$var1
|
78
|
+
reset
|
79
|
+
$var1 = '111111'
|
80
|
+
$var1
|
81
|
+
OUT
|
82
82
|
end
|
83
83
|
|
84
84
|
it 'assign variable' do
|
@@ -89,7 +89,6 @@ $var1
|
|
89
89
|
end
|
90
90
|
|
91
91
|
describe 'without facterdb' do
|
92
|
-
|
93
92
|
it 'run md5 function' do
|
94
93
|
allow(debugger).to receive(:options).and_return(code: "md5('sdafsd')", quiet: true, run_once: true, use_facterdb: false)
|
95
94
|
expect { debugger.run_command }.to output(/569ebc3d91672e7d3dce25de1684d0c9/).to_stdout
|
@@ -108,22 +107,22 @@ $var1
|
|
108
107
|
]
|
109
108
|
end
|
110
109
|
it 'list resources in catalog' do
|
111
|
-
allow(debugger).to receive(:options).and_return(code:
|
112
|
-
|
113
|
-
|
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')))
|
114
113
|
expect { debugger.run_command }.to output(/Puppet_enterprise/).to_stdout
|
115
114
|
end
|
116
115
|
end
|
117
116
|
|
118
117
|
describe 'can reset correctly' do
|
119
118
|
let(:input) do
|
120
|
-
|
121
|
-
$var1 = 'dsfasd'
|
122
|
-
$var1
|
123
|
-
reset
|
124
|
-
$var1 = '111111'
|
125
|
-
$var1
|
126
|
-
|
119
|
+
<<~OUT
|
120
|
+
$var1 = 'dsfasd'
|
121
|
+
$var1
|
122
|
+
reset
|
123
|
+
$var1 = '111111'
|
124
|
+
$var1
|
125
|
+
OUT
|
127
126
|
end
|
128
127
|
|
129
128
|
it 'assign variable' do
|
@@ -1,14 +1,14 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require
|
4
|
-
require
|
5
|
-
describe
|
3
|
+
require 'spec_helper'
|
4
|
+
require 'stringio'
|
5
|
+
describe 'PuppetDebugger' do
|
6
6
|
let(:resource) do
|
7
7
|
"service{'httpd': ensure => running}"
|
8
8
|
end
|
9
9
|
|
10
10
|
before(:each) do
|
11
|
-
debugger.handle_input(
|
11
|
+
debugger.handle_input('reset')
|
12
12
|
end
|
13
13
|
|
14
14
|
let(:output) do
|
@@ -31,56 +31,54 @@ describe "PuppetDebugger" do
|
|
31
31
|
debugger.parser.evaluate_string(debugger.scope, input)
|
32
32
|
end
|
33
33
|
|
34
|
-
describe
|
35
|
-
describe
|
34
|
+
describe 'native classes' do
|
35
|
+
describe 'create' do
|
36
36
|
let(:input) do
|
37
|
-
|
37
|
+
'class testfoo {}'
|
38
38
|
end
|
39
39
|
let(:debugger_output) do
|
40
|
-
"
|
40
|
+
" => Puppet::Type::Component {\n loglevel\e[0;37m => \e[0m\e[0;36mnotice\e[0m,\n name\e[0;37m => \e[0m\e[0;33m\"Testfoo\"\e[0m,\n title\e[0;37m => \e[0m\e[0;33m\"Class[Testfoo]\"\e[0m\n}\n"
|
41
41
|
end
|
42
42
|
it do
|
43
43
|
debugger.handle_input(input)
|
44
|
-
expect(output.string).to eq(
|
45
|
-
expect(debugger.known_resource_types[:hostclasses]).to include(
|
44
|
+
expect(output.string).to eq('')
|
45
|
+
expect(debugger.known_resource_types[:hostclasses]).to include('testfoo')
|
46
46
|
end
|
47
47
|
it do
|
48
48
|
debugger.handle_input(input)
|
49
|
-
debugger.handle_input(
|
50
|
-
expect(debugger.scope.compiler.catalog.classes).to include(
|
49
|
+
debugger.handle_input('include testfoo')
|
50
|
+
expect(debugger.scope.compiler.catalog.classes).to include('testfoo')
|
51
51
|
end
|
52
52
|
it do
|
53
53
|
debugger.handle_input(input)
|
54
|
-
debugger.handle_input(
|
55
|
-
expect(debugger.scope.compiler.catalog.resources.map(&:name)).to include(
|
54
|
+
debugger.handle_input('include testfoo')
|
55
|
+
expect(debugger.scope.compiler.catalog.resources.map(&:name)).to include('Testfoo')
|
56
56
|
end
|
57
57
|
end
|
58
58
|
end
|
59
59
|
|
60
|
-
describe
|
61
|
-
describe
|
60
|
+
describe 'native definitions' do
|
61
|
+
describe 'create' do
|
62
62
|
let(:input) do
|
63
|
-
|
63
|
+
'define testfoodefine {}'
|
64
64
|
end
|
65
65
|
let(:debugger_output) do
|
66
|
-
"
|
66
|
+
" => Puppet::Type::Component {\n loglevel\e[0;37m => \e[0m\e[0;36mnotice\e[0m,\n name\e[0;37m => \e[0m\e[0;33m\"some_name\"\e[0m,\n title\e[0;37m => \e[0m\e[0;33m\"Testfoo[some_name]\"\e[0m\n}\n"
|
67
67
|
end
|
68
68
|
it do
|
69
69
|
debugger.handle_input(input)
|
70
|
-
expect(debugger.scope.environment.known_resource_types.definitions.keys).to include(
|
71
|
-
expect(output.string).to eq(
|
70
|
+
expect(debugger.scope.environment.known_resource_types.definitions.keys).to include('testfoodefine')
|
71
|
+
expect(output.string).to eq('')
|
72
72
|
end
|
73
73
|
it do
|
74
74
|
debugger.handle_input(input)
|
75
75
|
debugger.handle_input("testfoodefine{'some_name':}")
|
76
|
-
expect(
|
77
|
-
expect(debugger.scope.compiler.resources.collect(&:type)).to include("Testfoodefine")
|
78
|
-
expect(output.string).to include("\n => Puppet::Type::Component")
|
76
|
+
expect(output.string).to include(' => Puppet::Type::Component')
|
79
77
|
end
|
80
78
|
end
|
81
79
|
end
|
82
80
|
|
83
|
-
describe
|
81
|
+
describe 'key_words' do
|
84
82
|
it do
|
85
83
|
expect(debugger.key_words.count).to be >= 30 if supports_datatypes?
|
86
84
|
end
|
@@ -90,9 +88,9 @@ describe "PuppetDebugger" do
|
|
90
88
|
end
|
91
89
|
end
|
92
90
|
|
93
|
-
describe
|
91
|
+
describe 'native functions', native_functions: true do
|
94
92
|
let(:func) do
|
95
|
-
<<-
|
93
|
+
<<-OUT
|
96
94
|
function debugger::bool2http($arg) {
|
97
95
|
case $arg {
|
98
96
|
false, undef, /(?i:false)/ : { 'Off' }
|
@@ -100,165 +98,164 @@ describe "PuppetDebugger" do
|
|
100
98
|
default : { "$arg" }
|
101
99
|
}
|
102
100
|
}
|
103
|
-
|
101
|
+
OUT
|
104
102
|
end
|
105
103
|
before(:each) do
|
106
104
|
debugger.handle_input(func)
|
107
105
|
end
|
108
|
-
describe
|
109
|
-
it
|
110
|
-
expect(output.string).to eq(
|
106
|
+
describe 'create' do
|
107
|
+
it 'shows function' do
|
108
|
+
expect(output.string).to eq('')
|
111
109
|
end
|
112
110
|
end
|
113
|
-
describe
|
111
|
+
describe 'run' do
|
114
112
|
let(:input) do
|
115
|
-
<<-
|
113
|
+
<<-OUT
|
116
114
|
debugger::bool2http(false)
|
117
|
-
|
115
|
+
OUT
|
118
116
|
end
|
119
117
|
it do
|
120
118
|
debugger.handle_input(input)
|
121
|
-
expect(output.string).to include(
|
119
|
+
expect(output.string).to include('Off')
|
122
120
|
end
|
123
121
|
end
|
124
122
|
end
|
125
123
|
|
126
|
-
describe
|
127
|
-
it
|
128
|
-
expect(resource_types.first.class.to_s).to eq(
|
124
|
+
describe 'returns a array of resource_types' do
|
125
|
+
it 'returns resource type' do
|
126
|
+
expect(resource_types.first.class.to_s).to eq('Puppet::Pops::Types::PResourceType')
|
129
127
|
end
|
130
128
|
end
|
131
129
|
|
132
|
-
describe
|
130
|
+
describe 'empty' do
|
133
131
|
let(:input) do
|
134
|
-
|
132
|
+
''
|
135
133
|
end
|
136
|
-
it
|
137
|
-
debugger_output =
|
134
|
+
it 'can run' do
|
135
|
+
debugger_output = ''
|
136
|
+
debugger.handle_input(input)
|
138
137
|
debugger.handle_input(input)
|
139
138
|
expect(output.string).to eq(debugger_output)
|
140
139
|
end
|
141
|
-
describe
|
140
|
+
describe 'space' do
|
142
141
|
let(:input) do
|
143
|
-
|
142
|
+
' '
|
144
143
|
end
|
145
|
-
it
|
146
|
-
debugger_output =
|
144
|
+
it 'can run' do
|
145
|
+
debugger_output = ''
|
147
146
|
debugger.handle_input(input)
|
148
147
|
expect(output.string).to eq(debugger_output)
|
149
148
|
end
|
150
149
|
end
|
151
150
|
end
|
152
151
|
|
153
|
-
describe
|
152
|
+
describe 'variables' do
|
154
153
|
let(:input) do
|
155
154
|
"$file_path = '/tmp/test2.txt'"
|
156
155
|
end
|
157
|
-
it
|
156
|
+
it 'can process a variable' do
|
158
157
|
debugger.handle_input(input)
|
159
|
-
expect(output.string).to match(
|
158
|
+
expect(output.string).to match(%r{/tmp/test2.txt})
|
160
159
|
end
|
161
160
|
end
|
162
161
|
|
163
|
-
describe
|
162
|
+
describe 'resource' do
|
164
163
|
let(:input) do
|
165
164
|
"file{'/tmp/test2.txt': ensure => present, mode => '0755'}"
|
166
165
|
end
|
167
|
-
it
|
166
|
+
it 'can process a resource' do
|
168
167
|
debugger_output = /Puppet::Type::File/
|
169
168
|
debugger.handle_input(input)
|
170
169
|
expect(output.string).to match(debugger_output)
|
171
170
|
end
|
172
171
|
end
|
173
172
|
|
174
|
-
describe
|
173
|
+
describe 'bad input' do
|
175
174
|
let(:input) do
|
176
|
-
|
175
|
+
'Service{'
|
177
176
|
end
|
178
|
-
it
|
177
|
+
it 'can process' do
|
179
178
|
debugger.handle_input(input)
|
180
|
-
expect(output.string).to match(
|
179
|
+
expect(output.string).to match(/Syntax error at end of/)
|
181
180
|
end
|
182
181
|
end
|
183
182
|
|
184
|
-
describe
|
183
|
+
describe 'map block' do
|
185
184
|
let(:input) do
|
186
185
|
"['/tmp/test3', '/tmp/test4'].map |String $path| { file{$path: ensure => present} }"
|
187
186
|
end
|
188
|
-
it
|
187
|
+
it 'can process a each block' do
|
189
188
|
debugger_output = /Puppet::Type::File/
|
190
189
|
debugger.handle_input(input)
|
191
190
|
expect(output.string).to match(debugger_output)
|
192
191
|
end
|
193
192
|
end
|
194
193
|
|
195
|
-
describe
|
194
|
+
describe 'each block' do
|
196
195
|
let(:input) do
|
197
196
|
"['/tmp/test3', '/tmp/test4'].each |String $path| { file{$path: ensure => present} }"
|
198
197
|
end
|
199
|
-
it
|
198
|
+
it 'can process a each block' do
|
200
199
|
debugger.handle_input(input)
|
201
|
-
expect(output.string).to match(
|
202
|
-
expect(output.string).to match(
|
200
|
+
expect(output.string).to match(%r{/tmp/test3})
|
201
|
+
expect(output.string).to match(%r{/tmp/test4})
|
203
202
|
end
|
204
203
|
end
|
205
204
|
|
206
|
-
describe
|
205
|
+
describe 'string' do
|
207
206
|
let(:input) do
|
208
|
-
|
207
|
+
'String'
|
209
208
|
end
|
210
|
-
it
|
209
|
+
it 'shows type' do
|
211
210
|
debugger.handle_input(input)
|
212
|
-
expect(output.string).to eq("
|
211
|
+
expect(output.string).to eq(" => String\n")
|
213
212
|
end
|
214
213
|
end
|
215
|
-
describe
|
214
|
+
describe 'Array', type_function: true do
|
216
215
|
let(:input) do
|
217
|
-
|
216
|
+
'type([1,2,3,4])'
|
218
217
|
end
|
219
|
-
it
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
expect(output.string).to eq(out)
|
224
|
-
end
|
218
|
+
it 'shows type' do
|
219
|
+
debugger.handle_input(input)
|
220
|
+
out = " => Tuple[Integer[1, 1], Integer[2, 2], Integer[3, 3], Integer[4, 4]]\n"
|
221
|
+
expect(output.string).to eq(out)
|
225
222
|
end
|
226
223
|
end
|
227
224
|
|
228
|
-
describe
|
225
|
+
describe 'multi diemension array' do
|
229
226
|
let(:input) do
|
230
|
-
|
227
|
+
'[[1, [23,4], [22], [1,[2232]]]]'
|
231
228
|
end
|
232
229
|
|
233
|
-
it
|
230
|
+
it 'handles multi array' do
|
234
231
|
debugger.handle_input(input)
|
235
|
-
expect(output.string.count(
|
232
|
+
expect(output.string.count('[')).to be >= 17
|
236
233
|
end
|
237
234
|
end
|
238
235
|
|
239
|
-
describe
|
240
|
-
it
|
236
|
+
describe 'command_completion' do
|
237
|
+
it 'should complete on tabs' do
|
241
238
|
allow(Readline).to receive(:line_buffer).and_return("\n")
|
242
|
-
expect(debugger.command_completion.call(
|
239
|
+
expect(debugger.command_completion.call('').count).to be >= 200
|
243
240
|
end
|
244
241
|
|
245
|
-
it
|
242
|
+
it '#key_words' do
|
246
243
|
expect(debugger.key_words.count).to be >= 100
|
247
244
|
end
|
248
245
|
end
|
249
246
|
|
250
|
-
describe
|
247
|
+
describe 'error message' do
|
251
248
|
let(:input) do
|
252
249
|
"file{'/tmp/test': ensure => present, contact => 'blah'}"
|
253
250
|
end
|
254
|
-
if Gem::Version.new(Puppet.version) >= Gem::Version.new(
|
255
|
-
it
|
251
|
+
if Gem::Version.new(Puppet.version) >= Gem::Version.new('4.0')
|
252
|
+
it 'show error message' do
|
256
253
|
debugger_output = /no\ parameter\ named\ 'contact'/
|
257
254
|
debugger.handle_input(input)
|
258
255
|
expect(output.string).to match(debugger_output)
|
259
256
|
end
|
260
257
|
else
|
261
|
-
it
|
258
|
+
it 'show error message' do
|
262
259
|
debugger_output = /Invalid\ parameter\ contact/
|
263
260
|
debugger.handle_input(input)
|
264
261
|
expect(output.string).to match(debugger_output)
|