diff --git a/Gemfile b/Gemfile index 1eb3a77223..1d38f8ccb2 100644 --- a/Gemfile +++ b/Gemfile @@ -113,6 +113,7 @@ group :development, :test do gem "i18n-tasks" gem "spring" gem "puma" + gem "open3", "~> 0.1.1" end group :test do diff --git a/Gemfile.lock b/Gemfile.lock index e3d9cc8bd7..fbec1fb396 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -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) @@ -572,6 +573,7 @@ DEPENDENCIES minitest-stub_any_instance mocha net-ldap + open3 (~> 0.1.1) paper_trail paranoia pg (~> 1.1) diff --git a/lib/tasks/test.rake b/lib/tasks/test.rake new file mode 100644 index 0000000000..96c7f58f78 --- /dev/null +++ b/lib/tasks/test.rake @@ -0,0 +1,43 @@ +# frozen_string_literal: true + +require 'open3' + +namespace :test do + modules = %w{ + gobierto_admin + gobierto_attachments + gobierto_budgets + gobierto_calendars + gobierto_cms gobierto_common + gobierto_core + gobierto_dashboards + gobierto_data + gobierto_exports + gobierto_indicators + gobierto_investments + gobierto_observatory + gobierto_people + gobierto_plans + gobierto_visualizations + gobierto_others + gobierto_engines + } + + modules.each do |mod| + desc "run test for module #{mod}.safe_constantize " + 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]}" + + 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