-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathGuardfile
85 lines (73 loc) · 1.56 KB
/
Guardfile
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
# A sample Guardfile
# More info at https://github.com/guard/guard#readme
require 'guard/plugin'
require 'childprocess'
module ::Guard
class RustTest < Plugin
def run_all
UI.info 'Running all cargo tests'
system('cargo test -j 4').tap do |success|
if success
UI.info 'SUCCESS'
else
UI.error 'FAILURE'
end
end
end
def run_on_changes(paths)
run_all
end
end
class RustBench < Plugin
def run_all
UI.info 'Running all cargo benchmarks'
system('cargo test -j 4 -- --bench').tap do |success|
if success
UI.info 'SUCCESS'
else
UI.error 'FAILURE'
end
end
end
def run_on_changes(paths)
run_all
end
end
class JohnTestServer < Plugin
def start
UI.info 'Starting John Server'
system('cargo build')
@process = ChildProcess.build('target/john')
@process.environment.merge!(
"PORT" => 3100,
"LD_LIBRARY_PATH" => "target/deps"
)
@process.io.inherit!
@process.start
@pid = @process.pid
end
def stop
UI.info 'Stopping John Server'
@process.stop if @pid && @process.alive?
end
def reload
stop
start
end
def run_on_changes(paths)
reload
end
end
end
guard :john_test_server do
watch(%r{^src/main.rs})
watch(%r{^src/server.rs})
end
guard :rust_test do
watch(%r{^tests/.+_test\.rs$})
watch(%r{^src/lib.rs$})
watch(%r{^src/river.rs$})
watch(%r{^src/server.rs$})
end
guard :rust_bench do
end