-
Notifications
You must be signed in to change notification settings - Fork 37
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Test #40
Conversation
I tried run_tests("firefox") from both /animint and /animint/tests, but neither worked... (same for phantomjs)
|
@tdhock you'll want to The newest version seems to break testing on the master branch (different arguments), but the exciting thing for us is that he added native support for spawning a daemonized file server. This should improve our current hack, but it seems to be the root of the Anyway, I started #41, which simply tries to implement the new daemon support. Let's try to get that working first... |
@tdhock The way we currently run tests (e.g. |
sure, that sounds fine to include those functions in the package and export On Fri, Jan 30, 2015 at 6:48 PM, Carson notifications@github.com wrote:
|
Ah, yes, I usually inject a library(animint)
init_tests("firefox")
run_tests(filter = "new-test") If tests fail, inject a devtools::load_all()
run_tests(filter = "new-test") |
And, actually for sake of autocomplete, these probably make more sense:
|
which and Sys.which depends on your PATH environment variable which you can get from the shell via
or in R via
so maybe you have to add something to the PATH ? it is weird if /usr/local/bin is not on the PATH by default, but you could add it via (before starting R)
|
- sudo rm -rf /usr/local/phantomjs | ||
- curl -L -O https://s3.amazonaws.com/travis-phantomjs/phantomjs-2.0.0-ubuntu-12.04.tar.bz2 | ||
- tar xjf phantomjs-2.0.0-ubuntu-12.04.tar.bz2 | ||
- sudo mv phantomjs /usr/local/phantomjs |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you should probably put it under /usr/local/bin (/usr/local is probably not on the PATH)
Grr. This is frustrating. If I interactively source the testhat.R script, it seems to work, but it doesn't when I do My current approach is to start an environment that stores testing info (as well as the remote driver) in |
why not just store the remDr object in the global environment, as on the On Fri, Mar 27, 2015 at 11:37 AM, Carson notifications@github.com wrote:
|
That's probably what I'll do next. I suppose it isn't a huge deal in this case, but I was trying to avoid that since (from my understanding) introducing objects into the global workspace is considered poor practice? |
Is it still poor practice if you remove them afterwards? On Fri, Mar 27, 2015 at 10:46 AM, Carson notifications@github.com wrote:
|
In this case I consider it to be good practice to put remDr in the global On Fri, Mar 27, 2015 at 11:47 AM, Susan VanderPlas <notifications@github.com
|
OK, I think this is finally functional. Go ahead and see if you can find any weaknesses @tdhock. This should make interactive testing a lot less painful. You can even switch back and forth between different browsers easily: tests_init()
tests_init("firefox") # shuts down phantomjs before starting selenium server
tests_init() # shuts down selenium before starting phantomjs
tests_run()
tests_exit() # shuts down everything (even local file servers) |
I'll update the wiki (hopefully tonight) and mention some things to be aware of when writing tests. |
if (!inherits(e, "try-error")) { | ||
pids <- as.integer(e) | ||
res <- c(res, tools::pskill(pids)) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
e could be an try-error message or a character vector of pids, right? I suggest to clarify using tryCatch:
tryCatch({
pid.lines <- readLines(pid_file(), warn=FALSE)
pids <- as.integer(pid.lines)
res <- c(res, tools::pskill(pids))
})
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes.
That approach will display an error message if there is an error, right? I think it makes sense to fail silently in this case.
This is great work, thanks a lot Carson. Besides the minor comments above, I think everything is perfect. Merge it when you like +1 |
For posterity, here are a couple things that are still sub-optimal: (1) (2) My hack for running a "daemonized" file servr. servr has a better solution, but it clashes with RSelenium's navigate method. |
This is currently broken, but a step closer to an ideal testing framework.
Most importantly, I want an argument to specify which browser to use for testing.
It might also be nice to eventually export a function like
animint::run_test()
one day, so to run a test on brand new code, we'd just have todevtools::load_all(); run_test()
.