Sha256: 4b9b56295acfd123f2b0e3793871624628997f0a2ff2d03fa8b0bf072dd7470c

Contents?: true

Size: 1.08 KB

Versions: 2

Compression:

Stored size: 1.08 KB

Contents

require "rake"
require "rake/tasklib"

module Fog
  module Rake
    class TestTask < ::Rake::TaskLib
      def initialize
        desc "Run the mocked tests"
        task :test do
          ::Rake::Task[:mock_tests].invoke
        end

        task :mock_tests do
          tests(true)
        end

        task :real_tests do
          tests(false)
        end
      end

      def tests(mocked)
        Fog::Formatador.display_line
        start = Time.now.to_i
        Thread.main[:results] = []
        threads = Fog.providers.map do |key, value|
          Thread.new do
            Thread.main[:results] << {
              provider: value,
              success: sh("export FOG_MOCK=#{mocked} && bundle exec shindont +#{key}")
            }
          end
        end
        threads.each(&:join)
        Fog::Formatador.display_table(Thread.main[:results].sort { |x, y| x[:provider] <=> y[:provider] })
        Fog::Formatador.display_line("[bold]FOG_MOCK=#{mocked}[/] tests completed in [bold]#{Time.now.to_i - start}[/] seconds")
        Fog::Formatador.display_line
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
fog-core-2.6.0 lib/tasks/test_task.rb
fog-core-2.5.0 lib/tasks/test_task.rb