~tim/scheme-vm

194d379f9451212a60308f300695a526a5d6ebf1 — Tim Morgan 4 years ago 192cb76
Update watchr script to only run relevant specs
2 files changed, 18 insertions(+), 5 deletions(-)

M .watchr
M spec/lib_spec.rb
M .watchr => .watchr +17 -4
@@ 1,8 1,21 @@
def run_suite
  cmd = IO.popen('rspec --color --tty spec 2>&1')
def run_tests(files, scm_file = nil)
  if scm_file
    puts scm_file
    env = { 'SCM_FILE' => scm_file }
  else
    puts files
    env = {}
  end
  cmd = IO.popen(env, "rspec --color --tty #{files} 2>&1")
  print cmd.getc until cmd.eof?
end

watch('.*') { run_suite }
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') }
watch('^vm.*')              { |m| run_tests('spec/vm_spec.rb spec/vm/*') }
watch('^compiler.*')        { |m| run_tests('spec/compiler_spec.rb spec/compiler/*') }
watch('^program.*')         { |m| run_tests('spec/program_spec.rb spec/program/*') }
watch('^parser.*')          { |m| run_tests('spec/parser_spec.rb spec/parser/*') }

Signal.trap('QUIT') { run_suite } # Ctrl-\
Signal.trap('QUIT') { run_tests('spec') } # Ctrl-\

M spec/lib_spec.rb => spec/lib_spec.rb +1 -1
@@ 10,7 10,7 @@ cached_program = Marshal.dump(program)
Dir[File.expand_path('../lib/**/*.scm', __FILE__)].each do |path|
  describe File.split(path).last do
    code = File.read(path).sub(/\(import \(scheme base\)\s+\(assert\)\s*\)/, '')
    focus = !(code =~ /^;; focus/).nil?
    focus = !(code =~ /^;; focus/).nil? || ENV['SCM_FILE'] == path[-ENV['SCM_FILE'].to_s.size..-1]
    skip = !(code =~ /^;; skip/).nil?
    debug = code =~ /^;; debug/ ? 2 : 0
    it 'passes all tests', focus: focus, skip: skip do