akhikolla / RcppDeepState

RcppDeepState, a simple way to fuzz test code in Rcpp packages
https://akhikolla.github.io./
8 stars 2 forks source link

tell the user when compilation/linking fails #31

Closed tdhock closed 4 years ago

tdhock commented 4 years ago

this is related to #30 in which deepstate test harness compilation says that compilation worked, but actually it did not because the test harness had not yet been generated.

you should also add code to handle (and a test case) packages with code that does not compile for whatever reason. Here is an example of some code for which linking fails but success is reported.

(base) tdhock@maude-MacBookPro:~/R/binsegRcpp$ git checkout does-not-compile
Already on 'does-not-compile'
Your branch is up to date with 'origin/does-not-compile'.

(base) tdhock@maude-MacBookPro:~/R/binsegRcpp$ R --vanilla -e 'RcppDeepState::deepstate_harness_compile_run(".")'

R version 4.0.2 (2020-06-22) -- "Taking Off Again"
Copyright (C) 2020 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

  Natural language support but running in an English locale

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

> RcppDeepState::deepstate_harness_compile_run(".")
[1] "rm -f *.o && make -f ./inst/testfiles/read_memory.Makefile "
clang++ -o  ~/R/binsegRcpp/inst/testfiles/read_memory_DeepState_TestHarness ~/R/binsegRcpp/inst/testfiles/read_memory_DeepState_TestHarness.o -I/home/tdhock/R/x86_64-pc-linux-gnu-library/4.0/RcppDeepState/include -I/home/tdhock/.RcppDeepState/deepstate-master/build -I/home/tdhock/.RcppDeepState/deepstate-master/src/include -L/home/tdhock/R/x86_64-pc-linux-gnu-library/4.0/RInside/lib -Wl,-rpath=/home/tdhock/R/x86_64-pc-linux-gnu-library/4.0/RInside/lib -L/home/tdhock/lib/R/lib -Wl,-rpath=/home/tdhock/lib/R/lib -L/home/tdhock/.RcppDeepState/deepstate-master/build -Wl,-rpath=/home/tdhock/.RcppDeepState/deepstate-master/build -lR -lRInside -ldeepstate  -I/home/tdhock/lib/R/include -I /home/tdhock/R/x86_64-pc-linux-gnu-library/4.0/Rcpp/include  -I /home/tdhock/R/x86_64-pc-linux-gnu-library/4.0/RcppArmadillo/include    -I /home/tdhock/.RcppDeepState/deepstate-master/src/include   ~/R/binsegRcpp/src/*.cpp
/home/tdhock/R/binsegRcpp/inst/testfiles/read_memory_DeepState_TestHarness.o: In function `DeepState_Test_read_memory_random_datatypes_read_memory_test()':
read_memory_DeepState_TestHarness.cpp:(.text+0x145a): undefined reference to `read_memory(int)'
/tmp/RcppExports-4b88db.o: In function `_binsegRcpp_read_memory':
RcppExports.cpp:(.text+0xce): undefined reference to `read_memory(int)'
clang: error: linker command failed with exit code 1 (use -v to see invocation)
inst/testfiles/read_memory.Makefile:5: recipe for target '/home/tdhock/R/binsegRcpp/inst/testfiles/read_memory_DeepState_TestHarness' failed
make: *** [/home/tdhock/R/binsegRcpp/inst/testfiles/read_memory_DeepState_TestHarness] Error 1
[1] "rm -f *.o && make -f ./inst/testfiles/read_new.Makefile "
clang++ -o  ~/R/binsegRcpp/inst/testfiles/read_new_DeepState_TestHarness ~/R/binsegRcpp/inst/testfiles/read_new_DeepState_TestHarness.o -I/home/tdhock/R/x86_64-pc-linux-gnu-library/4.0/RcppDeepState/include -I/home/tdhock/.RcppDeepState/deepstate-master/build -I/home/tdhock/.RcppDeepState/deepstate-master/src/include -L/home/tdhock/R/x86_64-pc-linux-gnu-library/4.0/RInside/lib -Wl,-rpath=/home/tdhock/R/x86_64-pc-linux-gnu-library/4.0/RInside/lib -L/home/tdhock/lib/R/lib -Wl,-rpath=/home/tdhock/lib/R/lib -L/home/tdhock/.RcppDeepState/deepstate-master/build -Wl,-rpath=/home/tdhock/.RcppDeepState/deepstate-master/build -lR -lRInside -ldeepstate  -I/home/tdhock/lib/R/include -I /home/tdhock/R/x86_64-pc-linux-gnu-library/4.0/Rcpp/include  -I /home/tdhock/R/x86_64-pc-linux-gnu-library/4.0/RcppArmadillo/include    -I /home/tdhock/.RcppDeepState/deepstate-master/src/include   ~/R/binsegRcpp/src/*.cpp
/tmp/RcppExports-52c34d.o: In function `_binsegRcpp_read_memory':
RcppExports.cpp:(.text+0xce): undefined reference to `read_memory(int)'
clang: error: linker command failed with exit code 1 (use -v to see invocation)
inst/testfiles/read_new.Makefile:5: recipe for target '/home/tdhock/R/binsegRcpp/inst/testfiles/read_new_DeepState_TestHarness' failed
make: *** [/home/tdhock/R/binsegRcpp/inst/testfiles/read_new_DeepState_TestHarness] Error 1
[1] "rm -f *.o && make -f ./inst/testfiles/read_malloc.Makefile "
clang++ -o  ~/R/binsegRcpp/inst/testfiles/read_malloc_DeepState_TestHarness ~/R/binsegRcpp/inst/testfiles/read_malloc_DeepState_TestHarness.o -I/home/tdhock/R/x86_64-pc-linux-gnu-library/4.0/RcppDeepState/include -I/home/tdhock/.RcppDeepState/deepstate-master/build -I/home/tdhock/.RcppDeepState/deepstate-master/src/include -L/home/tdhock/R/x86_64-pc-linux-gnu-library/4.0/RInside/lib -Wl,-rpath=/home/tdhock/R/x86_64-pc-linux-gnu-library/4.0/RInside/lib -L/home/tdhock/lib/R/lib -Wl,-rpath=/home/tdhock/lib/R/lib -L/home/tdhock/.RcppDeepState/deepstate-master/build -Wl,-rpath=/home/tdhock/.RcppDeepState/deepstate-master/build -lR -lRInside -ldeepstate  -I/home/tdhock/lib/R/include -I /home/tdhock/R/x86_64-pc-linux-gnu-library/4.0/Rcpp/include  -I /home/tdhock/R/x86_64-pc-linux-gnu-library/4.0/RcppArmadillo/include    -I /home/tdhock/.RcppDeepState/deepstate-master/src/include   ~/R/binsegRcpp/src/*.cpp
/tmp/RcppExports-8e9951.o: In function `_binsegRcpp_read_memory':
RcppExports.cpp:(.text+0xce): undefined reference to `read_memory(int)'
clang: error: linker command failed with exit code 1 (use -v to see invocation)
inst/testfiles/read_malloc.Makefile:5: recipe for target '/home/tdhock/R/binsegRcpp/inst/testfiles/read_malloc_DeepState_TestHarness' failed
make: *** [/home/tdhock/R/binsegRcpp/inst/testfiles/read_malloc_DeepState_TestHarness] Error 1
[1] "rm -f *.o && make -f ./inst/testfiles/binseg_normal.Makefile "
clang++ -o  ~/R/binsegRcpp/inst/testfiles/binseg_normal_DeepState_TestHarness ~/R/binsegRcpp/inst/testfiles/binseg_normal_DeepState_TestHarness.o -I/home/tdhock/R/x86_64-pc-linux-gnu-library/4.0/RcppDeepState/include -I/home/tdhock/.RcppDeepState/deepstate-master/build -I/home/tdhock/.RcppDeepState/deepstate-master/src/include -L/home/tdhock/R/x86_64-pc-linux-gnu-library/4.0/RInside/lib -Wl,-rpath=/home/tdhock/R/x86_64-pc-linux-gnu-library/4.0/RInside/lib -L/home/tdhock/lib/R/lib -Wl,-rpath=/home/tdhock/lib/R/lib -L/home/tdhock/.RcppDeepState/deepstate-master/build -Wl,-rpath=/home/tdhock/.RcppDeepState/deepstate-master/build -lR -lRInside -ldeepstate  -I/home/tdhock/lib/R/include -I /home/tdhock/R/x86_64-pc-linux-gnu-library/4.0/Rcpp/include  -I /home/tdhock/R/x86_64-pc-linux-gnu-library/4.0/RcppArmadillo/include    -I /home/tdhock/.RcppDeepState/deepstate-master/src/include   ~/R/binsegRcpp/src/*.cpp
/tmp/RcppExports-fb97b2.o: In function `_binsegRcpp_read_memory':
RcppExports.cpp:(.text+0xce): undefined reference to `read_memory(int)'
clang: error: linker command failed with exit code 1 (use -v to see invocation)
inst/testfiles/binseg_normal.Makefile:5: recipe for target '/home/tdhock/R/binsegRcpp/inst/testfiles/binseg_normal_DeepState_TestHarness' failed
make: *** [/home/tdhock/R/binsegRcpp/inst/testfiles/binseg_normal_DeepState_TestHarness] Error 1
[1] "rm -f *.o && make -f ./inst/testfiles/binseg_normal_cost.Makefile "
clang++ -o  ~/R/binsegRcpp/inst/testfiles/binseg_normal_cost_DeepState_TestHarness ~/R/binsegRcpp/inst/testfiles/binseg_normal_cost_DeepState_TestHarness.o -I/home/tdhock/R/x86_64-pc-linux-gnu-library/4.0/RcppDeepState/include -I/home/tdhock/.RcppDeepState/deepstate-master/build -I/home/tdhock/.RcppDeepState/deepstate-master/src/include -L/home/tdhock/R/x86_64-pc-linux-gnu-library/4.0/RInside/lib -Wl,-rpath=/home/tdhock/R/x86_64-pc-linux-gnu-library/4.0/RInside/lib -L/home/tdhock/lib/R/lib -Wl,-rpath=/home/tdhock/lib/R/lib -L/home/tdhock/.RcppDeepState/deepstate-master/build -Wl,-rpath=/home/tdhock/.RcppDeepState/deepstate-master/build -lR -lRInside -ldeepstate  -I/home/tdhock/lib/R/include -I /home/tdhock/R/x86_64-pc-linux-gnu-library/4.0/Rcpp/include  -I /home/tdhock/R/x86_64-pc-linux-gnu-library/4.0/RcppArmadillo/include    -I /home/tdhock/.RcppDeepState/deepstate-master/src/include   ~/R/binsegRcpp/src/*.cpp
/tmp/RcppExports-a293c1.o: In function `_binsegRcpp_read_memory':
RcppExports.cpp:(.text+0xce): undefined reference to `read_memory(int)'
clang: error: linker command failed with exit code 1 (use -v to see invocation)
inst/testfiles/binseg_normal_cost.Makefile:5: recipe for target '/home/tdhock/R/binsegRcpp/inst/testfiles/binseg_normal_cost_DeepState_TestHarness' failed
make: *** [/home/tdhock/R/binsegRcpp/inst/testfiles/binseg_normal_cost_DeepState_TestHarness] Error 1
[1] "Compiled all the functions in the package successfully"
> 
> 
(base) tdhock@maude-MacBookPro:~/R/binsegRcpp$ 

You should stop as soon as one of those compilation commands fails, so the user knows he needs to fix that.

akhikolla commented 4 years ago

Displaying a message when the user is unable to compile the codes. checking for deepstate test harness files and makefiles and as well as checking for the TestHarness executable generation and reports the user with a message saying the couldn't compile the testharness.

> deepstate_harness_compile_run("/home/akhila/R/binsegRcpp")
[1] "/home/akhila/R/binsegRcpp/inst/testfiles/rcpp_binseg_normal/Makefile"
TestHarness and makefile doesn't exist for - rcpp_binseg_normal
[1] "/home/akhila/R/binsegRcpp/inst/testfiles/rcpp_binseg_normal_cost/Makefile"
TestHarness and makefile doesn't exist for - rcpp_binseg_normal_cost
[1] "Issue compiling the function - rcpp_binseg_normal"     
[2] "Issue compiling the function - rcpp_binseg_normal_cost"
tdhock commented 4 years ago

are you using print? you should use message or warning instead.