Sha256: d63cf209f1c75c71a4da59cf413739f274e2b06f6c290f31740c20f858e55b70

Contents?: true

Size: 1.3 KB

Versions: 2

Compression:

Stored size: 1.3 KB

Contents

# Regression tester
#
# Info:: Pjotr's shared Ruby modules
# Author:: Pjotr Prins
# mail:: pjotr.prins@thebird.nl
# Copyright:: July 2007
# License:: Ruby License

module RegressionTest2

	def RegressionTest2.create b
		@@test_create = b
	end
	
	#  Invoke the regression test by passing a string - which ends up a file
	#  in test/regression with +filename+. When +create+ is +true+ the file
	#  will be created/overwritten. Otherwise it is tested against returning
	#  whether it has equal or not. When a test fails both test file and new
	#  file exist in the regression directory - so you can execute a diff.
	#
	#  Example:
	#    RegressionTest2.test `#{cfrubybin} --help`,'cfruby_helptext',$test_create

	def RegressionTest2.test text, filename, testdir, create = @@test_create
		fn = testdir+'/'+filename+'.rtest'
		fntest = fn+'.new'
		
		if create
			f = File.open(fn,'w')
			f.write text
			File.unlink fntest if File.exist? fntest
		else
			# ---- here we have to compare info
			if ! File.exist?(fn)
				raise "Cannot execute regression test because file #{fn} does not exist! - use --create option?"
			end
			f = File.open(fn)
			b = ''
			f.each do | line |
				b += line
			end
			if b!=text
				# ---- Write newer file
				f2 = File.open(fntest,'w')
				f2.write text
				return false
			end
		end
		true
	end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
bio-gff3-0.9.1 test/regressiontest2.rb
bio-gff3-0.9.0 test/regressiontest2.rb