Sha256: ac2a11e4c344d14159c3248aadf3c4da3372cf5dd6836a297249d1eb0b53db2d

Contents?: true

Size: 1.33 KB

Versions: 2

Compression:

Stored size: 1.33 KB

Contents

require 'test/unit'

# Select training if you want to renew golden files.
# TRAINING = true
TRAINING = false

Test::Unit.at_start do

    # Suite initialization.

    Dir.chdir( 'test' )

    $diru = "#{Dir.pwd}/../bin/diru"
    system( "#{$diru} --hport 41114 --hub" )
    system( "#{$diru} --hport 41114 -s" )
end

Test::Unit.at_exit do

    # Suite teardown.

    FileUtils.rm_f( "test_bookmarks.txt" )
    FileUtils.rm_f( "test_basic.log" ) unless TRAINING

    system( "#{$diru} --hport 41114 --hkill" )

    Dir.chdir( '..' )
end


# Tests.
class DiruTest < Test::Unit::TestCase

    def setup
    end

    def teardown
        assert( system( "diff test_basic.log golden.log" ), "FAILED: golden file diff" ) unless TRAINING
    end

    def test_basic()
        system( "sh -c test_diru.sh 2>&1 | tee test_basic.log > /dev/null" )
    end

end




if false

    # Paste to IRB for test directory creation.
    # <clip>
    require 'fileutils'
    def create_dirs( level, base )
        if level.empty?
            FileUtils.touch "empty.txt"
            return
        end
        cnt = level[0]
        cnt.times do |i|
            sub = "#{base}_#{i}"
            FileUtils.mkdir sub
            Dir.chdir sub
            create_dirs( level[1..-1], sub )
            Dir.chdir ".."
        end
    end

    create_dirs [2,5,3], "dir"
    # </clip>
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
diru-0.0.2 test/test_diru.rb
diru-0.0.1 test/test_diru.rb