summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormurphy <murphy@rubychan.de>2010-06-11 10:49:56 +0000
committermurphy <murphy@rubychan.de>2010-06-11 10:49:56 +0000
commite1fc595c0ef72537b2a01ff8591f83d4b077241e (patch)
tree981537d5d32ec989e603a976a9d00aef2762fb37
parent94d04c5dea0284d9ea35f558e8ed2a464f25edee (diff)
downloadcoderay-e1fc595c0ef72537b2a01ff8591f83d4b077241e.tar.gz
Added coderay executable tests.
-rwxr-xr-x[-rw-r--r--]bin/coderay0
-rwxr-xr-x[-rw-r--r--]bin/coderay_stylesheet0
-rw-r--r--etc/coderay-lib.tmproj18
-rw-r--r--rake_tasks/test.rake7
-rwxr-xr-xtest/executable/suite.rb45
5 files changed, 66 insertions, 4 deletions
diff --git a/bin/coderay b/bin/coderay
index ef819f7..ef819f7 100644..100755
--- a/bin/coderay
+++ b/bin/coderay
diff --git a/bin/coderay_stylesheet b/bin/coderay_stylesheet
index 0e19395..0e19395 100644..100755
--- a/bin/coderay_stylesheet
+++ b/bin/coderay_stylesheet
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 @@
<key>documents</key>
<array>
<dict>
+ <key>expanded</key>
+ <true/>
<key>name</key>
<string>lib</string>
<key>regexFolderFilter</key>
@@ -13,6 +15,8 @@
<string>../lib</string>
</dict>
<dict>
+ <key>expanded</key>
+ <true/>
<key>name</key>
<string>bin</string>
<key>regexFolderFilter</key>
@@ -55,8 +59,6 @@
<string>etc</string>
<key>regexFolderFilter</key>
<string>!.*/(\.[^/]*|CVS|_darcs|_MTN|\{arch\}|blib|.*~\.nib|.*\.(framework|app|pbproj|pbxproj|xcode(proj)?|bundle|log|aux))$</string>
- <key>selected</key>
- <true/>
<key>sourceDirectory</key>
<string></string>
</dict>
@@ -109,6 +111,16 @@
<string>../test/functional</string>
</dict>
<dict>
+ <key>expanded</key>
+ <true/>
+ <key>name</key>
+ <string>executable</string>
+ <key>regexFolderFilter</key>
+ <string>!.*/(\.[^/]*|CVS|vendor/plugins|index|doc|public/images|_darcs|_MTN|\{arch\}|blib|coverage|.*~\.nib|.*\.(framework|app|pbproj|pbxproj|xcode(proj)?|bundle|log|aux|gem))$</string>
+ <key>sourceDirectory</key>
+ <string>../test/executable</string>
+ </dict>
+ <dict>
<key>filename</key>
<string>../test/scanners/coderay_suite.rb</string>
<key>lastUsed</key>
@@ -118,7 +130,7 @@
<key>filename</key>
<string>../test/scanners/suite.rb</string>
<key>lastUsed</key>
- <date>2010-04-14T23:56:18Z</date>
+ <date>2010-06-02T02:27:42Z</date>
</dict>
<dict>
<key>filename</key>
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