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

pdk test unit --parallel --format= with no unit tests causes PDK error #1085

Closed
seanmil opened this issue Jun 9, 2021 · 1 comment · Fixed by #1096
Closed

pdk test unit --parallel --format= with no unit tests causes PDK error #1085

seanmil opened this issue Jun 9, 2021 · 1 comment · Fixed by #1096
Assignees
Labels
bug needs-triage Newly created issue that has not been reviewed by a PDK contributor

Comments

@seanmil
Copy link
Contributor

seanmil commented Jun 9, 2021

With PDK 2.1.0, when you have a module with no unit tests and run pdk test unit with both the --parallel and --format= options then it fails with this error:

pdk test unit --parallel --format=text:test_output.txt
pdk (INFO): Using Ruby 2.7.2
pdk (INFO): Using Puppet 7.5.0
[✔] Preparing to run the unit tests.
[✔] Running unit tests in parallel.
/opt/puppetlabs/pdk/private/ruby/2.4.10/lib/ruby/gems/2.4.0/gems/pdk-2.1.0/lib/pdk/util/json_finder.rb:42:in `objects': undefined method `compact' for nil:NilClass (NoMethodError)
	from /opt/puppetlabs/pdk/private/ruby/2.4.10/lib/ruby/gems/2.4.0/gems/pdk-2.1.0/lib/pdk/util.rb:210:in `find_all_json_in'
	from /opt/puppetlabs/pdk/private/ruby/2.4.10/lib/ruby/gems/2.4.0/gems/pdk-2.1.0/lib/pdk/tests/unit.rb:115:in `invoke'
	from /opt/puppetlabs/pdk/private/ruby/2.4.10/lib/ruby/gems/2.4.0/gems/pdk-2.1.0/lib/pdk/cli/test/unit.rb:80:in `block (2 levels) in <module:CLI>'
	from /opt/puppetlabs/pdk/private/ruby/2.4.10/lib/ruby/gems/2.4.0/gems/cri-2.10.1/lib/cri/command.rb:329:in `run_this'
	from /opt/puppetlabs/pdk/private/ruby/2.4.10/lib/ruby/gems/2.4.0/gems/cri-2.10.1/lib/cri/command.rb:269:in `run'
	from /opt/puppetlabs/pdk/private/ruby/2.4.10/lib/ruby/gems/2.4.0/gems/cri-2.10.1/lib/cri/command.rb:287:in `run'
	from /opt/puppetlabs/pdk/private/ruby/2.4.10/lib/ruby/gems/2.4.0/gems/cri-2.10.1/lib/cri/command.rb:287:in `run'
	from /opt/puppetlabs/pdk/private/ruby/2.4.10/lib/ruby/gems/2.4.0/gems/pdk-2.1.0/lib/pdk/cli.rb:71:in `run'
	from /opt/puppetlabs/pdk/private/ruby/2.4.10/lib/ruby/gems/2.4.0/gems/pdk-2.1.0/exe/pdk:6:in `<top (required)>'
	from /opt/puppetlabs/pdk/private/ruby/2.4.10/bin/pdk:23:in `load'
	from /opt/puppetlabs/pdk/private/ruby/2.4.10/bin/pdk:23:in `<main>'

To Reproduce:

pdk new module testmod
cd testmod
pdk test unit --parallel --format=text:output.txt
@seanmil seanmil added bug needs-triage Newly created issue that has not been reviewed by a PDK contributor labels Jun 9, 2021
@jpogran
Copy link
Contributor

jpogran commented Jun 9, 2021

Thanks for the report! It appears that the code path expects there to be stdout to parse, but when there are no tests to run PDK outputs that on stderr. Since this path isn't checking for stderr, it fails. We'll triage this in the next planning

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug needs-triage Newly created issue that has not been reviewed by a PDK contributor
Projects
None yet
3 participants