-
Notifications
You must be signed in to change notification settings - Fork 370
/
Rakefile
113 lines (93 loc) · 2.94 KB
/
Rakefile
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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
# frozen_string_literal: true
# Add your own tasks in files placed in lib/tasks ending in .rake,
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
if ENV["DEADLOCK_DEBUG"]
Thread.new do
loop do
sleep ENV["DEADLOCK_DEBUG"].to_f # seconds
puts
puts
puts
puts "## Deadlock Debug"
puts
Thread.list.each { |t|
puts "=" * 80
puts t.backtrace
}
end
end
end
require File.expand_path("../config/application", __FILE__)
begin
require "rubocop/rake_task"
RuboCop::RakeTask.new(:rubocop) do |task|
task.options = ["--display-cop-names"]
end
rescue LoadError
# We are in the production environment, where Rubocop is not required.
end
CodeTriage::Application.load_tasks
task "assets:profile" do
puts "=============="
StackProf.run(mode: :wall, out: "tmp/stackprof.dump") do
Rake::Task["assets:precompile"].invoke
end
end
# $ bundle exec rake assets:bench ; cd ~/documents/projects/sprockets; git co -; cd -; bundle exec rake assets:bench
task "assets:bench" do
measure = []
50.times do
`rm -rf tmp/cache/assets/sprockets/v4.0/ ; rm -rf public/assets; touch tmp;`
measure << Benchmark.measure do
`time env RAILS_ENV=production bundle exec rake assets:precompile`
end.real
end
puts "================ DONE ================"
puts measure.join("\n")
end
# overrides for bootsnap to eliminate relative paths
# TODO Rails 5.1 add test:system
%w[
test test:prepare test:generators test:models test:helpers
test:controllers test:mailers test:integration test:jobs
test:units test:functionals
].each { |task| Rake::Task[task].clear }
task :test do
$: << Rails.root.to_s + "/test"
if ENV.key?("TEST")
Rails::TestUnit::Runner.rake_run([ENV["TEST"]])
else
# TODO: Rails 5.1 Rails::TestUnit::Runner.rake_run(["test"], ["test/system/**/*"])
Rails::TestUnit::Runner.rake_run(["test"])
end
end
namespace :test do
["models", "helpers", "controllers", "mailers", "integration", "jobs"].each do |name|
task name => "test:prepare" do
$: << Rails.root.to_s + "/test"
Rails::TestUnit::Runner.rake_run(["test/#{name}"])
end
end
task generators: "test:prepare" do
$: << Rails.root.to_s + "/test"
Rails::TestUnit::Runner.rake_run(["test/lib/generators"])
end
task units: "test:prepare" do
$: << Rails.root.to_s + "/test"
Rails::TestUnit::Runner.rake_run(["test/models", "test/helpers", "test/unit"])
end
task functionals: "test:prepare" do
$: << Rails.root.to_s + "/test"
Rails::TestUnit::Runner.rake_run(["test/controllers", "test/mailers", "test/functional"])
end
desc "Run system tests only"
task system: "test:prepare" do
$: << Rails.root.to_s + "/test"
Rails::TestUnit::Runner.rake_run(["test/system"])
end
end
task default: [:test]
Rake::Task["assets:precompile"].enhance do
Rake::Task["db:migrate"].invoke
Rake::Task["db:schema:cache:dump"].invoke
end