Rakefiles: refactored "test" targets to support "...:pre" and "...:post" hooks stx-8.0.0
authorJan Vrany <jan.vrany@fit.cvut.cz>
Thu, 18 Jan 2018 13:27:55 +0000
branchstx-8.0.0
changeset 218 327e28e1fcaf
parent 217 6a5f241a2abc
child 219 c96964104b1a
Rakefiles: refactored "test" targets to support "...:pre" and "...:post" hooks like most of others. Also create (alias) target "<package name>:test" to run tests from a command line like: rake jv:libgdbs/tests:test
rakelib/test.rake
specs/stx-jv.rbspec
--- a/rakelib/test.rake	Wed Jan 17 22:08:08 2018 +0000
+++ b/rakelib/test.rake	Thu Jan 18 13:27:55 2018 +0000
@@ -17,7 +17,7 @@
     (@failed > 0 or @errors > 0) ? 'FAILED' : 'PASSED'
   end
 
-  # Creates a new summary for given package and report file. 
+  # Creates a new summary for given package and report file.
   def initialize(pkg_name, report_file)
     raise Exception.new("Report file does not exist! #{report_file}") unless File.exist? report_file
     @pkg = pkg_name
@@ -50,12 +50,12 @@
   report_dir = File.expand_path(REPORT_DIR)
   tmp_dir = File.expand_path(TMP_DIR)
 
-  # Set STX_TMPDIR environment to make sure all temporary files created by 
-  # Smalltalk/X goes to a local tmp directory (which should be discarded 
-  # regularly). This helps to avoid garbage to heap up on Windows slaves 
+  # Set STX_TMPDIR environment to make sure all temporary files created by
+  # Smalltalk/X goes to a local tmp directory (which should be discarded
+  # regularly). This helps to avoid garbage to heap up on Windows slaves
   # assuming workspaces is thrown away often.
   ENV['STX_TMPDIR'] = tmp_dir
-  
+
   if app
     exe_dir = BUILD_DIR / app.directory
     win32? ? (exe = "#{app.executable}.com") : (exe = "./#{app.executable}")
@@ -80,27 +80,34 @@
   app = project.application
   project.packages.each do |pkg|
     if pkg.test
-      task "test:package:#{pkg.name}" => ['stx:goodies/builder/reports', REPORT_DIR] do
+      task "test:package:#{pkg.name}:pre"
+      task "test:package:#{pkg.name}:post"
+      task "test:package:#{pkg.name}:main" => ['stx:goodies/builder/reports', REPORT_DIR] do
         report_file = File.expand_path(REPORT_DIR) / "#{pkg.name_components.join('_')}-#{BUILD_ID}-Test.xml"
-        # Sigh, sigh. On CI server, sometimes it happen that tests are simply not run. 
+        # Sigh, sigh. On CI server, sometimes it happen that tests are simply not run.
         # I was not able to debug the issue anyhow, any attempt to attach a debugger,
         # add a debug print or run it manually failed as the problem did not manifest.
-        # 
+        #
         # This is a feeble and horrible attempt to just cover up the problem by
         # trying multiple times. I don't want to spend more time chasing issues
-        # like this. Sorry. 
+        # like this. Sorry.
         #
-        # Let's see if it helps. 
+        # Let's see if it helps.
         5.times do #for i in 1..5 do
           pkg.coverage ? run_report(app, [pkg.name], TESTREPORT_CLASS, '', '--coverage') : run_report(app, [pkg.name], TESTREPORT_CLASS)
           # Extract summary from XML report and keep it. Yeah, parsing XML
-          # using regexps is a bad thing, but it's quick and lot less code!          
+          # using regexps is a bad thing, but it's quick and lot less code!
           break if File.exist?(report_file)
         end
         report_summary = TestReportSummary.new(pkg.name, report_file)
         TestReportSummary::SUMMARIES << report_summary
       end
+
+      task "test:package:#{pkg.name}" => [ "test:package:#{pkg.name}:pre",
+                                           "test:package:#{pkg.name}:main",
+                                           "test:package:#{pkg.name}:post" ]
       task :'test:packages' => "test:package:#{pkg.name}"
+      task "#{pkg.name}:test" => "test:package:#{pkg.name}"
     end
 
     if pkg.lint
--- a/specs/stx-jv.rbspec	Wed Jan 17 22:08:08 2018 +0000
+++ b/specs/stx-jv.rbspec	Thu Jan 18 13:27:55 2018 +0000
@@ -244,8 +244,15 @@
       end
     end
 
-
-
+    # Normally the test package is not compiled but we have to
+    # compile programs used in tests before running the tests
+    # themselves. Sigh...
+    task "test:package:jv:libgdbs/tests:pre" do
+      chdir BUILD_DIR / 'jv' / 'libgdbs' / 'tests' do
+        sh "make -f Makefile.init mf" if unix?
+        make "testprograms"
+      end
+    end
 
     task :'install:main' => :'dist:jv-branch'