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 43114 --hub" ) system( "#{$diru} --hport 43114 -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 43114 --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. # 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" # end