From 915a4cf3a34dc2b3610fca188a63783034996475 Mon Sep 17 00:00:00 2001 From: Devon Ryan Date: Mon, 18 Nov 2024 10:08:02 +0100 Subject: [PATCH 1/8] Address #10, don't write 4 bytes if fewer were requested --- 2bit.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/2bit.c b/2bit.c index df56782..ecf5593 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 < min(4, sz)) { seq[pos++] = byte2base(foo, offset++); } if(pos >= sz) return; From 5ee03788ed5e59fce4ce496887e37077f9471de8 Mon Sep 17 00:00:00 2001 From: Devon Ryan Date: Mon, 18 Nov 2024 10:25:20 +0100 Subject: [PATCH 2/8] test on github actions now --- .github/workflows/test.yml | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 .github/workflows/test.yml diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..fcfc8c5 --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,13 @@ +name: Test +on: + pull_request: + push: + +jobs: + test: + name: Test Linux + runs-on: ["ubuntu-latest", "macos-latest"] + steps: + - uses: actions/checkout@v2 + - run: | + make && make test From 9d50aba7804220df32f2eda5be1c8dbbb3c5aa97 Mon Sep 17 00:00:00 2001 From: Devon Ryan Date: Mon, 18 Nov 2024 10:27:04 +0100 Subject: [PATCH 3/8] typo --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index fcfc8c5..d55cb11 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -10,4 +10,4 @@ jobs: steps: - uses: actions/checkout@v2 - run: | - make && make test + make && make test From 0a57d8e43bb7fa36d7865125b8eb38416173f9d1 Mon Sep 17 00:00:00 2001 From: Devon Ryan Date: Mon, 18 Nov 2024 10:29:53 +0100 Subject: [PATCH 4/8] Not on push, also on OSX --- .github/workflows/test.yml | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index d55cb11..8ce53dc 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -1,12 +1,18 @@ name: Test on: pull_request: - push: jobs: - test: + testLinux: name: Test Linux - runs-on: ["ubuntu-latest", "macos-latest"] + 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: | From 52d3f7c38e17cd98e7a9ed5aa3cbdcec2e6efd24 Mon Sep 17 00:00:00 2001 From: Devon Ryan Date: Mon, 18 Nov 2024 10:35:19 +0100 Subject: [PATCH 5/8] This should be the better solution --- 2bit.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/2bit.c b/2bit.c index ecf5593..d98e5e4 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 < min(4, sz)) { + while(offset < sz && pos < sz) { seq[pos++] = byte2base(foo, offset++); } if(pos >= sz) return; From 0675b5c2bef023d1017796baff8bcdbd39eed628 Mon Sep 17 00:00:00 2001 From: Devon Ryan Date: Mon, 18 Nov 2024 10:37:33 +0100 Subject: [PATCH 6/8] debug test failure --- Makefile | 1 + 1 file changed, 1 insertion(+) diff --git a/Makefile b/Makefile index fe4fc63..242ffb3 100644 --- a/Makefile +++ b/Makefile @@ -47,6 +47,7 @@ test/exampleRead: lib2bit.so $(CC) -o $@ -I. -L. $(CFLAGS) test/exampleRead.c -l2bit $(LIBS) -Wl,-rpath . test: test/exampleRead + ./test/exampleRead test/foo.2bit ./test/test.py clean: From 26fc612fad8c8c9ea6da09f5bb206de8fe028d29 Mon Sep 17 00:00:00 2001 From: Devon Ryan Date: Mon, 18 Nov 2024 10:58:03 +0100 Subject: [PATCH 7/8] fix testing, compare to the expected output --- Makefile | 1 - test/expected | 12 ++++++++++++ test/test.py | 11 ++++------- 3 files changed, 16 insertions(+), 8 deletions(-) create mode 100644 test/expected diff --git a/Makefile b/Makefile index 242ffb3..fe4fc63 100644 --- a/Makefile +++ b/Makefile @@ -47,7 +47,6 @@ test/exampleRead: lib2bit.so $(CC) -o $@ -I. -L. $(CFLAGS) test/exampleRead.c -l2bit $(LIBS) -Wl,-rpath . test: test/exampleRead - ./test/exampleRead test/foo.2bit ./test/test.py clean: 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!") From 8895bfa67827fb8f06375a4269a244a11e14ccf5 Mon Sep 17 00:00:00 2001 From: Devon Ryan Date: Mon, 18 Nov 2024 11:00:01 +0100 Subject: [PATCH 8/8] Revert intermediate change --- .travis.yml | 9 --------- 2bit.c | 2 +- 2 files changed, 1 insertion(+), 10 deletions(-) delete mode 100644 .travis.yml 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 d98e5e4..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 < sz && pos < sz) { + while(offset < 4 && pos < sz) { seq[pos++] = byte2base(foo, offset++); } if(pos >= sz) return;