2015-09-22 15:12:14 +00:00
|
|
|
# encoding: utf-8
|
2015-10-06 16:55:44 +00:00
|
|
|
# author: Dominik Richter
|
|
|
|
|
2015-09-22 15:12:14 +00:00
|
|
|
require_relative 'docker_run'
|
|
|
|
require_relative '../lib/vulcano'
|
|
|
|
|
|
|
|
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|
|
2015-09-22 15:21:07 +00:00
|
|
|
results = @docker.run_all do |name, container|
|
2015-09-22 15:12:14 +00:00
|
|
|
status = test_container(container, report)
|
2015-09-22 15:21:07 +00:00
|
|
|
status.all? ? nil : "Failed to run tests on #{name}"
|
2015-09-22 15:12:14 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
# check if we were successful
|
2015-09-22 15:21:07 +00:00
|
|
|
failures = results.compact
|
|
|
|
failures.each { |f| puts "\033[31;1m#{f}\033[0m\n\n" }
|
2015-09-22 15:12:14 +00:00
|
|
|
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 = Vulcano::Runner.new(opts)
|
|
|
|
runner.add_tests(@tests)
|
|
|
|
tests = runner.tests.ordered_example_groups
|
|
|
|
tests.map { |g| g.run(report) }
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
DockerTester.new(tests).run
|