Skip to content

Commit

Permalink
improve output tests module using open3 gem
Browse files Browse the repository at this point in the history
  • Loading branch information
stbnrivas committed Jun 7, 2021
1 parent 4ccd3b1 commit 47b5b5a
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ group :development, :test do
gem "i18n-tasks"
gem "spring"
gem "puma"
gem "open3", "~> 0.1.1"
end

group :test do
Expand Down
2 changes: 2 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,7 @@ GEM
racc (~> 1.4)
nori (2.6.0)
oj (3.10.16)
open3 (0.1.1)
open4 (1.3.4)
os (1.1.1)
paper_trail (12.0.0)
Expand Down Expand Up @@ -572,6 +573,7 @@ DEPENDENCIES
minitest-stub_any_instance
mocha
net-ldap
open3 (~> 0.1.1)
paper_trail
paranoia
pg (~> 1.1)
Expand Down
14 changes: 12 additions & 2 deletions lib/tasks/test.rake
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# frozen_string_literal: true

require 'open3'

namespace :test do
modules = %w{
gobierto_admin
Expand All @@ -26,8 +28,16 @@ namespace :test do
task "#{mod}".to_sym, [:fail_fast_enable] => :environment do |_t, args|
files = `find test -path '*#{mod}*' -name '*_test.rb' | grep -v '#{mod}\/gobierto_'`.gsub("\n"," ")
cmd = "bin/rails test #{files} #{"--fail-fast" if args[:fail_fast_enable]}"
puts cmd
puts `#{cmd}`

Open3::popen3(cmd) do |std_in, std_out, std_err|
std_err.each_line do |line|
puts line
end
std_out.each_line do |line|
puts line
end
end

end
end
end

0 comments on commit 47b5b5a

Please sign in to comment.