pdk 1.7.1 → 1.8.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +37 -0
- data/lib/pdk/answer_file.rb +4 -3
- data/lib/pdk/cli.rb +3 -1
- data/lib/pdk/cli/new/module.rb +1 -0
- data/lib/pdk/cli/test/unit.rb +3 -0
- data/lib/pdk/cli/validate.rb +4 -1
- data/lib/pdk/generate/module.rb +6 -2
- data/lib/pdk/generate/puppet_object.rb +2 -1
- data/lib/pdk/module.rb +21 -0
- data/lib/pdk/module/build.rb +2 -11
- data/lib/pdk/module/convert.rb +12 -9
- data/lib/pdk/module/metadata.rb +5 -4
- data/lib/pdk/module/update_manager.rb +3 -2
- data/lib/pdk/tests/unit.rb +9 -7
- data/lib/pdk/util.rb +4 -3
- data/lib/pdk/util/bundler.rb +3 -8
- data/lib/pdk/util/filesystem.rb +12 -0
- data/lib/pdk/util/puppet_version.rb +22 -5
- data/lib/pdk/util/vendored_file.rb +4 -3
- data/lib/pdk/validate.rb +2 -1
- data/lib/pdk/validate/base_validator.rb +36 -8
- data/lib/pdk/validate/metadata_validator.rb +1 -2
- data/lib/pdk/validate/puppet/puppet_syntax.rb +4 -0
- data/lib/pdk/validate/ruby/rubocop.rb +2 -0
- data/lib/pdk/validate/tasks/metadata_lint.rb +126 -0
- data/lib/pdk/validate/tasks/name.rb +88 -0
- data/lib/pdk/validate/tasks_validator.rb +33 -0
- data/lib/pdk/version.rb +1 -1
- data/locales/pdk.pot +155 -139
- metadata +7 -3
- data/lib/pdk/validate/metadata/task_metadata_lint.rb +0 -124
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 45b3709175917e4c02f2195a9333c931393af8d4
|
4
|
+
data.tar.gz: 18e7cb21971f1e6f56906bba22bc46959724616d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fb148b8e30ac0af4974bbda5e1b379edfba820f80f7d13e803ec06d317e3feece0bd81ce59e36f9077c6a52d33c445ef41be394391fef0481581d31e13b5d718
|
7
|
+
data.tar.gz: 8a449fe30e4af21e5316d14f9f9df235c866c702eb6d9ec59b8747e342587ed60b4b7a91ab9756610f4790f75ab2ddec4ad0e3aaafceff98180bc107c0e78e9f
|
data/CHANGELOG.md
CHANGED
@@ -4,6 +4,42 @@ All changes to this repo will be documented in this file.
|
|
4
4
|
See the [release notes](https://puppet.com/docs/pdk/latest/release_notes.html) for a high-level summary.
|
5
5
|
|
6
6
|
|
7
|
+
## [v1.8.0](https://github.com/puppetlabs/pdk/tree/v1.8.0) (2018-11-27)
|
8
|
+
[Full Changelog](https://github.com/puppetlabs/pdk/compare/v1.7.1...v1.8.0)
|
9
|
+
|
10
|
+
**Implemented enhancements:**
|
11
|
+
|
12
|
+
- \(PDK-1090\) Add task name validator for existing tasks [\#598](https://github.com/puppetlabs/pdk/pull/598) ([rodjek](https://github.com/rodjek))
|
13
|
+
|
14
|
+
**Fixed bugs:**
|
15
|
+
|
16
|
+
- \(PDK-1180\) Cleanly handle a null pdk-version in metadata.json [\#599](https://github.com/puppetlabs/pdk/pull/599) ([rodjek](https://github.com/rodjek))
|
17
|
+
- \(PDK-1104\) Don't always override custom template url with default [\#597](https://github.com/puppetlabs/pdk/pull/597) ([rodjek](https://github.com/rodjek))
|
18
|
+
- \(PDK-654\) Allow rubocop to determine its own targets by default [\#594](https://github.com/puppetlabs/pdk/pull/594) ([rodjek](https://github.com/rodjek))
|
19
|
+
- \(PDK-1187\) Don't override bundler path on gem installs [\#592](https://github.com/puppetlabs/pdk/pull/592) ([rodjek](https://github.com/rodjek))
|
20
|
+
- \(PDK-547\) Ensure all PDK created files use LF line endings [\#590](https://github.com/puppetlabs/pdk/pull/590) ([rodjek](https://github.com/rodjek))
|
21
|
+
- \(PDK-1172\) Call PDK::Util::Bundler.ensure\_bundle! after module creation [\#589](https://github.com/puppetlabs/pdk/pull/589) ([rodjek](https://github.com/rodjek))
|
22
|
+
- \(PDK-1192\) Add module\_root/vendor/ to default ignored paths [\#588](https://github.com/puppetlabs/pdk/pull/588) ([rodjek](https://github.com/rodjek))
|
23
|
+
- \(PDK-1194\) Exclude plans/\*\*/\*.pp from PDK::Validate::PuppetSyntax [\#586](https://github.com/puppetlabs/pdk/pull/586) ([rodjek](https://github.com/rodjek))
|
24
|
+
- \(PDK-972\) Don't register a pending change when deleting non-existent files [\#585](https://github.com/puppetlabs/pdk/pull/585) ([rodjek](https://github.com/rodjek))
|
25
|
+
- \(PDK-1093\) Replace null values and empty data structures in metadata when converting [\#584](https://github.com/puppetlabs/pdk/pull/584) ([rodjek](https://github.com/rodjek))
|
26
|
+
- \(PDK-400\) Output the rspec run wall time in test unit summary [\#583](https://github.com/puppetlabs/pdk/pull/583) ([rodjek](https://github.com/rodjek))
|
27
|
+
- \(PDK-1200\) Fix bundle env handling with puppet-dev [\#579](https://github.com/puppetlabs/pdk/pull/579) ([bmjen](https://github.com/bmjen))
|
28
|
+
- \(PDK-925\) Exclude files that wouldn't be packaged from being validated [\#578](https://github.com/puppetlabs/pdk/pull/578) ([rodjek](https://github.com/rodjek))
|
29
|
+
|
30
|
+
**Closed issues:**
|
31
|
+
|
32
|
+
- Pdk validate should not assume that all puppet: URL require 'modules/'. [\#591](https://github.com/puppetlabs/pdk/issues/591)
|
33
|
+
- Create configuration to Overide default parameters [\#542](https://github.com/puppetlabs/pdk/issues/542)
|
34
|
+
|
35
|
+
**Merged pull requests:**
|
36
|
+
|
37
|
+
- \(maint\) Update package tests to add task name validation [\#600](https://github.com/puppetlabs/pdk/pull/600) ([bmjen](https://github.com/bmjen))
|
38
|
+
- \(maint\) Fix package tests [\#596](https://github.com/puppetlabs/pdk/pull/596) ([rodjek](https://github.com/rodjek))
|
39
|
+
- \(maint\) Add --skip-bundle-install to `pdk new module` [\#595](https://github.com/puppetlabs/pdk/pull/595) ([rodjek](https://github.com/rodjek))
|
40
|
+
- \(PDK-1208\) Raise lower bound of 'puppet' requirement for new modules [\#581](https://github.com/puppetlabs/pdk/pull/581) ([scotje](https://github.com/scotje))
|
41
|
+
- \(maint\) Bump version for dev [\#577](https://github.com/puppetlabs/pdk/pull/577) ([bmjen](https://github.com/bmjen))
|
42
|
+
|
7
43
|
## [v1.7.1](https://github.com/puppetlabs/pdk/tree/v1.7.1) (2018-10-05)
|
8
44
|
[Full Changelog](https://github.com/puppetlabs/pdk/compare/v1.7.0...v1.7.1)
|
9
45
|
|
@@ -20,6 +56,7 @@ See the [release notes](https://puppet.com/docs/pdk/latest/release_notes.html) f
|
|
20
56
|
|
21
57
|
**Merged pull requests:**
|
22
58
|
|
59
|
+
- Release Prep for 1.7.1 [\#576](https://github.com/puppetlabs/pdk/pull/576) ([bmjen](https://github.com/bmjen))
|
23
60
|
- \(maint\) Update PDK metadata defaults to include Puppet 6 [\#572](https://github.com/puppetlabs/pdk/pull/572) ([bmjen](https://github.com/bmjen))
|
24
61
|
- \(maint\) Update package tests for ruby 2.5.1 as the new default [\#571](https://github.com/puppetlabs/pdk/pull/571) ([bmjen](https://github.com/bmjen))
|
25
62
|
- Bump version to 1.8.0.pre [\#564](https://github.com/puppetlabs/pdk/pull/564) ([bmjen](https://github.com/bmjen))
|
data/lib/pdk/answer_file.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'json'
|
2
|
+
require 'pdk/util/filesystem'
|
2
3
|
|
3
4
|
module PDK
|
4
5
|
# Singleton accessor to the current answer file being used by the PDK.
|
@@ -21,6 +22,8 @@ module PDK
|
|
21
22
|
attr_reader :answers
|
22
23
|
attr_reader :answer_file_path
|
23
24
|
|
25
|
+
include PDK::Util::Filesystem
|
26
|
+
|
24
27
|
# Initialises the AnswerFile object, which stores the responses to certain
|
25
28
|
# interactive questions.
|
26
29
|
#
|
@@ -107,9 +110,7 @@ module PDK
|
|
107
110
|
def save_to_disk
|
108
111
|
FileUtils.mkdir_p(File.dirname(answer_file_path))
|
109
112
|
|
110
|
-
|
111
|
-
answer_file.puts JSON.pretty_generate(answers)
|
112
|
-
end
|
113
|
+
write_file(answer_file_path, JSON.pretty_generate(answers))
|
113
114
|
rescue SystemCallError, IOError => e
|
114
115
|
raise PDK::CLI::FatalError, _("Unable to write '%{file}': %{msg}") % {
|
115
116
|
file: answer_file_path,
|
data/lib/pdk/cli.rb
CHANGED
@@ -39,7 +39,9 @@ module PDK::CLI
|
|
39
39
|
end
|
40
40
|
|
41
41
|
def self.template_url_option(dsl)
|
42
|
-
|
42
|
+
desc = _('Specifies the URL to the template to use when creating new modules or classes. (default: %{default_url})') % { default_url: PDK::Util.default_template_url }
|
43
|
+
|
44
|
+
dsl.option nil, 'template-url', desc, argument: :required
|
43
45
|
end
|
44
46
|
|
45
47
|
def self.skip_interview_option(dsl)
|
data/lib/pdk/cli/new/module.rb
CHANGED
@@ -10,6 +10,7 @@ module PDK::CLI
|
|
10
10
|
|
11
11
|
option nil, 'license', _('Specifies the license this module is written under. ' \
|
12
12
|
"This should be a identifier from https://spdx.org/licenses/. Common values are 'Apache-2.0', 'MIT', or 'proprietary'."), argument: :required
|
13
|
+
option nil, 'skip-bundle-install', _('Do not automatically run `bundle install` after creating the module.'), hidden: true
|
13
14
|
|
14
15
|
run do |opts, args, _cmd|
|
15
16
|
require 'pdk/generate/module'
|
data/lib/pdk/cli/test/unit.rb
CHANGED
@@ -70,6 +70,9 @@ module PDK::CLI
|
|
70
70
|
puppet_env = PDK::CLI::Util.puppet_from_opts_or_env(opts)
|
71
71
|
PDK::Util::PuppetVersion.fetch_puppet_dev if opts.key?(:'puppet-dev')
|
72
72
|
PDK::Util::RubyVersion.use(puppet_env[:ruby_version])
|
73
|
+
|
74
|
+
opts.merge!(puppet_env[:gemset])
|
75
|
+
|
73
76
|
PDK::Util::Bundler.ensure_bundle!(puppet_env[:gemset])
|
74
77
|
|
75
78
|
exit_code = PDK::Test::Unit.invoke(report, opts)
|
data/lib/pdk/cli/validate.rb
CHANGED
@@ -6,7 +6,7 @@ module PDK::CLI
|
|
6
6
|
usage _('validate [validators] [options] [targets]')
|
7
7
|
summary _('Run static analysis tests.')
|
8
8
|
description _(
|
9
|
-
"Run metadata, Puppet, or
|
9
|
+
"Run metadata, Puppet, Ruby, or Tasks validation.\n\n" \
|
10
10
|
'[validators] is an optional comma-separated list of validators to use. ' \
|
11
11
|
'If not specified, all validators are used. ' \
|
12
12
|
"Note that when using PowerShell, the list of validators must be enclosed in single quotes.\n\n" \
|
@@ -91,6 +91,9 @@ module PDK::CLI
|
|
91
91
|
puppet_env = PDK::CLI::Util.puppet_from_opts_or_env(opts)
|
92
92
|
PDK::Util::PuppetVersion.fetch_puppet_dev if opts.key?(:'puppet-dev')
|
93
93
|
PDK::Util::RubyVersion.use(puppet_env[:ruby_version])
|
94
|
+
|
95
|
+
options.merge!(puppet_env[:gemset])
|
96
|
+
|
94
97
|
PDK::Util::Bundler.ensure_bundle!(puppet_env[:gemset])
|
95
98
|
|
96
99
|
exit_code = 0
|
data/lib/pdk/generate/module.rb
CHANGED
@@ -17,6 +17,8 @@ require 'pdk/util/version'
|
|
17
17
|
module PDK
|
18
18
|
module Generate
|
19
19
|
class Module
|
20
|
+
extend PDK::Util::Filesystem
|
21
|
+
|
20
22
|
def self.validate_options(opts)
|
21
23
|
unless PDK::CLI::Util::OptionValidator.valid_module_name?(opts[:module_name])
|
22
24
|
error_msg = _(
|
@@ -40,7 +42,7 @@ module PDK
|
|
40
42
|
|
41
43
|
begin
|
42
44
|
test_file = File.join(parent_dir, '.pdk-test-writable')
|
43
|
-
|
45
|
+
write_file(test_file, 'This file was created by the Puppet Development Kit to test if this folder was writable, you can safely remove this file.')
|
44
46
|
FileUtils.rm_f(test_file)
|
45
47
|
rescue Errno::EACCES
|
46
48
|
raise PDK::CLI::FatalError, _("You do not have permission to write to '%{parent_dir}'") % {
|
@@ -59,7 +61,7 @@ module PDK
|
|
59
61
|
templates.render do |file_path, file_content|
|
60
62
|
file = Pathname.new(temp_target_dir) + file_path
|
61
63
|
file.dirname.mkpath
|
62
|
-
file
|
64
|
+
write_file(file, file_content)
|
63
65
|
end
|
64
66
|
|
65
67
|
# Add information about the template used to generate the module to the
|
@@ -84,6 +86,8 @@ module PDK
|
|
84
86
|
|
85
87
|
begin
|
86
88
|
if FileUtils.mv(temp_target_dir, target_dir)
|
89
|
+
Dir.chdir(target_dir) { PDK::Util::Bundler.ensure_bundle! } unless opts[:'skip-bundle-install']
|
90
|
+
|
87
91
|
PDK.logger.info(_('Module \'%{name}\' generated at path \'%{path}\', from template \'%{template_url}\'.') % { name: opts[:module_name], path: target_dir, template_url: template_url })
|
88
92
|
PDK.logger.info(_('In your module directory, add classes with the \'pdk new class\' command.'))
|
89
93
|
end
|
@@ -5,6 +5,7 @@ require 'pdk/logger'
|
|
5
5
|
require 'pdk/module/metadata'
|
6
6
|
require 'pdk/module/templatedir'
|
7
7
|
require 'pdk/template_file'
|
8
|
+
require 'pdk/util/filesystem'
|
8
9
|
|
9
10
|
module PDK
|
10
11
|
module Generate
|
@@ -180,7 +181,7 @@ module PDK
|
|
180
181
|
}
|
181
182
|
end
|
182
183
|
|
183
|
-
|
184
|
+
PDK::Util::Filesystem.write_file(dest_path, file_content)
|
184
185
|
rescue SystemCallError => e
|
185
186
|
raise PDK::CLI::FatalError, _("Unable to write to file '%{path}': %{message}") % {
|
186
187
|
path: dest_path,
|
data/lib/pdk/module.rb
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
require 'pathspec'
|
2
|
+
|
3
|
+
module PDK
|
4
|
+
module Module
|
5
|
+
DEFAULT_IGNORED = [
|
6
|
+
'/pkg/',
|
7
|
+
'.*',
|
8
|
+
'~*',
|
9
|
+
'/coverage',
|
10
|
+
'/checksums.json',
|
11
|
+
'/REVISION',
|
12
|
+
'/spec/fixtures/modules/',
|
13
|
+
'/vendor/',
|
14
|
+
].freeze
|
15
|
+
|
16
|
+
def default_ignored_pathspec
|
17
|
+
@default_ignored_pathspec ||= PathSpec.new(DEFAULT_IGNORED)
|
18
|
+
end
|
19
|
+
module_function :default_ignored_pathspec
|
20
|
+
end
|
21
|
+
end
|
data/lib/pdk/module/build.rb
CHANGED
@@ -3,21 +3,12 @@ require 'minitar'
|
|
3
3
|
require 'zlib'
|
4
4
|
require 'pathspec'
|
5
5
|
require 'find'
|
6
|
+
require 'pdk/module'
|
6
7
|
require 'pdk/tests/unit'
|
7
8
|
|
8
9
|
module PDK
|
9
10
|
module Module
|
10
11
|
class Build
|
11
|
-
DEFAULT_IGNORED = [
|
12
|
-
'/pkg/',
|
13
|
-
'.*',
|
14
|
-
'~*',
|
15
|
-
'/coverage',
|
16
|
-
'/checksums.json',
|
17
|
-
'/REVISION',
|
18
|
-
'/spec/fixtures/modules/',
|
19
|
-
].freeze
|
20
|
-
|
21
12
|
def self.invoke(options = {})
|
22
13
|
new(options).build
|
23
14
|
end
|
@@ -213,7 +204,7 @@ module PDK
|
|
213
204
|
ignored = ignored.add("\/#{File.basename(target_dir)}\/")
|
214
205
|
end
|
215
206
|
|
216
|
-
DEFAULT_IGNORED.each { |r| ignored.add(r) }
|
207
|
+
PDK::Module::DEFAULT_IGNORED.each { |r| ignored.add(r) }
|
217
208
|
|
218
209
|
ignored
|
219
210
|
end
|
data/lib/pdk/module/convert.rb
CHANGED
@@ -108,19 +108,22 @@ module PDK
|
|
108
108
|
|
109
109
|
def update_metadata(metadata_path, template_metadata)
|
110
110
|
if File.file?(metadata_path)
|
111
|
-
|
112
|
-
begin
|
113
|
-
metadata = PDK::Module::Metadata.from_file(metadata_path)
|
114
|
-
new_values = PDK::Module::Metadata::DEFAULTS.reject { |key, _| metadata.data.key?(key) }
|
115
|
-
metadata.update!(new_values)
|
116
|
-
rescue ArgumentError
|
117
|
-
metadata = PDK::Generate::Module.prepare_metadata(options) unless options[:noop] # rubocop:disable Metrics/BlockNesting
|
118
|
-
end
|
119
|
-
else
|
111
|
+
unless File.readable?(metadata_path)
|
120
112
|
raise PDK::CLI::ExitWithError, _('Unable to update module metadata; %{path} exists but it is not readable.') % {
|
121
113
|
path: metadata_path,
|
122
114
|
}
|
123
115
|
end
|
116
|
+
|
117
|
+
begin
|
118
|
+
metadata = PDK::Module::Metadata.from_file(metadata_path)
|
119
|
+
new_values = PDK::Module::Metadata::DEFAULTS.select do |key, _|
|
120
|
+
!metadata.data.key?(key) || metadata.data[key].nil? ||
|
121
|
+
(key == 'requirements' && metadata.data[key].empty?)
|
122
|
+
end
|
123
|
+
metadata.update!(new_values)
|
124
|
+
rescue ArgumentError
|
125
|
+
metadata = PDK::Generate::Module.prepare_metadata(options) unless options[:noop]
|
126
|
+
end
|
124
127
|
elsif File.exist?(metadata_path)
|
125
128
|
raise PDK::CLI::ExitWithError, _('Unable to update module metadata; %{path} exists but it is not a file.') % {
|
126
129
|
path: metadata_path,
|
data/lib/pdk/module/metadata.rb
CHANGED
@@ -1,10 +1,13 @@
|
|
1
1
|
require 'json'
|
2
|
+
require 'pdk/util/filesystem'
|
2
3
|
|
3
4
|
module PDK
|
4
5
|
module Module
|
5
6
|
class Metadata
|
6
7
|
attr_accessor :data
|
7
8
|
|
9
|
+
include PDK::Util::Filesystem
|
10
|
+
|
8
11
|
OPERATING_SYSTEMS = {
|
9
12
|
'RedHat based Linux' => [
|
10
13
|
{
|
@@ -77,7 +80,7 @@ module PDK
|
|
77
80
|
OPERATING_SYSTEMS[os_name]
|
78
81
|
}.flatten,
|
79
82
|
'requirements' => [
|
80
|
-
{ 'name' => 'puppet', 'version_requirement' => '>= 4.
|
83
|
+
{ 'name' => 'puppet', 'version_requirement' => '>= 4.10.0 < 7.0.0' },
|
81
84
|
],
|
82
85
|
}.freeze
|
83
86
|
|
@@ -120,9 +123,7 @@ module PDK
|
|
120
123
|
end
|
121
124
|
|
122
125
|
def write!(path)
|
123
|
-
|
124
|
-
file.puts to_json
|
125
|
-
end
|
126
|
+
write_file(path, to_json)
|
126
127
|
end
|
127
128
|
|
128
129
|
def forge_ready?
|
@@ -3,6 +3,7 @@ require 'diff/lcs/hunk'
|
|
3
3
|
require 'English'
|
4
4
|
require 'fileutils'
|
5
5
|
require 'set'
|
6
|
+
require 'pdk/util/filesystem'
|
6
7
|
|
7
8
|
module PDK
|
8
9
|
module Module
|
@@ -48,7 +49,7 @@ module PDK
|
|
48
49
|
|
49
50
|
{
|
50
51
|
added: @added_files,
|
51
|
-
removed: @removed_files,
|
52
|
+
removed: @removed_files.select { |f| File.exist?(f) },
|
52
53
|
modified: @diff_cache.reject { |_, value| value.nil? },
|
53
54
|
}
|
54
55
|
end
|
@@ -148,7 +149,7 @@ module PDK
|
|
148
149
|
def write_file(path, content)
|
149
150
|
FileUtils.mkdir_p(File.dirname(path))
|
150
151
|
PDK.logger.debug(_("writing '%{path}'") % { path: path })
|
151
|
-
|
152
|
+
PDK::Util::Filesystem.write_file(path, content)
|
152
153
|
rescue Errno::EACCES
|
153
154
|
raise PDK::CLI::ExitWithError, _("You do not have permission to write to '%{path}'") % { path: path }
|
154
155
|
end
|
data/lib/pdk/tests/unit.rb
CHANGED
@@ -69,8 +69,11 @@ module PDK
|
|
69
69
|
setup
|
70
70
|
|
71
71
|
tests = options.fetch(:tests)
|
72
|
+
|
73
|
+
environment = { 'CI_SPEC_OPTIONS' => '--format j' }
|
74
|
+
environment['PUPPET_GEM_VERSION'] = options[:puppet] if options[:puppet]
|
72
75
|
spinner_msg = options.key?(:parallel) ? _('Running unit tests in parallel.') : _('Running unit tests.')
|
73
|
-
result = rake(cmd(tests, options), spinner_msg,
|
76
|
+
result = rake(cmd(tests, options), spinner_msg, environment)
|
74
77
|
|
75
78
|
json_result = if options.key?(:parallel)
|
76
79
|
PDK::Util.find_all_json_in(result[:stdout])
|
@@ -85,16 +88,16 @@ module PDK
|
|
85
88
|
|
86
89
|
raise PDK::CLI::FatalError, _('Unit test output did not contain a valid JSON result: %{output}') % { output: result[:stdout] } if json_result.nil? || json_result.empty?
|
87
90
|
|
88
|
-
json_result = merge_json_results(json_result
|
91
|
+
json_result = merge_json_results(json_result) if options.key?(:parallel)
|
89
92
|
|
90
|
-
parse_output(report, json_result)
|
93
|
+
parse_output(report, json_result, result[:duration])
|
91
94
|
|
92
95
|
result[:exit_code]
|
93
96
|
ensure
|
94
97
|
tear_down if options[:'clean-fixtures']
|
95
98
|
end
|
96
99
|
|
97
|
-
def self.parse_output(report, json_data)
|
100
|
+
def self.parse_output(report, json_data, duration)
|
98
101
|
# Output messages to stderr.
|
99
102
|
json_data['messages'] && json_data['messages'].each { |msg| $stderr.puts msg }
|
100
103
|
|
@@ -137,13 +140,13 @@ module PDK
|
|
137
140
|
# TODO: standardize summary output
|
138
141
|
$stderr.puts ' ' << _('Evaluated %{total} tests in %{duration} seconds: %{failures} failures, %{pending} pending.') % {
|
139
142
|
total: json_data['summary']['example_count'],
|
140
|
-
duration:
|
143
|
+
duration: duration,
|
141
144
|
failures: json_data['summary']['failure_count'],
|
142
145
|
pending: json_data['summary']['pending_count'],
|
143
146
|
}
|
144
147
|
end
|
145
148
|
|
146
|
-
def self.merge_json_results(json_data
|
149
|
+
def self.merge_json_results(json_data)
|
147
150
|
merged_json_result = {}
|
148
151
|
|
149
152
|
# Merge messages
|
@@ -164,7 +167,6 @@ module PDK
|
|
164
167
|
|
165
168
|
# Merge summaries
|
166
169
|
summary_hash = {
|
167
|
-
'duration' => duration,
|
168
170
|
'example_count' => 0,
|
169
171
|
'failure_count' => 0,
|
170
172
|
'pending_count' => 0,
|
data/lib/pdk/util.rb
CHANGED
@@ -4,6 +4,7 @@ require 'tempfile'
|
|
4
4
|
require 'pdk/util/version'
|
5
5
|
require 'pdk/util/windows'
|
6
6
|
require 'pdk/util/vendored_file'
|
7
|
+
require 'pdk/util/filesystem'
|
7
8
|
|
8
9
|
module PDK
|
9
10
|
module Util
|
@@ -256,10 +257,10 @@ module PDK
|
|
256
257
|
def module_pdk_version
|
257
258
|
metadata = module_metadata
|
258
259
|
|
259
|
-
if
|
260
|
-
metadata['pdk-version'].split.first
|
261
|
-
else
|
260
|
+
if metadata.nil? || metadata.fetch('pdk-version', nil).nil?
|
262
261
|
nil
|
262
|
+
else
|
263
|
+
metadata['pdk-version'].split.first
|
263
264
|
end
|
264
265
|
rescue ArgumentError => e
|
265
266
|
PDK.logger.error(e)
|
data/lib/pdk/util/bundler.rb
CHANGED
@@ -46,8 +46,9 @@ module PDK
|
|
46
46
|
bundle.update_lock!(with: gem_overrides, local: all_deps_available)
|
47
47
|
|
48
48
|
# If there are missing dependencies after updating the lockfile, let `bundle install`
|
49
|
-
# go out and get them.
|
50
|
-
|
49
|
+
# go out and get them. If the specified puppet gem version points to a remote location
|
50
|
+
# or local filepath, then run bundle install as well.
|
51
|
+
if !bundle.installed? || (gem_overrides[:puppet] && gem_overrides[:puppet].start_with?('file://', 'git://', 'https://'))
|
51
52
|
bundle.install!(gem_overrides)
|
52
53
|
end
|
53
54
|
|
@@ -96,7 +97,6 @@ module PDK
|
|
96
97
|
PDK.logger.debug(_('Checking for missing Gemfile dependencies.'))
|
97
98
|
|
98
99
|
argv = ['check', "--gemfile=#{gemfile}", '--dry-run']
|
99
|
-
argv << "--path=#{bundle_cachedir}" unless PDK::Util.package_install?
|
100
100
|
|
101
101
|
cmd = bundle_command(*argv).tap do |c|
|
102
102
|
c.update_environment(gemfile_env(gem_overrides)) unless gem_overrides.empty?
|
@@ -191,7 +191,6 @@ module PDK
|
|
191
191
|
def install!(gem_overrides = {})
|
192
192
|
argv = ['install', "--gemfile=#{gemfile}"]
|
193
193
|
argv << '-j4' unless Gem.win_platform? && Gem::Version.new(PDK::Util::RubyVersion.active_ruby_version) < Gem::Version.new('2.3.5')
|
194
|
-
argv << "--path=#{bundle_cachedir}" unless PDK::Util.package_install?
|
195
194
|
|
196
195
|
cmd = bundle_command(*argv).tap do |c|
|
197
196
|
c.add_spinner(_('Installing missing Gemfile dependencies.'))
|
@@ -248,10 +247,6 @@ module PDK
|
|
248
247
|
c.context = :module
|
249
248
|
end
|
250
249
|
end
|
251
|
-
|
252
|
-
def bundle_cachedir
|
253
|
-
@bundle_cachedir ||= PDK::Util.package_install? ? PDK::Util.package_cachedir : File.join(PDK::Util.cachedir)
|
254
|
-
end
|
255
250
|
end
|
256
251
|
end
|
257
252
|
end
|