--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/rakelib/test.rake Sun May 22 00:32:07 2016 +0100
@@ -0,0 +1,138 @@
+
+desc "Run tests"
+task :'test' => :'test:all'
+
+desc "Run tests (alias for target test)"
+task :'tests' => :'test'
+
+
+task :'setup:tasks' => :'setup:tasks:test'
+
+def run_report(app, packages, report, global_opts = '', report_opts = '')
+ #run_report_st = BUILD_DIR / 'stx' / 'goodies' / 'builder' / 'reports' / 'report-runner-old.st'
+ run_report_st = BUILD_DIR / 'stx' / 'goodies' / 'builder' / 'reports' / 'report-runner.st'
+ coveragerportformat_dot_st = BUILD_DIR / 'stx' / 'goodies' / 'builder' / 'reports' / 'Builder__CoverageReportFormat.st'
+
+ report_dir = File.expand_path(REPORT_DIR)
+
+
+ if app
+ exe_dir = BUILD_DIR / app.directory
+ if win32?
+ exe = "#{app.executable}.com"
+ else
+ exe = "./#{app.executable}"
+ end
+ else
+ exe_dir = BUILD_DIR / 'stx' / 'projects' / 'smalltalk'
+ if win32?
+ exe = "stx.com"
+ else
+ exe = "./stx"
+ end
+ end
+
+ chdir exe_dir do
+
+ packages_args = ''
+ packages.each { | p | packages_args += " -p #{p}" }
+
+ if File.exist?(coveragerportformat_dot_st)
+ runner_opts = "-abortOnSEGV -I --execute #{run_report_st}"
+ else
+ runner_opts = "-I -f #{run_report_st}"
+ end
+
+
+ #sh "#{exe} -I --quick -execue f #{run_report_st} -o #{report_dir} -r #{report} -p #{pkg.name}"
+ sh "#{exe} #{runner_opts} #{global_opts} -D #{report_dir} -r #{report} #{report_opts} #{packages_args}"
+ end
+end
+
+task :'setup:tasks:test' do
+ app = project.application
+ packages = []
+ project.packages.each do | pkg |
+ if pkg.test
+ task "test:package:#{pkg.name}" => [ 'stx:goodies/builder/reports', REPORT_DIR ] do
+ if pkg.coverage
+ run_report(app, [ pkg.name ], 'Builder::TestReport', '', '--coverage')
+ else
+ run_report(app, [ pkg.name ], 'Builder::TestReport')
+ end
+ end
+ task :'test:packages' => "test:package:#{pkg.name}"
+ end
+
+ if pkg.lint
+ task "lint:package:#{pkg.name}" => [ 'stx:goodies/builder/reports', REPORT_DIR ] do
+ #puts "LINT DISABLED (because of some bug in recent SmallLint - runs out of memory)"
+ run_report(app, [ pkg.name ], 'Builder::LintReport')
+ end
+ task :'lint:packages' => "lint:package:#{pkg.name}"
+ end
+ end
+end
+
+task :'setup:tasks' => :'setup:tasks:test'
+task :'test:setup' => :'setup'
+task :'lint:setup' => :'setup'
+
+namespace :'test' do
+ task :'all' => [ :'setup', :'pre', :'main', :'post' ]
+ task :'pre'
+ task :'post'
+
+ directory REPORT_DIR
+
+ task :'setup'
+
+ task :'main' => [:'setup', :'packages' ]
+
+ task :'packages'
+end
+
+desc "Run static analysis on the code (SmallLint)"
+task :'lint' => :'lint:all'
+
+
+namespace :'lint' do
+ task :'all' => [ :'setup', :'pre', :'main', :'post' ]
+ task :'pre'
+ task :'post'
+
+ directory REPORT_DIR
+
+ task :'setup'
+
+ task :'main' => [:'setup', :'packages' ]
+
+ task :'packages'
+end
+
+
+
+task BUILD_DIR / 'stx' / 'goodies' / 'builder' / 'reports' => BUILD_DIR do
+ if File.exist?(BUILD_DIR / 'stx' / 'goodies' / 'builder' / 'reports')
+ update(:'swing:hg', 'stx/goodies/builder', :branch => 'jv')
+ else
+ checkout(:'swing:hg', 'stx/goodies/builder', :branch => 'jv')
+ end
+end
+
+#task :'compile:post' => [ :'stx:builder/hudson', :'test' ]
+
+task 'stx:goodies/builder/reports' => [ BUILD_DIR / 'stx' / 'goodies' / 'builder' / 'reports',
+ :'compile:config' ] do
+ chdir BUILD_DIR / 'stx' / 'goodies' / 'sunit' do
+ make
+ end
+ chdir BUILD_DIR / 'stx' / 'goodies' / 'builder' / 'reports' do
+ if (unix? and File.exist?("Makefile.init"))
+ make "-f" "Makefile.init"
+ else
+ make
+ end
+ end
+end
+