Class: TestExecutor

Inherits:
Object
  • Object
show all
Defined in:
lib/gitarro/backend.rb

Overview

This is a private class, which has the task to execute/run tests called by Backend

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ TestExecutor

Returns a new instance of TestExecutor.



77
78
79
80
81
82
83
# File 'lib/gitarro/backend.rb', line 77

def initialize(options)
  @options = options
  @options.each do |key, value|
    instance_variable_set("@#{key}", value)
    self.class.send(:attr_accessor, key)
  end
end

Instance Method Details

#pr_test(pr) ⇒ Object

this will clone the repo and execute the tests



86
87
88
89
90
91
92
93
94
95
96
97
# File 'lib/gitarro/backend.rb', line 86

def pr_test(pr)
  git = GitOp.new(@git_dir, pr, @options)
  # merge PR-branch to upstream branch
  git.merge_pr_totarget(pr.base.ref, pr.head.ref)
  # export variables
  export_pr_variables(pr)
  # do valid tests and store the result
  test_status = run_script
  # del branch
  git.del_pr_branch(pr.base.ref, pr.head.ref)
  test_status
end

#run_scriptObject

run validation script for validating the PR.



100
101
102
103
104
# File 'lib/gitarro/backend.rb', line 100

def run_script
  script_exists?(@test_file)
  puts `#{@test_file}`
  $CHILD_STATUS.exitstatus.nonzero? ? 'failure' : 'success'
end