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

Tests hang because external command thinks it's running in interactive terminal #40

Open
kolen opened this issue Dec 4, 2018 · 1 comment

Comments

@kolen
Copy link

kolen commented Dec 4, 2018

I use minitest-mode to run tests in Rails app that has schema in SQL format, so Rails test helpers run external psql program to load that schema into test database.

psql displays its output through pager (less, more) if it detects it's running in interactive terminal and output is larger than terminal size. compilation-mode's command runner allocates pseudo terminal so psql thinks it's running in interactive terminal:

18046 ttys004    0:02.51 ruby -Ilib:test:spec test/functional/foo_controller_test.rb
18063 ttys004    0:02.41 ruby bin/rails db:test:prepare

Because it's not a real interactive terminal, I can't press a key to skip more and continue, so test process hangs forever.

(Not sure if it can be fixed without fixing underlying compilation-mode)

(The part of the problem is that compilation-mode's tty does not support TIOCGWINSZ ioctl)

Minimal example of test with this behavior (requires psql tool and postgresql server, I think you can replace it with just system "echo|less" because less also checks for interactivity):

require "minitest/autorun"

class ExternalCommandTest < Minitest::Test
  def test_external_command
    system "psql postgres -c 'select 1;'"
  end
end
@kolen
Copy link
Author

kolen commented Dec 6, 2018

  • It's possible to run M-x comint-mode and terminal becomes interactible, so the issue turned out less important. I didn't know about comint-mode before.
  • If minitest-mode added | cat at the end of command line (bundle exec … | cat), then it would disable such pagers. However, I'm not sure if such feature would be really useful and not harmful.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant