Sha256: 8227ae8c5b6bc7d632aee6311e3154e47b3364e435c4a28325421a53675d2f0e

Contents?: true

Size: 960 Bytes

Versions: 6

Compression:

Stored size: 960 Bytes

Contents

class Heidi
  class Tester
    attr_reader :build, :project, :message

    def initialize(build)
      @build    = build
      @project  = build.project
      @message  = ""
    end

    def test!
      build.log(:info, "Starting tests")

      tests_failed = false

      if build.hooks[:tests].empty?
        build.log(:error, "There are no test hooks")
        @message = "There are no test hooks"
        return false
      end

      build.hooks[:tests].each do |hook|
        res = hook.perform(build.build_root)

        if res.S?.to_i != 0
          log "--- test #{hook.name} failed ---"
          log(res.err.empty? ? "No error message given" : res.err)

          @message = "tests failed"
          tests_failed = true
          break

        else
          log(res.out) unless res.out.empty?
        end
      end

      return tests_failed ? false : true
    end

    def log(string)
      build.logs["test.log"].raw(string)
    end


  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
heidi-0.1.2 lib/heidi/tester.rb
heidi-0.1.1 lib/heidi/tester.rb
heidi-0.1.0 lib/heidi/tester.rb
heidi-0.0.4 lib/heidi/tester.rb
heidi-0.0.3 lib/heidi/tester.rb
heidi-0.0.2 lib/heidi/tester.rb