From b92af44362a2c7edcd9d68c021d10ed5e126ce78 Mon Sep 17 00:00:00 2001 From: murphy Date: Fri, 1 Jan 2010 06:11:36 +0000 Subject: Improved scanner tests: known issues, JRuby bug workaround (see #136). --- etc/coderay-lib.tmproj | 97 +++++++-------------------- test/scanners/coderay_suite.rb | 40 ++++++++++- test/scanners/javascript/xml.known-issue.yaml | 2 + test/scanners/ruby/unicode.known-issue.yaml | 2 + test/scanners/yaml/suite.rb | 2 +- 5 files changed, 68 insertions(+), 75 deletions(-) create mode 100644 test/scanners/javascript/xml.known-issue.yaml create mode 100644 test/scanners/ruby/unicode.known-issue.yaml diff --git a/etc/coderay-lib.tmproj b/etc/coderay-lib.tmproj index 99bcdec..0e65c88 100644 --- a/etc/coderay-lib.tmproj +++ b/etc/coderay-lib.tmproj @@ -2,9 +2,13 @@ + currentDocument + ../diff documents + expanded + name lib regexFolderFilter @@ -24,13 +28,15 @@ filename ../diff lastUsed - 2009-12-31T04:25:13Z + 2010-01-01T05:59:47Z + selected + filename ../Changes.textile lastUsed - 2009-12-31T03:02:34Z + 2010-01-01T05:59:47Z filename @@ -90,9 +96,11 @@ filename ../Rakefile lastUsed - 2009-12-28T04:00:03Z + 2010-01-01T05:57:27Z + expanded + name functional regexFolderFilter @@ -104,13 +112,13 @@ filename ../test/scanners/coderay_suite.rb lastUsed - 2009-12-30T20:08:02Z + 2010-01-01T05:57:20Z filename ../test/scanners/suite.rb lastUsed - 2008-08-04T21:50:01Z + 2010-01-01T05:50:18Z filename @@ -123,33 +131,19 @@ 200 metaData - ../lib/coderay/helpers/file_type.rb + ../diff caret column - 18 - line - 217 - - firstVisibleColumn - 0 - firstVisibleLine - 205 - - ../lib/coderay/scanners/_map.rb - - caret - - column - 17 + 15 line - 17 + 94 firstVisibleColumn 0 firstVisibleLine - 0 + 88 ../lib/coderay/scanners/delphi.rb @@ -253,20 +247,6 @@ 178 - ../lib/coderay/scanners/ruby/patterns.rb - - caret - - column - 0 - line - 0 - - firstVisibleColumn - 0 - firstVisibleLine - 0 - ../lib/coderay/scanners/yaml.rb caret @@ -325,51 +305,26 @@ 76 - ../test/functional/vhdl.rb - - caret - - column - 13 - line - 0 - - columnSelection - - firstVisibleColumn - 0 - firstVisibleLine - 0 - selectFrom - - column - 39 - line - 0 - - selectTo - - column - 13 - line - 0 - - - ../test/scanners/suite.rb + ../rake_tasks/test.rake caret column - 0 + 31 line - 4 + 79 firstVisibleColumn 0 firstVisibleLine - 0 + 44 + openDocuments + + ../rake_tasks/test.rake + ../diff + showFileHierarchyDrawer windowFrame diff --git a/test/scanners/coderay_suite.rb b/test/scanners/coderay_suite.rb index ee33cb8..d233401 100644 --- a/test/scanners/coderay_suite.rb +++ b/test/scanners/coderay_suite.rb @@ -1,4 +1,5 @@ require 'benchmark' +require 'yaml' require 'fileutils' $mydir = File.dirname(__FILE__) @@ -170,6 +171,7 @@ module CodeRay puts '%d'.yellow % examples.size + " example#{'s' if examples.size > 1} found.".green end for example_filename in examples + @known_issue_description = @known_issue_ticket_url = nil name = File.basename(example_filename, ".#{extension}") next if ENV['lang'] && ENV['only'] && ENV['only'] != name filesize_in_kb = File.size(example_filename) / 1024.0 @@ -177,7 +179,7 @@ module CodeRay tokens = example_test example_filename, name, scanner, max - if time = @time_for_encoding + if defined?(@time_for_encoding) && time = @time_for_encoding kilo_tokens_per_second = tokens.size / time / 1000 print 'finished in '.green + '%5.2fs'.white % time if filesize_in_kb > 1 @@ -186,13 +188,25 @@ module CodeRay @time_for_encoding = nil end puts '.'.green + if @known_issue_description + print ' KNOWN ISSUE: '.cyan + print @known_issue_description.yellow + puts + print ' ' * 25 + if @known_issue_ticket_url + puts 'See '.yellow + @known_issue_ticket_url.white + '.'.yellow + else + puts 'No ticket yet. Visit '.yellow + + 'http://redmine.rubychan.de/projects/coderay/issues/new'.white + '.'.yellow + end + end end end end def example_test example_filename, name, scanner, max if File.size(example_filename) > MAX_CODE_SIZE_TO_TEST and not ENV['only'] - print 'too big, ' + print 'too big' return end code = File.open(example_filename, 'rb') { |f| break f.read } @@ -218,6 +232,11 @@ module CodeRay end def random_test scanner, max + if defined?(JRUBY_VERSION) && JRUBY_VERSION == '1.4.0' && %w[ruby nitroxhtml rhtml].include?(scanner.lang) + puts 'Random test skipped due to a bug in JRuby. See http://redmine.rubychan.de/issues/136.'.red + @@warning_about_jruby_bug = true + return + end print "Random test...".yellow okay = true for size in (0..max).progress @@ -317,7 +336,22 @@ module CodeRay assert(ok, "Scan error: unexpected output".red) if ENV['assert'] print "\b" * 'complete...'.size - print 'complete, '.green_or_red(ok) + known_issue = expected_filename.sub(/\.expected\..*/, '.known-issue.yaml') + if !ok && File.exist?(known_issue) + known_issue = YAML.load_file(known_issue) + ticket_url = known_issue['ticket_url'] + @known_issue_description = known_issue['description'] + if ticket_url && ticket_url[/(\d+)\/?$/] + @known_issue_ticket_url = ticket_url + ticket_info = 'see #' + $1 + else + ticket_info = 'ticket ?' + end + print ticket_info.rjust('complete'.size).red + print ', '.green + else + print 'complete, '.green_or_red(ok) + end else File.open(expected_filename, 'wb') { |f| f.write result } print "\b" * 'complete...'.size, "new test, ".blue diff --git a/test/scanners/javascript/xml.known-issue.yaml b/test/scanners/javascript/xml.known-issue.yaml new file mode 100644 index 0000000..8132156 --- /dev/null +++ b/test/scanners/javascript/xml.known-issue.yaml @@ -0,0 +1,2 @@ +description: JavaScript scanner is confused by nested XML literals. +ticket_url: http://redmine.rubychan.de/issues/ \ No newline at end of file diff --git a/test/scanners/ruby/unicode.known-issue.yaml b/test/scanners/ruby/unicode.known-issue.yaml new file mode 100644 index 0000000..49e1cf0 --- /dev/null +++ b/test/scanners/ruby/unicode.known-issue.yaml @@ -0,0 +1,2 @@ +description: This ruby version doesn't scan all ruby identifier chars via \w. +# ticket_url: http://redmine.rubychan.de/issues/ \ No newline at end of file diff --git a/test/scanners/yaml/suite.rb b/test/scanners/yaml/suite.rb index 7e11075..c4ac0d4 100644 --- a/test/scanners/yaml/suite.rb +++ b/test/scanners/yaml/suite.rb @@ -1,3 +1,3 @@ -class YAML < CodeRay::TestCase +class YAML_ < CodeRay::TestCase @lang = :yaml end -- cgit v1.2.1