1
1
namespace :test do
2
-
3
2
desc 'run all sample tests'
4
3
task :samples do
5
4
ruby './sample/suite.rb'
6
5
end
7
-
6
+
8
7
desc 'run functional tests'
9
8
task :functional do
10
9
ruby './test/functional/suite.rb'
11
10
ruby './test/functional/for_redcloth.rb'
12
11
end
13
-
12
+
14
13
desc 'run unit tests'
15
14
task :units do
16
15
ruby './test/unit/suite.rb'
17
16
end
18
-
17
+
19
18
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
-
28
19
desc 'run all scanner tests'
29
20
task :scanners => :update_scanner_suite do
30
21
ruby scanner_suite
31
22
end
32
-
23
+
33
24
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/'
37
45
end
38
46
end
39
-
47
+
40
48
namespace :scanner do
41
49
Dir [ './test/scanners/*' ] . each do |scanner |
42
50
next unless File . directory? scanner
@@ -47,7 +55,7 @@ namespace :test do
47
55
end
48
56
end
49
57
end
50
-
58
+
51
59
desc 'clean test output files'
52
60
task :clean do
53
61
for file in Dir [ 'test/scanners/**/*.actual.*' ]
@@ -63,7 +71,7 @@ namespace :test do
63
71
rm file
64
72
end
65
73
end
66
-
74
+
67
75
desc 'test the CodeRay executable'
68
76
task :exe do
69
77
if RUBY_VERSION >= '1.8.7'
@@ -74,7 +82,6 @@ namespace :test do
74
82
puts "Skipping."
75
83
end
76
84
end
77
-
78
85
end
79
86
80
87
task :test => %w( test:functional test:units test:exe )
0 commit comments