arthurnn/minitest-emacs

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

Opened this issue · 1 comments

kolen commented

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 commented
  • 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.