-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy path.watchr.rb
More file actions
36 lines (31 loc) · 683 Bytes
/
.watchr.rb
File metadata and controls
36 lines (31 loc) · 683 Bytes
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
watch( 'test/.*_test\.rb' ) { |m| run_test_file(m[0]) }
watch( 'lib/ruby/**/(.*)\.rb' ) { |m| run_test_file("test/#{m[1]}_test.rb") }
def run(cmd)
puts cmd
`#{cmd}`
end
def run_test_file(file)
system('clear')
result = run "ruby #{file}"
puts result
end
def run_all_tests
@interrupted = false
system('clear')
result = run "ruby test/all_suite.rb"
puts result
end
@interrupted = false
# Ctrl-C
Signal.trap 'INT' do
if @interrupted then
@wants_to_quit = true
abort("\n")
else
puts "Interrupt a second time to quit"
@interrupted = true
Kernel.sleep 1.5
# raise Interrupt, nil # let the run loop catch it
run_all_tests
end
end