Skip to content
Snippets Groups Projects
Commit 306aa66d authored by Veronique Legrand's avatar Veronique Legrand
Browse files

Made better use of tests with cmake to make installation of the software easier

parent 9dc48b2b
No related branches found
Tags v1.0
No related merge requests found
Pipeline #71122 passed
...@@ -7,7 +7,4 @@ makefile_generation_and_compilation_plus_run_nrt_tests_cluster: ...@@ -7,7 +7,4 @@ makefile_generation_and_compilation_plus_run_nrt_tests_cluster:
- echo $PATH - echo $PATH
- cmake .. - cmake ..
- cmake --build . - cmake --build .
- ./test_FqBackend - make test
- ./test_InfoDisplay
- ../../test/nrt_test.sh .
...@@ -69,6 +69,14 @@ message(" directory above is : ${DIR_ONE_ABOVE}") ...@@ -69,6 +69,14 @@ message(" directory above is : ${DIR_ONE_ABOVE}")
#if (POSIX_SH_PROGRAM) #if (POSIX_SH_PROGRAM)
# add_test(non_regression ${POSIX_SH_PROGRAM} ${DIR_ONE_ABOVE}/test/nrt_test.sh) # add_test(non_regression ${POSIX_SH_PROGRAM} ${DIR_ONE_ABOVE}/test/nrt_test.sh)
#endif(POSIX_SH_PROGRAM) #endif(POSIX_SH_PROGRAM)
enable_testing()
set(TEST_DATA_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../test/data)
set(TEST_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../test)
add_test(NAME unit_fqBackend COMMAND test_FqBackend WORKING_DIRECTORY ${TEST_DATA_DIR})
add_test(NAME unit_infoDisplay COMMAND test_InfoDisplay WORKING_DIRECTORY ${TEST_DATA_DIR})
if (POSIX_SH_PROGRAM)
add_test(non_regression ${POSIX_SH_PROGRAM} ${TEST_DIR}/nrt_test.sh . ${TEST_DATA_DIR})
endif(POSIX_SH_PROGRAM)
message("* Current build type is : ${CMAKE_BUILD_TYPE}") message("* Current build type is : ${CMAKE_BUILD_TYPE}")
...@@ -95,7 +95,8 @@ void check_row(const FqInfos& fq_infos, const T_expected& exp, unsigned int i) { ...@@ -95,7 +95,8 @@ void check_row(const FqInfos& fq_infos, const T_expected& exp, unsigned int i) {
TEST_CASE("Process a fastq file and returns a structure that contains information on it (number of reads, number of bases and so on") { TEST_CASE("Process a fastq file and returns a structure that contains information on it (number of reads, number of bases and so on") {
FqInfos fq_infos; FqInfos fq_infos;
FqBackend be("../../test/data/klebsiella_100_1.fq"); //FqBackend be("../../test/data/klebsiella_100_1.fq");
FqBackend be("klebsiella_100_1.fq");
be.processFile(); be.processFile();
fq_infos=be.getInfos(); fq_infos=be.getInfos();
check_totals(fq_infos); check_totals(fq_infos);
...@@ -151,8 +152,13 @@ TEST_CASE("Process a fastq file and returns a structure that contains informatio ...@@ -151,8 +152,13 @@ TEST_CASE("Process a fastq file and returns a structure that contains informatio
} }
TEST_CASE("Checks the case of @ and + characters in read score") { TEST_CASE("Checks the case of @ and + characters in read score") {
/*
char buf[10000];
char * ret=getcwd(buf,10000);
cout<<"working dir: "<<buf<<endl;*/
FqInfos fq_infos; FqInfos fq_infos;
FqBackend be("../../test/data/SRR1.fq"); //FqBackend be("../../test/data/SRR1.fq");
FqBackend be("SRR1.fq");
be.processFile(); be.processFile();
fq_infos=be.getInfos(); fq_infos=be.getInfos();
REQUIRE(fq_infos.nb_reads==1); REQUIRE(fq_infos.nb_reads==1);
......
...@@ -66,10 +66,12 @@ int compareFilesLileByLine(char * filename1,char* filename2) { ...@@ -66,10 +66,12 @@ int compareFilesLileByLine(char * filename1,char* filename2) {
TEST_CASE("Loads a serialized FqInfos object and format its content for display") { TEST_CASE("Loads a serialized FqInfos object and format its content for display") {
FqInfos fq_infos; FqInfos fq_infos;
fq_infos.deserialize("../../test/data/FqInfos.txt"); //fq_infos.deserialize("../../test/data/FqInfos.txt");
fq_infos.deserialize("FqInfos.txt");
ofstream o("formatted.txt"); ofstream o("formatted.txt");
InfoDisplay d=InfoDisplay(&o); InfoDisplay d=InfoDisplay(&o);
d.display(fq_infos); d.display(fq_infos);
int ret=compareFilesLileByLine((char *) "formatted.txt",(char *) "../../test/data/output_fastq_info.txt"); //int ret=compareFilesLileByLine((char *) "formatted.txt",(char *) "../../test/data/output_fastq_info.txt");
int ret=compareFilesLileByLine((char *) "formatted.txt",(char *) "output_fastq_info.txt");
REQUIRE(ret==0); REQUIRE(ret==0);
} }
#!/bin/sh #!/bin/sh
# test script intended to be ran from exe_dir # test script intended to be ran from exe_dir
exe_dir=$1 exe_dir=$1
test_dir=../../test #test_dir=../../test
data_dir=$2
echo "test1" echo "test1"
pwd pwd
$exe_dir/fqreport -i $test_dir/data/klebsiella_100_1.fq>out1.txt || exit 1 #$exe_dir/fqreport -i $data_dir/klebsiella_100_1.fq>out1.txt || exit 1
cmp out1.txt $test_dir/data/output_fastq_info.txt || exit 2 #cmp out1.txt $data_dir/output_fastq_info.txt || exit 2
echo "test2" echo "test2"
$exe_dir/fqreport -i $test_dir/data/klebsiella_100_1.fq -f "test">out1.txt ||exit 3 $exe_dir/fqreport -i $data_dir/klebsiella_100_1.fq -f "test">out1.txt ||exit 3
grep -q "test" out1.txt || exit 4 grep -q "test" out1.txt || exit 4
cmp out1.txt $test_dir/data/output_fastq_info_fname.txt || exit 5 cmp out1.txt $data_dir/output_fastq_info_fname.txt || exit 5
echo "test3" echo "test3"
cat $test_dir/data/klebsiella_100_1.fq|$exe_dir/fqreport>out1.txt ||exit 6 cat $data_dir/klebsiella_100_1.fq|$exe_dir/fqreport>out1.txt ||exit 6
cmp out1.txt $test_dir/data/output_fastq_info_noname.txt || exit 7 cmp out1.txt $data_dir/output_fastq_info_noname.txt || exit 7
echo "test4" echo "test4"
cat $test_dir/data/klebsiella_100_1.fq|$exe_dir/fqreport -f "test" -p 33 >out1.txt||exit 8 cat $data_dir/klebsiella_100_1.fq|$exe_dir/fqreport -f "test" -p 33 >out1.txt||exit 8
cmp out1.txt $test_dir/data/output_fastq_info_fname.txt|| exit 9 cmp out1.txt $data_dir/output_fastq_info_fname.txt|| exit 9
echo "test5" echo "test5"
cat $test_dir/data/klebsiella_100_1.fq|$exe_dir/fqreport -f "test" -p 33 -o out1.txt ||exit 10 cat $data_dir/klebsiella_100_1.fq|$exe_dir/fqreport -f "test" -p 33 -o out1.txt ||exit 10
cmp out1.txt $test_dir/data/output_fastq_info_fname.txt|| exit 11 cmp out1.txt $data_dir/output_fastq_info_fname.txt|| exit 11
echo "test6" echo "test6"
$exe_dir/fqreport -i $test_dir/data/klebsiella_100_1.fq -f "test" -p 33 -o out1.txt ||exit 12 $exe_dir/fqreport -i $data_dir/klebsiella_100_1.fq -f "test" -p 33 -o out1.txt ||exit 12
cmp out1.txt $test_dir/data/output_fastq_info_fname.txt|| exit 13 cmp out1.txt $data_dir/output_fastq_info_fname.txt|| exit 13
echo "test7" echo "test7"
ret=`$exe_dir/fqreport -i $test_dir/data/klebsiella_100_1.fq -f "test" -p 34 -o out1.txt` ret=`$exe_dir/fqreport -i $data_dir/klebsiella_100_1.fq -f "test" -p 34 -o out1.txt`
if [ "$?" -eq 0 ]; then exit 14;fi if [ "$?" -eq 0 ]; then exit 14;fi
echo $ret|grep -q -v "USAGE" out1.txt || exit 15 echo $ret|grep -q -v "USAGE" out1.txt || exit 15
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment