/
test_run_utils.rb
75 lines (67 loc) · 2.07 KB
/
test_run_utils.rb
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
require_relative './rake_utils'
require_relative '../../deployment'
require 'cdo/hip_chat'
def with_hipchat_logging(name)
start_time = Time.now
HipChat.log "Running #{name}..."
yield if block_given?
HipChat.log "#{name} succeeded in #{RakeUtils.format_duration(Time.now - start_time)}"
rescue => e
# notify developers room and our own room
"<b>#{name}</b> failed in #{RakeUtils.format_duration(Time.now - start_time)}".tap do |message|
HipChat.log message, color: 'red', notify: 1
HipChat.developers message, color: 'red', notify: 1
end
# log detailed error information in our own room
puts "#{e}\n#{CDO.backtrace e}", message_format: 'text'
raise
end
module TestRunUtils
def self.run_apps_tests
Dir.chdir(apps_dir) do
with_hipchat_logging('apps tests') do
RakeUtils.system 'npm run test-low-memory'
end
end
end
def self.run_local_ui_test
feature_path = File.expand_path(ENV['feature'])
Dir.chdir(dashboard_dir('test/ui/')) do
RakeUtils.system "./runner.rb --verbose --pegasus=localhost.code.org:3000 --dashboard=localhost-studio.code.org:3000 --local --feature=#{feature_path}"
end
end
def self.run_blockly_core_tests
Dir.chdir(blockly_core_dir) do
with_hipchat_logging('blockly core tests') do
RakeUtils.system './test.sh'
end
end
end
def self.run_dashboard_tests
Dir.chdir(dashboard_dir) do
with_hipchat_logging('dashboard tests') do
RakeUtils.system_stream_output "RAILS_ENV=#{rack_env}", "RACK_ENV=#{rack_env}", 'bundle', 'exec', 'rails', 'test'
RakeUtils.rake_stream_output 'konacha:run'
end
end
end
def self.run_pegasus_tests
Dir.chdir(pegasus_dir) do
with_hipchat_logging('pegasus tests') do
RakeUtils.rake_stream_output 'test'
end
end
end
def self.run_shared_tests
Dir.chdir(shared_dir) do
with_hipchat_logging('shared tests') do
RakeUtils.rake_stream_output 'test'
end
end
end
def self.run_lib_tests
Dir.chdir(lib_dir) do
RakeUtils.rake_stream_output 'test'
end
end
end