diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..8ce53dc --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,19 @@ +name: Test +on: + pull_request: + +jobs: + testLinux: + name: Test Linux + runs-on: "ubuntu-latest" + steps: + - uses: actions/checkout@v2 + - run: | + make && make test + testOSX: + name: Test OSX + runs-on: "macos-latest" + steps: + - uses: actions/checkout@v2 + - run: | + make && make test diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index cea8d84..0000000 --- a/.travis.yml +++ /dev/null @@ -1,9 +0,0 @@ -sudo: false -language: c -os: - - linux - - osx -script: make && make test -compiler: - - clang - - gcc diff --git a/2bit.c b/2bit.c index df56782..bb0eee9 100644 --- a/2bit.c +++ b/2bit.c @@ -69,7 +69,7 @@ void bytes2bases(char *seq, uint8_t *byte, uint32_t sz, int offset) { // Deal with the first partial byte if(offset != 0) { - while(offset < 4) { + while(offset < 4 && pos < sz) { seq[pos++] = byte2base(foo, offset++); } if(pos >= sz) return; diff --git a/test/expected b/test/expected new file mode 100644 index 0000000..81038c3 --- /dev/null +++ b/test/expected @@ -0,0 +1,12 @@ +0 chr1 150 offset 0x4a +1 chr2 100 offset 0x88 +NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNACGTACGTACGTagctagctGATCGATCGTAGCTAGCTAGCTAGCTGATCNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN +NNNNNNNNNNNNNNNNNNNNNNNNNNACGTACGTACGTagctagctGATC +0 0.080000 +1 0.080000 +2 0.086667 +3 0.086667 +0 0.120000 +1 0.120000 +2 0.120000 +3 0.120000 diff --git a/test/test.py b/test/test.py index cec6832..7f1484b 100755 --- a/test/test.py +++ b/test/test.py @@ -9,12 +9,9 @@ # N.B., this MUST be run from within the source directory! # Read test -p1 = Popen(["./test/exampleRead", "test/foo.2bit"], stdout=PIPE) -try: - p2 = Popen(["md5sum"], stdin=p1.stdout, stdout=PIPE) -except: - p2 = Popen(["md5"], stdin=p1.stdout, stdout=PIPE) -md5sum = p2.communicate()[0].strip().split()[0] -assert(md5sum == "0274c32c7f3dd75e8991f6107dca6a5f") +o = open("test/found", "w") +check_call(["./test/exampleRead", "test/foo.2bit"], stdout=o) +o.close() +check_call(["diff", "test/found", "test/expected"]) print("Passed!")