rakelib/test.rake
branchstx-8.0.0
changeset 218 327e28e1fcaf
parent 187 79e249bd767a
child 236 5a4e789cdd40
equal deleted inserted replaced
217:6a5f241a2abc 218:327e28e1fcaf
    15 
    15 
    16   def outcome
    16   def outcome
    17     (@failed > 0 or @errors > 0) ? 'FAILED' : 'PASSED'
    17     (@failed > 0 or @errors > 0) ? 'FAILED' : 'PASSED'
    18   end
    18   end
    19 
    19 
    20   # Creates a new summary for given package and report file. 
    20   # Creates a new summary for given package and report file.
    21   def initialize(pkg_name, report_file)
    21   def initialize(pkg_name, report_file)
    22     raise Exception.new("Report file does not exist! #{report_file}") unless File.exist? report_file
    22     raise Exception.new("Report file does not exist! #{report_file}") unless File.exist? report_file
    23     @pkg = pkg_name
    23     @pkg = pkg_name
    24     matches = PATTERN.match(IO.read(report_file, 512))
    24     matches = PATTERN.match(IO.read(report_file, 512))
    25 
    25 
    48   coveragerportformat_dot_st = BUILD_DIR / 'stx' / 'goodies' / 'builder' / 'reports' / 'Builder__CoverageReportFormat.st'
    48   coveragerportformat_dot_st = BUILD_DIR / 'stx' / 'goodies' / 'builder' / 'reports' / 'Builder__CoverageReportFormat.st'
    49 
    49 
    50   report_dir = File.expand_path(REPORT_DIR)
    50   report_dir = File.expand_path(REPORT_DIR)
    51   tmp_dir = File.expand_path(TMP_DIR)
    51   tmp_dir = File.expand_path(TMP_DIR)
    52 
    52 
    53   # Set STX_TMPDIR environment to make sure all temporary files created by 
    53   # Set STX_TMPDIR environment to make sure all temporary files created by
    54   # Smalltalk/X goes to a local tmp directory (which should be discarded 
    54   # Smalltalk/X goes to a local tmp directory (which should be discarded
    55   # regularly). This helps to avoid garbage to heap up on Windows slaves 
    55   # regularly). This helps to avoid garbage to heap up on Windows slaves
    56   # assuming workspaces is thrown away often.
    56   # assuming workspaces is thrown away often.
    57   ENV['STX_TMPDIR'] = tmp_dir
    57   ENV['STX_TMPDIR'] = tmp_dir
    58   
    58 
    59   if app
    59   if app
    60     exe_dir = BUILD_DIR / app.directory
    60     exe_dir = BUILD_DIR / app.directory
    61     win32? ? (exe = "#{app.executable}.com") : (exe = "./#{app.executable}")
    61     win32? ? (exe = "#{app.executable}.com") : (exe = "./#{app.executable}")
    62   else
    62   else
    63     exe_dir = BUILD_DIR / 'stx' / 'projects' / 'smalltalk'
    63     exe_dir = BUILD_DIR / 'stx' / 'projects' / 'smalltalk'
    78 task :'setup:tasks:test' do
    78 task :'setup:tasks:test' do
    79   $__testresults__ = []
    79   $__testresults__ = []
    80   app = project.application
    80   app = project.application
    81   project.packages.each do |pkg|
    81   project.packages.each do |pkg|
    82     if pkg.test
    82     if pkg.test
    83       task "test:package:#{pkg.name}" => ['stx:goodies/builder/reports', REPORT_DIR] do
    83       task "test:package:#{pkg.name}:pre"
       
    84       task "test:package:#{pkg.name}:post"
       
    85       task "test:package:#{pkg.name}:main" => ['stx:goodies/builder/reports', REPORT_DIR] do
    84         report_file = File.expand_path(REPORT_DIR) / "#{pkg.name_components.join('_')}-#{BUILD_ID}-Test.xml"
    86         report_file = File.expand_path(REPORT_DIR) / "#{pkg.name_components.join('_')}-#{BUILD_ID}-Test.xml"
    85         # Sigh, sigh. On CI server, sometimes it happen that tests are simply not run. 
    87         # Sigh, sigh. On CI server, sometimes it happen that tests are simply not run.
    86         # I was not able to debug the issue anyhow, any attempt to attach a debugger,
    88         # I was not able to debug the issue anyhow, any attempt to attach a debugger,
    87         # add a debug print or run it manually failed as the problem did not manifest.
    89         # add a debug print or run it manually failed as the problem did not manifest.
    88         # 
    90         #
    89         # This is a feeble and horrible attempt to just cover up the problem by
    91         # This is a feeble and horrible attempt to just cover up the problem by
    90         # trying multiple times. I don't want to spend more time chasing issues
    92         # trying multiple times. I don't want to spend more time chasing issues
    91         # like this. Sorry. 
    93         # like this. Sorry.
    92         #
    94         #
    93         # Let's see if it helps. 
    95         # Let's see if it helps.
    94         5.times do #for i in 1..5 do
    96         5.times do #for i in 1..5 do
    95           pkg.coverage ? run_report(app, [pkg.name], TESTREPORT_CLASS, '', '--coverage') : run_report(app, [pkg.name], TESTREPORT_CLASS)
    97           pkg.coverage ? run_report(app, [pkg.name], TESTREPORT_CLASS, '', '--coverage') : run_report(app, [pkg.name], TESTREPORT_CLASS)
    96           # Extract summary from XML report and keep it. Yeah, parsing XML
    98           # Extract summary from XML report and keep it. Yeah, parsing XML
    97           # using regexps is a bad thing, but it's quick and lot less code!          
    99           # using regexps is a bad thing, but it's quick and lot less code!
    98           break if File.exist?(report_file)
   100           break if File.exist?(report_file)
    99         end
   101         end
   100         report_summary = TestReportSummary.new(pkg.name, report_file)
   102         report_summary = TestReportSummary.new(pkg.name, report_file)
   101         TestReportSummary::SUMMARIES << report_summary
   103         TestReportSummary::SUMMARIES << report_summary
   102       end
   104       end
       
   105 
       
   106       task "test:package:#{pkg.name}" => [ "test:package:#{pkg.name}:pre",
       
   107                                            "test:package:#{pkg.name}:main",
       
   108                                            "test:package:#{pkg.name}:post" ]
   103       task :'test:packages' => "test:package:#{pkg.name}"
   109       task :'test:packages' => "test:package:#{pkg.name}"
       
   110       task "#{pkg.name}:test" => "test:package:#{pkg.name}"
   104     end
   111     end
   105 
   112 
   106     if pkg.lint
   113     if pkg.lint
   107       task "lint:package:#{pkg.name}" => %W(stx:goodies/builder/reports REPORT_DIR) do
   114       task "lint:package:#{pkg.name}" => %W(stx:goodies/builder/reports REPORT_DIR) do
   108         #puts "LINT DISABLED (because of some bug in recent SmallLint - runs out of memory)"
   115         #puts "LINT DISABLED (because of some bug in recent SmallLint - runs out of memory)"