Skip to content

Commit

Permalink
worker: Redirect stderr of split command to stdout
Browse files Browse the repository at this point in the history
Usually RSpec prints errors to stderr, so we have to grab it too in
order to display a helpful error message in case this command fails.

Ideally we'd do this with popen3, but this is good enough for now,
considering #6.
  • Loading branch information
agis committed Aug 3, 2020
1 parent d502c79 commit 5cb8faf
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions lib/rspecq/worker.rb
Original file line number Diff line number Diff line change
Expand Up @@ -163,13 +163,10 @@ def reset_rspec_state!
# Their errors will be reported in the normal flow, when they're picked up
# as jobs by a worker.
def files_to_example_ids(files)
# TODO: do this programatically
cmd = "DISABLE_SPRING=1 bundle exec rspec --dry-run --format json #{files.join(' ')}"
cmd = "DISABLE_SPRING=1 bundle exec rspec --dry-run --format json #{files.join(' ')} 2>&1"
out = `#{cmd}`

if !$?.success?
puts out
puts $?.inspect
rspec_output = begin
JSON.parse(out)
rescue JSON::ParserError
Expand All @@ -184,7 +181,6 @@ def files_to_example_ids(files)
)

pp rspec_output
puts

return files
end
Expand All @@ -201,6 +197,8 @@ def elapsed(since)
Process.clock_gettime(Process::CLOCK_MONOTONIC) - since
end

# Prints msg to standard output and emits an event to Sentry, if the
# SENTRY_DSN environment variable is set.
def log_event(msg, level, additional={})
puts msg

Expand Down

0 comments on commit 5cb8faf

Please sign in to comment.