Class: DTR::TestTask
- Defined in:
- lib/dtr/raketasks.rb
Overview
Create tasks that run a set of tests with DTR injected. The TestTask will create the following targets:
[:dtr]:
Create a task that runs a set of tests by DTR master.
[DTR::PackageTask]:
Create a packaging task that will package the project into
distributable files for running test on remote machine.
All test files should be included.
Example:
require 'dtr/raketasks'
DTR::TestTask.new do |t|
t.libs << "test"
t.test_files = FileList['test/test*.rb']
t.verbose = true
t.processes = 1 # default is 1
t.package_files.include("lib/**/*") # default is FileList["**/*"]
t.package_files.include("test/**/*")
end
This task inherits from Rake::TestTask, and adds 2 DTR specific options: processes and package_files.
Instance Attribute Summary collapse
-
#package_files ⇒ Object
List of files to be included in the package for running tests on remote agent.
-
#processes ⇒ Object
The option processes is used to start an DTR agent in same directory with master process.
Instance Method Summary collapse
- #define ⇒ Object
-
#initialize(name = :dtr) ⇒ TestTask
constructor
A new instance of TestTask.
Constructor Details
#initialize(name = :dtr) ⇒ TestTask
Returns a new instance of TestTask.
70 71 72 73 74 |
# File 'lib/dtr/raketasks.rb', line 70 def initialize(name=:dtr) @processes = 1 @package_files = Rake::FileList.new super(name) end |
Instance Attribute Details
#package_files ⇒ Object
List of files to be included in the package for running tests on remote agent. The agent, which starts in same directory on same machine with master process, would skip copying codebase. The default package files is Rake::FileList[“*/”].
68 69 70 |
# File 'lib/dtr/raketasks.rb', line 68 def package_files @package_files end |
#processes ⇒ Object
The option processes is used to start an DTR agent in same directory with master process. The number of processes is the size of runners launched by agent for running tests. If processes is set to 0, then there is no agent started locally. Default is 1.
61 62 63 |
# File 'lib/dtr/raketasks.rb', line 61 def processes @processes end |
Instance Method Details
#define ⇒ Object
76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 |
# File 'lib/dtr/raketasks.rb', line 76 def define PackageTask.new do |p| p.package_files = package_files if p.package_files.empty? p.package_files.include("**/*") end end @libs.unshift DTR.lib_path lib_path = @libs.join(File::PATH_SEPARATOR) desc "Run tests with DTR injected" task @name do start_agent run_code = '' RakeFileUtils.verbose(@verbose) do run_code = rake_loader @ruby_opts.unshift( "-I#{lib_path}" ) @ruby_opts.unshift( "-w" ) if @warning ruby @ruby_opts.join(" ") + " \"#{run_code}\" " + file_list.unshift('dtr/test_unit_injection.rb').collect { |fn| "\"#{fn}\"" }.join(' ') + " #{option_list}" end end self end |