test.rake
1.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
t = Rake::Task[:test]
if t.respond_to?(:clear)
t.clear
else
t.prerequisites.clear
t.instance_variable_get('@actions').clear
end
desc 'Runs Seleniun acceptance tests'
task :selenium do
sh "xvfb-run -a cucumber -p selenium --format #{ENV['CUCUMBER_FORMAT'] || 'progress'}"
end
TestTasks = %w(test:units test:functionals test:integration)
CucumberTasks = %w(cucumber selenium)
NoosferoTasks = %w(test:noosfero_plugins)
AllTasks = TestTasks + CucumberTasks + NoosferoTasks
task :test do
data = []
failed = []
AllTasks.each do |task|
t0 = Time.now.to_i
begin
ENV['RAILS_ENV'] = 'test'
Rake::Task[task].invoke
status = 'PASS'
rescue => e
failed << task
status = 'FAIL'
end
t1 = Time.now.to_i
duration = t1 - t0
data << { :name => task, :status => status, :duration => Time.at(duration).utc.strftime("%H:%M:%S") }
end
puts
printf "%-30s %-6s %s\n", 'Task', 'Status', 'Duration'
printf "%-30s %-6s %s\n", '-' * 30, '-' * 6, '--------'
data.each do |entry|
printf "%-30s %-6s %s\n", entry[:name], entry[:status], entry[:duration]
end
puts
abort "Errors running #{failed.join(', ')}!" if failed.any?
end