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:



290
291
292
293
294
295
296
297
298
299
300
301
# File 'lib/xctasks/test_task.rb', line 290

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.



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

def config
  @config
end

#namespace_nameObject (readonly)

Returns the value of attribute namespace_name.



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

def namespace_name
  @namespace_name
end

#prepare_dependencyObject (readonly)

Returns the value of attribute prepare_dependency.



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

def prepare_dependency
  @prepare_dependency
end

#subtasksObject

Returns the value of attribute subtasks.



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

def subtasks
  @subtasks
end

Instance Method Details

#define_rake_tasksObject



317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
# File 'lib/xctasks/test_task.rb', line 317

def define_rake_tasks
  namespace self.namespace_name do
    task (prepare_dependency ? { prepare: prepare_dependency} : :prepare ) do
      fail "No such workspace: #{workspace}" unless File.exists?(workspace)
      fail "Invalid schemes directory: #{schemes_dir}" unless schemes_dir.nil? || File.exists?(schemes_dir)
      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
      subtasks.each { |subtask| subtask.prepare }
    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:



311
312
313
314
315
# File 'lib/xctasks/test_task.rb', line 311

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