From e1fc595c0ef72537b2a01ff8591f83d4b077241e Mon Sep 17 00:00:00 2001 From: murphy Date: Fri, 11 Jun 2010 10:49:56 +0000 Subject: Added coderay executable tests. --- bin/coderay | 0 bin/coderay_stylesheet | 0 etc/coderay-lib.tmproj | 18 +++++++++++++++--- rake_tasks/test.rake | 7 ++++++- test/executable/suite.rb | 45 +++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 66 insertions(+), 4 deletions(-) mode change 100644 => 100755 bin/coderay mode change 100644 => 100755 bin/coderay_stylesheet create mode 100755 test/executable/suite.rb diff --git a/bin/coderay b/bin/coderay old mode 100644 new mode 100755 diff --git a/bin/coderay_stylesheet b/bin/coderay_stylesheet old mode 100644 new mode 100755 diff --git a/etc/coderay-lib.tmproj b/etc/coderay-lib.tmproj index df84e43..b724cd4 100644 --- a/etc/coderay-lib.tmproj +++ b/etc/coderay-lib.tmproj @@ -5,6 +5,8 @@ documents + expanded + name lib regexFolderFilter @@ -13,6 +15,8 @@ ../lib + expanded + name bin regexFolderFilter @@ -55,8 +59,6 @@ etc regexFolderFilter !.*/(\.[^/]*|CVS|_darcs|_MTN|\{arch\}|blib|.*~\.nib|.*\.(framework|app|pbproj|pbxproj|xcode(proj)?|bundle|log|aux))$ - selected - sourceDirectory @@ -108,6 +110,16 @@ sourceDirectory ../test/functional + + expanded + + name + executable + regexFolderFilter + !.*/(\.[^/]*|CVS|vendor/plugins|index|doc|public/images|_darcs|_MTN|\{arch\}|blib|coverage|.*~\.nib|.*\.(framework|app|pbproj|pbxproj|xcode(proj)?|bundle|log|aux|gem))$ + sourceDirectory + ../test/executable + filename ../test/scanners/coderay_suite.rb @@ -118,7 +130,7 @@ filename ../test/scanners/suite.rb lastUsed - 2010-04-14T23:56:18Z + 2010-06-02T02:27:42Z filename diff --git a/rake_tasks/test.rake b/rake_tasks/test.rake index 8f114a4..661c47b 100644 --- a/rake_tasks/test.rake +++ b/rake_tasks/test.rake @@ -76,7 +76,12 @@ namespace :test do end end + desc 'test the CodeRay executable' + task :exe do + ruby './test/executable/suite.rb' + end + end -task :test => %w( test:functional test:scanners ) +task :test => %w( test:functional test:exe test:scanners ) task :samples => 'test:samples' \ No newline at end of file diff --git a/test/executable/suite.rb b/test/executable/suite.rb new file mode 100755 index 0000000..da84fb0 --- /dev/null +++ b/test/executable/suite.rb @@ -0,0 +1,45 @@ +require 'test/unit' +require 'pathname' + +MYDIR = File.dirname(__FILE__) + +$:.unshift 'lib' +require 'coderay' +puts "Running basic CodeRay #{CodeRay::VERSION} executable tests..." + +class TestCodeRayExecutable < Test::Unit::TestCase + + ruby = `ps -c #$$`[/\w+\Z/] + ruby = 'jruby' if ruby == 'java' + + ROOT_DIR = Pathname.new(File.dirname(__FILE__)) + '..' + '..' + EXECUTABLE = ROOT_DIR + 'bin' + 'coderay2' + EXE_COMMAND = '%s -wI%s %s'% [ + ruby, # calling Ruby process command + ROOT_DIR + 'lib', # library dir + EXECUTABLE + ] + + def coderay args + command = "#{EXE_COMMAND} #{args}" + # puts command + `#{command}` + end + + def test_simple + assert_equal '', coderay('') + end + + VERSION_PATTERN = /\ACodeRay \d\.\d\.\d\n\z/ + def test_version + assert_match(VERSION_PATTERN, coderay('--version')) + assert_match(VERSION_PATTERN, coderay('-v')) + end + + HELP_PATTERN = /Usage:/ + def test_help + assert_match(HELP_PATTERN, coderay('--help')) + assert_match(HELP_PATTERN, coderay('-h')) + end + +end \ No newline at end of file -- cgit v1.2.1