Sha256: 92d4e92e3c4c0d1d6cc75d1862c61aabc41cef4470460e729ec107d9fb9ded09

Contents?: true

Size: 1.15 KB

Versions: 40

Compression:

Stored size: 1.15 KB

Contents

# encoding: utf-8
# author: Dominik Richter

require_relative 'docker_run'
require_relative '../lib/inspec'

tests = ARGV
if tests.empty?
  puts 'Nothing to do.'
  exit 0
end

class DockerTester
  def initialize(tests)
    @tests = tests
    @docker = DockerRunner.new
  end

  def run
    puts ['Running tests:', @tests].flatten.join("\n- ")
    puts ''

    conf = RSpec.configuration
    reporter = conf.reporter
    results = nil

    # start reporting loop
    reporter.report(0) do |report|
      results = @docker.run_all do |name, container|
        status = test_container(container, report)
        status.all? ? nil : "Failed to run tests on #{name}"
      end
    end

    # check if we were successful
    failures = results.compact
    failures.each { |f| puts "\033[31;1m#{f}\033[0m\n\n" }
    failures.empty? or fail 'Test failures'
  end

  def test_container(container, report)
    puts "--> run test on docker #{container.id}"
    opts = { 'target' => "docker://#{container.id}" }
    runner = Inspec::Runner.new(opts)
    @tests.each { |test| runner.add_target(test, opts) }
    runner.tests.map { |g| g.run(report) }
  end
end

DockerTester.new(tests).run

Version data entries

40 entries across 40 versions & 1 rubygems

Version Path
inspec-0.19.1 test/docker_test.rb
inspec-0.19.0 test/docker_test.rb
inspec-0.18.0 test/docker_test.rb
inspec-0.17.1 test/docker_test.rb
inspec-0.17.0 test/docker_test.rb
inspec-0.16.4 test/docker_test.rb
inspec-0.16.3 test/docker_test.rb
inspec-0.16.2 test/docker_test.rb
inspec-0.16.1 test/docker_test.rb
inspec-0.16.0 test/docker_test.rb
inspec-0.15.0 test/docker_test.rb
inspec-0.14.8 test/docker_test.rb
inspec-0.14.7 test/docker_test.rb
inspec-0.14.6 test/docker_test.rb
inspec-0.14.5 test/docker_test.rb
inspec-0.14.4 test/docker_test.rb
inspec-0.14.3 test/docker_test.rb
inspec-0.14.2 test/docker_test.rb
inspec-0.14.1 test/docker_test.rb
inspec-0.14.0 test/docker_test.rb