forked from openxc/openxcplatform.com
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Rakefile
68 lines (58 loc) · 1.33 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
require 'html-proofer'
require 'rake/testtask'
require 'open-uri'
def build
if not system "bundle exec jekyll build"
raise "Build failed"
end
end
def serve(port=nil, local_dev=true)
Process.spawn("bundle exec jekyll serve --host 0.0.0.0 #{"-P #{port}" if port } -w")
end
namespace :test do
Rake::TestTask.new(:unit_tests) do |test|
test.libs << 'test'
test.test_files = FileList['tests/**/test_*.rb']
test.verbose = true
end
end
task :test do
begin
pid = serve(4001, false)
10.times do
begin
open("http://localhost:4001")
break
rescue SystemCallError
sleep 2
end
end
HTMLProofer.check_directory("./_site",
:href_ignore => ["#"],
:alt_ignore => [
],
:disable_external => true,
:check_favicon => false,
:parallel => { :in_processes => 4},
).run
sleep 2
Rake::Task['test:unit_tests'].invoke
ensure
# TODO this causes a big interrupt trackback but it's OK to ignore, but it
# would be nice to silence that so the test output is more visible.
Process.kill(:SIGINT, pid)
end
end
task :clean do
rm_rf "./_site"
end
task :serve do
pid = serve()
Process.wait(pid)
end
task :build do
build()
end
task :tidy do
system 'find _site -name "*.html" -exec echo {} \; -exec tidy -errors -q {} \;'
end