Sha256: 4fa1c0b663b637b5b902bbeb7a5ea7657f0e037e9bc33e4c061205f2704bf777

Contents?: true

Size: 1.45 KB

Versions: 29

Compression:

Stored size: 1.45 KB

Contents

require File.expand_path('../helper', __FILE__)
require 'rake/clean'

class TestRakeClean < Rake::TestCase
  def test_clean
    load 'rake/clean.rb', true

    assert Rake::Task['clean'], "Should define clean"
    assert Rake::Task['clobber'], "Should define clobber"
    assert Rake::Task['clobber'].prerequisites.include?("clean"),
      "Clobber should require clean"
  end

  def test_cleanup
    file_name = create_undeletable_file

    out, _ = capture_io do
      Rake::Cleaner.cleanup(file_name, :verbose => false)
    end
    assert_match(/failed to remove/i, out)

  ensure
    remove_undeletable_file
  end

  def test_cleanup_ignores_missing_files
    file_name = File.join(@tempdir, "missing_directory", "no_such_file")

    out, _ = capture_io do
      Rake::Cleaner.cleanup(file_name, :verbose => false)
    end
    refute_match(/failed to remove/i, out)
  end

  private

  def create_undeletable_file
    dir_name = File.join(@tempdir, "deletedir")
    file_name = File.join(dir_name, "deleteme")
    FileUtils.mkdir(dir_name)
    FileUtils.touch(file_name)
    FileUtils.chmod(0, file_name)
    FileUtils.chmod(0, dir_name)
    file_name
  end

  def remove_undeletable_file
    dir_name = File.join(@tempdir, "deletedir")
    file_name = File.join(dir_name, "deleteme")
    FileUtils.chmod(0777, dir_name)
    FileUtils.chmod(0777, file_name)
    Rake::Cleaner.cleanup(file_name, :verbose => false)
    Rake::Cleaner.cleanup(dir_name, :verbose => false)
  end
end

Version data entries

29 entries across 22 versions & 7 rubygems

Version Path
honeybadger-2.4.0 vendor/gems/ruby/2.1.0/gems/rake-10.3.2/test/test_rake_clean.rb
honeybadger-2.4.0 vendor/gems/ruby/2.2.0/gems/rake-10.3.2/test/test_rake_clean.rb
honeybadger-2.4.0 vendor/gems/ruby/1.9.1/gems/rake-10.3.2/test/test_rake_clean.rb
allegro_api_client-0.0.9 gems/ruby/2.1.0/gems/rake-10.3.2/test/test_rake_clean.rb
apl-library-0.0.90 vendor/bundle/ruby/2.1.0/gems/apl-library-0.0.90/vendor/bundle/ruby/1.8/gems/rake-10.3.2/test/test_rake_clean.rb
apl-library-0.0.90 vendor/bundle/ruby/1.9.1/gems/rake-10.3.2/test/test_rake_clean.rb
apl-library-0.0.90 vendor/bundle/ruby/1.8/gems/rake-10.3.2/test/test_rake_clean.rb
apl-library-0.0.90 vendor/bundle/ruby/2.1.0/gems/rake-10.3.2/test/test_rake_clean.rb
apl-library-0.0.90 vendor/bundle/ruby/2.1.0/gems/apl-library-0.0.90/vendor/bundle/ruby/2.1.0/gems/rake-10.3.2/test/test_rake_clean.rb
apl-library-0.0.90 vendor/bundle/ruby/2.1.0/gems/apl-library-0.0.90/vendor/bundle/ruby/1.9.1/gems/rake-10.3.2/test/test_rake_clean.rb
allegro_api_client-0.0.8 gems/ruby/2.1.0/gems/rake-10.3.2/test/test_rake_clean.rb
allegro_api_client-0.0.7 gems/ruby/2.1.0/gems/rake-10.3.2/test/test_rake_clean.rb
allegro_api_client-0.0.6 gems/ruby/2.1.0/gems/rake-10.3.2/test/test_rake_clean.rb
allegro_api_client-0.0.5 gems/ruby/2.1.0/gems/rake-10.3.2/test/test_rake_clean.rb
allegro_api_client-0.0.4 gems/ruby/2.1.0/gems/rake-10.3.2/test/test_rake_clean.rb
allegro_api_client-0.0.3 gems/ruby/2.1.0/gems/rake-10.3.2/test/test_rake_clean.rb
allegro_api_client-0.0.2 gems/ruby/2.1.0/gems/rake-10.3.2/test/test_rake_clean.rb
allegro_api_client-0.0.1 gems/ruby/2.1.0/gems/rake-10.3.2/test/test_rake_clean.rb
nanumfont-rails-0.1 vendor/bundle/ruby/2.1.0/gems/rake-10.3.2/test/test_rake_clean.rb
spline-0.0.11 vendor/bundle/ruby/2.1.0/gems/rake-10.3.2/test/test_rake_clean.rb