aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile12
-rw-r--r--guix.scm6
-rwxr-xr-xrun_tests.sh6
-rw-r--r--test/dev_tests.rb25
-rw-r--r--test/lib/test-helpers.rb24
5 files changed, 60 insertions, 13 deletions
diff --git a/Makefile b/Makefile
index fd0e55b..a671e46 100644
--- a/Makefile
+++ b/Makefile
@@ -234,9 +234,13 @@ unittests: all ./bin/unittests-gemma
./bin/unittests-gemma
fast-check: all unittests
+ rm -vf output/*
+ ruby -Eutf-8 -Itest ./test/dev_tests.rb | tee ./dev_test.log
+
+old-check: all unittests
rm -vf test/output/*
- cd test && ./dev_test_suite.sh | tee ../dev_test.log
- grep -q 'success rate: 100%' dev_test.log
+ cd test && ./dev_test_suite.sh | tee ../test.log
+ grep -q 'success rate: 100%' test.log
slow-check: all
rm -vf test/output/*
@@ -248,9 +252,7 @@ lengthy-check: all
cd test && ./lengthy_test_suite.sh | tee ../lengthy_test.log
grep -q 'success rate: 100%' lengthy_test.log
-check: fast-check slow-check
-
-check-all: check lengthy-check
+check: fast-check
clean:
rm -vf $(SRC_DIR)/*.o
diff --git a/guix.scm b/guix.scm
index 2eea555..188c842 100644
--- a/guix.scm
+++ b/guix.scm
@@ -24,7 +24,8 @@
(gnu packages ninja)
(gnu packages parallel)
(gnu packages perl)
- (gnu packages perl6)
+ ;; (gnu packages perl6)
+ (gnu packages ruby)
(gnu packages pkg-config)
;; (gnu packages shell) ;; for shunit2
(srfi srfi-1)
@@ -50,11 +51,12 @@
("gsl" ,gsl)
;; ("shunit2" ,shunit2) ;; comes with gemma
("openblas" ,openblas)
+ ("ruby" ,ruby) ;; for testing
("zlib:static" ,zlib "static")
("zlib" ,zlib)
))
(native-inputs ; for running tests
- `(("perl" ,perl)
+ `(("perl" ,perl)
("which" ,which)
))
(home-page "https://github.com/genetics-statistics")
diff --git a/run_tests.sh b/run_tests.sh
deleted file mode 100755
index 1b220b0..0000000
--- a/run_tests.sh
+++ /dev/null
@@ -1,6 +0,0 @@
-#!/usr/bin/env bash
-
-# The "tr" command fixes the ^M characters in the output.
-cd test
-./test_suite.sh 2>&1 | tr '\r' '\n' > test.log
-cat test.log | grep -q 'success rate: 100%'
diff --git a/test/dev_tests.rb b/test/dev_tests.rb
new file mode 100644
index 0000000..8ce8dbc
--- /dev/null
+++ b/test/dev_tests.rb
@@ -0,0 +1,25 @@
+
+require 'minitest/autorun'
+require 'lib/test-helpers'
+
+class TestQuick < MiniTest::Test
+
+ include TestHelpers
+
+ def setup
+ end
+
+ def test_linear_model
+ assert gemma("-g ./example/mouse_hs1940.geno.txt.gz \
+ -p ./example/mouse_hs1940.pheno.txt \
+ -n 1 \
+ -a ./example/mouse_hs1940.anno.txt \
+ -lm \
+ -o mouse_hs1940_CD8_lm")
+
+ expect('output/mouse_hs1940_CD8_lm.assoc.txt',[[2,1,"rs3707673"],
+ [2,10,"5.252187e-05"],
+ [3,9,"3.909916e-02"]])
+ end
+
+end
diff --git a/test/lib/test-helpers.rb b/test/lib/test-helpers.rb
new file mode 100644
index 0000000..72b9cd9
--- /dev/null
+++ b/test/lib/test-helpers.rb
@@ -0,0 +1,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