Skip to content

Commit 08014f1

Browse files
author
RickR
committed
Use Open3.capture3 instead of Kernel.system in _run
(fixes guard#146)
1 parent b7946a0 commit 08014f1

File tree

2 files changed

+62
-56
lines changed

2 files changed

+62
-56
lines changed

lib/guard/minitest/runner.rb

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
require 'guard/minitest/inspector'
22
require 'English'
3+
require 'open3'
34

45
module Guard
56
class Minitest < Plugin
@@ -40,7 +41,7 @@ def run(paths, options = {})
4041

4142
begin
4243
status = _run_possibly_bundled_command(paths, options[:all])
43-
rescue Errno::ENOENT => e
44+
rescue RuntimeError, Errno::ENOENT => e
4445
Compat::UI.error e.message
4546
throw :task_has_failed
4647
end
@@ -124,9 +125,12 @@ def autorun?
124125

125126
def _run(*args)
126127
Compat::UI.debug "Running: #{args.join(' ')}"
127-
return $CHILD_STATUS.exitstatus unless Kernel.system(*args).nil?
128+
out, err, st = Open3.capture3(*args)
129+
return st.exitstatus unless st.exitstatus.nil?
128130

129-
fail Errno::ENOENT, args.join(' ')
131+
fail "Failed to execute #{args.join}, #{st}"
132+
rescue Errno::ENOENT => e
133+
fail Errno::ENOENT, args.join
130134
end
131135

132136
def _run_possibly_bundled_command(paths, all)

0 commit comments

Comments
 (0)