Rakefiles: execute tests in random order
authorJan Vrany <jan.vrany@fit.cvut.cz>
Fri, 24 Aug 2018 13:34:05 +0100
changeset 250 86db38276922
parent 249 20b718d60bba
child 254 70c9861ad62f
Rakefiles: execute tests in random order As some tests are CPU bound while some others are IO bound, this should help to distribute the load more evenly in cases where multiple tests (`rake test` invocations) are run in parallel (such as on CI)
rakelib/test.rake
--- a/rakelib/test.rake	Fri Jul 06 16:35:55 2018 +0100
+++ b/rakelib/test.rake	Fri Aug 24 13:34:05 2018 +0100
@@ -84,7 +84,13 @@
 task :'setup:tasks:test' do
   $__testresults__ = []
   app = project.application
-  project.packages.each do |pkg|
+
+  # We shuffle the order of the packages by purpose.
+  # Some tests are CPU bound while some are IO bound,
+  # so this should help to distribute the load more evenly
+  # in cases where multiple tests (`rake test` invocations)
+  # are run in parallel (such as on CI)
+  project.packages.shuffle.each do |pkg|
     if pkg.test
       task "test:package:#{pkg.name}:pre"
       task "test:package:#{pkg.name}:post"
@@ -148,7 +154,7 @@
     puts
     puts 'OVERALL SUMMARY'
     puts
-    TestReportSummary::SUMMARIES.each do |test_summary|
+    (TestReportSummary::SUMMARIES.sort { | a, b | a.pkg <=> b.pkg }).each do |test_summary|
       puts "%-20s %s - %d run, %d passed, %d skipped, %d failed, %d errors" % [
         test_summary.pkg,
         test_summary.outcome,