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-641) Make pdk bundle fully interactive #712

Merged
merged 2 commits into from
Jul 30, 2019

Conversation

scotje
Copy link
Contributor

@scotje scotje commented Jul 24, 2019

Previously, the subprocess invoked by pdk bundle had its output
streams buffered as a side effect of the subprocess infrastructure used
for other commands. Additionally, the input stream was not connected to
the subprocess at all.

This commit adds a new subclass of PDK::CLI::Exec::Command called
PDK::CLI::Exec::InteractiveCommand that bypasses all of the output
buffering, spinners, etc. that the parent class implements and instead
uses Ruby's built-in Kernel.system method to run the subprocess fully
interactively. The pdk bundle subcommand is also updated to use this
new class for invoking Bundler.

If this approach proves successful, it will likely be conditionally
extended to certain invocations of pdk test unit in a future PR.

@scotje
Copy link
Contributor Author

scotje commented Jul 24, 2019

Still need to add some unit tests for the new class but wanted to get this up for some conceptual review.

Tested the approach on macOS, Linux, and Windows and it seems to work. (Tested by adding a pry breakpoint into a spec file and then running pdk bundle exec rake spec.)

@coveralls
Copy link

coveralls commented Jul 24, 2019

Coverage Status

Coverage increased (+0.1%) to 92.065% when pulling de03313 on scotje:641_pdk_bundle_passthru into 2c34863 on puppetlabs:master.

@process = ChildProcess.build(*@argv)
@process.leader = true

@stdout = Tempfile.new('stdout').tap { |io| io.sync = true }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Warning: Tempfile doesn't set binary mode, so CRLF will be used on Windows which may not be what you want.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The stuff in lib/pdk/cli/exec/command.rb was extracted out into it's own file but pretty much unchanged from the current implementation. So this is a good thing to know but shouldn't be a regression from current behavior.

PDK::Util::RubyVersion.gem_paths_raw.map { |gem_path| File.join(gem_path, 'bin') },
package_binpath,
PDK::Util.package_install? ? PDK::Util::Git.git_paths : nil,
ENV['PATH'],
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Warning: ENV has known issues with non-ASCII characters on Windows environment variables. https://github.com/puppetlabs/puppet/blob/eb19bedb221959bd202e598401a3d29ea77950c9/spec/unit/util_spec.rb#L99-L218

Typically this comes from non-English Usernames e.g. C:\Users\jmüller

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similar to above, good thing to know but shouldn't be a regression since this is the existing implementation.

@glennsarti
Copy link
Contributor

Manually tested with cmd.exe, powershell.exe, conemu and new windows terminal. Confirmed I can use pry interactively within a bundle exec but not within `pdk test unit

scotje added 2 commits July 29, 2019 13:22
Previously, the subprocess invoked by `pdk bundle` had its output
streams buffered as a side effect of the subprocess infrastructure used
for other commands. Additionally, the input stream was not connected to
the subprocess at all.

This commit adds a new subclass of `PDK::CLI::Exec::Command` called
`PDK::CLI::Exec::InteractiveCommand` that bypasses all of the output
buffering, spinners, etc. that the parent class implements and instead
uses Ruby's built-in `Kernel.system` method to run the subprocess fully
interactively. The `pdk bundle` subcommand is also updated to use this
new class for invoking Bundler.

If this approach proves successful, it will likely be conditionally
extended to certain invocations of `pdk test unit` in a future PR.
@scotje scotje force-pushed the 641_pdk_bundle_passthru branch from 3f4e346 to de03313 Compare July 29, 2019 20:23
@scotje
Copy link
Contributor Author

scotje commented Jul 29, 2019

Updated with unit tests, I'm wondering how necessary acceptance/package tests are since it would mostly be testing that Kernel#system is behaving correctly?

@scotje
Copy link
Contributor Author

scotje commented Jul 30, 2019

We decided to separately ticket automated acceptance tests for this, so I think this is ready to merge.

Copy link
Contributor

@glennsarti glennsarti left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's mergin' time

@glennsarti glennsarti merged commit d6aabe1 into puppetlabs:master Jul 30, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants