[R-sig-Debian] running unit tests on the stringr package
Johannes Ranke
jranke at uni-bremen.de
Mon Apr 20 11:36:11 CEST 2015
Dear Raju
I agree to Dirk that this is not really the best place for these matters, but
as I got curious, I checked and found you should use test_package() and not
test_dir(), as the latter does not load unexported functions of the package
(such as check_string()) that may occur in the tests.
For packaging of r-cran-stringr, it is probably most efficient to file a bug
report there because of the missing Suggests for r-cran-testthat.
Kind regards,
Johannes
Am Sonntag, 19. April 2015, 17:58:53 schrieb kamaraju kusumanchi:
> I am trying to learn how to run the unit tests in the stringr package
> and have the following questions.
>
> 1) The r-cran-stringr package does not suggest/depend on the
> r-cran-testthat package . Would it make sense to add such a thing
> since after all the tests in /usr/lib/R/site-library/stringr/tests
> rely on testthat package?
>
> 2) I am getting the following error when trying to run the unit tests
>
> % R
> R version 3.1.1 (2014-07-10) -- "Sock it to Me"
> ...
>
> > library('testthat')
> > library('stringr')
> > test_dir('/usr/lib/R/site-library/stringr/tests')
>
> String and pattern checks : 123
> Counting matches : ....
> Detecting patterns : ..........
> Duplicating strings : ......
> Extract patterns : ..
> Joining strings : ......
> String length : .........
> Locations : ............
> Matching groups : ..............
> Test padding : ....
> Splitting strings : .........................
> Extracting substrings : ...................
> Trimming strings : ........
>
>
> 1. Failure(@test-check.r#4): string is atomic
> ---------------------------------- check_string(list()) does not match
> 'must be an atomic'. Actual value: "Error in force(expr) : could not find
> function "check_string"\n"
>
> 2. Failure(@test-check.r#9): pattern is a string
> ------------------------------- check_pattern(1) does not match 'must be a
> character vector'. Actual value: "Error in force(expr) : could not find
> function
> "check_pattern"\n"
>
> 3. Error: error when string and pattern lengths incompatible
> ------------------- could not find function "check_pattern"
> 1: withCallingHandlers(eval(code, new_test_environment), error =
> capture_calls) 2: eval(code, new_test_environment)
> 3: eval(expr, envir, enclos)
> 4: expect_that(check_pattern(letters, "a"), equals(letters)) at
> test-check.r:14 5: condition(object)
> 6: compare(expected, actual, ...)
> 7: compare.character(expected, actual, ...)
> 8: identical(x, y)
>
> What am I doing wrong?
>
> I am using a Debian box with a combo of Wheezy + Jessie
>
> % dpkg -l r-cran-testthat r-cran-stringr r-base
> ii r-base 3.1.1-1 all
> GNU R statistical computation and graphics system
> ii r-cran-stringr 0.6.2-2 all
> Make it easier to work with strings
> ii r-cran-testthat 0.9.1-1 amd64
> GNU R testsuite
>
> regards
> raju
--
PD Dr. Johannes Ranke
Kronacher Str. 8
79639 Grenzach-Wyhlen
More information about the R-SIG-Debian
mailing list