Sha256: aa9cdb698269b666a1beca3870bf088f78de1a09122eca6609a4d24225563e39

Contents?: true

Size: 1.8 KB

Versions: 139

Compression:

Stored size: 1.8 KB

Contents

#!/usr/bin/env ruby

require 'test/unit'
require 'fileutils'
require 'rake'
require 'test/filecreation'

######################################################################
class TestFileCreationTask < Test::Unit::TestCase
  include Rake
  include FileCreation

  DUMMY_DIR = 'testdata/dummy_dir'

  def setup
    Task.clear
  end

  def teardown
    FileUtils.rm_rf DUMMY_DIR
  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

139 entries across 111 versions & 11 rubygems

Version Path
craigmarksmith-rake-0.8.3.100 test/test_file_creation_task.rb
craigmarksmith-rake-0.8.4.101 test/test_file_creation_task.rb
craigmarksmith-rake-0.8.4.102 test/test_file_creation_task.rb
craigmarksmith-rake-0.8.4.103 test/test_file_creation_task.rb
elliottcable-echoe-3.1.1 vendor/rake/test/test_file_creation_task.rb
elliottcable-echoe-3.1.2 vendor/rake/test/test_file_creation_task.rb
jimweirich-rake-0.8.1.10 test/test_file_creation_task.rb
jimweirich-rake-0.8.1.11 test/test_file_creation_task.rb
jimweirich-rake-0.8.1.5 test/test_file_creation_task.rb
jimweirich-rake-0.8.1.6 test/test_file_creation_task.rb
jimweirich-rake-0.8.1.7 test/test_file_creation_task.rb
jimweirich-rake-0.8.1.8 test/test_file_creation_task.rb
jimweirich-rake-0.8.1.9 test/test_file_creation_task.rb
jimweirich-rake-0.8.2.99 test/test_file_creation_task.rb
jimweirich-rake-0.8.2 test/test_file_creation_task.rb
jimweirich-rake-0.8.3.1 test/test_file_creation_task.rb
jimweirich-rake-0.8.3.100 test/test_file_creation_task.rb
jimweirich-rake-0.8.3.99 test/test_file_creation_task.rb
jimweirich-rake-0.8.3 test/test_file_creation_task.rb
jimweirich-rake-0.8.4.99 test/test_file_creation_task.rb