Sha256: 88db768fbb5c7e815fb6c911d8d953616cc76467e034b7d5066c9bdfd4f272f3

Contents?: true

Size: 1.03 KB

Versions: 5

Compression:

Stored size: 1.03 KB

Contents

module DeepTest
  class TestTask
    attr_writer :pattern, :processes

    def initialize(name = :deep_test)
      @name = name
      yield self if block_given?
      define
    end
    
    def define
      desc "Run '#{@name}' suite using DeepTest"
      task @name => %w[deep_test:server:start] do
        begin
          deep_test_lib = File.expand_path(File.dirname(__FILE__) + "/..")
          
          # workers
          starter = File.expand_path(File.dirname(__FILE__) + "/start_workers.rb")
          ruby "-I#{deep_test_lib} #{starter} '#{processes}' '#{pattern}'"

          # loader
          loader = File.expand_path(File.dirname(__FILE__) + "/loader.rb")
          ruby "-I#{deep_test_lib} #{loader} '#{pattern}'"
        ensure
          Rake::Task["deep_test:workers:stop"].invoke
          Rake::Task["deep_test:server:stop"].invoke
        end
      end
    end
    
    def pattern
      Dir.pwd + "/" + (@pattern || "test/**/*_test.rb")
    end
    
    def processes
      @processes ? @processes.to_i : 2
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
deep_test-1.0.0 lib/deep_test/test_task.rb
deep_test-1.0.1 lib/deep_test/test_task.rb
deep_test-1.0.2 lib/deep_test/test_task.rb
deep_test-1.0.3 lib/deep_test/test_task.rb
deep_test-1.0.4 lib/deep_test/test_task.rb