Sha256: e9a05613bfb1b462f41b4690741a7dfb67a2b3d61e390e85be8b35c08f1ca61f

Contents?: true

Size: 1.32 KB

Versions: 6

Compression:

Stored size: 1.32 KB

Contents

# frozen_string_literal: true

require 'test_helper'
require 'appmap/config'

class IncludeExcludeTest < Minitest::Test
  include FixtureFile

  INCLUDE_EXCLUDE_FIXTURE_DIR = File.join(FIXTURE_DIR, 'includes_excludes')

  def setup
    @package_dir = AppMap::Config::PackageDir.new(File.join(INCLUDE_EXCLUDE_FIXTURE_DIR, 'lib')).tap do |c|
      c.package_name = 'include_exclude'
    end
  end

  def test_exclude_dir
    @package_dir.exclude = %w[b]
    assert_equal %w[lib/root_1.rb lib/a], normalized_children
  end

  def test_exclude_file
    @package_dir.exclude = %w[root_1.rb]
    assert_equal %w[lib/a lib/b], normalized_children
  end

  def test_exclude_subfile
    @package_dir.exclude = %w[a/a_1.rb root_1.rb b]
    assert_equal %w[lib/a], normalized_children
    assert_equal %w[lib/a/a_2.rb lib/a/x], normalize_paths(@package_dir.children.first.children.map(&:path))
  end

  def test_exclude_subdir
    @package_dir.exclude = %w[a/a_1.rb root_1.rb b a/x]
    assert_equal %w[lib/a], normalized_children
    assert_equal %w[lib/a/a_2.rb], normalize_paths(@package_dir.children.first.children.map(&:path))
  end

  protected

  def normalized_children
    normalize_paths(@package_dir.children.map(&:path))
  end

  def normalize_paths(paths)
    paths.map { |p| Pathname.new(p).to_s.gsub("#{INCLUDE_EXCLUDE_FIXTURE_DIR}/", '') }
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
appmap-0.23.0 test/include_exclude_test.rb
appmap-0.22.0 test/include_exclude_test.rb
appmap-0.21.0 test/include_exclude_test.rb
appmap-0.20.0 test/include_exclude_test.rb
appmap-0.19.0 test/include_exclude_test.rb
appmap-0.18.1 test/include_exclude_test.rb