Git Product home page Git Product logo

Comments (10)

hadley avatar hadley commented on September 14, 2024

Failure with Rscript but not R, usually indicates that I've forgotten to declare a base R package dependency.

from testthat.

floybix avatar floybix commented on September 14, 2024

Seems to be something to do with ReferenceClasses...

$ Rscript -e "library(testthat); library(methods); SummaryReporter$new"
NULL

whereas the same in an interactive session prints out a class method definition. But I can't see any difference in the sessionInfo() between the two cases, arrgh

from testthat.

hadley avatar hadley commented on September 14, 2024

It works with R -e, but not with Rscript, but I don't see any differences in sessionInfo either:

public : R -e "library(testthat); sessionInfo()"
> library(testthat); sessionInfo()
R version 2.14.1 (2011-12-22)
Platform: x86_64-apple-darwin9.8.0/x86_64 (64-bit)

locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

attached base packages:
[1] stats     graphics  utils     datasets  grDevices methods   base     

other attached packages:
[1] testthat_0.6

loaded via a namespace (and not attached):
[1] evaluate_0.3 plyr_1.7.1   stringr_0.6 
> 
> 
public : Rscript -e "library(testthat); sessionInfo()"
R version 2.14.1 (2011-12-22)
Platform: x86_64-apple-darwin9.8.0/x86_64 (64-bit)

locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

attached base packages:
[1] stats     graphics  utils     datasets  grDevices base     

other attached packages:
[1] testthat_0.6

loaded via a namespace (and not attached):
[1] evaluate_0.3 plyr_1.7.1   stringr_0.6 

from testthat.

hadley avatar hadley commented on September 14, 2024

Oh, except that methods is missing, and order seems to matter:


Rscript -e "library(methods); library(testthat); SummaryReporter\$new"Class method definition for method new()
function (...) 
{
    methods::new(def, ...)
}
<environment: 0x102fe10a8>

 Methods used:  
    "methods", "new"

from testthat.

markmfredrickson avatar markmfredrickson commented on September 14, 2024

I think this bug is still live. I've install_githubed from master.

I run auto test via R -e from within a Makefile, though it also occurs in interactive sessions. I think it cropped up when I upgraded 2.14, though I'm not actually sure.

testthat will run the tests initially just fine. If I change the source documents, the tests are properly restarted and run. However, when I change a test file, I get:

Rerunning tests:  test.testStatistics.R 
Error in envRefInferField(x, what, getClass(class(x)), selfEnv) : 
  "new" is not a valid field or method name for reference class “SummaryReporter”

While not necessarily the cleanest test case, you can run my tests via:

$ git clone [email protected]:markmfredrickson/RItools.git
$ cd RItools
$ make autotest
... add a space to tests/test.*

from testthat.

xuanxu avatar xuanxu commented on September 14, 2024

I'm still having this bug with R 2.15.0 and testthat 0.6. when running a script via Rscript

Error in find_reporter(reporter) : attempt to apply non-function
Calls: test_dir -> find_reporter
Execution halted

With a simple tests.R using test_dir():

#!/usr/bin/env Rscript
library("testthat")
test_dir("distributions/tests/")

+1 to reopen the issue.

from testthat.

hadley avatar hadley commented on September 14, 2024

@xuanxu - you need the development version from github.

@markmfredrickson - that sounds like a different bug (which I'm pretty sure I've also fixed)

from testthat.

markmfredrickson avatar markmfredrickson commented on September 14, 2024

@markmfredrickson - that sounds like a different bug (which I'm pretty sure I've also fixed)

Confirmed. Thanks!

from testthat.

xuanxu avatar xuanxu commented on September 14, 2024

Thanks @hadley, is there a new version release planned anytime soon?

from testthat.

hadley avatar hadley commented on September 14, 2024

Yes, hopefully in the next week or two.

from testthat.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.