Sha256: 7a03a030b6888b071d01a64bf9388cee01c341936b125320881ca7fa0dc53929

Contents?: true

Size: 902 Bytes

Versions: 2

Compression:

Stored size: 902 Bytes

Contents

#!/usr/bin/env ruby
# encoding: UTF-8

require 'spruz/xt'
require 'spruz/lines_file'
include Spruz::GO
require 'utils'
include Utils

def cmd(*args)
  puts args * ' '
  exec *args
end

filename = ARGV.shift or fail "require filename or filename:line_number as first argument"
$opt = go 'n:'
if testname = $opt['n']
  cmd "testrb", '-I', 'lib:test:ext', '-n', testname , filename
elsif filename =~ /^\s*([^:]+):(\d+)/
  filename, line_number = $1, $2
  lf = Spruz::LinesFile.for_filename filename, line_number.to_i
  if testname = lf.match_backward(/def\s+(\S+?)(?:\(|\s*$)/).full?(:first)
    puts "Running test #{testname.inspect} at #{filename}:#{lf.line_number}"
    cmd "testrb", '-I', 'lib:test:ext', '-n', testname , filename
  else
    warn "no test found before line #{line_number}"
    exit 1
  end
else
  puts "Running ALL tests in #{filename}"
  cmd "testrb", '-Ilib:test:ext', filename
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
utils-0.0.18 bin/probe
utils-0.0.17 bin/probe