Sha256: 6d866da087a3de56560675740dccc2a97858dc99e89d5d0a6d347308eab53336

Contents?: true

Size: 892 Bytes

Versions: 57

Compression:

Stored size: 892 Bytes

Contents

# frozen_string_literal: true
require 'minitest/reporters'
require 'fileutils'
require 'json'

require 'minitest/queue/test_data'

module Minitest
  module Queue
    class TestDataReporter < Minitest::Reporters::BaseReporter
      def initialize(report_path: 'log/test_data.json', base_path: nil, namespace: '')
        super({})
        @report_path = File.absolute_path(report_path)
        @base_path = base_path || Dir.pwd
        @namespace = namespace || ''
      end

      def report
        super

        result = tests.map.with_index do |test, index|
          Queue::TestData.new(test: test, index: index,
                              base_path: @base_path, namespace: @namespace).to_h
        end.to_json

        dirname = File.dirname(@report_path)
        FileUtils.mkdir_p(dirname)
        File.open(@report_path, 'w+') { |file| file << result }
      end
    end
  end
end

Version data entries

57 entries across 57 versions & 1 rubygems

Version Path
ci-queue-0.21.1 lib/minitest/queue/test_data_reporter.rb
ci-queue-0.21.0 lib/minitest/queue/test_data_reporter.rb
ci-queue-0.20.9 lib/minitest/queue/test_data_reporter.rb
ci-queue-0.20.8 lib/minitest/queue/test_data_reporter.rb
ci-queue-0.20.7 lib/minitest/queue/test_data_reporter.rb
ci-queue-0.20.6 lib/minitest/queue/test_data_reporter.rb
ci-queue-0.20.5 lib/minitest/queue/test_data_reporter.rb
ci-queue-0.20.4 lib/minitest/queue/test_data_reporter.rb
ci-queue-0.20.3 lib/minitest/queue/test_data_reporter.rb
ci-queue-0.20.2 lib/minitest/queue/test_data_reporter.rb
ci-queue-0.20.1 lib/minitest/queue/test_data_reporter.rb
ci-queue-0.20.0 lib/minitest/queue/test_data_reporter.rb
ci-queue-0.19.0 lib/minitest/queue/test_data_reporter.rb
ci-queue-0.18.0 lib/minitest/queue/test_data_reporter.rb
ci-queue-0.17.2 lib/minitest/queue/test_data_reporter.rb
ci-queue-0.17.1 lib/minitest/queue/test_data_reporter.rb
ci-queue-0.17.0 lib/minitest/queue/test_data_reporter.rb