Skip to content

Instantly share code, notes, and snippets.

@seven1m
Created July 17, 2018 01:31
Show Gist options
  • Save seven1m/5dcc4c9f47f066360f59139fe1884a8e to your computer and use it in GitHub Desktop.
Save seven1m/5dcc4c9f47f066360f59139fe1884a8e to your computer and use it in GitHub Desktop.
Observr script for comiling a Rust project and running tests when files are saved.
require 'open3'
def test
puts
puts '========================================='
puts
_, stdout, wait_thr = Open3.popen2('cargo test -- --nocapture --test-threads=1')
print stdout.getc until stdout.eof?
wait_thr.value.success?
end
def build
puts
puts '========================================='
puts
_, stdout, wait_thr = Open3.popen2('cargo build')
print stdout.getc until stdout.eof?
wait_thr.value.success?
end
def bench
puts
puts '========================================='
puts
_, stdout, wait_thr = Open3.popen2('cargo bench -- --nocapture')
print stdout.getc until stdout.eof?
wait_thr.value.success?
end
watch('^src/.*') { test && build }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment