root/branches/raggi/tasks/tests.rake

Revision 723, 4.3 kB (checked in by raggi, 1 year ago)

Merge forward from trunk r712 to HEAD

Line 
1 # This is used by several rake tasks, that parameterize the
2 # behavior so we can use the same tests to test both the
3 # extension and non-extension versions.
4 def run_tests t, libr, test_filename_filter="test_*.rb"
5   require 'test/unit/testsuite'
6   require 'test/unit/ui/console/testrunner'
7
8   runner = Test::Unit::UI::Console::TestRunner
9
10   $eventmachine_library = ((RUBY_PLATFORM =~ /java/) ? :java : libr)
11   $LOAD_PATH.unshift('tests')
12   $stderr.puts "Checking for test cases:" #if t.verbose
13
14   if test_filename_filter.is_a?(Array)
15     test_filename_filter.each {|testcase|
16       $stderr.puts "\t#{testcase}"
17       load "tests/#{testcase}"
18     }
19   else
20     Dir["tests/#{test_filename_filter}"].each do |testcase|
21       $stderr.puts "\t#{testcase}" #if t.verbose
22       load testcase
23     end
24   end
25
26   suite = Test::Unit::TestSuite.new($name)
27
28   ObjectSpace.each_object(Class) do |testcase|
29     suite << testcase.suite if testcase < Test::Unit::TestCase
30   end
31
32   runner.run(suite)
33 end
34
35 desc "Run tests for #{Spec.name}."
36 task :test do |t|
37   run_tests t, nil
38 end
39
40 namespace :test do
41   desc "Run tests for #{Spec.name}."
42   task :partial do |t|
43     lib = RUBY_PLATFORM =~ /java/ ? :java : :extension
44     run_tests t, lib, [
45       "test_basic.rb",
46       "test_epoll.rb",
47       "test_errors.rb",
48       "test_eventables.rb",
49       "test_exc.rb",
50       "test_futures.rb",
51       "test_hc.rb",
52       "test_httpclient2.rb",
53       "test_httpclient.rb",
54       "test_kb.rb",
55       #"test_ltp2.rb",
56       "test_ltp.rb",
57       "test_next_tick.rb",
58       "test_processes.rb",
59       "test_pure.rb",
60       "test_running.rb",
61       "test_sasl.rb",
62       #"test_send_file.rb",
63       "test_servers.rb",
64       "test_smtpclient.rb",
65       "test_smtpserver.rb",
66       "test_spawn.rb",
67       "test_timers.rb",
68       "test_ud.rb",
69     ]
70   end
71  
72   desc "Run java tests for #$name."
73   task :testjava do |t|
74     run_tests t, :java
75   end
76
77   desc "Run pure-ruby tests for #$name."
78   task :testpr do |t|
79     run_tests t, :pure_ruby
80   end
81
82   desc "Run extension tests for #$name."
83   task :testext do |t|
84     run_tests t, :extension
85   end
86
87   desc "PROVISIONAL: run tests for user-defined events"
88   task :ud do |t|
89     run_tests t, :extension, "test_ud.rb"
90   end
91
92   desc "PROVISIONAL: run tests for line/text protocol handler"
93   task :ltp do |t|
94     run_tests t, :extension, "test_ltp*.rb"
95   end
96
97   desc "PROVISIONAL: run tests for header/content protocol handler"
98   task :hc do |t|
99     run_tests t, :extension, "test_hc.rb"
100   end
101
102   desc "PROVISIONAL: run tests for exceptions"
103   task :exc do |t|
104     run_tests t, :extension, "test_exc.rb"
105   end
106
107   desc "Test protocol handlers"
108   task :protocols => [ :hc, :ltp ]
109
110
111   desc "Test HTTP client"
112   task :httpclient do |t|
113     run_tests t, :extension, "test_httpclient.rb"
114   end
115
116   desc "Test HTTP client2"
117   task :httpclient2 do |t|
118     run_tests t, :extension, "test_httpclient2.rb"
119   end
120
121   desc "Test futures"
122   task :futures do |t|
123     run_tests t, :extension, "test_future*.rb"
124   end
125
126   desc "Test Timers"
127   task :timers do |t|
128     run_tests t, :extension, "test_timer*.rb"
129   end
130
131   desc "Test Next Tick"
132   task :next_tick do |t|
133     run_tests t, :extension, "test_next_tick*.rb"
134   end
135
136   desc "Test Epoll"
137   task :epoll do |t|
138     run_tests t, :extension, "test_epoll*.rb"
139   end
140
141   desc "Test Servers"
142   task :servers do |t|
143     run_tests t, :extension, "test_servers*.rb"
144   end
145
146   desc "Test Basic"
147   task :basic do |t|
148     run_tests t, :extension, "test_basic*.rb"
149   end
150
151   desc "Test Send File"
152   task :send_file do |t|
153     run_tests t, :extension, "test_send_file*.rb"
154   end
155
156   desc "Test Running"
157   task :running do |t|
158     run_tests t, :extension, "test_running*.rb"
159   end
160
161   desc "Test Keyboard Events"
162   task :keyboard do |t|
163     run_tests t, :extension, "test_kb*.rb"
164   end
165
166   desc "Test Spawn"
167   task :spawn do |t|
168     run_tests t, :spawn, "test_spawn*.rb"
169   end
170
171   desc "Test SMTP"
172   task :smtp do |t|
173     run_tests t, :extension, "test_smtp*.rb"
174   end
175
176   desc "Test Errors"
177   task :errors do |t|
178     run_tests t, :extension, "test_errors*.rb"
179   end
180
181   desc "Test Pure Ruby"
182   task :pure do |t|
183     run_tests t, :extension, "test_pure*.rb"
184   end
185
186   desc "Test Processes"
187   task :processes do |t|
188     run_tests t, :extension, "test_process*.rb"
189   end
190
191   desc "Test SASL"
192   task :sasl do |t|
193     run_tests t, :java, "test_sasl*.rb"
194   end
195 end
Note: See TracBrowser for help on using the browser.