Sha256: 3adf9eb37dbf164b2d7c046888de3f01b0b7c71d91e3a2d1bc18e350ab551a58

Contents?: true

Size: 1.44 KB

Versions: 23

Compression:

Stored size: 1.44 KB

Contents

# frozen_string_literal: true

require 'eac_ruby_utils/core_ext'
require 'eac_ruby_utils/fs/logs'
require 'eac_ruby_utils/fs_cache'
require 'eac_ruby_utils/listable'
require 'eac_ruby_utils/on_clean_ruby_environment'

module EacRubyGemsUtils
  module Tests
    class Base
      include ::EacRubyUtils::Listable

      enable_simple_cache
      lists.add_string :result, :failed, :nonexistent, :successful

      common_constructor :gem

      def elegible?
        dependency_present? && gem.root.join(test_directory).exist?
      end

      def dependency_present?
        gem.gemfile_path.exist? && gem.gemfile_lock_gem_version(dependency_gem).present?
      end

      def name
        self.class.name.demodulize.gsub(/Test\z/, '')
      end

      def to_s
        "#{gem}[#{name}]"
      end

      private

      def logs_uncached
        ::EacRubyUtils::Fs::Logs.new.add(:stdout).add(:stderr)
      end

      def result_uncached
        return RESULT_NONEXISTENT unless elegible?

        exec_run_with_log ? RESULT_SUCCESSFUL : RESULT_FAILED
      end

      def exec_run
        gem.bundle('exec', *bundle_exec_args).chdir_root.execute
      end

      def exec_run_with_log
        r = exec_run
        logs[:stdout].write(r[:stdout])
        logs[:stderr].write(r[:stderr])
        r[:exit_code].zero?
      end

      def root_cache
        ::EacRubyUtils.fs_cache.child(gem.root.to_s.parameterize, self.class.name.parameterize)
      end
    end
  end
end

Version data entries

23 entries across 23 versions & 2 rubygems

Version Path
avm-tools-0.106.0 vendor/eac_ruby_gems_utils/lib/eac_ruby_gems_utils/tests/base.rb
avm-tools-0.105.0 vendor/eac_ruby_gems_utils/lib/eac_ruby_gems_utils/tests/base.rb
eac_ruby_gems_utils-0.9.5 lib/eac_ruby_gems_utils/tests/base.rb
avm-tools-0.104.0 vendor/eac_ruby_gems_utils/lib/eac_ruby_gems_utils/tests/base.rb
avm-tools-0.103.1 vendor/eac_ruby_gems_utils/lib/eac_ruby_gems_utils/tests/base.rb
avm-tools-0.103.0 vendor/eac_ruby_gems_utils/lib/eac_ruby_gems_utils/tests/base.rb
avm-tools-0.102.2 vendor/eac_ruby_gems_utils/lib/eac_ruby_gems_utils/tests/base.rb
avm-tools-0.102.1 vendor/eac_ruby_gems_utils/lib/eac_ruby_gems_utils/tests/base.rb
eac_ruby_gems_utils-0.9.4 lib/eac_ruby_gems_utils/tests/base.rb
avm-tools-0.102.0 vendor/eac_ruby_gems_utils/lib/eac_ruby_gems_utils/tests/base.rb
avm-tools-0.101.0 vendor/eac_ruby_gems_utils/lib/eac_ruby_gems_utils/tests/base.rb
avm-tools-0.100.0 vendor/eac_ruby_gems_utils/lib/eac_ruby_gems_utils/tests/base.rb
avm-tools-0.99.1 vendor/eac_ruby_gems_utils/lib/eac_ruby_gems_utils/tests/base.rb
eac_ruby_gems_utils-0.9.3 lib/eac_ruby_gems_utils/tests/base.rb
avm-tools-0.99.0 vendor/eac_ruby_gems_utils/lib/eac_ruby_gems_utils/tests/base.rb
avm-tools-0.98.0 vendor/eac_ruby_gems_utils/lib/eac_ruby_gems_utils/tests/base.rb
eac_ruby_gems_utils-0.9.2 lib/eac_ruby_gems_utils/tests/base.rb
avm-tools-0.97.0 vendor/eac_ruby_gems_utils/lib/eac_ruby_gems_utils/tests/base.rb
avm-tools-0.96.0 vendor/eac_ruby_gems_utils/lib/eac_ruby_gems_utils/tests/base.rb
eac_ruby_gems_utils-0.9.1 lib/eac_ruby_gems_utils/tests/base.rb