Skip to content

Commit 2e2eccb

Browse files
committed
cleanups, helpful message when old svn checkout is found
1 parent 93937e0 commit 2e2eccb

File tree

1 file changed

+27
-20
lines changed

1 file changed

+27
-20
lines changed

rake_tasks/test.rake

Lines changed: 27 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,50 @@
11
namespace :test do
2-
32
desc 'run all sample tests'
43
task :samples do
54
ruby './sample/suite.rb'
65
end
7-
6+
87
desc 'run functional tests'
98
task :functional do
109
ruby './test/functional/suite.rb'
1110
ruby './test/functional/for_redcloth.rb'
1211
end
13-
12+
1413
desc 'run unit tests'
1514
task :units do
1615
ruby './test/unit/suite.rb'
1716
end
18-
17+
1918
scanner_suite = 'test/scanners/suite.rb'
20-
task scanner_suite do
21-
unless File.exist? scanner_suite
22-
puts 'Scanner tests not found; downloading from GitHub...'
23-
sh 'git clone https://github.com/rubychan/coderay-scanner-tests.git test/scanners/'
24-
puts 'Finished.'
25-
end
26-
end
27-
2819
desc 'run all scanner tests'
2920
task :scanners => :update_scanner_suite do
3021
ruby scanner_suite
3122
end
32-
23+
3324
desc 'update scanner test suite from GitHub'
34-
task :update_scanner_suite => scanner_suite do
35-
Dir.chdir(File.dirname(scanner_suite)) do
36-
sh "git pull"
25+
task :update_scanner_suite do
26+
if File.exist? scanner_suite
27+
Dir.chdir File.dirname(scanner_suite) do
28+
if File.directory? '.git'
29+
puts 'Updating scanner test suite...'
30+
sh 'git pull'
31+
elsif File.directory? '.svn'
32+
raise <<-ERROR
33+
Found the deprecated Subversion scanner test suite in ./#{File.dirname(scanner_suite)}.
34+
Please rename or remove it and run again to use the GitHub repository:
35+
36+
mv test/scanners test/scanners-old
37+
ERROR
38+
else
39+
raise 'No scanner test suite found.'
40+
end
41+
end
42+
else
43+
puts 'Downloading scanner test suite...'
44+
sh 'git clone https://github.com/rubychan/coderay-scanner-tests.git test/scanners/'
3745
end
3846
end
39-
47+
4048
namespace :scanner do
4149
Dir['./test/scanners/*'].each do |scanner|
4250
next unless File.directory? scanner
@@ -47,7 +55,7 @@ namespace :test do
4755
end
4856
end
4957
end
50-
58+
5159
desc 'clean test output files'
5260
task :clean do
5361
for file in Dir['test/scanners/**/*.actual.*']
@@ -63,7 +71,7 @@ namespace :test do
6371
rm file
6472
end
6573
end
66-
74+
6775
desc 'test the CodeRay executable'
6876
task :exe do
6977
if RUBY_VERSION >= '1.8.7'
@@ -74,7 +82,6 @@ namespace :test do
7482
puts "Skipping."
7583
end
7684
end
77-
7885
end
7986

8087
task :test => %w(test:functional test:units test:exe)

0 commit comments

Comments
 (0)