~tim/scheme-vm

b7d99956c3c87a762cf8b704f2fa1ec1c6e99c49 — Tim Morgan 3 years ago 26d3baf
Improve .watchr script
1 files changed, 11 insertions(+), 0 deletions(-)

M .watchr
M .watchr => .watchr +11 -0
@@ 1,4 1,8 @@
def run_tests(files, scm_file = nil)
  if (ft = focused_tests).any?
    puts "Running focused test(s)..."
    files = ft.join(' ')
  end
  if scm_file
    puts scm_file
    env = { 'SCM_FILE' => scm_file }


@@ 11,10 15,17 @@ def run_tests(files, scm_file = nil)
end

def compile
  puts
  puts '========================================='
  puts
  cmd = IO.popen('cargo build --release')
  print cmd.getc until cmd.eof?
end

def focused_tests
  Dir['spec/**/*_spec.rb'].to_a.select { |f| File.read(f).match(/focus|focus:|fdescribe|fcontext|fit ['"]/) rescue nil }
end

watch('^spec/.*_spec\.rb')  { |m| run_tests(m.to_s) }
watch('^spec/.*-spec\.scm') { |m| run_tests('spec/lib_spec.rb', m.to_s) }
watch('^lib')               { |m| run_tests('spec/lib_spec.rb') }