aboutsummaryrefslogtreecommitdiff
path: root/test/lib/test-helpers.rb
blob: 72b9cd91467849f62661e4d39a9dc970fe4468fe (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
module TestHelpers

  # Runs gemma and returns true if successful
  def gemma(opts)
    system("./bin/gemma #{opts}")
  end

  def read(fn, line=0)
    count = 0
    File.open(fn, "r:utf-8").each_line { |ln|
      return ln.chomp.split("\t") if count == line
      count += 1
    }
  end

  def expect(fn, list)
    lines = File.read(fn).split("\n") # avoid this for large files
    list.each do | l |
      line,colnum,value = l
      cols = lines[line].chomp.split("\t")
      assert_equal value,cols[colnum]
    end
  end
end