Sha256: 2108ff33d4eced269110fee14e1adaa6221c3711b1f32b4d8f7c4a386f4c2d86

Contents?: true

Size: 1.79 KB

Versions: 47

Compression:

Stored size: 1.79 KB

Contents

require File.expand_path('../helper', __FILE__)
require 'fileutils'

######################################################################
class TestRakeFileCreationTask < Rake::TestCase
  include Rake
  include Rake::DSL

  DUMMY_DIR = 'testdata/dummy_dir'

  def setup
    super

    Task.clear
  end

  def teardown
    FileUtils.rm_rf DUMMY_DIR

    super
  end

  def test_file_needed
    create_dir DUMMY_DIR
    fc_task = Task[DUMMY_DIR]
    assert_equal DUMMY_DIR, fc_task.name
    FileUtils.rm_rf fc_task.name
    assert fc_task.needed?, "file should be needed"
    FileUtils.mkdir fc_task.name
    assert_equal nil, fc_task.prerequisites.collect{|n| Task[n].timestamp}.max
    assert ! fc_task.needed?, "file should not be needed"
  end

  def test_directory
    directory DUMMY_DIR
    fc_task = Task[DUMMY_DIR]
    assert_equal DUMMY_DIR, fc_task.name
    assert FileCreationTask === fc_task
  end

  def test_no_retriggers_on_filecreate_task
    create_timed_files(OLDFILE, NEWFILE)
    t1 = Rake.application.intern(FileCreationTask, OLDFILE).enhance([NEWFILE])
    t2 = Rake.application.intern(FileCreationTask, NEWFILE)
    assert ! t2.needed?, "Should not need to build new file"
    assert ! t1.needed?, "Should not need to rebuild old file because of new"
  end

  def test_no_retriggers_on_file_task
    create_timed_files(OLDFILE, NEWFILE)
    t1 = Rake.application.intern(FileCreationTask, OLDFILE).enhance([NEWFILE])
    t2 = Rake.application.intern(FileCreationTask, NEWFILE)
    assert ! t2.needed?, "Should not need to build new file"
    assert ! t1.needed?, "Should not need to rebuild old file because of new"
  end

  def test_very_early_timestamp
    t1 = Rake.application.intern(FileCreationTask, OLDFILE)
    assert t1.timestamp < Time.now
    assert t1.timestamp < Time.now - 1000000
  end
end

Version data entries

47 entries across 34 versions & 5 rubygems

Version Path
dirty_history-0.7.3 dirty_history/ruby/1.9.1/gems/rake-0.9.2/test/test_rake_file_creation_task.rb
dirty_history-0.7.2 dirty_history/ruby/1.9.1/gems/rake-0.9.2/test/test_rake_file_creation_task.rb
dirty_history-0.7.1 dirty_history/ruby/1.9.1/gems/rake-0.9.2/test/test_rake_file_creation_task.rb
dirty_history-0.7.0 dirty_history/ruby/1.9.1/gems/rake-0.9.2/test/test_rake_file_creation_task.rb
dirty_history-0.6.7 dirty_history/ruby/1.9.1/gems/rake-0.9.2/test/test_rake_file_creation_task.rb
dirty_history-0.6.6 dirty_history/ruby/1.9.1/gems/rake-0.9.2/test/test_rake_file_creation_task.rb
dirty_history-0.6.5 dirty_history/ruby/1.9.1/gems/rake-0.9.2/test/test_rake_file_creation_task.rb
dirty_history-0.6.4 dirty_history/ruby/1.9.1/gems/rake-0.9.2/test/test_rake_file_creation_task.rb
dirty_history-0.6.3 dirty_history/ruby/1.9.1/gems/rake-0.9.2/test/test_rake_file_creation_task.rb
dirty_history-0.6.2 dirty_history/ruby/1.9.1/gems/rake-0.9.2/test/test_rake_file_creation_task.rb
dirty_history-0.6.1 dirty_history/ruby/1.9.1/gems/rake-0.9.2/test/test_rake_file_creation_task.rb
dirty_history-0.6.0 dirty_history/ruby/1.9.1/gems/rake-0.9.2/test/test_rake_file_creation_task.rb
dirty_history-0.5.4 dirty_history/ruby/1.9.1/gems/rake-0.9.2/test/test_rake_file_creation_task.rb
dirty_history-0.5.3 dirty_history/ruby/1.9.1/gems/rake-0.9.2/test/test_rake_file_creation_task.rb
dirty_history-0.5.2 dirty_history/ruby/1.9.1/gems/dirty_history-0.2.0/dirty_history/ruby/1.9.1/gems/rake-0.9.2/test/test_rake_file_creation_task.rb
dirty_history-0.5.2 dirty_history/ruby/1.9.1/gems/rake-0.9.2/test/test_rake_file_creation_task.rb
dirty_history-0.5.1 dirty_history/ruby/1.9.1/gems/rake-0.9.2/test/test_rake_file_creation_task.rb
dirty_history-0.5.1 dirty_history/ruby/1.9.1/gems/dirty_history-0.2.0/dirty_history/ruby/1.9.1/gems/rake-0.9.2/test/test_rake_file_creation_task.rb
dirty_history-0.5.0 dirty_history/ruby/1.9.1/gems/dirty_history-0.2.0/dirty_history/ruby/1.9.1/gems/rake-0.9.2/test/test_rake_file_creation_task.rb
dirty_history-0.5.0 dirty_history/ruby/1.9.1/gems/rake-0.9.2/test/test_rake_file_creation_task.rb