Sha256: fbb7f34b17f81a9651deee2088c73ba3de1db2bc6a77442ce530782a2949b217

Contents?: true

Size: 1004 Bytes

Versions: 1

Compression:

Stored size: 1004 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

          @message = "tests failed"
          tests_failed = true
          break

        else
          log res.out
        end
      end

      return tests_failed ? false : true
    end

    def log(string)
      File.open(
        File.join(build.root, "test.log"),
        File::CREAT|File::WRONLY|File::APPEND
      ) do |f|
        f.puts string
      end
    end


  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
heidi-0.0.1 lib/heidi/tester.rb