Class: XCTasks::TestTask

Inherits:
Rake::TaskLib
  • Object
show all
Extended by:
Configuration::Delegations
Includes:
Rake::DSL
Defined in:
lib/xctasks/test_task.rb

Defined Under Namespace

Classes: Configuration, ConfigurationError, Destination, Subtask

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Configuration::Delegations

extended

Constructor Details

#initialize(namespace_name = :test) {|_self| ... } ⇒ TestTask

Returns a new instance of TestTask.

Yields:

  • (_self)

Yield Parameters:

Raises:



266
267
268
269
270
271
272
273
274
275
276
277
# File 'lib/xctasks/test_task.rb', line 266

def initialize(namespace_name = :test)
  @namespace_name = namespace_name
  @config = Configuration.new
  @subtasks = []
  @namespace_name = namespace_name.kind_of?(Hash) ? namespace_name.keys.first : namespace_name
  @prepare_dependency = namespace_name.kind_of?(Hash) ? namespace_name.values.first : nil      
  
  yield self if block_given?
  raise ConfigurationError, "A workspace must be configured" unless workspace
  raise ConfigurationError, "At least one subtask must be configured" if subtasks.empty?
  define_rake_tasks
end

Instance Attribute Details

#configObject (readonly)

Returns the value of attribute config.



263
264
265
# File 'lib/xctasks/test_task.rb', line 263

def config
  @config
end

#namespace_nameObject (readonly)

Returns the value of attribute namespace_name.



263
264
265
# File 'lib/xctasks/test_task.rb', line 263

def namespace_name
  @namespace_name
end

#prepare_dependencyObject (readonly)

Returns the value of attribute prepare_dependency.



263
264
265
# File 'lib/xctasks/test_task.rb', line 263

def prepare_dependency
  @prepare_dependency
end

#subtasksObject

Returns the value of attribute subtasks.



263
264
265
# File 'lib/xctasks/test_task.rb', line 263

def subtasks
  @subtasks
end

Instance Method Details

#define_rake_tasksObject



293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
# File 'lib/xctasks/test_task.rb', line 293

def define_rake_tasks
  namespace self.namespace_name do
    task (prepare_dependency ? { prepare: prepare_dependency} : :prepare ) do
      File.truncate(output_log, 0) if output_log && File.exists?(output_log)
      if schemes_dir
        FileUtils::Verbose.mkdir_p "#{workspace}/xcshareddata/xcschemes"
        FileUtils::Verbose.cp Dir.glob("#{schemes_dir}/*.xcscheme"), "#{workspace}/xcshareddata/xcschemes"
      end
    end
    
    subtasks.each { |subtask| subtask.define_rake_tasks }
  end
  
  subtask_names = subtasks.map { |subtask| subtask.name }
  desc "Run all tests (#{subtask_names.join(', ')})"
  task namespace_name => subtask_names.map { |subtask_name| "#{namespace_name}:#{subtask_name}" } do
    XCTasks::TestReport.instance.report
  end
end

#subtask(name_options) {|subtask| ... } ⇒ Object

Yields:



287
288
289
290
291
# File 'lib/xctasks/test_task.rb', line 287

def subtask(name_options)
  subtask = Subtask.new(name_options, config)
  yield subtask if block_given?
  @subtasks << subtask
end