Debian Codegraph @

rake_tasks/test.rake

raw
1 namespace :test do
2 desc 'run functional tests'
3 task :functional do
4 ruby './test/functional/suite.rb'
5 ruby './test/functional/for_redcloth.rb' unless (''.chop! rescue true)
6 end
7
8 desc 'run unit tests'
9 task :units do
10 ruby './test/unit/suite.rb'
11 end
12
13 scanner_suite = 'test/scanners/suite.rb'
14 desc 'run all scanner tests'
15 task :scanners => :update_scanner_suite do
16 ruby scanner_suite
17 end
18
19 desc 'update scanner test suite from GitHub'
20 task :update_scanner_suite do
21 if File.exist? scanner_suite
22 Dir.chdir File.dirname(scanner_suite) do
23 if File.directory? '.git'
24 puts 'Updating scanner test suite...'
25 sh 'git pull'
26 elsif File.directory? '.svn'
27 raise <<-ERROR
28 Found the deprecated Subversion scanner test suite in ./#{File.dirname(scanner_suite)}.
29 Please rename or remove it and run again to use the GitHub repository:
30
31 mv test/scanners test/scanners-old
32 ERROR
33 else
34 raise 'No scanner test suite found.'
35 end
36 end
37 else
38 puts 'Downloading scanner test suite...'
39 sh 'git clone https://github.com/rubychan/coderay-scanner-tests.git test/scanners/'
40 end unless ENV['SKIP_UPDATE_SCANNER_SUITE']
41 end
42
43 namespace :scanner do
44 Dir['./test/scanners/*'].each do |scanner|
45 next unless File.directory? scanner
46 lang = File.basename(scanner)
47 desc "run all scanner tests for #{lang}"
48 task lang => :update_scanner_suite do
49 ruby "./test/scanners/suite.rb #{lang}"
50 end
51 end
52 end
53
54 desc 'clean test output files'
55 task :clean do
56 for file in Dir['test/scanners/**/*.actual.*']
57 rm file
58 end
59 for file in Dir['test/scanners/**/*.debug.diff']
60 rm file
61 end
62 for file in Dir['test/scanners/**/*.debug.diff.html']
63 rm file
64 end
65 for file in Dir['test/scanners/**/*.expected.html']
66 rm file
67 end
68 end
69
70 desc 'test the CodeRay executable'
71 task :exe do
72 if RUBY_VERSION >= '1.8.7'
73 ruby './test/executable/suite.rb'
74 else
75 puts
76 puts "Can't run executable tests because shoulda-context requires Ruby 1.8.7+."
77 puts "Skipping."
78 end
79 end
80 end
81
82 if RUBY_VERSION >= '1.9'
83 require 'rspec/core/rake_task'
84 RSpec::Core::RakeTask.new(:spec)
85 end
86
87 task :test => %w(test:functional test:units test:exe spec)